/* ============================================================
   MA TOURNÉE — identité "signalétique routière"
   Bleu panneau #14294E · Jaune signalisation #FFC400
   Typo : Barlow / Barlow Condensed (héritage panneaux routiers)
   Signature : plaques d'arrêt jaunes à coin coupé
   ============================================================ */

:root {
  --bleu:    #14294E;
  --bleu-2:  #1F3A6B;
  --jaune:   #FFC400;
  --jaune-2: #E8B200;
  --fond:    #EFF1F4;
  --carte:   #FFFFFF;
  --texte:   #1C2434;
  --gris:    #64708A;
  --ligne:   #D8DDE6;
  --vert:    #1B9C5C;
  --rouge:   #D14B42;
  --radius:  12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Barlow", system-ui, sans-serif;
  font-size: 16px;
  color: var(--texte);
  background: var(--fond);
  padding-bottom: env(safe-area-inset-bottom);
}

main { max-width: 640px; margin: 0 auto; padding: 14px 14px 40px; }

h1 {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700; font-size: 30px;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--bleu); margin: 14px 0 4px;
}
h2 {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 600; font-size: 21px;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--gris); margin: 26px 0 8px;
}
.hint { color: var(--gris); margin: 0 0 14px; }

/* ---------- Barre du haut ---------- */
#topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bleu); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.brand {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700; font-size: 20px; letter-spacing: 1.5px;
  display: flex; align-items: center; gap: 8px;
}
.brand-plate { color: var(--jaune); }

/* ---------- Boutons ---------- */
button {
  font-family: inherit; font-size: 16px; font-weight: 600;
  border: 0; border-radius: var(--radius);
  padding: 13px 18px; cursor: pointer;
  background: var(--carte); color: var(--bleu);
  box-shadow: 0 1px 2px rgba(20,41,78,.12);
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: translateY(1px); }
button.primary {
  background: var(--jaune); color: var(--bleu);
  width: 100%;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 21px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  box-shadow: 0 2px 0 var(--jaune-2);
}
button.primary.big { padding: 16px; font-size: 24px; }
button.ghost {
  background: transparent; color: #fff;
  border: 1px solid rgba(255,255,255,.45);
  box-shadow: none; padding: 7px 12px; font-size: 14px;
}
button.small { padding: 7px 12px; font-size: 14px; }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--jaune); outline-offset: 2px;
}

/* ---------- Écran création ---------- */
textarea {
  width: 100%; resize: vertical;
  font: 15px/1.55 "Barlow", sans-serif;
  border: 1px solid var(--ligne); border-radius: var(--radius);
  padding: 12px; background: var(--carte); color: var(--texte);
}
.count { text-align: right; color: var(--gris); font-size: 13px; margin: 4px 2px 12px; }

.opt {
  display: flex; align-items: center; gap: 10px;
  background: var(--carte); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
}
.opt input { width: 20px; height: 20px; accent-color: var(--bleu); flex: none; }
.opt small { color: var(--gris); font-weight: 400; }

.status {
  margin-top: 14px; padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--carte); color: var(--gris);
}
.status.warn {
  background: #FFF4D6; color: #7A5B00;
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
}
.status.error { background: #FBE9E7; color: var(--rouge); white-space: pre-line; }

/* Tournées enregistrées */
#saved-list { list-style: none; margin: 0; padding: 0; }
#saved-list li {
  display: flex; align-items: center; gap: 10px;
  background: var(--carte); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px;
}
#saved-list .t-name { flex: 1; font-weight: 600; }
#saved-list .t-date { color: var(--gris); font-size: 12px; }

/* ---------- Écran tournée ---------- */
#map {
  height: 36vh; min-height: 230px;
  border-radius: var(--radius);
  border: 1px solid var(--ligne);
  margin-bottom: 12px;
}

#tour-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 12px;
}
#tour-stats {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700; font-size: 19px; color: var(--bleu);
  white-space: nowrap;
}
.progress-wrap { flex: 1; display: flex; align-items: center; gap: 8px; }
.progress {
  flex: 1; height: 10px; border-radius: 5px;
  background: var(--ligne); overflow: hidden;
}
#progress-bar { height: 100%; width: 0; background: var(--vert); transition: width .3s; }
#progress-label { font-weight: 600; color: var(--gris); font-size: 14px; }

/* Prochain arrêt */
#next-card {
  background: var(--bleu); color: #fff;
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(20,41,78,.25);
}
.next-label {
  font-family: "Barlow Condensed", sans-serif;
  text-transform: uppercase; letter-spacing: 1.5px;
  font-size: 14px; color: var(--jaune); margin-bottom: 4px;
}
.next-addr { font-size: 17px; font-weight: 600; margin-bottom: 12px; }

#done-card {
  background: var(--vert); color: #fff; text-align: center;
  border-radius: var(--radius); padding: 22px; margin-bottom: 14px;
}
.done-emoji { font-size: 34px; }
.done-text { font-family: "Barlow Condensed", sans-serif; font-size: 22px; font-weight: 700; }

