/* ══════════════════════════════════════════════════════════════════
   Mobilité & Énergie France — Edition PHP
   Thème sombre « zinc » fidèle à la version Node/Next.js
   ══════════════════════════════════════════════════════════════════ */

:root {
  --bg: #09090b;          /* zinc-950 */
  --bg-soft: #18181b;     /* zinc-900 */
  --bg-soft2: rgba(24, 24, 27, .6);
  --border: #27272a;      /* zinc-800 */
  --border-soft: #3f3f46; /* zinc-700 */
  --text: #f4f4f5;        /* zinc-100 */
  --text-2: #d4d4d8;      /* zinc-300 */
  --text-3: #a1a1aa;      /* zinc-400 */
  --text-4: #71717a;      /* zinc-500 */
  --amber: #f59e0b;
  --amber-2: #fbbf24;
  --emerald: #10b981;
  --emerald-2: #34d399;
  --lime: #a3e635;
  --teal: #2dd4bf;
  --fuchsia: #e879f9;
  --sky: #38bdf8;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.amber-text   { color: var(--amber); }
.emerald-text { color: var(--emerald); }
.emerald2-text{ color: #6ee7b7; }
.lime-text    { color: var(--lime); }
.teal-text    { color: var(--teal); }
.fuchsia-text { color: var(--fuchsia); }
.sky-text     { color: var(--sky); }
.right        { margin-left: auto; }
.wrap-h       { flex-wrap: wrap; row-gap: 6px; }

/* ── En-tête ─────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 900;
  background: rgba(9, 9, 11, .95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 80rem; margin: 0 auto; padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #09090b;
  background: linear-gradient(135deg, var(--amber) 0%, var(--emerald) 50%, var(--fuchsia) 100%);
}
.brand h1 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand p  { font-size: 10px; color: var(--text-4); line-height: 1.2; }

.freshness { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fresh-badge {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--bg-soft2);
  color: var(--text-3); font-size: 10px; padding: 3px 8px; border-radius: 999px;
}
.fresh-badge em { font-style: normal; color: var(--text-4); }
.dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; }
.dot-amber, .dot-emerald, .dot-fuchsia, .dot-sky { animation: pulse 2.4s ease-in-out infinite; }
.dot-amber   { background: var(--amber-2); }
.dot-emerald { background: var(--emerald-2); }
.dot-fuchsia { background: var(--fuchsia); }
.dot-sky     { background: var(--sky); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.clock {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border); background: var(--bg-soft2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; color: var(--text-2); padding: 3px 8px; border-radius: 6px;
}

/* ── Contenu ─────────────────────────────────────────────────────── */
.app-main { max-width: 80rem; width: 100%; margin: 0 auto; flex: 1; padding: 14px 16px; }

.layer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.layers-icon { color: var(--text-4); display: inline-flex; }
.layer-toggle {
  border-radius: 999px; border: 1px solid var(--border); background: transparent;
  color: var(--text-4); font-size: 12px; font-weight: 500; padding: 5px 12px; cursor: pointer;
  transition: all .15s ease;
}
.layer-toggle.amber.active   { border-color: rgba(245,158,11,.6);  background: rgba(245,158,11,.1);  color: #fcd34d; }
.layer-toggle.emerald.active { border-color: rgba(16,185,129,.6);  background: rgba(16,185,129,.1);  color: #6ee7b7; }
.layer-toggle.fuchsia.active { border-color: rgba(232,121,249,.6); background: rgba(232,121,249,.1); color: #f5d0fe; }
.layer-hint { margin-left: auto; font-size: 12px; color: var(--text-4); display: none; }
@media (min-width: 640px) { .layer-hint { display: block; } }

.map-wrap {
  height: 52vh; min-height: 380px; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
}
#map { width: 100%; height: 100%; background: #0a0a0a; }

/* ── Onglets ─────────────────────────────────────────────────────── */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 20px; background: var(--bg-soft); border-radius: 10px; padding: 4px; }
.tab {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 6px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-3); font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.tab-label { display: none; }
@media (min-width: 640px) { .tab-label { display: inline; } }
.tab.amber.active   { background: rgba(245,158,11,.15);  color: #fcd34d; }
.tab.emerald.active { background: rgba(16,185,129,.15);  color: #6ee7b7; }
.tab.fuchsia.active { background: rgba(232,121,249,.15); color: #f5d0fe; }
.tab.sky.active     { background: rgba(56,189,248,.15);  color: #7dd3fc; }

.panel { display: none; margin-top: 16px; }
.panel.active { display: block; }
.panel > * + *, .panel .grid-2 { margin-top: 0; }
.panel > .card { margin-bottom: 16px; }

/* ── Cartes ──────────────────────────────────────────────────────── */
.card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 14px 16px 8px;
}
.card-head h2 {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 15px; font-weight: 600; color: var(--text);
}
.card-head svg { flex-shrink: 0; }
.card-meta { font-size: 12px; font-weight: 400; color: var(--text-4); }
.card-body { padding: 8px 16px 16px; }

.sub-title { font-size: 12px; font-weight: 600; color: var(--text-3); margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.hint { margin-top: 12px; font-size: 12px; color: var(--text-4); }

/* ── Grilles / KPI ───────────────────────────────────────────────── */
.grid-6 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-5 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
@media (min-width: 640px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1024px) {
  .grid-6 { grid-template-columns: repeat(6, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
}

.kpi { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.kpi-label { font-size: 12px; color: var(--text-3); }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.kpi-note  { font-size: 10px; color: var(--text-4); margin-top: 2px; }

.skeleton {
  display: block; border-radius: 8px;
  background: linear-gradient(90deg, #18181b 25%, #27272a 50%, #18181b 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Cartes carburant cliquables ─────────────────────────────────── */
.fuel-card {
  text-align: left; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-soft2); padding: 12px; cursor: pointer; transition: border-color .15s;
}
.fuel-card:hover { border-color: var(--border-soft); }
.fuel-card.active { border-color: rgba(245,158,11,.6); background: rgba(245,158,11,.1); }
.fuel-card .fc-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.fuel-card .fc-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.fuel-card .fc-price { display: block; margin-top: 4px; font-size: 18px; font-weight: 600; color: var(--text); }
.fuel-card .fc-range { display: block; font-size: 10px; color: var(--text-4); }

/* ── Histogramme carburants (CSS pur) ────────────────────────────── */
.fuel-chart {
  margin-top: 16px; height: 176px; display: flex; align-items: stretch;
  gap: 6px; padding: 8px 4px 0; border-bottom: 1px solid var(--border-soft);
}
.fuel-chart .fc-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
.fuel-chart .fc-val { font-size: 9px; color: var(--text-3); margin-bottom: 2px; }
.fuel-chart .fc-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.fuel-chart .fc-bar-max { width: 38%; background: #52525b; opacity: .35; border-radius: 4px 4px 0 0; }
.fuel-chart .fc-bar-avg { width: 38%; border-radius: 4px 4px 0 0; }
.fuel-chart-x { display: flex; gap: 6px; margin-top: 6px; }
.fuel-chart-x span { flex: 1; text-align: center; font-size: 11px; color: var(--text-3); }

/* ── Recherche / boutons ─────────────────────────────────────────── */
.search-row { display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 640px) { .search-row { flex-direction: row; } }
.input-wrap { position: relative; flex: 1; }
.input-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-4); pointer-events: none; }
.input-wrap input {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; padding: 9px 12px 9px 32px; outline: none;
}
.input-wrap input:focus { border-color: var(--border-soft); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border-radius: 8px; border: 0; font-size: 13px; font-weight: 500;
  padding: 9px 14px; cursor: pointer; transition: filter .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.amber-btn   { background: #d97706; color: #fff; }
.emerald-btn { background: #059669; color: #fff; }
.sky-btn     { background: #0284c7; color: #fff; }
.ghost-btn   { background: transparent; border: 1px solid var(--border-soft); color: var(--text-2); font-size: 12px; padding: 6px 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px;
  border: 1px solid var(--border-soft); color: var(--text-3);
  padding: 3px 8px; border-radius: 999px;
}
.emerald-badge { border-color: #065f46; color: #34d399; }
.fuchsia-badge { border-color: #86198f; color: #f0abfc; }
.pulse { width: 7px; height: 7px; border-radius: 999px; background: var(--fuchsia); display: inline-block; animation: pulse 1.2s ease-in-out infinite; }

/* ── Listes de stations ──────────────────────────────────────────── */
.station-list { margin-top: 12px; max-height: 384px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.station-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); background: var(--bg-soft2);
  border-radius: 10px; padding: 10px;
}
.station-rank {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 999px;
  background: rgba(245,158,11,.15); color: var(--amber);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.station-info { min-width: 0; flex: 1; }
.station-name { font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-sub  { font-size: 12px; color: var(--text-4); }
.station-price { flex-shrink: 0; text-align: right; }
.station-price .sp-main { font-size: 13px; font-weight: 700; color: var(--amber); }
.station-price .sp-alt { font-size: 10px; color: var(--text-4); }
.station-maj { flex-shrink: 0; }

/* ── IRVE ────────────────────────────────────────────────────────── */
.irve-power { display: flex; flex-direction: column; align-items: center; gap: 16px; }
@media (min-width: 640px) { .irve-power { flex-direction: row; } .irve-power > * { width: 50%; } }
.pie-wrap { width: 190px; height: 190px; margin: 0 auto; border-radius: 50%; position: relative; }
.pie-hole { position: absolute; inset: 26%; background: var(--bg-soft); border-radius: 50%; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 11px; color: var(--text-4); }
.power-legend { display: flex; flex-direction: column; gap: 8px; }
.pl-row .pl-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 2px; }
.pl-row .pl-name { color: var(--text-2); }
.pl-row .pl-count { color: var(--text-4); }
.pl-bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.pl-fill { height: 100%; border-radius: 999px; }

.hbar-list { display: flex; flex-direction: column; gap: 10px; }
.hbar-row .hb-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 3px; }
.hbar-row .hb-name { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.hbar-row .hb-val  { color: var(--text-4); }
.hbar { height: 12px; background: var(--border); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--emerald); border-radius: 0 4px 4px 0; }

.irve-item { border: 1px solid var(--border); background: var(--bg-soft2); border-radius: 10px; padding: 10px; }
.irve-item .top { display: flex; justify-content: space-between; gap: 8px; }
.prises { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.chip { background: var(--border); color: var(--text-2); font-size: 10px; padding: 2px 6px; border-radius: 4px; }
.chip.free { background: #064e3b; color: #6ee7b7; }

/* ── GTFS ────────────────────────────────────────────────────────── */
.gtfs-row { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 640px) { .gtfs-row { flex-direction: row; align-items: center; } }
.select {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 14px; outline: none;
}
@media (min-width: 640px) { .select { width: 288px; } }
.badges-row { display: flex; flex-wrap: wrap; gap: 8px; }
.gtfs-controls { display: inline-flex; align-items: center; gap: 10px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); cursor: pointer; }
.check input { accent-color: #d946ef; }
.route-card { border: 1px solid var(--border); background: var(--bg-soft2); border-radius: 10px; padding: 12px; text-align: center; }
.route-card .r-lbl { font-size: 12px; color: var(--text-4); }
.route-card .r-name { font-size: 18px; font-weight: 700; color: #f0abfc; }
.route-card .r-count { font-size: 10px; color: var(--text-4); }

/* ── ORE ─────────────────────────────────────────────────────────── */
.table-wrap { margin-top: 12px; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
table.ore { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ore th {
  position: sticky; top: 0; background: var(--bg-soft); color: var(--text-3);
  font-weight: 600; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
}
table.ore td { padding: 8px 12px; border-bottom: 1px solid rgba(39,39,42,.6); color: var(--text-2); }
table.ore tr:last-child td { border-bottom: 0; }
table.ore td.num, table.ore th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ratio-pill { display: inline-block; min-width: 52px; text-align: center; border-radius: 999px; font-size: 11px; font-weight: 600; padding: 2px 8px; }
.empty-note { padding: 24px; text-align: center; color: var(--text-4); font-size: 13px; }

/* ── Leaflet sombre ──────────────────────────────────────────────── */
.leaflet-container { background: #0a0a0a; font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border-soft);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.leaflet-popup-content { margin: 10px 12px; font-size: 12px; line-height: 1.5; }
.leaflet-popup-content b { font-size: 12px; }
.leaflet-popup-close-button { color: var(--text-4) !important; }
.leaflet-bar a, .leaflet-control-attribution {
  background: var(--bg-soft) !important; color: var(--text-3) !important;
  border-color: var(--border) !important;
}
.leaflet-control-attribution a { color: var(--text-3) !important; }
.leaflet-bar a:hover { background: #27272a !important; }
.leaflet-control-zoom { border: 1px solid var(--border) !important; }
.vehicle-icon, .vehicle-icon-stale { background: transparent; border: 0; }

/* ── Pied de page ────────────────────────────────────────────────── */
.app-footer {
  margin-top: auto; border-top: 1px solid var(--border); background: var(--bg);
}
.app-footer span { font-size: 11px; color: var(--text-4); }
.footer-inner { max-width: 80rem; margin: 0 auto; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 4px 16px; }

/* ── Scrollbars ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-soft); }
