/* ═══════════════════════════════════════════════════════════
   tranWay — Estilos principales
   Estética: industrial / utilitarian · Syne + DM Mono
   ═══════════════════════════════════════════════════════════ */

/* ── Variables de tema ──────────────────────────────────── */
:root {
  --accent:       #00e5a0;
  --accent-dim:   #00c288;
  --accent-glow:  rgba(0, 229, 160, 0.18);
  --danger:       #ff4f4f;
  --warn:         #ffb347;

  --radius-sm:    6px;
  --radius-md:    12px;
  --radius-lg:    20px;

  --transition:   0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Syne', sans-serif;
  --font-mono:    'DM Mono', monospace;

  /* Alturas fijas de las barras */
  --header-h:     52px;
  --controls-h:   140px; /* trayecto-selector + tab-nav */
  --footer-h:     calc(52px + env(safe-area-inset-bottom, 0px));
}

/* Esqueleto de carga */
.skeleton {
  background: linear-gradient(90deg, 
    var(--color-background-secondary) 25%, 
    var(--color-background-tertiary) 50%, 
    var(--color-background-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Tema claro */
@media (prefers-color-scheme: light) {
  :root {
    --bg:           #f0f4f8;
    --bg-card:      #ffffff;
    --bg-card-2:    #e8edf3;
    --bg-modal:     #ffffff;
    --border:       rgba(0,0,0,0.10);
    --border-strong:rgba(0,0,0,0.18);
    --text-primary: #0d1b2a;
    --text-secondary:#4a5568;
    --text-muted:   #8896a5;
    --header-bg:    rgba(240,244,248,0.92);
    --footer-bg:    rgba(240,244,248,0.95);
    --shadow-card:  0 2px 12px rgba(0,0,0,0.08);
    --shadow-modal: 0 -8px 40px rgba(0,0,0,0.14);
  }
}

/* Tema oscuro */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0b1219;
    --bg-card:      #131e28;
    --bg-card-2:    #1a2535;
    --bg-modal:     #131e28;
    --border:       rgba(255,255,255,0.07);
    --border-strong:rgba(255,255,255,0.14);
    --text-primary: #e8f0f7;
    --text-secondary:#a8c4d8;
    --text-muted:   #7a9ab5;
    --header-bg:    rgba(11,18,25,0.92);
    --footer-bg:    rgba(11,18,25,0.96);
    --shadow-card:  0 2px 16px rgba(0,0,0,0.4);
    --shadow-modal: 0 -8px 40px rgba(0,0,0,0.6);
  }
}

/* ── Reset y base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100dvh;        /* Moderno: viewport visual real en móvil */
  height: 100vh;         /* Fallback para navegadores sin dvh */
  overflow: hidden;
}

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text-primary);
  height: 100dvh;        /* Ocupa exactamente el viewport visible */
  height: 100vh;         /* Fallback */
  max-height: 100dvh;    /* Impide que el body crezca más allá del viewport */
  display: flex;
  flex-direction: column;
  overflow: hidden;      /* el scroll lo gestiona cada zona internamente */
  overflow-x: hidden;
  /* Safe area: solo top — el bottom lo gestiona #alerts-bar internamente */
  padding-top: constant(safe-area-inset-top, 0);
  padding-top: env(safe-area-inset-top, 0);
}

button { cursor: pointer; border: none; background: none; font-family: inherit; }
input  { font-family: var(--font-mono); }
a      { color: var(--accent); text-decoration: none; }

/* ── Barra superior de status ────────────────────────────── */
#status-bar {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

#status-ambito-name, #btn-ambito{
  display: none;
}

#status-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  overflow: hidden;
  white-space: nowrap;
}

#status-datetime {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.status-sep {
  color: var(--text-muted);
  font-size: 10px;
  display: none;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
  transition: var(--transition);
  white-space: nowrap;
}
.status-pill:hover, .status-pill:active {
  background: var(--accent);
  color: #0b1219;
  border-color: var(--accent);
}
.status-pill .chevron {
  width: 10px; height: 10px;
  opacity: 0.6;
}
#status-transport-icon { font-size: 13px; }

