﻿/*
   Mi Ruta  Diseño v2  |  Público / Transporte
   Tema claro + oscuro, glassmorphism, diseño moderno
*/

/* 
   VARIABLES  MODO OSCURO (default)
    */
:root {
  --topbar-h: 60px;
  --radius-2xl: 24px;
  --radius-xl:  18px;
  --radius-lg:  14px;
  --radius-md:  10px;
  --radius-sm:  8px;
  --trans:      0.22s ease;
  --trans-slow: 0.4s cubic-bezier(0.4,0,0.2,1);

  /* Fondo */
  --bg-base:    #070f1a;
  --bg-hero:    linear-gradient(145deg, #0b1828 0%, #0f1f35 40%, #0a2240 100%);
  --bg-body:    #0b1624;

  /* Superficies */
  --surface:    #0f1e33;
  --surface-2:  #162843;
  --surface-3:  #1d3454;
  --surface-4:  #254065;
  --glass:      rgba(15,30,51,0.82);
  --glass-light:rgba(22,40,67,0.7);

  /* Bordes */
  --border:     rgba(255,255,255,0.08);
  --border-med: rgba(255,255,255,0.14);
  --border-hi:  rgba(255,255,255,0.24);

  /* Texto */
  --text:       #f0f6ff;
  --text-2:     #b8cee8;
  --text-muted: #7a97ba;
  --text-dim:   #425e7a;

  /* Acento primario */
  --accent:       #ec483b;
  --accent-dark:  #c83830;
  --accent-glow:  rgba(236,72,59,0.32);
  --accent-light: rgba(236,72,59,0.12);

  /* Acento secundario */
  --accent-2:     #fbbf24;
  --success:      #34d399;
  --success-bg:   rgba(52,211,153,0.12);
  --danger:       #f87171;
  --danger-bg:    rgba(248,113,113,0.12);

  /* Paleta de rutas */
  --rc0:#ff6b2b; --rc1:#3b82f6; --rc2:#34d399; --rc3:#c084fc;
  --rc4:#fbbf24; --rc5:#22d3ee; --rc6:#f472b6; --rc7:#a3e635;
  --rc8:#fb923c; --rc9:#4ade80; --rc10:#818cf8; --rc11:#2dd4bf;

  /* Mapa: tile oscuro */
  --tile-filter: brightness(0.78) saturate(0.65) hue-rotate(5deg);
}

/* 
   VARIABLES  MODO CLARO
    */
[data-theme="light"] {
  --bg-base:    #f3f7fd;
  --bg-hero:    linear-gradient(145deg, #e8f0fc 0%, #dce9ff 40%, #d0e2ff 100%);
  --bg-body:    #eef3fb;

  --surface:    #ffffff;
  --surface-2:  #f0f5fd;
  --surface-3:  #e4edf9;
  --surface-4:  #d5e3f5;
  --glass:      rgba(15,30,51,0.82);
  --glass-light:rgba(255,255,255,0.72);

  --border:     rgba(30,60,120,0.1);
  --border-med: rgba(30,60,120,0.16);
  --border-hi:  rgba(30,60,120,0.28);

  --text:       #0c1a30;
  --text-2:     #2a4570;
  --text-muted: #4a6898;
  --text-dim:   #8aa3c4;

  --accent:       #ec483b;
  --accent-dark:  #c83830;
  --accent-glow:  rgba(236,72,59,0.22);
  --accent-light: rgba(236,72,59,0.09);

  --accent-2:     #d97706;
  --success:      #059669;
  --success-bg:   rgba(5,150,105,0.1);
  --danger:       #dc2626;
  --danger-bg:    rgba(220,38,38,0.1);

  --tile-filter: brightness(1.02) saturate(1.1);
}

/* 
   RESET & BASE
    */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.35s ease, color 0.35s ease;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 4px; }

/* 
   TOPBAR
    */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-med);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 1000;
  box-shadow: 0 2px 24px rgba(0,0,0,0.18);
  transition: background 0.35s ease, border-color 0.35s ease;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.brand-icon {
  position: relative;
  height: calc(var(--topbar-h) - 18px);
  width: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.brand-logo {
  height: 100%;
  width: auto;
  max-width: 180px;
  object-fit: contain;
}
.brand-svg {
  width: 34px; height: 34px;
}
.brand-text {
  font-size: 1.08rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.status-label { white-space: nowrap; }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.4s;
}
.dot--idle  { background: var(--text-dim); }
.dot--ok    { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot--error { background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* Botón de tema */
.theme-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.2);
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,0.22) 0%, transparent 50%),
    linear-gradient(145deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04));
  color: #ffd166;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.22),
    0 8px 18px rgba(0,0,0,0.24);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  flex-shrink: 0;
  overflow: hidden;
}
.theme-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.32);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.32),
    0 10px 26px rgba(249,115,22,0.28);
}
.theme-btn:active {
  transform: translateY(0);
}
.theme-btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(249,115,22,0.34),
    inset 0 1px 0 rgba(255,255,255,0.22),
    0 10px 22px rgba(0,0,0,0.24);
}

