/* =========================
   VARIABLES & BASE
   Base design "track." (portée depuis entrepot_3d_app/app/src/brand.css, via scan_camion_app/
   static/style.css) : indigo/encre, Space Grotesk + JetBrains Mono, rayons/ombres dédiés.
   Thème clair fixe, pas de dark mode auto. App optimisée usage PDA (Zebra TC22).
========================= */
:root{
  --bg:#F6F7F9;
  --card:#FFFFFF;
  --panel-2:#EEF0FE;
  --zone-bg:#FAFBFC;
  --text:#101215;
  --muted:#6A6F78;
  --text-discreet:#9AA0A8;
  --border:#E6E8EC;
  --divider-2:#F2F3F5;

  --primary:#4F5DF5;
  --primary-dark:#3F4CE0;
  --primary-border:#C6CBF8;
  --navbar:#101215;
  --row-hover:rgba(79, 93, 245, 0.06);

  --success:#2E9E63;
  --success-bg:#F1F9F4;
  --success-text:#1F7A4C;
  --danger:#C0392B;
  --danger-bg:#FDF2F2;
  --danger-border:#E8C4C0;
  --amber:#E0A83C;
  --amber-text:#B4741F;
  --amber-bg:#FEF3E7;

  --radius-btn:9px;
  --radius-card:13px;
  --radius-tile:14px;
  --radius-modal:16px;
  --shadow-card:0 1px 2px rgba(16,18,21,.04);
  --shadow-card-hover:0 8px 24px rgba(16,18,21,.09);
  --shadow-primary-btn:0 1px 2px rgba(79,93,245,.35);
  --shadow-modal:0 24px 60px rgba(12,14,18,.45);

  --font-display:'Space Grotesk', sans-serif;
  --font-mono-brand:'JetBrains Mono', monospace;
}

*{box-sizing:border-box}

html, body{
  margin:0;
  padding:0;
  max-width:100%;
  overflow-x:hidden;
}

body{
  font-family: var(--font-display), system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:var(--bg);
  color:var(--text);
  /* Désactiver le zoom sur double-tap pour PDA */
  touch-action: manipulation;
}

/* =========================
   ICÔNES (sprite _icons.html)
========================= */
.icon{
  width:16px;
  height:16px;
  stroke:currentColor;
  fill:none;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
  flex-shrink:0;
  vertical-align:-3px;
}

.icon-sm{ width:13px; height:13px; }
.icon-lg{ width:20px; height:20px; }

/* =========================
   NAVBAR
========================= */
.app-navbar{
  position:sticky;
  top:0;
  left:0;
  width:100%;
  min-height:44px;
  background:var(--navbar);
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:8px;
  padding:6px 14px;
  z-index:999;
  box-shadow:0 2px 8px rgba(0,0,0,.3);
}

.nav-col-left{ justify-self:start; }
.nav-col-center{ justify-self:center; }
.nav-col-right{ justify-self:end; }

.app-nav-group{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  background:rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.1);
  border-radius:10px;
  padding:4px;
}

.app-link{
  display:flex;
  align-items:center;
  gap:6px;
  color:#CBD5E1;
  padding:7px 14px;
  border-radius:7px;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.12);
  font-size:13px;
  font-weight:600;
  font-family:var(--font-display);
  white-space:nowrap;
  text-decoration:none;
  transition:all .15s;
  cursor:pointer;
}

.app-link:hover{
  background:rgba(255,255,255,.16);
  border-color:rgba(255,255,255,.3);
  color:#F1F5F9;
  text-decoration:none;
}

.app-link.active{
  background:var(--primary);
  border-color:var(--primary);
  color:#fff;
  box-shadow:0 1px 4px rgba(79,93,245,.35);
}

.app-link.active:hover{
  background:var(--primary);
  color:#fff;
}

.app-link.danger{
  color:#FCA5A5;
  background:transparent;
}

.site-badge{
  background:rgba(255,255,255,.1);
  color:#fff;
  border:1px solid rgba(255,255,255,.2);
  font-weight:600;
  white-space:nowrap;
}

@media (max-width: 900px){
  main.container{
    padding-top:20px;
  }
}

/* =========================
   LAYOUT
========================= */
.container{max-width:1180px; margin:0 auto; padding:18px 16px 40px;}

h1{
  margin:10px 0 14px;
  font-size:26px;
  font-weight:600;
  font-family:var(--font-display);
  letter-spacing:-0.01em;
}