/* Botón reintentar en cabecera (solo visible en estado error) */
.btn-retry-header {
  color: var(--danger);
}
.btn-retry-header:hover {
  background: rgba(255,79,79,0.12);
  color: var(--danger);
}
.btn-retry-header svg {
  width: 18px; height: 18px;
}

.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition);
  flex-shrink: 0;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--bg-card-2); color: var(--text-primary); }

#status-sync {
  width: 36px;
  display: flex; align-items: center; justify-content: center;
}

.sync-idle, .sync-loading, .sync-ok, .sync-error {
  width: 8px; height: 8px;
  border-radius: 50%;
  transition: background 0.4s;
}
.sync-idle    { background: var(--text-muted); }
.sync-loading { background: var(--warn); animation: pulse-sync 1s infinite; }
.sync-ok      { background: var(--accent); }
.sync-error   { background: var(--danger); }

@keyframes pulse-sync {
  0%, 100% { opacity: 1; } 50% { opacity: 0.3; }
}

/* ── Zona de controles fijos ─────────────────────────────── */
#fixed-controls {
  position: fixed;
  top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  height: var(--controls-h);
  background: var(--bg);
  z-index: 95; /* Por encima de main-area para que no se meta debajo */
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 12px 6px;
  border-bottom: 2px solid var(--accent-dim); /* Color propio: visible contra el gradiente */
  /* Efecto glassmorphism para que se vea bien sobre el scroll */
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  /* Sombra para separación visual clara */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ── Área central ────────────────────────────────────────── */
#main-area {
  position: fixed;
  top: calc(var(--header-h) + var(--controls-h) + env(safe-area-inset-top, 0px));
  bottom: var(--footer-h); /* Solo la altura del alerts-bar */
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px 40px; /* padding-top para separación clara del borde */
  gap: 12px;
  z-index: 50; /* Menor que fixed-controls (95) para que quede debajo */
  -webkit-overflow-scrolling: touch;
  /* Prevenir pull-to-refresh y bounce que causan bloqueos */
  overscroll-behavior-y: contain;
}

/* ── Selector de trayecto ────────────────────────────────── */
#trayecto-selector {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  box-shadow: var(--shadow-card);
}

.trayecto-route {
  display: flex;
  align-items: center;
  gap: 0;
}

.route-node {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: var(--transition);
  text-align: left;
}
.route-node:hover { background: var(--bg-card-2); }

.route-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.route-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.route-node.origin  .route-label { color: var(--accent); }
.route-node.destination .route-label { color: var(--warn); }

.route-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 4px;
}

.invert-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
}
.invert-btn svg { width: 14px; height: 14px; }
.invert-btn:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(180deg);
}

/* ── Pestañas IDA / VUELTA ───────────────────────────────── */
#tab-nav {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 4px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  transition: var(--transition);
}
.tab-btn svg { width: 14px; height: 14px; }

.tab-btn.active {
  background: var(--accent);
  color: #0b1219;
}
.tab-btn:not(.active):hover {
  background: var(--bg-card-2);
  color: var(--text-primary);
}

/* Tab con paradas: aspecto de selector interactivo */
.tab-btn.has-paradas {
  cursor: pointer;
  border: 1px solid rgba(0,229,160,0.25);
}
.tab-btn.has-paradas:not(.active) {
  color: var(--accent);
}
.tab-btn.has-paradas:not(.active):hover {
  background: var(--accent-glow);
  border-color: rgba(0,229,160,0.5);
}

/* Tab sin paradas: no parece selector, solo cambia sentido */
.tab-btn:not(.has-paradas) {
  cursor: pointer;
  border: none;
}

/* ── Panel de horarios ───────────────────────────────────── */
#horarios-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 200px;
}

/* Estados vacío/error/cargando */
/* CRÍTICO: .state-view { display:flex } tiene igual especificidad que [hidden] y lo sobreescribe.
   Hay que forzar display:none cuando el atributo hidden está presente. */
.state-view[hidden] { display: none !important; }

.state-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  min-height: 160px;
}
.state-icon { font-size: 36px; }

/* Loader ring */
.loader-ring {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tarjeta de bus ──────────────────────────────────────── */
.bus-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  animation: slide-in 0.22s ease both;
  position: relative;
  overflow: hidden;
  min-height: 76px;
}
.bus-card:hover { border-color: var(--border-strong); }

