/* =====================================================================
   COLIVIA — Système visuel
   Direction : fret / hi-vis. Encre marine + ambre cargo.
   L'accent de marque (--accent) est surchargeable par société.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
  --ink:        #0E1726;   /* encre marine — chrome principal   */
  --ink-2:      #172336;   /* surfaces sombres                  */
  --ink-3:      #24344d;   /* bordures sur fond sombre          */
  --accent:     #F2A900;   /* ambre cargo — accent par défaut   */
  --accent-ink: #0E1726;   /* texte sur ambre                   */
  --paper:      #F7F8FA;   /* fond clair                        */
  --card:       #FFFFFF;
  --line:       #E4E7EC;   /* filets                            */
  --text:       #1B2430;
  --muted:      #667085;

  /* Étapes */
  --st-exp:  #5B7CFA;   /* Expédition */
  --st-dep:  #F2A900;   /* Départ     */
  --st-arr:  #12A5A5;   /* Arrivée    */
  --st-liv:  #17B26A;   /* Livraison  */

  --ok:   #17B26A;
  --warn: #F79009;
  --err:  #D92D20;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --display: 'Archivo', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--body);
  color: var(--text);
  background: var(--paper);
  line-height: 1.5;
  font-size: 15px;
}
a { color: inherit; }
h1,h2,h3,h4 { font-family: var(--display); margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 700; }

/* ---- Layout applicatif : barre latérale + contenu ------------------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--ink);
  color: #C7D0DE;
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 800; font-size: 1.25rem;
  color: #fff; letter-spacing: -.02em; margin-bottom: 4px;
}
.brand .dot { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }
.brand small { display:block; font-family: var(--body); font-weight:500; font-size:.68rem; color:#8896aa; letter-spacing:0; }

.nav { margin-top: 22px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 8px; text-decoration: none;
  color: #AEB8C7; font-weight: 500; font-size: .92rem;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav .sec { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
            color: #5f6c81; margin: 18px 0 6px 11px; }
.nav a .i { width: 18px; text-align: center; opacity: .9; }

.sidebar .foot { margin-top: auto; font-size: .78rem; color: #6b7688; padding-top: 16px; }
.sidebar .foot a { color: #aeb8c7; }

.main { padding: 26px 30px 60px; min-width: 0; }

/* ---- Barre supérieure ----------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between;
          margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.topbar .who { font-size: .86rem; color: var(--muted); }
.topbar .who b { color: var(--text); }

/* ---- Cartes / grilles ----------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line);
        border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 18px; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- KPI ------------------------------------------------------------ */
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
       padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .k-val { font-family: var(--display); font-weight: 800; font-size: 1.9rem; margin-top: 4px; }
.kpi .k-sub { font-size: .8rem; color: var(--muted); }

/* ---- Tableaux ------------------------------------------------------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
          color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: #fafbfc; }
.tbl .code { font-family: var(--display); font-weight: 700; letter-spacing: .02em; }

/* ---- Badges d'étape / statut ---------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
         border-radius: 999px; font-size: .76rem; font-weight: 600; }
.badge .d { width: 7px; height: 7px; border-radius: 50%; }
.b-exp { background: #eef1ff; color: #3448c5; } .b-exp .d { background: var(--st-exp); }
.b-dep { background: #fff5e0; color: #96690a; } .b-dep .d { background: var(--st-dep); }
.b-arr { background: #e2f7f7; color: #0a6f6f; } .b-arr .d { background: var(--st-arr); }
.b-liv { background: #e4f8ee; color: #08753f; } .b-liv .d { background: var(--st-liv); }
.b-cree{ background: #eef0f3; color: #475467; } .b-cree .d{ background: #98a2b3; }
.b-actif   { background:#e4f8ee; color:#08753f; } .b-actif .d{ background:var(--ok); }
.b-test    { background:#fff5e0; color:#96690a; } .b-test .d{ background:var(--warn); }
.b-suspendu{ background:#fde7e6; color:#a51c15; } .b-suspendu .d{ background:var(--err); }
.b-expire  { background:#fde7e6; color:#a51c15; } .b-expire .d{ background:var(--err); }

/* ---- Boutons -------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
       font-family: var(--body); font-weight: 600; font-size: .9rem;
       padding: 10px 16px; border-radius: 9px; border: 1px solid transparent;
       text-decoration: none; transition: filter .15s, background .15s; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(.95); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-2); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: #f7f8fa; }
.btn-danger { background: #fff; border-color: #f2c4c1; color: var(--err); }
.btn-danger:hover { background: #fdf3f2; }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Formulaires ---------------------------------------------------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 9px; font: inherit; background: #fff; color: var(--text);
}
.input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242,169,0,.18);
}
.row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ---- Alertes -------------------------------------------------------- */
.alert { padding: 11px 15px; border-radius: 10px; font-size: .9rem; margin-bottom: 14px;
         border: 1px solid transparent; }