[data-theme="light"] .theme-btn {
  border-color: rgba(30,60,120,0.2);
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,0.9) 0%, transparent 52%),
    linear-gradient(145deg, rgba(255,255,255,0.92), rgba(220,232,250,0.88));
  color: #f59e0b;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.95),
    0 8px 18px rgba(18,38,74,0.16);
}

.theme-icon {
  position: absolute;
  width: 19px;
  height: 19px;
  display: block;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#iconSun { filter: drop-shadow(0 0 6px rgba(253,186,116,0.45)); }
#iconMoon { color: #93c5fd; filter: drop-shadow(0 0 6px rgba(147,197,253,0.45)); }

.theme-icon.hidden {
  opacity: 0;
  transform: scale(0.65) rotate(-25deg);
  pointer-events: none;
}

/* Sync bar */
.sync-bar {
  position: fixed;
  top: calc(var(--topbar-h) - 2px);
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  pointer-events: none;
  z-index: 1001;
  transform-origin: left;
}
.sync-bar.syncing {
  opacity: 1;
  animation: syncAnim 1.8s ease-in-out infinite;
}
@keyframes syncAnim {
  0%   { clip-path: inset(0 100% 0 0); }
  55%  { clip-path: inset(0 15%  0 0); }
  80%  { clip-path: inset(0 0    0 0); }
  100% { clip-path: inset(0 0    0 100%); }
}

/* 
   MAPA
    */
#map {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: var(--bg-base);
}
#map .leaflet-tile { filter: var(--tile-filter); }

.leaflet-control-zoom {
  border: 1px solid var(--border-med) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25) !important;
  margin-top: calc(var(--topbar-h) + 0.7rem) !important;
}
.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text-muted) !important;
  border-bottom: 1px solid var(--border) !important;
  width: 38px !important; height: 38px !important;
  line-height: 38px !important;
  font-size: 1.1rem !important;
  transition: all var(--trans);
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; color: var(--text) !important; }
.leaflet-popup, .leaflet-popup.leaflet-zoom-animated { display: none !important; }

/* 
   SPINNER
    */