/* Línea de color lateral según tipo de día */
.bus-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 3px 0 0 3px;
}
.bus-card.dias-sab::before    { background: var(--warn); }
.bus-card.dias-dyf::before    { background: #a78bfa; }
.bus-card.dias-sdf::before    { background: #60a5fa; }
.bus-card.dias-lv::before     { background: var(--accent); }

/* Hora de salida grande */
.bus-hora {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  flex-shrink: 0;
}

.bus-hora-salida {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.bus-hora-llegada {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Info central: columna con 3 sub-filas */
.bus-info {
  flex: 1 0 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}
/* Fila 1: línea + tipo + badge alarma (si existe) a la dcha */
.bus-info-top {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  flex-wrap: nowrap;
}
/* El badge de alarma en fila-top se empuja a la derecha */
.bus-info-top .alarma-countdown {
  margin-left: auto;
  flex-shrink: 0;
}
/* Fila 2: días a la izda, badges (alarma+countdown+campana) a la dcha */
.bus-info-mid {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;   /* necesario para que margin-left:auto en card-right funcione */
}
/* Fila 3: observación */
.bus-info-bot {
  display: flex;
  align-items: center;
}

.bus-linea {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.08em;
  background: var(--accent-glow);
  border: 1px solid rgba(0,229,160,0.2);
  border-radius: 4px;
  padding: 1px 6px;
  display: inline-block;
  width: fit-content;
}

.bus-dias {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 6px;
  display: inline-block;
  width: fit-content;
  background: transparent;
}

.bus-obs {
  font-size: 10px;
  /*color: var(--text-muted);*/
  color: #60a5fa;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Countdown */
.bus-countdown {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.bus-countdown.soon {
  background: rgba(255,79,79,0.15);
  color: var(--danger);
  border: 1px solid rgba(255,79,79,0.3);
}
.bus-countdown.near {
  background: rgba(255,179,71,0.15);
  color: var(--warn);
  border: 1px solid rgba(255,179,71,0.3);
}
.bus-countdown.ok {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(0,229,160,0.2);
}

/* Botón campana */
.btn-bell {
  width: 28px; 
  height: 28px;
  border-radius: 50%;
  display: flex; 
  align-items: center; 
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-card-2);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition);
}

.btn-bell svg { width: 13px; height: 13px; }
.btn-bell:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-bell.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1219;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Lista de buses (contenedor de cards) ────────────────── */
#buses-list[hidden] { display: none !important; }
#buses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Banner de día (Hoy / Mañana) */
.day-banner {
  color: var(--warn, #ffb347);
  background: rgba(255, 179, 71, 0.1);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  /*color: var(--text-muted);*/
  padding: 4px 2px 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

/* ── Barra inferior de alertas ───────────────────────────── */
#alerts-bar {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px env(safe-area-inset-bottom, 0px);
  background: var(--footer-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid var(--border);
  z-index: 100;
  overflow: hidden;
}

#alerts-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  color: var(--text-muted);
}
#alerts-label svg { width: 14px; height: 14px; }
#alerts-label span {
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.10em;
  font-family: var(--font-mono);
}

#alerts-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  display: flex;
  align-items: center;
}
#alerts-scroll::-webkit-scrollbar { display: none; }

#alerts-list {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
}

.alerts-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 0 8px;
}

/* Chip de alerta */
.alert-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  white-space: nowrap;
  cursor: default;
  transition: var(--transition);
  flex-shrink: 0;
  animation: slide-in 0.2s ease both;
}
.alert-chip:hover { border-color: var(--border-strong); }
.alert-chip.alert-active { border-color: var(--accent); }

.alert-chip-time {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}
.alert-chip-info {
  font-size: 9px;
  color: #60a5fa;
}
.alert-chip-del {
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
  margin-left: 2px;
}
.alert-chip-del:hover { color: var(--danger); }
.alert-chip-del svg { width: 10px; height: 10px; }

/* Versión en footer inferior derecha */
#footer-version {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  opacity: 0.6;
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 6px;
}