h2{
  margin:0 0 10px;
  font-size:18px;
  font-weight:600;
  font-family:var(--font-display);
}

.hint{color:var(--muted); font-size:13px; margin:6px 0 0}

.grid{display:grid; gap:14px; grid-template-columns: 1fr 1fr;}
@media (max-width: 980px){ .grid{grid-template-columns:1fr;} }

/* =========================
   CARDS
========================= */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius-card);
  box-shadow:var(--shadow-card);
  padding:14px;
  max-width:100%;
  overflow:hidden;
}

.section-title{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; margin-bottom:10px;
  flex-wrap:wrap;
}

.section-title h2{
  display:flex;
  align-items:center;
  gap:8px;
  margin:0;
}

.badge{
  font-size:12px;
  padding:5px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--zone-bg);
  color:var(--muted);
  font-weight:600;
  font-family:var(--font-display);
  white-space:nowrap;
}

/* =========================
   STATUS DOT (petit indicateur coloré, remplace les emojis 🟢/⚫)
========================= */
.status-dot{
  display:inline-block;
  width:9px;
  height:9px;
  border-radius:50%;
  background:var(--text-discreet);
  flex-shrink:0;
}

.status-dot-ok{ background:var(--success); }
.status-dot-closed{ background:var(--text-discreet); }
.status-dot-warn{ background:var(--amber); }
.status-dot-err{ background:var(--danger); }

/* =========================
   STEP NUMBER (badges 1/2/3 des étapes de scan, remplace 1️⃣2️⃣3️⃣)
========================= */
.step-num{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:20px;
  height:20px;
  border-radius:50%;
  background:var(--primary);
  color:#fff;
  font-size:12px;
  font-weight:700;
  flex-shrink:0;
}

/* =========================
   PROGRESS BAR (couverture / avancement)
========================= */
.progress-track{
  height:16px;
  border:1px solid var(--border);
  border-radius:999px;
  overflow:hidden;
  background:var(--zone-bg);
}

.progress-fill{
  height:100%;
  background:var(--primary);
}

label{display:block; margin-top:10px; font-size:13px; color:var(--muted); font-weight:600;}
input, select, textarea{
  width:100%;
  margin-top:6px;
  padding:10px 12px;
  border-radius:var(--radius-btn);
  border:1px solid var(--border);
  outline:none;
  background:white;
  color:var(--text);
  font-family:var(--font-display);
  /* Amélioration pour PDA */
  font-size:16px; /* Évite le zoom automatique sur iOS/Android */
}
input:focus, select:focus, textarea:focus{
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79,93,245,.18);
}

.row{display:grid; grid-template-columns: 1fr 1fr; gap:10px;}
@media (max-width: 680px){ .row{grid-template-columns:1fr;} }

/* =========================
   BUTTONS
========================= */
.btn{
  margin-top:12px;
  padding:10px 16px;
  border:0;
  border-radius:var(--radius-btn);
  cursor:pointer;
  font-weight:600;
  font-family:var(--font-display);
  background:var(--primary);
  color:white;
  box-shadow:var(--shadow-primary-btn);
  text-decoration:none;
  display:inline-block;
  /* Amélioration tactile */
  min-height:44px;
  font-size:15px;
}
a.btn{ text-decoration:none; }
.btn:hover{ background:var(--primary-dark); }
.btn:active{transform:scale(0.98);}