.map-spinner {
  position: fixed;
  top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  background: rgba(7,15,26,0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 600;
}
[data-theme="light"] .map-spinner { background: rgba(243,247,253,0.8); }
.map-spinner.hidden { display: none; }

.spinner-ring {
  width: 44px; height: 44px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.72s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-text { font-size: 0.88rem; color: var(--text-muted); font-weight: 500; }

/* 
   ROUTE PICKER
    */
.route-picker {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: contain;
  background: var(--bg-body);
  transition: opacity var(--trans-slow), transform var(--trans-slow);
}
.route-picker.hiding {
  opacity: 0;
  transform: scale(0.96) translateY(-10px);
  pointer-events: none;
}
.route-picker.hidden { display: none; }

/* ── Header azul ── */
.picker-header {
  background: linear-gradient(135deg, #14263f 0%, #1e3658 52%, #2b4870 100%);
  padding: calc(var(--topbar-h) + 1.2rem) 1.5rem 2.4rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-radius: 0 0 28px 28px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.picker-header::after {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.picker-header-greeting {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.72);
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.picker-header-title {
  font-size: clamp(1.55rem, 5vw, 2rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.18;
  letter-spacing: -0.3px;
  margin-bottom: 0.3rem;
}
.picker-header-sub {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.65);
}
.picker-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 4px;
}
.picker-avatar-img {
  width: 34px; height: 34px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

/* ── Buscador ── */
.picker-search-wrap {
  position: relative;
  padding: 0 1.2rem;
  margin-top: -1.3rem;
  margin-bottom: 0;
  flex-shrink: 0;
  z-index: 2;
}
.picker-search-icon {
  position: absolute;
  left: 2.05rem;
  top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--text-dim);
  pointer-events: none;
}
.picker-search {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border-med);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 0.85rem 1.1rem 0.85rem 2.7rem;
  outline: none;
  transition: border-color var(--trans), box-shadow var(--trans);
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
}
.picker-search:focus {
  border-color: #1e3658;
  box-shadow: 0 0 0 4px rgba(30,54,88,0.25), 0 4px 20px rgba(0,0,0,0.18);
}
.picker-search::placeholder { color: var(--text-dim); }

/* ── Body scrollable ── */
.picker-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1.35rem 1.2rem 0.5rem;
}

/* Etiqueta de sección */
.section-label {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.9rem;
}

/* ── Lista de rutas ── */
.route-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 0.5rem;
}

/* Tarjeta de ruta — angular moderno + glass */
.route-btn {
  position: relative;
  width: 100%;
  height: 144px;
  border: none;
  border-radius: 26px;
  color: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  overflow: hidden;
  padding: 0;
  isolation: isolate;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
  background: #0f1f35;
}
.route-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 18px 34px rgba(236,72,59,0.24);
}
.route-btn:active {
  transform: scale(0.995);
}

.route-card-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  pointer-events: none;
}
.route-btn:hover .route-card-bg {
  transform: scale(1.08);
}

.route-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(15,23,42,0.94) 0%, rgba(15,23,42,0.72) 56%, rgba(15,23,42,0) 100%);
  z-index: 1;
}

.route-card-glass {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.58);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  clip-path: polygon(0 0, 60% 0, 45% 100%, 0 100%);
  z-index: 2;
}

.route-card-accent {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(53% - 2px);
  width: 4px;
  transform: skewX(-23deg);
  background: linear-gradient(180deg, #fb923c 0%, #f97316 45%, #f59e0b 100%);
  z-index: 3;
  box-shadow: 0 0 14px rgba(251,146,60,0.45);
}

.route-card-float-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}
.route-card-float-bus {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.85;
  pointer-events: none;
}

.route-card-content {
  position: relative;
  z-index: 5;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.15rem 1.4rem;
}

.route-card-heading {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
}

.route-card-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fb923c 0%, #f59e0b 100%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 7px 16px rgba(245,158,11,0.3);
}