/* ── Modales ─────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  position: relative;
  background: var(--bg-modal);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-modal);
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  animation: sheet-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.modal-sheet--small { max-height: 60dvh; }

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card-2);
  color: var(--text-secondary);
  transition: var(--transition);
}
.modal-close svg { width: 14px; height: 14px; }
.modal-close:hover { background: var(--danger); color: white; }

.modal-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-search svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.modal-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
}
.modal-search input::placeholder { color: var(--text-muted); }

.modal-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0 16px;
}

.modal-list-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 10px 20px 4px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--bg-modal);
}

.modal-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  border-left: 2px solid transparent;
}
.modal-list-item:hover { background: var(--bg-card-2); }
.modal-list-item.selected {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-glow);
}
.modal-list-item .item-icon { font-size: 18px; }

.modal-list--icons .modal-list-item {
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
}

/* ── Modal alerta ─────────────────────────────────────────── */
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.alerta-preview {
  background: var(--bg-card-2);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  border-left: 3px solid var(--accent);
}

.alerta-label {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* .alerta-minutes-row, .minutes-step y #alerta-minutos[type=number]
   eliminados — sustituidos por .cfg-minutes-row / .cfg-min-btn del panel de config */

.alerta-dias-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.alerta-dias-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.dia-chip {
  padding: 5px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.dia-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1219;
}
.dia-chip:disabled {
  opacity: 0.28;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Pantalla de configuración ───────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: slide-right-in 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
.screen[hidden] { display: none; }

@keyframes slide-right-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.screen-header h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.screen-back {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card-2);
  color: var(--text-secondary);
  transition: var(--transition);
}
.screen-back svg { width: 18px; height: 18px; }
.screen-back:hover { background: var(--bg-card); color: var(--text-primary); }

.screen-body {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.config-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.config-section h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.config-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.config-field input {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}
.config-field input:focus { border-color: var(--accent); }

.config-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.cache-info {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.7;
}

.config-actions { padding-top: 8px; }

/* ── Botones comunes ─────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--accent);
  color: #0b1219;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary svg { width: 16px; height: 16px; }
.btn-full { width: 100%; }

.btn-danger {
  padding: 10px 16px;
  background: rgba(255,79,79,0.1);
  border: 1px solid rgba(255,79,79,0.3);
  color: var(--danger);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}
.btn-danger:hover { background: rgba(255,79,79,0.2); }

/* ── Toast ───────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(var(--footer-h) + 12px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 400;
  max-width: 90vw;
  text-align: center;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Scrollbar custom ────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

#sync-indicator {
  width: 12px; height: 12px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: default;
  transition: color 0.3s;
}
.sync-ok      { color: #22c55e; }   /* verde  */
.sync-error   { color: #ef4444; }   /* rojo   */
.sync-loading { color: #f59e0b; animation: spin 1s linear infinite; }

/* ── Indicadores visuales de alerta en bus-card ─────────────────────────────
   Añadir este bloque al final de css/app.css
   ─────────────────────────────────────────────────────────────────────────── */

/* Wrapper de la campana: posición relativa para alojar el badge */
.bell-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;  /* Separación entre badges y campanilla */
  flex-shrink: 0;
}

/* Badge "✓" encima de la campana cuando la alerta está activa */
.bell-badge {
  /*position: absolute;
  top:   -5px;
  right: -6px;
  background: var(--color-accent, #f59e0b);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 99px;
  pointer-events: none;
  letter-spacing: 0;*/
  display: none !important;
}

/* Añadir al final de app.css */

.btn-bell:disabled {
  opacity: 0.9;
  cursor: default;
  pointer-events: auto; /* Mantener pointer-events para que el tooltip funcione */
}

.btn-bell:disabled:hover {
  background: var(--bg-card-2);
  border-color: var(--border);
  transform: none;
}

/* Opcional: tooltip visual para el estado deshabilitado */
.btn-bell:disabled::after {
  display: none;
}

/* Campana rellena y coloreada cuando tiene alerta activa */
.bell-wrapper.bell-active .btn-bell {
  background: var(--accent) !important;           /* Fondo sólido */
  border-color: var(--accent) !important;
  color: #0b1219 !important;                      /* Color oscuro para contraste */
  opacity: 1;
}

.bell-wrapper.bell-active .btn-bell svg {
    /*filter: drop-shadow(0 0 3px color-mix(in srgb, var(--color-accent, #f59e0b) 60%, transparent));*/
}

/* Borde sutil en la card entera para reforzar que tiene alerta */
.bus-card.has-alert {
  border-left-color: var(--color-accent, #f59e0b) !important;
  /*box-shadow: inset 3px 0 0 var(--color-accent, #f59e0b);*/
}

/* Sobreescribir el ::before con rojo cuando hay alerta activa,
   independientemente del tipo de día (dias-lv, dias-sab, etc.) */
.bus-card.has-alert::before {
  background: var(--danger) !important;
}

/* ── Chip de alerta en la barra inferior: globo indicador ───────────────────
   El chip ya existente recibe una pequeña mejora visual cuando está activo   */

/* Indicador de "alerta activa" en el chip de la barra inferior */
.alert-chip.alert-active {
  /* Si ya tienes este selector, solo añade las propiedades nuevas */
  position: relative;
}

/* Punto pulsante en la esquina superior derecha del chip activo */
.alert-chip.alert-active::before {
  /*content: '';
  position: absolute;
  top:   -4px;
  right: -4px;
  width:  10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-accent, #f59e0b);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-accent, #f59e0b) 60%, transparent);
  animation: pulse-dot 2s ease-in-out infinite;*/
  display: none;
}

@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-accent, #f59e0b) 50%, transparent); }
  60%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
/* ═══════════════════════════════════════════════════════════
   CONFIGURACIÓN — Pestañas y paneles de transporte
   ═══════════════════════════════════════════════════════════ */

/* ── Barra de pestañas ───────────────────────────────────── */
#cfg-tabs {
  display: flex;
  overflow-x: auto;
  gap: 2px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 60px;           /* debajo del screen-header */
  z-index: 9;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#cfg-tabs::-webkit-scrollbar { display: none; }

.cfg-tab {
  flex-shrink: 0;
  padding: 11px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}
.cfg-tab:hover  { color: var(--text-secondary); }
.cfg-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Paneles de contenido ────────────────────────────────── */
.cfg-panel {
  display: none;
}
.cfg-panel.active {
  display: flex;
}

/* Reutilizamos .screen-body para el padding/gap/max-width  */

/* ── Botones de minutos ───────────────────────────────────── */
.cfg-minutes-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cfg-min-btn {
  flex: 1 0 calc(16.6% - 8px);
  min-width: 44px;
  padding: 10px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  transition: var(--transition);
}
.cfg-min-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.cfg-min-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1219;
  font-weight: 700;
}

/* ── Panel de transporte: secciones ─────────────────────── */
.cfg-transport-panel .config-section + .config-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

/* Campo URL con botón de test inline */
.cfg-url-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.cfg-url-row input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  min-width: 0;
}
.cfg-url-row input:focus { border-color: var(--accent); }
.cfg-url-row input::placeholder { color: var(--text-muted); font-size: 11px; }

.btn-test-url {
  flex-shrink: 0;
  padding: 10px 12px;
  background: var(--bg-card-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
}
.btn-test-url:hover  { border-color: var(--accent); color: var(--accent); }
.btn-test-url.ok     { border-color: #22c55e; color: #22c55e; background: rgba(34,197,94,0.08); }
.btn-test-url.error  { border-color: var(--danger); color: var(--danger); background: rgba(255,79,79,0.08); }

/* Estado de la URL (ok / error / vacía) */
.cfg-url-status {
  font-size: 11px;
  font-family: var(--font-mono);
  min-height: 16px;
  transition: color 0.2s;
}
.cfg-url-status.ok    { color: #22c55e; }
.cfg-url-status.error { color: var(--danger); }

/* Label de campo en paneles de transporte */
.cfg-transport-panel .config-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Contenedor para los contadores de tiempo (legacy, mantenido por compatibilidad) */
.countdown-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 70px;
}

/* Zona derecha dentro de bus-info-mid: badges en fila horizontal */
.card-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Layout de 3 filas de la bus-card ───────────────────────────────────────── */
/* card-row eliminado — sustituido por bus-info-top/mid/bot */

/* Estilo base para el contador de alarma */
.alarma-countdown {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  animation: fade-in 0.3s ease;
}

/* Versión soon (menos de 5 min) */
.alarma-countdown.soon {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.6);
  font-weight: 700;
  animation: pulse-alarma 1.5s infinite;
}

/* Versión near (5-15 min) */
.alarma-countdown.near {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
}

/* Animación de pulso */
@keyframes pulse-alarma {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.02); }
}

/* Ajustar el contador de viaje en layout horizontal */
.viaje-countdown {
  margin-top: 0;
  font-size: 11px;
  flex-shrink: 0;
}
/* ── Estilo para servicios premium (barra izquierda azul) ─────────────────── */
.bus-card.dias-premium::before {
    background: #3b82f6;  /* Azul brillante */
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

/* Opcional: también podemos darle un estilo al texto del tipo de servicio */
.bus-card.dias-premium .bus-linea {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

/* Si quieres que el badge de "PREMIUM" sea más visible */
.bus-card.dias-premium .tipo-servicio {
    color: #3b82f6;
    font-weight: 700;
}
.tipo-servicio {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--bg-card-2);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
    border: 1px solid rgba(0, 229, 160, 0.2);
}

.bus-card.dias-premium .tipo-servicio {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ── Autenticación ───────────────────────────────────────── */
#user-container {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.google-login-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
    white-space: nowrap;
}

.google-login-btn:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.google-login-btn svg {
    width: 16px;
    height: 16px;
}

.user-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 4px;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    transition: var(--transition);
}

.user-button:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-button svg {
    opacity: 0.6;
}

/* Menú de usuario */
.user-menu {
    position: fixed;
    width: 260px;
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-modal);
    z-index: 1000;
    overflow: hidden;
    animation: fade-in 0.15s ease;
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-card-2);
    border-bottom: 1px solid var(--border);
}

