/* DPS Météo Chantier — thème sombre, contraste élevé (lisible en plein soleil). */

:root {
  --bg: #07090d;
  --panel: #10141b;
  --panel-2: #181e27;
  --line: #273040;
  --text: #f3f6fa;
  --muted: #9aa7b6;
  --blue: #2f46ff;
  --sky: #0a99f5;
  --red: #d42026;

  --go: #22c55e;
  --go-bg: #0f2e1b;
  --warn: #fbbf24;
  --warn-bg: #352708;
  --bad: #f04444;
  --bad-bg: #3a1012;
  --night: #475569;

  --radius: 14px;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100vh;
}

a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.loading { padding: 32px var(--gutter); color: var(--muted); text-align: center; }

/* ---------- En-tête ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(7, 9, 13, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px 12px;
  padding: 8px var(--gutter) 0;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img { height: 40px; width: auto; display: block; }
.brand-sub {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); border-left: 1px solid var(--line); padding-left: 10px; white-space: nowrap;
}

.top-info { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
#updated { white-space: nowrap; }

.tabs { grid-column: 1 / -1; display: flex; gap: 4px; }
.tabs a {
  text-decoration: none; padding: 8px 14px 10px; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--sky); }

.kp-badge {
  font-weight: 700; font-size: 0.85rem; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap;
}
.kp-badge.calme { color: var(--go); border-color: var(--go); }
.kp-badge.agite { color: var(--warn); border-color: var(--warn); }
.kp-badge.tempete { color: var(--bad); border-color: var(--bad); }

.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; font-weight: 600; cursor: pointer; min-height: 44px;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--sky); border-color: var(--sky); color: #001424; }
.btn-danger { color: var(--bad); }
.btn-icon { padding: 0; width: 44px; height: 44px; display: grid; place-items: center; }
.btn-sm { min-height: 36px; padding: 6px 10px; }
.btn-icon.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mise en page ---------- */

main { max-width: 1280px; margin: 0 auto; padding: 16px var(--gutter) 24px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 16px;
}
.card > h2, .section-title { margin: 0 0 10px; font-size: 1.05rem; }

.foot { text-align: center; padding: 8px var(--gutter) 24px; max-width: 1280px; margin: 0 auto; }

.error { color: var(--bad); }
.empty { text-align: center; padding: 28px 12px; }
.empty h2 { margin-top: 0; }

/* ---------- Verdicts ---------- */