.route-card-texts {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.route-btn-name {
  font-size: 1.02rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-btn-sub {
  margin-top: 2px;
  font-size: 0.72rem;
  color: rgba(253,186,116,0.9);
  font-weight: 600;
}

.route-btn-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  padding: 0.52rem 1.25rem;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(90deg, #f97316 0%, #f59e0b 100%);
  box-shadow: 0 8px 20px rgba(249,115,22,0.35);
  transition: transform 0.25s ease, filter 0.25s ease;
}

.route-btn:hover .route-btn-select {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

/* Estados de carga / vacío */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 3.5rem 0 2rem;
  color: var(--text-dim);
  font-size: 0.88rem;
}
.loading-dots { display: flex; gap: 6px; }
.loading-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #1e3658;
  animation: dotPulse 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.18s; }
.loading-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes dotPulse { 0%,100%{transform:scale(0.6);opacity:0.4} 50%{transform:scale(1);opacity:1} }

.no-results {
  text-align: center;
  padding: 2.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Nav inferior ── */
.picker-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0.6rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border-med);
  flex-shrink: 0;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.62rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.4rem 1.2rem;
  border-radius: var(--radius-md);
  transition: color var(--trans);
}
.nav-item--active { color: #ec483b; }
[data-theme="light"] .nav-item--active { color: #ec483b; }
.nav-item svg { flex-shrink: 0; }


/* 
   HUD (tarjeta de ruta activa)
    */
.active-hud {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 800;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--border-med);
  padding: 1.1rem 1.25rem calc(1.1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.28);
  transform: translateY(0);
  transition: transform var(--trans-slow), background 0.35s ease;
}
.active-hud.hidden {
  transform: translateY(110%);
  pointer-events: none;
}

/* Cabecera del HUD */
.hud-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.hud-route-badge {
  width: 46px; height: 46px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  border: 1.5px solid rgba(255,107,43,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  transition: background 0.3s ease;
}
.hud-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.hud-eyebrow {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--accent);
}
.hud-route-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-conn { flex-shrink: 0; }

/* Chips de stats */
.hud-stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  transition: background 0.2s ease;
}
.stat-chip--total { background: var(--surface-3); }
.stat-chip--moving {
  background: var(--success-bg);
  border-color: rgba(52,211,153,0.25);
  color: var(--success);
}
.stat-chip--time {
  background: transparent;
  color: #fff;
  font-size: 0.76rem;
}
.chip-icon { font-size: 0.85rem; }
.chip-val  { font-size: 0.88rem; font-weight: 700; }
.chip-val--sm { font-size: 0.76rem; font-weight: 600; }

/* Acciones */
.hud-actions {
  display: flex;
  gap: 0.6rem;
}
.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.72rem 1rem;
  transition: all var(--trans);
  white-space: nowrap;
}
.hud-btn--secondary {
  background: var(--surface-2);
  border: 1.5px solid var(--border-med);
  color: var(--text-2);
  min-width: 110px;
}
.hud-btn--secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-hi);
  color: var(--text);
}
.hud-btn--primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.hud-btn--primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 24px var(--accent-glow);
  transform: translateY(-1px);
}
.hud-btn--primary:active { transform: translateY(0); filter: brightness(0.95); }

/* 
   TOAST
    */
.toast {
  position: fixed;
  bottom: calc(180px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-lg);
  padding: 0.7rem 1.3rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  max-width: min(88vw, 400px);
  z-index: 900;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  transition: opacity 0.3s ease, transform 0.3s ease;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast--hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}
.toast--error { border-color: var(--danger); color: var(--danger); }
.toast--info  { border-color: rgba(59,130,246,0.3); }

/* 
   DRAWER (detalle de unidad)
    */
.drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-height: 65vh;
  background: var(--surface);
  border-top: 1.5px solid var(--border-med);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 50px rgba(0,0,0,0.4);
  transform: translateY(0);
  transition: transform var(--trans-slow);
}
.drawer--hidden { transform: translateY(100%); }

.drawer-grip {
  width: 44px; height: 5px;
  background: var(--border-hi);
  border-radius: 3px;
  margin: 0.9rem auto 0;
  flex-shrink: 0;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-header-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.drawer-bus-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.drawer-header h3 {
  font-size: 1rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-close {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--trans);
}
.drawer-close:hover {
  background: var(--surface-3);
  border-color: var(--border-hi);
  color: var(--text);
}

.drawer-body {
  overflow-y: auto;
  padding: 1.2rem 1.25rem 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
}
.detail-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}
.detail-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.detail-item.full { grid-column: 1 / -1; }

/* 
   RESPONSIVE
    */

