/* ============================================================
   Check Camion — thème nuit (kit/tokens.css)
   Fond #050E14 · cartes #07141C · accent cyan #41D6F5
   Typo : Barlow Condensed (titres, plaques, labels) / Barlow (texte)
   Le panneau constat (.schema-card) est la SEULE surface claire.
   ============================================================ */
@import url('tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&family=Barlow+Condensed:wght@600;700&display=swap');

:root {
  /* Variables historiques remappées sur les tokens du kit */
  --bg: var(--mt-bg);
  --surface: var(--mt-surface);
  --surface-2: var(--mt-surface-2);
  --border: var(--mt-border);
  --text: var(--mt-text);
  --muted: var(--mt-text-muted);
  --accent: var(--mt-cyan);
  --accent-strong: var(--mt-cyan-dim);
  --accent-soft: rgba(65, 214, 245, 0.14);
  --on-accent: var(--mt-on-cyan);
  --cyan: var(--mt-cyan);
  --cyan-soft: rgba(65, 214, 245, 0.14);
  --dark: var(--mt-surface);
  --dark-2: var(--mt-surface-2);
  --dark-3: #10293A;
  --dark-border: var(--mt-border);
  --dark-text: var(--mt-text-muted);
  --ok: var(--mt-ok);
  --ok-soft: rgba(62, 207, 142, 0.14);
  --warn: #e8b04b;
  --warn-soft: rgba(232, 176, 75, 0.14);
  --danger: var(--mt-danger);
  --danger-soft: rgba(224, 92, 92, 0.14);
  --radius: var(--mt-radius-card);
  --radius-sm: var(--mt-radius-btn);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 4px 16px rgba(0, 0, 0, 0.25);
  --font-head: var(--mt-font-display);
  --font-body: var(--mt-font);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1 { font-family: var(--font-head); font-size: 28px; margin: 4px 0; letter-spacing: 0.02em; }
h2 { font-family: var(--font-head); font-size: 17px; margin: 0; letter-spacing: 0.03em; }
h3 { font-family: var(--font-head); font-size: 15px; margin: 0; letter-spacing: 0.03em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.icon { flex: none; vertical-align: -0.18em; }

/* ---- layout : sidebar sombre ---- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 20;
  background: var(--dark);
  padding: 22px 14px 16px; display: flex; flex-direction: column; gap: 22px;
}
.content { margin-left: 240px; padding: 28px 32px 60px; max-width: 1500px; }

.brand { display: flex; gap: 11px; align-items: center; padding: 0 6px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--mt-cyan) 0%, var(--mt-cyan-dim) 120%);
  color: var(--mt-on-cyan); display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(65, 214, 245, 0.3);
}
.brand-logo svg { width: 21px; height: 21px; }
.brand-logo.big { width: 58px; height: 58px; border-radius: 16px; margin: 0 auto 10px; }
.brand-logo.big svg { width: 30px; height: 30px; }
.brand-logo.orange { background: linear-gradient(135deg, var(--warn) 0%, #ffc355 120%); box-shadow: 0 4px 14px rgba(245, 147, 0, 0.35); }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 16px; color: var(--mt-text); letter-spacing: 0.04em; }
.sidebar .brand-sub { font-size: 11px; color: var(--dark-text); }
.brand-sub { font-size: 11px; color: var(--muted); }

.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px; color: var(--dark-text); font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a .icon { opacity: 0.75; }
.sidebar nav a:hover { background: var(--dark-3); color: var(--mt-text); }
.sidebar nav a.active {
  background: linear-gradient(90deg, rgba(65, 214, 245, 0.16), rgba(65, 214, 245, 0.05));
  color: var(--mt-text); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar nav a.active .icon { opacity: 1; color: var(--cyan); }
.logout {
  display: flex; align-items: center; gap: 10px;
  color: var(--dark-text); font-size: 13px; padding: 10px 12px; border-radius: 10px;
}
.logout:hover { color: #ff8f94; background: var(--dark-3); }

/* topbar mobile */
@media (max-width: 900px) {
  .sidebar {
    position: sticky; top: 0; inset: auto; width: auto;
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 12px;
  }
  .sidebar .brand-sub { display: none; }
  .sidebar nav {
    flex-direction: row; gap: 2px; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a { padding: 8px 10px; white-space: nowrap; font-size: 13px; }
  .sidebar nav a.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .logout span { display: none; }
  .content { margin-left: 0; padding: 16px 14px 48px; }
}

/* ---- header & panels ---- */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.back-link { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.back-link:hover { color: var(--accent); }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* ---- KPI ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--cyan));
}
.kpi.warn::before { background: linear-gradient(180deg, var(--warn), #ffc355); }
.kpi.danger::before { background: linear-gradient(180deg, var(--danger), #ff8f94); }
.kpi.ok::before { background: linear-gradient(180deg, var(--ok), #3ed9ab); }
.kpi-value { font-family: var(--font-head); font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.data-table th, .data-table td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover { background: var(--accent-soft); }

/* ---- forms ---- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px;
  min-height: 40px;
}
textarea { min-height: 64px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.14);
}
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-col { display: flex; flex-direction: column; gap: 10px; }
.check-inline { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }
.check-inline input { min-height: auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toast-host {
  position: fixed; top: 18px; right: 18px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  min-width: 220px; max-width: 340px; padding: 12px 16px; border-radius: 10px;
  color: #fff; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  opacity: 0; transform: translateY(-8px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }

.date-nav { display: inline-flex; align-items: center; gap: 6px; }
.btn-icon { padding: 8px; line-height: 0; }
.btn-icon svg { display: block; }

/* ---- groupes de défauts par véhicule ---- */
.defect-group { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.defect-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; background: var(--surface-2, #f6f8fc); border-bottom: 1px solid var(--border);
}
.defect-group-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plate-tag {
  font-family: var(--font-head); font-size: 17px; font-weight: 700; letter-spacing: 1.5px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px;
}
.defect-group-actions { display: flex; align-items: center; gap: 12px; }
.defect-group .table-wrap { border: 0; }
.cb-col { width: 34px; text-align: center; }
.or-defect-list { margin: 8px 0 4px; padding-left: 18px; max-height: 160px; overflow: auto; }
.or-defect-list li { font-size: 13px; color: var(--text); margin-bottom: 3px; }

/* ---- buttons / badges ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; min-height: 40px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface);
  font-weight: 600; font-size: 13px; cursor: pointer; color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: 0 2px 10px rgba(65, 214, 245, 0.25);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger-soft:hover { background: rgba(224, 92, 92, 0.24); }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-sm { padding: 5px 10px; font-size: 12px; min-height: 32px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--muted);
  white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.cyan { background: var(--cyan-soft); color: var(--cyan); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font-weight: 600; font-size: 12px; }

/* ---- schémas SVG : panneau constat blanc (la SEULE surface claire) ---- */
.schemas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.schema-card {
  border: 1px solid var(--mt-panel-border); border-radius: var(--radius-sm); padding: 12px;
  background: var(--mt-panel); color: var(--mt-panel-text);
}
.schema-title {
  font-family: var(--font-head); font-size: 13px; font-weight: 700; color: var(--mt-panel-text);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.12em;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.schema-tag {
  text-transform: none; letter-spacing: 0; font-weight: 700; font-size: 11px;
  font-family: var(--font-body);
  color: var(--mt-panel-muted); background: rgba(38, 43, 51, 0.07);
  border-radius: 999px; padding: 2px 9px;
}
.schema-svg { width: 100%; height: auto; display: block; }
/* Line-art du kit : encre noire fine, aucun aplat, aucun pointillé. Le rendu
   vectoriel (vues sans PNG, ex. pneus) reprend la même grammaire. */
.schema-svg .outline { fill: none; stroke: #141414; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.schema-svg .line { fill: none; stroke: #141414; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.schema-svg .line-soft { fill: none; stroke: #9aa0a8; stroke-width: 1; stroke-linecap: round; }
/* Remplissage blanc = occlusion : l'essieu passe derrière le pneu. */
.schema-svg .wheel { fill: #fff; stroke: #141414; stroke-width: 1.7; stroke-linejoin: round; }
.schema-svg .hub { fill: #fff; stroke: #141414; stroke-width: 1.2; }
.schema-svg .glass { fill: none; stroke: #141414; stroke-width: 1.3; stroke-linejoin: round; }
.schema-svg .ground { fill: none; stroke: #c9ced6; stroke-width: 1.2; stroke-linecap: round; }
.schema-svg .zone { fill: transparent; stroke: transparent; cursor: pointer; transition: fill 0.12s; }
.schema-svg .zone:hover { fill: rgba(38, 43, 51, 0.07); }
.schema-svg .zone.required-empty { stroke: #c9962f; stroke-width: 2; stroke-dasharray: 6 4; fill: rgba(201, 150, 47, 0.07); }
.schema-svg .zone.required-toggle { fill: rgba(201, 150, 47, 0.16); stroke: #c9962f; stroke-width: 2; }
.schema-svg .marker { cursor: pointer; }
.schema-svg .marker circle.bg-ok { fill: var(--mt-ok); stroke: #fff; stroke-width: 2.5; }
.schema-svg .marker circle.bg-ko { fill: var(--mt-danger); stroke: #fff; stroke-width: 2.5; }
.schema-svg .marker .marker-symbol { fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.schema-svg .marker-count circle { fill: #fff; stroke: var(--mt-panel-border); }
.schema-svg .marker-count .count { fill: var(--mt-panel-text); font-size: 13px; font-weight: 700; text-anchor: middle; font-family: var(--font-body); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.ko { background: var(--danger); }
.dot.req { background: transparent; border: 2px dashed var(--warn); }

/* ---- check detail layout ---- */
.check-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .check-layout { grid-template-columns: 1fr; } }
.side-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto;
  box-shadow: var(--shadow);
}
@media (max-width: 1100px) { .side-panel { position: static; max-height: none; } }
.side-panel-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.side-panel-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.photo-card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.photo-card img { width: 100%; display: block; cursor: zoom-in; }
.photo-card .meta { padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist li {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 13px; border-radius: var(--radius-sm);
  background: var(--ok-soft); color: var(--ok); font-weight: 500;
}
.checklist li .icon { align-self: center; }
.checklist li.defect { background: var(--danger-soft); color: var(--danger); box-shadow: inset 3px 0 0 var(--danger); }
.checklist li .comment { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.signature-img { max-width: 100%; max-height: 140px; border: 1px solid var(--mt-panel-border); border-radius: var(--radius-sm); background: var(--mt-panel); }
.mini-map { height: 180px; border-radius: var(--radius-sm); }

/* ---- items editor ---- */
.items-editor { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.items-editor li { display: flex; gap: 8px; align-items: center; }
.items-editor input[type="text"] { flex: 1; min-width: 120px; }

/* ---- modal / lightbox / toast / flash ---- */
.modal { position: fixed; inset: 0; background: rgba(13, 16, 28, 0.55); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box {
  background: var(--surface); border-radius: 18px; padding: 24px; width: 100%;
  max-width: 460px; display: flex; flex-direction: column; gap: 12px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(10, 15, 35, 0.25);
}
.modal-box.large { max-width: 680px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 9px; border: none; background: var(--surface-2); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.lightbox { position: fixed; inset: 0; background: rgba(10, 12, 24, 0.92); z-index: 100; display: grid; place-items: center; padding: 30px; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: var(--radius-sm); }
.lightbox-close {
  position: absolute; top: 18px; right: 22px; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 10px;
  background: rgba(255, 255, 255, 0.1); border: none; color: #fff; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox-caption { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; color: #cfd6ea; font-size: 13px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 9px;
  padding: 13px 20px; border-radius: 12px; font-weight: 600; z-index: 60;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast .icon { color: var(--ok); }
.flash { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin: 8px 0; }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-success { background: var(--ok-soft); color: var(--ok); }

/* ---- auth (login) ---- */
.auth-body {
  display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background:
    radial-gradient(700px 380px at 85% -10%, rgba(65, 214, 245, 0.12), transparent 65%),
    radial-gradient(600px 340px at -10% 110%, rgba(47, 160, 188, 0.10), transparent 60%),
    var(--mt-bg);
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 38px 34px; width: 100%; max-width: 390px; text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.auth-card h1 { margin: 6px 0 2px; font-size: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; text-align: left; }
.file-label input { margin-top: 4px; }
@media (max-width: 480px) {
  .auth-card { padding: 28px 22px; }
  h1 { font-size: 22px; }
}