.v-pill {
  display: inline-block; font-weight: 800; font-size: 0.78rem; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.v-go .v-pill, .v-pill.v-go { background: var(--go); color: #03200e; }
.v-prudence .v-pill, .v-pill.v-prudence { background: var(--warn); color: #2b1d00; }
.v-nogo .v-pill, .v-pill.v-nogo { background: var(--bad); color: #fff; }
.v-nuit .v-pill, .v-pill.v-nuit { background: var(--night); color: #e2e8f0; }

.c-go { color: var(--go); }
.c-warn { color: var(--warn); }
.c-bad { color: var(--bad); }

/* Indice d'accord : 3 barres */
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle; }
.bars i { width: 4px; background: var(--line); border-radius: 1px; }
.bars i:nth-child(1) { height: 5px; }
.bars i:nth-child(2) { height: 9px; }
.bars i:nth-child(3) { height: 14px; }
.bars.b1 i:nth-child(-n+1) { background: var(--bad); }
.bars.b2 i:nth-child(-n+2) { background: var(--warn); }
.bars.b3 i { background: var(--go); }

/* ---------- Meilleurs créneaux ---------- */

.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.slots a {
  display: grid; grid-template-columns: 5.5em 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; background: var(--go-bg); border: 1px solid #1d5a35; border-radius: 10px;
  text-decoration: none;
}
.slots .s-day { font-weight: 700; }
.slots .s-city { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slots .s-time { font-weight: 700; color: var(--go); white-space: nowrap; }

/* ---------- Carte ville + bande 10 jours ---------- */

.city-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; }
.city-h h2 { margin: 0; font-size: 1.2rem; }
.city-next { margin-left: auto; font-size: 0.85rem; }

.days {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(88px, 1fr);
  gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.day {
  scroll-snap-align: start; text-decoration: none; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 8px 4px 10px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--line); border-top: 4px solid var(--line); text-align: center; font-size: 0.85rem;
}
.day:hover { border-color: var(--muted); }
.day.v-go { border-top-color: var(--go); }
.day.v-prudence { border-top-color: var(--warn); }
.day.v-nogo { border-top-color: var(--bad); }
.day.today { outline: 2px solid var(--sky); outline-offset: -1px; }
.d-name { font-weight: 700; font-size: 0.9rem; }
.d-sky { font-size: 1.6rem; line-height: 1.2; }
.d-temp { font-weight: 600; }
.d-temp .lo { color: var(--muted); }
.d-models { color: var(--muted); font-size: 0.72rem; }
.d-slot { font-size: 0.75rem; font-weight: 700; min-height: 1.1em; }

/* ---------- Détail jour ---------- */

.day-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.day-head h1 { margin: 0; font-size: 1.3rem; }
.day-head .v-pill { font-size: 1rem; padding: 6px 12px; }
.day-nav { margin-left: auto; display: flex; gap: 6px; }
.back { text-decoration: none; color: var(--muted); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font-size: 0.88rem; white-space: nowrap;
}
.chip b { font-weight: 700; }
button.chip { cursor: pointer; }
button.chip.active { background: var(--sky); border-color: var(--sky); color: #001424; font-weight: 700; }

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
.tbl { border-collapse: collapse; width: 100%; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 8px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tbl thead th { background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 0.78rem; position: sticky; top: 0; }
.tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; background: var(--panel); font-weight: 700; z-index: 1; }
.tbl thead th:first-child { background: var(--panel-2); z-index: 2; }
.tbl tr.now td { background: #0b2236; }
.tbl tr.now td:first-child { background: #0b2236; }
.tbl tr.night td { color: var(--muted); }
.tbl td.reasons { text-align: left; color: var(--muted); font-size: 0.8rem; white-space: normal; min-width: 140px; }
.tbl td.out { background: #3a2a05; color: var(--warn); font-weight: 700; outline: 1px solid var(--warn); outline-offset: -2px; }
.tbl td.med, .tbl th.med { background: #121a24; font-weight: 700; }
.arrow { display: inline-block; font-weight: 700; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.toolbar .section-title { margin: 0; margin-right: auto; }

.legend { margin-top: 8px; }

/* ---------- Réglages ---------- */

.search { position: relative; }
.search input, .field input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; min-height: 44px; font-size: 16px;
}
.search input:focus, .field input:focus { outline: 2px solid var(--sky); outline-offset: 0; border-color: var(--sky); }
.results { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.results button {
  width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.results button:hover { border-color: var(--sky); }

.city-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.city-list li {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}
.city-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.thr { display: grid; gap: 10px; }
.thr-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; align-items: end;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.thr-row > .lbl { grid-column: 1 / -1; font-weight: 700; }
.field { display: grid; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.field input { color: var(--text); }
.field.go span::before { content: "● "; color: var(--go); }
.field.nogo span::before { content: "● "; color: var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.saved { color: var(--go); font-weight: 600; align-self: center; }

/* ---------- Écrans larges ---------- */

@media (min-width: 720px) {
  .top { grid-template-columns: auto 1fr auto; padding-top: 10px; }
  .tabs { grid-column: auto; grid-row: 1; grid-column-start: 2; justify-content: center; }
  .tabs a { padding-bottom: 12px; }
  .brand img { height: 48px; }
  .slots { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .thr { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 24px; }
  .d-sky { font-size: 1.9rem; }
}

@media (max-width: 640px) {
  .brand-sub { display: none; }
  #updated { display: none; }
}

/* ---------- Sections repliables ---------- */

details > summary {
  cursor: pointer; font-weight: 700; padding: 6px 0; list-style: none; min-height: 32px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; color: var(--sky); }
details[open] > summary::before { content: "▾ "; }
details.advanced { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.tbl .why { font-size: 0.7rem; color: var(--muted); margin-top: 2px; white-space: normal; max-width: 90px; margin-inline: auto; line-height: 1.15; }
.tbl th, .tbl td { padding: 7px 6px; }

/* ---------- Code d'accès ---------- */

body.locked .tabs, body.locked .top-info { visibility: hidden; }
.lock { max-width: 320px; margin: 40px auto; display: grid; gap: 14px; justify-items: center; text-align: center; }
.lock h2 { margin: 0; }
.lock input {
  width: 100%; text-align: center; font-size: 28px; letter-spacing: 0.4em; padding: 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
}
.lock input:focus { outline: 2px solid var(--sky); border-color: var(--sky); }
.lock .btn { width: 100%; }
.lock .error { min-height: 1.2em; margin: 0; }

/* ---------- Mode drone / perche ---------- */

.mode { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.mode button {
  background: none; border: 0; border-radius: 7px; padding: 6px 10px; min-height: 36px;
  font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.mode button.active { background: var(--sky); color: #001424; }
@media (max-width: 420px) { .mode-txt { display: none; } .mode button { padding: 6px 12px; font-size: 1.1rem; } }

.pills { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; }
.pills .v-pill { font-size: 0.68rem; padding: 3px 5px; }

/* ---------- No-go version canapé ---------- */

.v-pill.netflix, .v-nogo .v-pill.netflix {
  background: #000; color: #e50914; border: 1px solid #3a0a0d;
  font-family: "Bebas Neue", Impact, "Arial Narrow", sans-serif; font-weight: 400;
  font-size: 0.95rem; letter-spacing: 0.06em; line-height: 1.1; padding: 2px 7px;
}
.day-head .v-pill.netflix { font-size: 1.3rem; padding: 4px 12px; }

/* ---------- Ajout de ville depuis l'accueil ---------- */

.add-btn { width: 100%; margin-bottom: 16px; border-style: dashed; color: var(--sky); font-size: 1rem; }