/* ── Móvil & tablet (< 1024px): picker como hoja inferior, mapa visible detrás ── */
@media (max-width: 1023px) {
  .route-picker {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 42vh;
    min-height: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -6px 40px rgba(0,0,0,0.42);
    overflow: hidden;
  }
  .route-picker.hiding {
    opacity: 1;
    transform: translateY(110%);
    transition: transform 0.35s cubic-bezier(0.32,0.72,0,1) !important;
  }
  /* Handle de arrastre visible */
  .picker-header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.35);
    pointer-events: none;
  }
  /* Header compacto sin offset del topbar */
  .picker-header {
    padding: 1.5rem 1.4rem 1.8rem;
    border-radius: 22px 22px 0 0;
    cursor: grab;
  }
  .picker-header:active { cursor: grabbing; }
  /* Cuando la hoja está en peek, ocultar body para evitar scroll indeseado */
  .route-picker.sheet--peek .picker-search-wrap,
  .route-picker.sheet--peek .picker-body { opacity: 0; pointer-events: none; }
}

@media (max-width: 480px) {
  :root { --topbar-h: 56px; }
  .picker-header { padding: 1.3rem 1.2rem 1.6rem; }
  .picker-header-title { font-size: 1.55rem; }
  .picker-body  { padding: 1.2rem 1rem 0.5rem; }
  .route-btn { height: 132px; border-radius: 22px; }
  .route-card-content { padding: 1rem 1rem 1rem 1.05rem; }
  .route-card-badge { width: 38px; height: 38px; border-radius: 10px; font-size: 0.8rem; }
  .route-btn-name { font-size: 0.92rem; }
  .route-btn-sub { font-size: 0.66rem; }
  .route-btn-select { font-size: 0.77rem; padding: 0.46rem 1rem; }
  .active-hud   { gap: 0.7rem; padding: 0.9rem 1rem calc(0.9rem + env(safe-area-inset-bottom)); }
  .hud-btn--secondary { min-width: 90px; font-size: 0.82rem; }
  .drawer-body  { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .topbar-status .status-label { display: none; }
}

@media (min-width: 640px) and (max-width: 1023px) {
  .active-hud {
    left: 50%;
    right: auto;
    width: min(500px, 96vw);
    transform: translateX(-50%);
    bottom: 1.5rem;
    border-radius: var(--radius-2xl);
    border: 1.5px solid var(--border-med);
  }
  .active-hud.hidden { transform: translateX(-50%) translateY(200%); }
  .drawer {
    left: 50%;
    right: auto;
    width: min(440px, 96vw);
    transform: translateX(-50%);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }
  .drawer--hidden { transform: translateX(-50%) translateY(100%); }
  .toast { bottom: 12rem; }
}

/* ══════════════════════════════════════════════════════
   DESKTOP  ≥ 1024px — Sidebar izquierdo + mapa derecho
══════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  :root {
    --topbar-h:  68px;
    --sidebar-w: 400px;
  }

  /* Topbar más espacioso */
  .topbar { padding: 0 2rem 0 1.5rem; }
  .brand-text { font-size: 1.15rem; letter-spacing: -0.4px; }

  /* Mapa desplazado al costado del sidebar */
  #map { left: var(--sidebar-w); }

  /* Spinner solo sobre el área de mapa */
  .map-spinner { left: var(--sidebar-w); }

  /* ─ Route Picker: panel izquierdo fijo ─ */
  .route-picker {
    width: var(--sidebar-w);
    right: auto;
    bottom: auto;
    height: 100dvh;
    border-radius: 0;
    border-right: 1px solid var(--border-med);
    box-shadow: 2px 0 24px rgba(0,0,0,0.22);
    cursor: default;
  }
  .route-picker.hiding {
    opacity: 0;
    transform: translateX(-24px);
  }
  /* Ocultar handle de arrastre en desktop */
  .picker-header::before { display: none; }
  .picker-header {
    padding: calc(var(--topbar-h) + 1.6rem) 1.6rem 2.5rem;
    border-radius: 0;
    cursor: default;
  }
  .picker-header:active { cursor: default; }
  /* Asegurarse de que el body sea siempre visible en desktop */
  .route-picker.sheet--peek .picker-search-wrap,
  .route-picker.sheet--peek .picker-body { opacity: 1; pointer-events: auto; }
  .picker-search-wrap { padding: 0 1.4rem; }
  .picker-body        { padding: 1.4rem 1.4rem 1rem; }
  .section-label      { font-size: 0.85rem; }

  /* ─ Active HUD: sidebar completo izquierdo ─ */
  .active-hud {
    left: 0;
    right: auto;
    width: var(--sidebar-w);
    top: var(--topbar-h);
    bottom: 0;
    border-top: none;
    border-right: 1px solid var(--border-med);
    border-radius: 0;
    padding: 2rem 1.6rem;
    flex-direction: column;
    gap: 1.4rem;
    justify-content: flex-start;
    transform: none;
    overflow-y: auto;
    box-shadow: 2px 0 24px rgba(0,0,0,0.2);
  }
  .active-hud.hidden {
    transform: translateX(-110%);
    pointer-events: none;
  }
  .hud-route-badge {
    width: 60px; height: 60px;
    font-size: 1.7rem;
    border-radius: var(--radius-lg);
  }
  .hud-route-name { font-size: 1.2rem; }
  .hud-eyebrow    { font-size: 0.72rem; }
  .hud-stats      { gap: 0.65rem; flex-wrap: wrap; }
  .stat-chip      { padding: 0.5rem 1rem; font-size: 0.88rem; }
  .hud-actions {
    margin-top: auto;
    flex-direction: column;
    gap: 0.75rem;
  }
  .hud-btn {
    width: 100%;
    padding: 0.9rem 1.25rem;
    font-size: 0.95rem;
    justify-content: center;
  }
  .hud-btn--secondary { min-width: unset; }

  /* ─ Drawer: sobre el área de mapa ─ */
  .drawer {
    left: var(--sidebar-w);
    right: 0;
    width: auto;
    max-height: 52vh;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    transform: translateY(0);
  }
  .drawer--hidden { transform: translateY(100%); }

  /* ─ Toast: centrado en el área de mapa ─ */
  .toast {
    left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) / 2);
    bottom: 2.5rem;
    transform: translateX(-50%);
  }
  .toast--hidden {
    transform: translateX(-50%) translateY(8px);
  }
}

