/* ── Variables & Reset ─────────────────────────────────────────────────────── */
:root {
  --bg:        #0f172a;
  --panel-bg:  #1e293b;
  --border:    #334155;
  --text:      #f1f5f9;
  --text-muted:#94a3b8;
  --accent:    #3b82f6;
  --accentarr: #187936;
  --accent-h:  #2563eb;
  --shadow:    rgba(0,0,0,.5);
  --radius:    10px;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
}

/* ── Carte (fond plein écran) ──────────────────────────────────────────────── */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ── Bouton hamburger ──────────────────────────────────────────────────────── */
#menu-toggle {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  width: 42px;
  height: 42px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 8px var(--shadow);
  transition: background .2s;
}
#menu-toggle:hover { background: var(--border); }
#menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .25s, opacity .25s;
}
/* Animation → croix quand ouvert */
body.nav-open #menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.nav-open #menu-toggle span:nth-child(2) { opacity: 0; }
body.nav-open #menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Panneau de navigation latéral ────────────────────────────────────────── */
#side-nav {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 280px;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  z-index: 300;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 20px var(--shadow);
}
body.nav-open #side-nav { transform: translateX(0); }

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.nav-logo { font-size: 15px; font-weight: 700; }

#menu-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: background .15s;
}
#menu-close:hover { background: var(--border); color: var(--text); }

#side-nav ul { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; }

.nav-link {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.05); }
.nav-link.active {
  background: rgba(59,130,246,.12);
  border-left-color: var(--accent);
}
.nav-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.nav-label { font-size: 14px; font-weight: 600; line-height: 1.2; }
.nav-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Overlay (ferme le nav au clic dehors) ─────────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s;
}
body.nav-open #overlay { opacity: 1; pointer-events: all; }

/* ── Panneau d'info (slide depuis la droite) ───────────────────────────────── */
#info-panel {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: 400px;
  max-width: calc(100vw - 28px);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 150;
  overflow-y: auto;
  padding: 16px;
  box-shadow: -4px 0 20px var(--shadow);
  transform: translateX(0);
  transition: transform .25s, opacity .25s;
}
#info-panel.hidden {
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
}
#info-panel li { font-size: 12px; line-height: 1.5; margin-bottom: 4px; }

#info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--border);
  border: none;
  color: var(--text);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#info-close:hover { background: var(--accent); }

#info-content h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  padding-right: 30px;
  line-height: 1.3;
}
#info-content p  { font-size: 13px; line-height: 1.6; color: var(--text-muted); margin-bottom: 6px; }
#info-content strong { color: var(--text); }
#info-content table { font-size: 13px; }
#info-content td { padding: 4px 6px; vertical-align: top; }


#info-train.hidden {
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
}

#refresh-btn.hidden {
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
}

/* ── Loader ────────────────────────────────────────────────────────────────── */
#loader {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 14px var(--shadow);
  font-size: 13px;
  transition: opacity .2s;
}
#loader.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── MapLibre overrides ────────────────────────────────────────────────────── */
.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left { z-index: 5; }
.maplibregl-ctrl-attrib { font-size: 10px; }