.alert-success { background: #e7f8ef; border-color: #b6eccd; color: #08753f; }
.alert-error   { background: #fdeceb; border-color: #f7c9c5; color: #a51c15; }
.alert-info    { background: #eef4ff; border-color: #cdddff; color: #2a4bb5; }
.alert-warn    { background: #fff6e5; border-color: #f7dfa8; color: #92610a; }

/* =====================================================================
   RAIL DE SUIVI — l'élément signature (4 étapes)
   ===================================================================== */
.rail { display: grid; grid-template-columns: repeat(4, 1fr); position: relative; margin: 8px 0 4px; }
.rail::before { content: ''; position: absolute; top: 19px; left: 12%; right: 12%;
                height: 3px; background: var(--line); border-radius: 3px; }
.rail .step { text-align: center; position: relative; z-index: 1; }
.rail .knob { width: 40px; height: 40px; margin: 0 auto 8px; border-radius: 50%;
              display: grid; place-items: center; background: #fff; border: 3px solid var(--line);
              font-weight: 800; color: var(--muted); font-family: var(--display); }
.rail .step .lbl { font-size: .8rem; font-weight: 600; color: var(--muted); }
.rail .step .time { font-size: .72rem; color: var(--muted); margin-top: 2px; min-height: 1em; }
.rail .step.done .knob { border-color: transparent; color: #fff; }
.rail .step.done .lbl { color: var(--text); }
.rail .step.done.s-expedition .knob { background: var(--st-exp); }
.rail .step.done.s-depart     .knob { background: var(--st-dep); color: var(--ink); }
.rail .step.done.s-arrivee    .knob { background: var(--st-arr); }
.rail .step.done.s-livraison  .knob { background: var(--st-liv); }

/* transport pastille entre deux étapes */
.transport-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px;
                 background: var(--ink); color: #fff; border-radius: 999px;
                 font-size: .82rem; font-weight: 600; }

/* ---- Album photo ---------------------------------------------------- */
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.album figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background:#fff; }
.album img { width: 100%; height: 120px; object-fit: cover; display: block; }
.album figcaption { font-size: .76rem; color: var(--muted); padding: 7px 9px; }

/* ---- Carte (Leaflet) ------------------------------------------------ */
#map { height: 440px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }

/* ---- Page d'authentification / suivi public ------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center;
             background: radial-gradient(1200px 600px at 100% -10%, #1c2b45 0%, var(--ink) 55%); padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px;
             box-shadow: 0 24px 60px rgba(0,0,0,.35); padding: 32px; }
.auth-card .brand { color: var(--ink); justify-content: center; margin-bottom: 22px; }

/* ---- Divers --------------------------------------------------------- */
.muted { color: var(--muted); }
.mono { font-family: var(--display); letter-spacing: .02em; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.stack > * + * { margin-top: 10px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.right { text-align: right; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center;
             flex-wrap: wrap; gap: 8px; }
  .sidebar .foot, .nav .sec { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; margin-top: 0; }
  .grid.cols-3, .grid.cols-4, .grid.cols-2 { grid-template-columns: 1fr; }
  .row, .row-3 { grid-template-columns: 1fr; }
  .rail { grid-template-columns: repeat(4, 1fr); }
}

/* Accessibilité : focus visible + reduced motion */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
