/* =============================================================
   Qui Conduit ? — feuille de style
   Thème sombre par défaut, thème clair via [data-theme="light"]
   ============================================================= */

/* ---------- Variables de couleurs ---------- */
:root {
  --bg:        #0f1115;
  --bg-soft:   #161a21;
  --card:      #1b2029;
  --card-2:    #222836;
  --text:      #f2f5f9;
  --text-dim:  #9aa5b6;
  --border:    #2a313d;
  --primary:   #2f7cf6;
  --primary-2: #1f63d4;
  --accent:    #ffb02e;
  --success:   #22c55e;
  --danger:    #ef4444;
  --shadow:    0 6px 20px rgba(0,0,0,.35);
  --radius:    18px;
  --tabbar-h:  68px;
}

[data-theme="light"] {
  --bg:        #f3f5f9;
  --bg-soft:   #ffffff;
  --card:      #ffffff;
  --card-2:    #eef1f6;
  --text:      #131720;
  --text-dim:  #66738a;
  --border:    #dde3ec;
  --primary:   #1f6feb;
  --primary-2: #1559c0;
  --accent:    #e08600;
  --shadow:    0 6px 20px rgba(20,30,60,.10);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  transition: background .25s ease, color .25s ease;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }

/* ---------- En-tête ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header__title { flex: 1; font-weight: 700; font-size: 17px; text-align: center; }
.icon-btn {
  width: 40px; height: 40px; flex: 0 0 40px;
  border: none; border-radius: 12px;
  background: var(--card); color: var(--text);
  font-size: 18px; cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

/* ---------- Vues ---------- */
main { max-width: 620px; margin: 0 auto; padding: 16px 14px 24px; }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-title { font-size: 22px; margin-bottom: 14px; }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .08em;
                 color: var(--text-dim); margin: 22px 0 10px; }

/* ---------- Accueil ---------- */
.hero { text-align: center; padding: 18px 0 22px; }
.hero__title { font-size: 32px; font-weight: 800; letter-spacing: -.5px; }
.hero__subtitle { color: var(--text-dim); margin: 0; }