/* ---------- Liste des arrêts ---------- */
#stop-list { list-style: none; margin: 0 0 14px; padding: 0; }
.stop {
  display: flex; align-items: center; gap: 12px;
  background: var(--carte); border-radius: var(--radius);
  padding: 11px 12px; margin-bottom: 8px;
  border-left: 4px solid transparent;
}
.stop.is-next { border-left-color: var(--jaune); }
.stop.is-done { opacity: .55; }
.stop.is-done .stop-addr { text-decoration: line-through; }

/* Signature : plaque d'arrêt jaune à coin coupé */
.plate {
  flex: none; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--jaune); color: var(--bleu);
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700; font-size: 20px;
  border: 2px solid var(--bleu);
  border-radius: 8px;
  clip-path: polygon(0 0, 100% 0, 100% 72%, 72% 100%, 0 100%);
}
.stop.is-done .plate { background: var(--vert); color: #fff; border-color: var(--vert); clip-path: none; }

.stop-main { flex: 1; min-width: 0; }
.stop-addr { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }

.stop-btns { display: flex; flex-direction: column; gap: 6px; flex: none; }
.stop-btns button {
  padding: 6px 10px; font-size: 13px; border-radius: 8px;
  box-shadow: none; border: 1px solid var(--ligne);
}
.stop-btns .b-check { color: var(--vert); border-color: var(--vert); }
.stop.is-done .b-check { background: var(--vert); color: #fff; }

.stop-move { display: flex; flex-direction: column; gap: 4px; flex: none; }
.stop-move button {
  padding: 3px 9px; font-size: 14px; line-height: 1;
  border-radius: 7px; box-shadow: none;
  border: 1px solid var(--ligne); color: var(--gris); background: var(--fond);
}

/* ---------- Actions bas de page ---------- */
.tour-actions { display: flex; gap: 10px; margin: 14px 0; }
.tour-actions button { flex: 1; }

.nav-pref {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--carte); border-radius: var(--radius); padding: 12px 14px;
  color: var(--gris); font-size: 14px;
}
.nav-pref select {
  font: 600 15px "Barlow", sans-serif; color: var(--bleu);
  border: 1px solid var(--ligne); border-radius: 8px; padding: 8px 10px;
  background: var(--fond);
}

/* ---------- Marqueurs Leaflet (mêmes plaques que la liste) ---------- */
.marker-plate {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--jaune); color: var(--bleu);
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700; font-size: 15px;
  border: 2px solid var(--bleu); border-radius: 7px;
  clip-path: polygon(0 0, 100% 0, 100% 72%, 72% 100%, 0 100%);
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.marker-plate.done { background: var(--vert); color: #fff; border-color: var(--vert); clip-path: none; }
.marker-plate.start { background: var(--bleu); color: var(--jaune); clip-path: none; border-radius: 50%; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--bleu); color: #fff;
  padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  z-index: 2000; max-width: 88vw; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ============================================================
   v2 — recherche avec suggestions, brouillon, gain de temps
   ============================================================ */

.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap input {
  width: 100%; padding: 14px;
  font: 16px "Barlow", sans-serif;
  border: 2px solid var(--bleu); border-radius: var(--radius);
  background: var(--carte); color: var(--texte);
  -webkit-appearance: none;
}
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  z-index: 1500; list-style: none; margin: 0; padding: 4px;
  background: var(--carte); border: 1px solid var(--ligne);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20,41,78,.18);
  max-height: 46vh; overflow-y: auto;
}
.suggest li {
  padding: 12px; border-radius: 8px;
  font-size: 15px; line-height: 1.3; cursor: pointer;
}
.suggest li:active, .suggest li:hover { background: #FFF4D6; }

#draft-list { list-style: none; margin: 0 0 4px; padding: 0; }
.draft-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--carte); border-radius: var(--radius);
  padding: 9px 12px; margin-bottom: 6px;
}
.draft-addr { flex: 1; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.plate.sm { width: 28px; height: 28px; font-size: 15px; }

.b-del {
  flex: none; padding: 5px 10px; font-size: 14px; line-height: 1;
  border-radius: 7px; box-shadow: none;
  border: 1px solid var(--ligne); color: var(--rouge); background: var(--fond);
}

#bulk {
  background: var(--carte); border-radius: var(--radius);
  padding: 12px 14px; margin: 10px 0 14px;
}
#bulk summary {
  cursor: pointer; font-weight: 600; color: var(--bleu);
  -webkit-tap-highlight-color: transparent;
}
#bulk textarea { margin-top: 10px; border-color: var(--ligne); }
#bulk button { margin-top: 8px; }

#gain-banner {
  background: #E7F6EE; color: #0E6B3D;
  border: 1px solid #BCE5CF;
  border-radius: var(--radius);
  padding: 11px 14px; margin-bottom: 12px;
  font-size: 15px;
}
#gain-banner s { color: var(--gris); }
#gain-banner b {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 19px; color: #0E6B3D;
}
#gain-banner .gain { font-weight: 700; }