.btn-secondary{
  background:var(--navbar);
  color:#fff;
  box-shadow:none;
}
.btn-secondary:hover{ background:#05070A; }

.btn-success{
  background:var(--success);
  box-shadow:none;
}
.btn-success:hover{ background:#25844F; }

.btn-danger{
  background:var(--danger);
  box-shadow:none;
}
.btn-danger:hover{ background:#A6301F; }

.btn-ghost{
  background:transparent;
  color:var(--text);
  border:1px solid var(--border);
  box-shadow:none;
}
.btn-ghost:hover{
  background:var(--panel-2);
  border-color:var(--primary);
  color:var(--primary);
}

.btn-sm{
  padding:6px 12px;
  font-size:12px;
  border-radius:7px;
  font-weight:600;
  white-space:nowrap;
  min-height:auto;
  margin-top:0;
}

/* Bouton icône rond (bascule scan/manuel, à côté d'un champ) */
.btn-icon-toggle{
  width:50px;
  flex-shrink:0;
  background:var(--muted);
  color:white;
  border:none;
  border-radius:10px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.btn-icon-toggle:hover{ background:#565C64; }
.btn-icon-toggle-active{ background:var(--success); }
.btn-icon-toggle-active:hover{ background:#25844F; }

/* =========================
   TABS (sous-onglets internes à une page)
========================= */
.tabs{
  display:flex;
  gap:4px;
  margin:0 0 18px;
  flex-wrap:wrap;
  border-bottom:1px solid var(--border);
}

.tab{
  text-decoration:none;
  padding:9px 4px;
  margin-right:22px;
  font-size:13px;
  font-weight:600;
  font-family:var(--font-display);
  color:var(--muted);
  border-bottom:2px solid transparent;
  background:none;
  border-top:none;
  border-left:none;
  border-right:none;
  cursor:pointer;
}

.tab:hover{
  color:var(--text);
  text-decoration:none;
}

.tab.active{
  color:var(--primary);
  border-bottom-color:var(--primary);
}

table{width:100%; border-collapse:collapse; margin-top:10px;}
th, td{
  border-bottom:1px solid var(--divider-2);
  padding:10px 8px;
  font-size:13px;
  vertical-align:top;
}
th{color:var(--text-discreet); font-weight:500; background:var(--zone-bg); font-size:11px; font-family:var(--font-mono-brand); text-transform:uppercase; letter-spacing:.06em;}
tr:hover td{background:var(--zone-bg);}

.messages{margin:0 0 12px}
.msg{padding:10px 12px; border-radius:10px; border:1px solid; margin-bottom:8px; font-size:13px; font-weight:600;}
.msg.error{background:var(--danger-bg); border-color:var(--danger-border); color:var(--danger);}
.msg.success{background:var(--success-bg); border-color:#CFE6D9; color:var(--success-text);}
.msg.warning{background:var(--amber-bg); border-color:#F0D5A8; color:var(--amber-text);}

a{ color:var(--primary); font-weight:600; }
a.link{ color:var(--primary); font-weight:600; text-decoration:none; }
a.link:hover{ text-decoration:underline; }

/* =========================
   MOVEMENT CARD (mouvements optimisée PDA)
========================= */
.movement-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}

.movement-card.completed {
  background: var(--success-bg);
  border-color: #CFE6D9;
}

/* Grosses zones tactiles pour les actions critiques */
.touch-target {
  min-height: 54px;
  min-width: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Optimisations spécifiques pour les checkbox (mouvements) */
input[type="checkbox"] {
  width: 32px;
  height: 32px;
  cursor: pointer;
}

/* ========================================
   OPTIMISATIONS PDA (TC22 - ~6 pouces)
   ======================================== */

@media (max-width: 480px) {
  body { font-size: 15px; }
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }

  .container { padding: 8px 8px 30px; }

  .card { padding: 10px; margin-top: 8px; }

  .app-navbar { padding: 4px 8px; min-height:unset; }

  .site-badge { font-size: 10px; padding: 3px 6px; }

  .btn {
    min-height: 50px;
    font-size: 16px;
    font-weight: 700;
    padding: 12px 16px;
  }

  input, select {
    padding: 14px 12px;
    font-size: 16px;
    min-height: 50px;
  }

  table { font-size: 12px; }
  th, td { padding: 8px 6px; }

  .hide-on-mobile { display: none; }

  .badge { font-size: 11px; padding: 4px 8px; }

  .msg { font-size: 14px; font-weight: 600; }

  .row { grid-template-columns: 1fr; gap: 8px; }

  input[type="checkbox"] { width: 40px; height: 40px; }

  .movement-card { padding: 12px; margin-bottom: 10px; }

  * { -webkit-overflow-scrolling: touch; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* =========================
   NAVBAR SUR PDA / PETIT ÉCRAN
   L'app surplus a 5 entrées de menu en profil admin : sans ça la grille
   3 colonnes de .app-navbar déborde horizontalement sur un TC22 (360px).
========================= */
@media (max-width: 620px){
  .app-navbar{
    grid-template-columns:1fr;
    justify-items:stretch;
    gap:6px;
  }
  .nav-col-left, .nav-col-center, .nav-col-right{ justify-self:stretch; }
  .nav-col-right{ display:flex; justify-content:flex-end; }
  .app-nav-group{ justify-content:flex-start; }
  .app-link{ padding:7px 10px; font-size:13px; }
}