/* ---------- Boutons ---------- */
.btn {
  display: block; width: 100%;
  padding: 15px 18px; margin-bottom: 12px;
  border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 700; font-family: inherit;
  color: var(--text); background: var(--card);
  cursor: pointer; text-align: center;
  transition: transform .12s ease, filter .15s ease, background .2s ease;
}
.btn:active { transform: scale(.97); }
.btn--xl { padding: 20px; font-size: 18px; letter-spacing: .02em; }
.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.btn--primary:hover { background: var(--primary-2); }
.btn--accent  { background: var(--accent); color: #1a1200; box-shadow: var(--shadow); }
.btn--success { background: var(--success); color: #04220f; }
.btn--danger  { background: var(--danger); color: #fff; }
.btn--ghost   { background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.btn--danger-ghost { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn--huge { padding: 28px 18px; font-size: 20px; border-radius: 24px; }

/* ---------- Cartes ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card__title { font-size: 16px; margin-bottom: 12px; }

/* Carte voyage (accueil) */
.trip-card { cursor: pointer; }
.trip-card__name { font-size: 19px; font-weight: 700; }
.trip-card__route { color: var(--primary); font-weight: 600; }
.trip-card__meta { color: var(--text-dim); font-size: 14px; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; margin-top: 6px;
}
.badge--ongoing  { background: rgba(34,197,94,.15); color: var(--success); }
.badge--finished { background: rgba(154,165,182,.18); color: var(--text-dim); }
.badge--new      { background: rgba(47,124,246,.18); color: var(--primary); }

/* ---------- Formulaires ---------- */
.field { display: block; margin-bottom: 14px; }
.field__label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.input {
  width: 100%; padding: 14px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  font-size: 16px; font-family: inherit;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .grid-2 { grid-template-columns: 1fr; } }

.drivers-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.driver-row { display: flex; gap: 8px; align-items: center; }
.driver-row .input { flex: 1; }
.driver-row button {
  flex: 0 0 46px; height: 46px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--danger); font-size: 18px; cursor: pointer;
}

/* ---------- Écran conducteur actuel ---------- */
.current-driver {
  text-align: center;
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: 26px; padding: 26px 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.current-driver__label { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-dim); }
.current-driver__name {
  font-size: clamp(38px, 12vw, 56px); font-weight: 900;
  letter-spacing: -1px; margin: 6px 0 4px; word-break: break-word;
}
.current-driver__since { color: var(--text-dim); font-size: 15px; }
.chrono {
  margin-top: 14px; font-size: 30px; font-weight: 800;
  font-variant-numeric: tabular-nums; color: var(--accent);
}
.chrono__label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .1em; }

.pulse-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--success); margin-right: 6px;
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- Historique ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.timeline li:last-child { border-bottom: none; }
.timeline__time { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 56px; color: var(--primary); }
.timeline__text { flex: 1; }

.segment {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.segment:last-child { border-bottom: none; }
.segment__info { flex: 1; }
.segment__driver { font-weight: 700; font-size: 17px; }
.segment__range { color: var(--text-dim); font-size: 14px; font-variant-numeric: tabular-nums; }
.segment__dur { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.link-btn {
  background: none; border: none; color: var(--primary);
  font-size: 14px; font-weight: 700; cursor: pointer; padding: 6px;
  font-family: inherit;
}

/* ---------- Résultat de recherche ---------- */
.result {
  text-align: center; border: 2px solid var(--accent);
  background: var(--card); border-radius: 24px; padding: 24px 18px; margin-bottom: 14px;
}
.result__q { color: var(--text-dim); font-size: 15px; }
.result__name { font-size: clamp(34px, 11vw, 50px); font-weight: 900; margin: 8px 0; }
.result__none { color: var(--danger); font-weight: 700; font-size: 18px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv__k { color: var(--text-dim); font-size: 14px; }
.kv__v { font-weight: 700; text-align: right; }

/* ---------- Divers ---------- */
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.empty {
  text-align: center; color: var(--text-dim);
  padding: 30px 16px; border: 1px dashed var(--border); border-radius: var(--radius);
}
.disclaimer {
  color: var(--text-dim); font-size: 12px; line-height: 1.5;
  background: var(--card-2); border-radius: 14px; padding: 12px; margin-top: 22px;
}

/* Interrupteur */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: 0 0 52px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute; inset: 0; background: var(--card-2);
  border: 1px solid var(--border); border-radius: 999px; transition: .2s; cursor: pointer;
}
.switch__slider::before {
  content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px;
  background: var(--text); border-radius: 50%; transition: .2s;
}
.switch input:checked + .switch__slider { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch__slider::before { transform: translateX(22px); background: #fff; }

/* ---------- Barre de navigation ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  background: color-mix(in srgb, var(--bg-soft) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; color: var(--text-dim);
  font-family: inherit; font-size: 11px; font-weight: 600;
  padding: 9px 4px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab__icon { font-size: 20px; line-height: 1; }
.tab.is-active { color: var(--primary); }
.tab:active { transform: scale(.94); }

/* ---------- Modale ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px;
  background: var(--bg-soft);
  border-radius: 26px 26px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: slideUp .22s ease;
  border-top: 1px solid var(--border);
}
@keyframes slideUp { from { transform: translateY(30px); } to { transform: none; } }
.modal__title { font-size: 20px; font-weight: 800; margin-bottom: 6px; text-align: center; }
.modal__text { color: var(--text-dim); text-align: center; margin-bottom: 18px; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 26px; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  z-index: 200; animation: fadeIn .2s ease; max-width: 90vw; text-align: center;
}

/* ---------- Lieux (géolocalisation optionnelle) ---------- */
.segment-block { border-bottom: 1px solid var(--border); }
.segment-block:last-child { border-bottom: none; }
.segment-block .segment { border-bottom: none; padding-bottom: 4px; }
.geo {
  background: var(--card-2);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.7;
}
.geo-line { word-break: break-word; }
.geo-line .link-btn { padding: 2px 4px; font-size: 13px; }
a.link-btn { text-decoration: none; display: inline-block; }
a.link-btn:hover { text-decoration: underline; }
