:root {
  --bg-dark: #141B26;
  --bg-panel: #1D2736;
  --text-light: #EAF0F8;
  --accent-sun: #F2B035;
  --accent-short: #E2622B;
  --accent-fresh: #3D8BE8;
  --accent-a: #5FCE7A;
  --accent-b: #E2622B;
  --border-subtle: rgba(234, 240, 248, 0.12);
  --danger: #F26B5C;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-dark);
  color: var(--text-light);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  background: var(--bg-panel);
  padding: 10px 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 20;
}
.app-header__title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.app-header__sun { color: var(--accent-sun); }
.app-header__subtitle {
  margin: 0;
  font-size: 0.8rem;
  color: rgba(234, 240, 248, 0.6);
}

/* Main / map */
.app-main {
  position: relative;
  flex: 1;
  /* garantit une vraie hauteur de carte même avec le texte SEO sous la ligne
     de flottaison : l'app occupe l'écran, le pied de page se lit en défilant */
  min-height: calc(100vh - 58px);
  min-height: calc(100dvh - 58px);
}

#map {
  position: absolute;
  inset: 0;
  background: #0d1119;
  /* isole les calques internes de Leaflet (z-index élevés) pour que le
     panneau de contrôle reste toujours au-dessus de la carte */
  isolation: isolate;
}

/* Panel toggle (mobile) */
.panel-toggle {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 25;
  background: var(--accent-sun);
  color: #1a1305;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  display: none;
}

/* Control panel */
.panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  border-radius: 16px 16px 0 0;
  max-height: 62vh;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.35);
}
.panel__scroll {
  overflow-y: auto;
  max-height: 62vh;
  padding: 14px 16px 22px;
}

.instructions {
  margin: 0 0 14px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(234, 240, 248, 0.85);
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field--row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.field__label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: rgba(234, 240, 248, 0.85);
}
.field__value {
  color: var(--accent-sun);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 12px 16px;
  border: none;
  cursor: pointer;
  margin-right: 10px;
  margin-bottom: 8px;
  min-height: 44px;
  transition: filter 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); }
.btn--primary {
  background: var(--accent-sun);
  color: #1a1305;
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--primary:disabled {
  background: #4a4536;
  color: rgba(234,240,248,0.4);
  cursor: not-allowed;
}
.btn--ghost {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border-subtle);
}
.btn--ghost:hover { background: rgba(234,240,248,0.06); }

/* Champs d'adresse */
.text-input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 16px; /* évite le zoom automatique d'iOS sur focus */
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(234, 240, 248, 0.06);
  color: var(--text-light);
}
.text-input::placeholder { color: rgba(234, 240, 248, 0.4); }
.text-input:focus {
  outline: 2px solid var(--accent-sun);
  outline-offset: 1px;
  border-color: transparent;
}

/* Bandeau météo */
.weather-info {
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-bottom: 14px;
  color: rgba(234, 240, 248, 0.85);
}
.weather-info[data-kind="rain"] { color: #8FC9F5; }

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2a3346, var(--accent-sun));
  outline: none;
  margin: 6px 0;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-sun);
  border: 3px solid var(--bg-panel);
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-sun);
  border: 3px solid var(--bg-panel);
  cursor: pointer;
}
.slider__ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: rgba(234, 240, 248, 0.5);
  margin-top: 2px;
}
.sun-info {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: rgba(242, 176, 53, 0.9);
}

/* Checkboxes */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.checkbox-label input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent-sun);
}

/* Status message */
.status-message {
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-bottom: 12px;
}
.status-message[data-kind="error"] { color: var(--danger); }
.status-message[data-kind="ok"] { color: #7BD98C; }
.status-message[data-kind="loading"] { color: var(--accent-sun); }

/* Stats panel */
.stats-panel {
  background: rgba(234, 240, 248, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
}
.stats-panel__title {
  font-size: 0.95rem;
  margin: 0 0 10px;
}
.route-stat {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
  font-size: 0.85rem;
}
.route-stat__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}
.route-stat__body strong { display: block; margin-bottom: 2px; }
.stat-extra {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: rgba(234, 240, 248, 0.75);
}

/* Mode résultats : une fois le trajet calculé, on masque les réglages et le
   texte d'explication pour ne garder que l'essentiel */
.panel--results .instructions,
.panel--results #route-form,
.panel--results .field,
.panel--results .weather-info {
  display: none;
}
.panel--results .stats-panel { margin-top: 0; }

.stats-panel__actions { margin-top: 12px; }
.stats-panel__actions .btn { margin-bottom: 0; }

/* Mode guidage : le panneau s'efface, la barre d'instructions prend le bas */
.panel--guidance { display: none; }

.guidance-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.35);
  padding: 0 16px 18px;
}
.guidance-bar__progress {
  height: 5px;
  border-radius: 999px 999px 0 0;
  background: rgba(234, 240, 248, 0.1);
  overflow: hidden;
  margin: 0 -16px 12px;
}
.guidance-bar__progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-fresh);
  transition: width 0.4s ease;
}
.guidance-bar__row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.guidance-bar__row--buttons {
  margin-top: 12px;
  justify-content: flex-end;
}
.guidance-bar__icon { font-size: 1.8rem; flex-shrink: 0; }
.guidance-bar__instruction {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}
.guidance-bar__sub {
  font-size: 0.82rem;
  color: rgba(234, 240, 248, 0.7);
  margin-top: 3px;
}
.guidance-nav-btn {
  font-size: 1.3rem;
  min-width: 52px;
  padding: 8px 0;
}
.guidance-bar .btn { margin: 0; }

@media (min-width: 860px) {
  .guidance-bar { max-width: 480px; left: auto; right: 16px; bottom: 16px; border-radius: 16px; }
  .guidance-bar__progress { border-radius: 999px 999px 0 0; }
}

/* Custom map markers */
.marker-pin {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.marker-pin span {
  transform: rotate(45deg);
  color: #0d1119;
  font-weight: 800;
  font-size: 0.75rem;
}
.marker-pin--a { background: var(--accent-a); }
.marker-pin--b { background: var(--accent-b); }

/* Shadow canvas overlay */
.shadow-canvas-layer {
  pointer-events: none;
}

/* SEO footer text */
.seo-footer {
  background: var(--bg-panel);
  padding: 28px 18px 40px;
  border-top: 1px solid var(--border-subtle);
}
.seo-footer__title {
  font-size: 1.05rem;
  margin: 0 0 14px;
}
.seo-footer p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: rgba(234, 240, 248, 0.75);
  max-width: 720px;
  margin: 0 0 14px;
}

/* Desktop layout: side panel instead of bottom sheet */
@media (min-width: 860px) {
  .app-main { display: flex; }
  #map { position: static; flex: 1; }
  .panel {
    position: static;
    width: 360px;
    max-height: none;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--border-subtle);
    box-shadow: none;
    flex-shrink: 0;
  }
  .panel__scroll { max-height: none; height: 100%; }
  .panel-toggle { display: none; }
}

/* Mobile: collapsible bottom sheet */
@media (max-width: 859px) {
  .panel-toggle { display: block; }
  .panel.is-collapsed { transform: translateY(calc(100% - 54px)); }
  .panel { transition: transform 0.2s ease; }
}

/* Leaflet popup dark theme touch */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-panel);
  color: var(--text-light);
}

/* Focus visibility for accessibility */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-sun);
  outline-offset: 2px;
}