@media (min-width: 1280px) {
  :root { --sidebar-w: 440px; }
}

/* ══════════════════════════════════════════════════════
   BOTÓN MI UBICACIÓN
══════════════════════════════════════════════════════ */
.locate-btn {
  position: fixed;
  z-index: 500;
  /* Se coloca debajo del control de zoom de Leaflet (topright) */
  top: calc(var(--topbar-h) + 96px);
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border-med);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,0.36);
  transition: color var(--trans), background var(--trans), box-shadow var(--trans);
}
.locate-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.locate-btn:active { opacity: 0.8; }

.locate-btn--active {
  color: #3b82f6;
  border-color: rgba(59,130,246,0.45);
  box-shadow: 0 1px 5px rgba(0,0,0,0.36), 0 0 0 2px rgba(59,130,246,0.18);
}

/* Spinner mientras carga el GPS */
.locate-btn--loading svg {
  animation: spin 1s linear infinite;
  opacity: 0.5;
}

@media (min-width: 1024px) {
  .locate-btn { top: calc(var(--topbar-h) + 106px); right: 10px; }
}

/* ══════════════════════════════════════════════════════
   MARCADOR DE UBICACIÓN DEL USUARIO
══════════════════════════════════════════════════════ */
.user-location-dot {
  width: 24px;
  height: 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-location-pulse {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(59,130,246,0.22);
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  animation: user-pulse 2s ease-out infinite;
  pointer-events: none;
}
.user-location-core {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.6);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
@keyframes user-pulse {
  0%   { transform: translate(-50%,-50%) scale(0.4); opacity: 0.8; }
  70%  { transform: translate(-50%,-50%) scale(1.4); opacity: 0;   }
  100% { transform: translate(-50%,-50%) scale(1.4); opacity: 0;   }
}

/* Líneas de rutas — cursor pointer para indicar que son clicables */
.leaflet-overlay-pane path {
  cursor: pointer;
}