.user-menu-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-menu-header div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.user-menu-header strong {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-header small {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-item {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-menu-item:hover {
    background: var(--accent-glow);
    color: var(--accent);
}

.user-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

#toast.error-toast {
    background: #ff4f4f;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(255, 79, 79, 0.3);
}
/* Toast de error */
#toast.error {
    background: #ff4f4f;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(255, 79, 79, 0.4);
    border-left: 4px solid #ff1744;
}

/* Toast de advertencia */
#toast.warning {
    background: #ffb347;
    color: #0b1219;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(255, 179, 71, 0.4);
    border-left: 4px solid #ff9800;
}
/* ── Botón secundario ──────────────────────────────────────── */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-card-2);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--accent);
    color: var(--accent);
}
.btn-secondary svg { flex-shrink: 0; }

/* ── User info card en panel de perfil ─────────────────────── */
.user-info-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
/* ── Días de alerta en color amarillo ─────────────────── */
.alert-chip-dias {
    color: var(--warn, #ffb347);
    font-weight: 600;
    background: rgba(255, 179, 71, 0.1);
    padding: 0 2px;
    border-radius: 3px;
}

/* Opcional: mejorar contraste cuando el chip está activo */
.alert-chip.alert-active .alert-chip-dias {
    color: #ffb347;
    background: rgba(255, 179, 71, 0.15);
}
/* Indicador de servicio en barra superior */
.servicio-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 4px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-right: 6px;
}

