/* ============================================================
   SuiviAchats — app.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:   #1a56a0;
  --primary-d: #133f7a;
  --accent:    #f59e0b;
  --danger:    #dc3545;
  --success:   #198754;
  --warning:   #fd7e14;
  --bg:        #f5f7fa;
  --surface:   #ffffff;
  --border:    #dee2e6;
  --text:      #212529;
  --muted:     #6c757d;
  --radius:    6px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
}

body { font-family: system-ui, -apple-system, sans-serif; font-size: 14px;
       color: var(--text); background: var(--bg); line-height: 1.5; }

/* ---- Navbar ---- */
.navbar { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.5rem;
          background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 100; }
.nav-brand { display: flex; align-items: center; gap: .5rem; font-size: 1rem;
             font-weight: 700; white-space: nowrap; }
.nav-links { display: flex; gap: .25rem; list-style: none; flex: 1; }
.nav-links a { color: rgba(255,255,255,.85); text-decoration: none; padding: .35rem .7rem;
               border-radius: var(--radius); transition: background .15s; }
.nav-links a:hover, .nav-links a.active { background: rgba(255,255,255,.15); color: #fff; }
.nav-user { display: flex; align-items: center; gap: .75rem; font-size: .8rem;
            border-left: 1px solid rgba(255,255,255,.2); padding-left: 1rem; }
.nav-user span { font-weight: 600; }
.nav-user small { color: rgba(255,255,255,.7); }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu { display: none; position: absolute; top: 100%; left: 0; min-width: 180px;
                 background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
                 box-shadow: var(--shadow); z-index: 200; }
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu li { list-style: none; }
.dropdown-menu a { color: var(--text); display: block; padding: .5rem .9rem; text-decoration: none; }
.dropdown-menu a:hover { background: var(--bg); }

/* ---- Layout ---- */
.container { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }
.page-header { margin-bottom: 1.25rem; padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.page-header h1 { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.footer { text-align: center; padding: 1rem; font-size: .75rem; color: var(--muted);
          border-top: 1px solid var(--border); margin-top: 2rem; }

/* ---- Cards / Panels ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 1.25rem; box-shadow: var(--shadow); }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--primary); }

/* ---- KPI Grid ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
       padding: 1rem 1.25rem; border-left: 4px solid var(--primary); }
.kpi .kpi-val { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.kpi .kpi-label { font-size: .8rem; color: var(--muted); margin-top: .2rem; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #f1f3f5; font-weight: 600; text-align: left; padding: .55rem .75rem;
     border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #f8f9fa; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: .25em .6em; font-size: .75em; font-weight: 600;
         color: #fff; border-radius: 20px; white-space: nowrap; }

/* ---- Boutons ---- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem 1rem;
       border: none; border-radius: var(--radius); cursor: pointer; font-size: .875rem;
       font-weight: 500; text-decoration: none; transition: opacity .15s; }
.btn:hover { opacity: .85; }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-warning  { background: var(--warning);  color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm       { padding: .25rem .6rem !important; font-size: .8rem !important; border-radius: 4px !important; }
.navbar .btn-sm { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }

.btn-group    { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Formulaires ---- */
.form-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid.col3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full  { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
label { font-weight: 500; font-size: .85rem; }
input, select, textarea {
  padding: .45rem .65rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .875rem; font-family: inherit; background: var(--surface);
  transition: border-color .15s; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,160,.15); }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: .78rem; color: var(--muted); }
.required::after { content: ' *'; color: var(--danger); }

/* ---- Alertes ---- */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; }
.alert-success { background: #d1e7dd; color: #0a3622; border-left: 4px solid var(--success); }
.alert-danger   { background: #f8d7da; color: #58151c; border-left: 4px solid var(--danger); }
.alert-warning  { background: #fff3cd; color: #664d03; border-left: 4px solid var(--accent); }
.alert-info     { background: #cff4fc; color: #055160; border-left: 4px solid #0dcaf0; }

/* ---- Workflow timeline ---- */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content:''; position:absolute; left:.6rem; top:0; bottom:0;
                    width:2px; background:var(--border); }
.timeline-item { position: relative; margin-bottom: 1rem; }
.timeline-item::before { content:''; position:absolute; left:-1.55rem; top:.35rem;
                          width:10px; height:10px; border-radius:50%;
                          background:var(--primary); border:2px solid #fff; }
.timeline-item.rejet::before { background:var(--danger); }
.timeline-date { font-size:.75rem; color:var(--muted); }
.timeline-action { font-weight:600; }
.timeline-comment { font-size:.85rem; color:var(--muted); margin-top:.15rem; }

/* ---- Workflow steps indicator ---- */
.wf-steps { display:flex; gap:0; margin-bottom:1.5rem; overflow-x:auto; }
.wf-step { flex:1; min-width:100px; text-align:center; padding:.5rem .25rem;
           font-size:.75rem; position:relative; }
.wf-step::after { content:''; position:absolute; top:50%; right:0; transform:translateY(-50%);
                  width:0; height:0; border-top:10px solid transparent;
                  border-bottom:10px solid transparent; border-left:10px solid; z-index:1; }
.wf-step:last-child::after { display:none; }
.wf-step.done   { background:#d1e7dd; color:#0a3622; }
.wf-step.done::after   { border-left-color:#d1e7dd; }
.wf-step.active { background:var(--primary); color:#fff; font-weight:600; }
.wf-step.active::after { border-left-color:var(--primary); }
.wf-step.todo   { background:#f1f3f5; color:var(--muted); }
.wf-step.todo::after   { border-left-color:#f1f3f5; }

/* ---- Niveau engagement box ---- */
.niveau-box { padding:.75rem 1rem; border-radius:var(--radius); margin:.5rem 0; }
.niveau-1 { background:#d1e7dd; border-left:4px solid var(--success); }
.niveau-2 { background:#fff3cd; border-left:4px solid var(--warning); }
.niveau-3 { background:#f8d7da; border-left:4px solid var(--danger); }

/* ---- Responsive ---- */
@media(max-width:768px){
  .form-grid, .form-grid.col3 { grid-template-columns:1fr; }
  .form-full { grid-column: auto; }
  .nav-links { display:none; }
  .kpi-grid { grid-template-columns:1fr 1fr; }
}

/* ---- Validation champs ---- */
/* Seulement si le champ a été touché (classe .touched ajoutée par JS) */
input.touched:invalid {
  border-color: var(--danger);
  background: #fff8f8;
}
input.touched:valid:not([type="file"]):not([type="number"]):not([value=""]) {
  border-color: #86efac;
}
.field-error {
  font-size: .78rem;
  color: var(--danger);
  margin-top: .2rem;
  display: none;
}
input.touched:invalid + .field-error {
  display: block;
}