.servicio-icon {
  font-size: 14px;
  line-height: 1;
}

.servicio-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Botón para cambiar servicio en el menú de usuario */
.user-menu-item [data-action="cambiar-servicio"] {
  color: var(--accent);
}
.bus-obs {
    display: block;
    min-height: 1.2em;
    line-height: 1.2;
}
.bus-card {
    min-height: 80px; /* Ajusta según tu diseño */
}
/* ── Botón "Cargar el día completo" ─────────────────────────────────────── */
/* Oculto por defecto — solo visible cuando body.user-logged (auth gestionado en notifyAuthChange) */
#btn-dia-completo {
  display: none;
}
body.user-logged #btn-dia-completo {
  display: block;
  width: 100%;
  padding: 10px 16px;
  margin-top: 8px;
  background: rgba(96, 165, 250, 0.1);
  color: #60a5fa;
  border: 1px dashed #60a5fa;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
}
body.user-logged #btn-dia-completo:hover,
body.user-logged #btn-dia-completo:active {
  background: rgba(96, 165, 250, 0.2);
  border-color: #93c5fd;
  color: #93c5fd;
}
/* ── Popup detalle de alerta (sheet desde abajo) ──────────────────────────── */
#popup-alerta-detalle {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 900;
}
#popup-alerta-detalle[hidden] { display: none; }

.popup-detalle-box {
  background: var(--color-surface, #1e1e2e);
  border-radius: 16px 16px 0 0;
  padding: 1.2rem 1.4rem 2.2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 -4px 28px rgba(0, 0, 0, .5);
  animation: slideUp .22s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.popup-detalle-box h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-accent, #f59e0b);
  letter-spacing: .01em;
}

.popup-detalle-fila {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .4rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  font-size: .88rem;
}

.popup-detalle-label {
  color: var(--color-text-muted, #888);
  flex-shrink: 0;
  margin-right: .8rem;
}

.popup-estado.activa  { color: #4ade80; font-weight: 600; }
.popup-estado.pausada { color: #f87171; font-weight: 600; }

.popup-detalle-acciones {
  display: flex;
  gap: .75rem;
  margin-top: 1.3rem;
}

.popup-detalle-acciones button {
  flex: 1;
  padding: .7rem;
  border-radius: 10px;
  border: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.popup-detalle-acciones button:active { opacity: .75; }

.btn-popup-secondary {
  background: var(--color-surface-alt, #2a2a3e);
  color: var(--color-text, #fff);
  border: 1px solid rgba(255,255,255,.12) !important;
}
.btn-popup-danger {
  background: #ef4444;
  color: #fff;
}
.alert-chip.alert-paused {
  border-color: #ef4444;
}
#btn-retry{
  display: none;
}

/* Preferencias regionales */
.pref-row {
    margin-bottom: 16px;
}

.pref-row label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #8fa3b8);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pref-select {
    width: 100%;
    background: var(--bg-card-2, rgba(255,255,255,0.06));
    border: 1px solid var(--border, rgba(255,255,255,0.12));
    border-radius: var(--radius-md, 8px);
    color: var(--text-primary, #e8f0fe);
    font-size: 15px;
    padding: 10px 12px;
    box-sizing: border-box;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238fa3b8' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.pref-select:focus {
    border-color: var(--accent, #00e5a0);
}

.pref-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pref-select option {
    background: var(--bg-card, #0f1923);
    color: var(--text-primary, #e8f0fe);
}

.config-hint {
    font-size: 12px;
    color: var(--text-muted, #8fa3b8);
    margin-top: 4px;
    line-height: 1.5;
}
/* Modal de novedades */
#modal-novedades .news-subtitle {
    font-size: 0.9rem;
    color: #ffb347;
    margin-bottom: 8px;
    line-height: 1.3;
}

#modal-novedades .news-item:last-child {
    border-bottom: none !important;
}

#modal-novedades .news-item h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

#modal-novedades .news-item h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 24px 0 10px 0;
    color: var(--accent, #00e5a0);
}

#modal-novedades .news-item h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 20px 0 8px 0;
    color: var(--text-primary);
}

#modal-novedades .news-item strong {
    color: var(--accent, #00e5a0);
    font-weight: 700;
}

#modal-novedades .news-item em {
    color: var(--text-muted);
    font-style: italic;
}

#modal-novedades .news-item ul, 
#modal-novedades .news-item ol {
    margin: 8px 0 16px 20px;
    color: var(--text-primary);
}

#modal-novedades .news-item li {
    margin-bottom: 4px;
}

#modal-novedades .news-item code {
    background: var(--bg-card-2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'DM Mono', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

.loader-ring {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Estilo para horas con prioridad de scraper */
.bus-hora-salida.scraper-priority {
    color: #00a8ff; /* Azul similar a los comentarios */
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.bus-hora-salida.scraper-priority:hover {
    opacity: 0.8;
}

/* Si quieres un efecto de feedback al hacer click */
.bus-hora-salida.scraper-priority:active {
    transform: scale(0.95);
}

/* ── Preferencias de notificaciones ─────────────────────────────────────── */

/* Grupo de badges numéricos (1-5 avisos) */
.badge-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border, #ccc);
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-btn.active {
  background: var(--accent, #0070f3);
  border-color: var(--accent, #0070f3);
  color: #fff;
}

.badge-btn:focus-visible {
  outline: 2px solid var(--accent, #0070f3);
  outline-offset: 2px;
}

/* Fila de preferencia con columna (label encima) */
.pref-row--col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Fila con toggle a la derecha */
.pref-row--toggle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pref-row--toggle > div {
  flex: 1;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  display: block;
  width: 48px;
  height: 28px;
  background: var(--border-strong);
  border-radius: 14px;
  transition: background 0.2s;
  position: relative;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent, #0070f3);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent, #0070f3);
  outline-offset: 2px;
}
.pref-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}
/* Chip de alerta: estado "disparada" — alarma ya sonó, borde amarillo */
.alert-chip.alert-fired {
  border-color: var(--warn);        /* amarillo #ffb347 */
}
.alert-chip.alert-fired .alert-chip-time {
  color: var(--warn);
}
/* Línea + tipo de servicio en la misma fila */
.bus-linea-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
/* card-right: bloque duplicado eliminado */

/* ── Popup de aviso genérico (mismo look que #popup-alerta-detalle) ───────── */
.popup-aviso {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 900;
}
.popup-aviso[hidden] { display: none; }

.popup-aviso-cuerpo {
  line-height: 1.55;
  font-size: .9rem;
  color: var(--color-text, #fff);
  margin-bottom: .25rem;
}
.popup-aviso-cuerpo p {
  margin: 0 0 .6rem;
}
.popup-aviso-cuerpo p:last-child {
  margin-bottom: 0;
}
.bus-card--pasado {
  opacity: 0.45;
  filter: grayscale(0.4);
}
/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER LEGAL
   ═══════════════════════════════════════════════════════════════════════════ */

#legal-footer {
  position: fixed;
  bottom: var(--footer-h); /* Justo encima del alerts-bar */
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.6;
  transition: opacity 0.3s ease;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  z-index: 85; /* Por debajo del alerts-bar (90) pero por encima del main-area */
  min-height: 32px; /* 4px más alto: de 28px a 32px */
  pointer-events: none; /* Permite que los clicks pasen a través excepto en los enlaces */
}

/* Solo los enlaces son clickables */
#legal-footer a {
  pointer-events: auto;
}

#legal-footer:hover {
  opacity: 1;
}

.legal-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.legal-link:hover,
.legal-link:focus {
  color: var(--accent);
  opacity: 1;
  text-decoration: underline;
}

.legal-sep {
  color: var(--text-muted);
  user-select: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL LEGAL
   ═══════════════════════════════════════════════════════════════════════════ */

.modal-sheet--legal {
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-body--legal {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
}

.legal-content {
  padding: 24px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.legal-content p {
  margin: 0 0 1.2em 0;
}

.legal-content p:last-child {
  margin-bottom: 0;
}

.legal-content strong,
.legal-content b {
  font-weight: 600;
  color: var(--text-primary);
}

.legal-content a {
  color: var(--accent);
  text-decoration: underline;
}

.legal-content a:hover {
  color: var(--accent-hover);
}

/* Estados de carga y error */
.legal-loading,
.legal-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 16px;
}

.legal-loading .loader-ring {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.legal-loading p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.legal-error {
  color: var(--text-secondary);
}

.legal-error .state-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.legal-error p {
  margin: 0 0 8px 0;
}

.legal-error-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Responsive */
@media (max-width: 640px) {
  /* Aumentar padding en móvil para mejor separación visual */
  #main-area {
    padding-top: 20px;
  }
  
  /* Aumentar sombra en móvil para que se vea mejor la separación */
  #fixed-controls {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  }
  
  .modal-sheet--legal {
    max-height: 90vh;
  }
  
  .legal-content {
    padding: 20px 16px;
    font-size: 0.875rem;
  }
  
  #legal-footer {
    font-size: 0.65rem;
    gap: 5px;
    padding: 8px 8px;
    min-height: 28px; /* 4px más en móvil también: de 24px a 28px */
    opacity: 1;
  }
  
  .legal-link {
    white-space: nowrap;
  }
}

/* Móviles muy pequeños */
@media (max-width: 380px) {
  #legal-footer {
    font-size: 0.6rem;
    gap: 4px;
    padding: 5px 6px;
  }
  
  .legal-sep {
    font-size: 0.5rem;
  }
}