/* ═══════════════════════════════════════════════════════════════
   Nautilus PWA — Estilos v5
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg:       #0b1018;
  --panel:    #141d28;
  --panel2:   #1c2838;
  --text:     #eef2f7;
  --muted:    #8a9bb0;
  --line:     #243040;
  --accent:   #f5c518;
  --accent2:  #e89c00;
  --ok:       #22c55e;
  --ok-dark:  #14532d;
  --bad:      #ef4444;
  --bad-dark: #450a0a;
  --blue:     #3b82f6;
  --blue-dark:#0f2a5e;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.45);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }

/* ── Login ─────────────────────────────────────────────────────── */
.login-screen { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); background: linear-gradient(160deg, #0b1018 60%, #111e30); }
.login-hero { text-align: center; margin-bottom: 32px; }
.login-logo {
  width: 72px; height: 72px; border-radius: 22px; background: var(--accent); color: #111;
  font-weight: 900; font-size: 34px; display: grid; place-items: center; margin: 0 auto 16px;
  box-shadow: 0 0 0 8px rgba(245,197,24,.12), 0 0 40px rgba(245,197,24,.2);
}
.login-title { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.login-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.field-label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 7px; font-weight: 500; }
input {
  background: var(--bg); border: 1.5px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 15px 14px; font-size: 16px; outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; margin: 0; line-height: 1.5; text-align: center; }

/* ── Botones ────────────────────────────────────────────────────── */
button { border: 0; border-radius: 12px; font-weight: 700; cursor: pointer; color: var(--text); background: var(--panel2); font-family: var(--font); transition: opacity 0.12s; }
button:active { opacity: 0.75; }
.btn-lg { min-height: 56px; padding: 14px 16px; font-size: 16px; width: 100%; border-radius: 14px; }
.primary { background: var(--accent); color: #111; font-size: 17px; }
.ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.danger { background: var(--bad-dark); color: #fca5a5; border: 1.5px solid #7f1d1d; }
.error { color: var(--bad); font-size: 13px; margin: 0; }

/* ── App shell ──────────────────────────────────────────────────── */
.screen.app-shell { display: flex; flex-direction: column; height: 100%; position: relative; }
.app-shell[hidden] { display: none !important; }

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-shrink: 0;
  gap: 12px;
}
.topbar-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.topbar-info strong { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-meta { display: flex; align-items: center; gap: 8px; }
#lbl-unidad { color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.chip.libre { background: rgba(34,197,94,.15); color: #4ade80; border: 1px solid rgba(34,197,94,.3); }
.chip.ocupado { background: rgba(245,197,24,.15); color: var(--accent); border: 1px solid rgba(245,197,24,.3); }
.chip.offline { background: rgba(138,155,176,.1); color: var(--muted); border: 1px solid var(--line); }

.toggle-gps {
  min-width: 88px; min-height: 40px; padding: 8px 14px; font-size: 13px; font-weight: 700;
  border-radius: 20px; display: flex; align-items: center; gap: 7px; flex-shrink: 0;
}
.toggle-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.toggle-gps.off { background: rgba(239,68,68,.15); color: #fca5a5; border: 1.5px solid rgba(239,68,68,.3); }
.toggle-gps.off .toggle-dot { background: var(--bad); }
.toggle-gps.on { background: rgba(34,197,94,.15); color: #4ade80; border: 1.5px solid rgba(34,197,94,.3); }
.toggle-gps.on .toggle-dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }

/* ── Páginas ────────────────────────────────────────────────────── */
#pages { flex: 1; position: relative; overflow: hidden; z-index: 0; isolation: isolate; }
.page { display: none; height: 100%; overflow-y: auto; flex-direction: column; }
.page.active { display: flex; }
.page[data-page="inicio"].active { padding: 0; }
.page:not([data-page="inicio"]).active { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
.page-header { margin-bottom: 16px; }
.page-header h2 { margin: 0; font-size: 22px; font-weight: 800; }
.section-title { margin: 20px 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.section-block { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

/* ── Mapa ───────────────────────────────────────────────────────── */
#map { flex: 1; min-height: 0; position: relative; z-index: 0; }
.leaflet-container { z-index: 0 !important; }
.leaflet-pane, .leaflet-map-pane, .leaflet-tile-pane, .leaflet-overlay-pane,
.leaflet-shadow-pane, .leaflet-marker-pane, .leaflet-tooltip-pane, .leaflet-popup-pane,
.leaflet-top, .leaflet-bottom { z-index: 1 !important; }
.leaflet-control-attribution { font-size: 10px !important; }

/* ── Status bar (sin viaje) ─────────────────────────────────────── */
.status-bar {
  padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line);
  position: relative; z-index: 2; flex-shrink: 0;
}
.status-text { font-size: 13px; color: var(--muted); }

/* ── Panel de viaje en curso ────────────────────────────────────── */
.viaje-panel {
  background: var(--panel); border-top: 2px solid var(--accent);
  position: relative; z-index: 2; flex-shrink: 0;
  padding: 14px 16px 16px;
}
.viaje-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.viaje-panel-price { font-size: 28px; font-weight: 900; color: var(--accent); line-height: 1; }
.viaje-panel-dest { text-align: right; min-width: 0; }
.vp-label { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.viaje-panel-dest strong { display: block; font-size: 15px; color: var(--text); margin-top: 2px; }
.viaje-panel-info { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.vp-icon { width: 20px; text-align: center; flex-shrink: 0; }
.viaje-panel-info span:last-child { line-height: 1.4; }
.maps-link {
  display: block; text-align: center; color: var(--blue); font-size: 13px; font-weight: 600;
  text-decoration: none; padding: 6px 0 2px; margin-top: 4px;
}
.maps-link:active { opacity: 0.7; }

/* ── Botones de acción del viaje ────────────────────────────────── */
.viaje-acciones { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.btn-accion {
  min-height: 52px; border-radius: 12px; font-size: 13px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 6px; border: 1.5px solid transparent;
}
.btn-accion span:first-child { font-size: 18px; }
.btn-cerca { background: var(--blue-dark); color: #93c5fd; border-color: rgba(59,130,246,.35); }
.btn-llegue { background: var(--ok-dark); color: #86efac; border-color: rgba(34,197,94,.35); }
.btn-finalizar { background: var(--bad-dark); color: #fca5a5; border-color: rgba(239,68,68,.35); }

/* ── Tab bar ────────────────────────────────────────────────────── */
.tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); flex-shrink: 0; z-index: 3;
}
.tab {
  min-height: 58px; background: transparent; color: var(--muted); font-size: 11px;
  font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 0; padding: 6px 2px;
}
.tab-icon { font-size: 20px; line-height: 1; }
.tab.active { color: var(--accent); }
.tab.active .tab-icon { filter: drop-shadow(0 0 4px rgba(245,197,24,.5)); }

/* ── Listas / items ─────────────────────────────────────────────── */
.lista { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.item {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.item p { margin: 5px 0 0; font-size: 14px; color: var(--muted); line-height: 1.4; }
.item strong { font-size: 16px; font-weight: 700; }
.item .btn-lg { margin-top: 12px; }
.empty { color: var(--muted); padding: 12px 0; font-size: 14px; }
.link { color: var(--blue); text-decoration: none; font-weight: 600; }

/* ── Saldo ──────────────────────────────────────────────────────── */
.saldo-hero {
  background: linear-gradient(135deg, var(--panel) 0%, #1a2a1a 100%);
  border: 1px solid var(--ok-dark); border-radius: 20px;
  padding: 32px 20px; text-align: center; margin-bottom: 16px;
}
.saldo-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.saldo-amount { display: block; font-size: 52px; font-weight: 900; color: var(--ok); margin: 8px 0; }
.saldo-pase { display: block; font-size: 12px; color: var(--muted); }

/* ── Cuenta ─────────────────────────────────────────────────────── */
.cuenta-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.cuenta-avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #111; font-weight: 900; font-size: 22px; display: grid; place-items: center; flex-shrink: 0; }
.cuenta-info { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }

/* ══════════════════════════════════════════════════════════════════
   OVERLAY DE OFERTA
   ══════════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(5, 8, 14, 0.88);
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  z-index: 20000;
  transform: translateZ(0); isolation: isolate; pointer-events: auto;
}
.overlay[hidden] { display: none !important; }

.oferta-sheet {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border: 1px solid rgba(245,197,24,.35);
  border-radius: 24px;
  padding: 20px 18px 18px;
  box-shadow: 0 0 0 1px rgba(245,197,24,.12), 0 32px 80px rgba(0,0,0,.7), 0 0 60px rgba(245,197,24,.1);
  animation: sheetIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative; z-index: 20001;
}
@keyframes sheetIn { from { transform: scale(0.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Cabecera oferta */
.oferta-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kicker { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: 0.06em; text-transform: uppercase; }

/* Timer circular */
.oferta-timer-wrap { position: relative; width: 40px; height: 40px; }
.timer-ring { width: 40px; height: 40px; transform: rotate(-90deg); }
.timer-ring-bg { fill: none; stroke: var(--line); stroke-width: 3; }
.timer-ring-arc {
  fill: none; stroke: var(--accent); stroke-width: 3;
  stroke-dasharray: 94.25; stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-ring-arc.urgent { stroke: var(--bad); }
.timer-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: var(--text);
}

/* Precio destacado */
.oferta-price {
  font-size: 46px; font-weight: 900; color: var(--accent);
  line-height: 1; margin: 4px 0 14px; letter-spacing: -1px;
}

/* Filas info */
.oferta-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.oferta-row { display: flex; align-items: flex-start; gap: 10px; }
.oferta-row-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; margin-top: 1px; }
.oferta-row-label { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.oferta-row strong { font-size: 15px; font-weight: 700; color: var(--text); display: block; margin-top: 1px; line-height: 1.3; }

/* Slider */
.slide-wrap { margin: 0 0 10px; }
.slide-track {
  position: relative; height: 64px; border-radius: 32px;
  background: #0b1018; border: 1.5px solid var(--line); overflow: hidden;
  user-select: none; touch-action: none;
  transition: border-color 0.2s, background 0.2s;
}
.slide-track.ready { background: rgba(34,197,94,.1); border-color: var(--ok); }
.slide-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 14px; font-weight: 700; pointer-events: none;
  letter-spacing: 0.01em;
}
.slide-knob {
  position: absolute; left: 4px; top: 4px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #111; font-size: 28px; font-weight: 900;
  display: grid; place-items: center; z-index: 2; border: 0;
  touch-action: none; cursor: grab;
  box-shadow: 0 4px 16px rgba(245,197,24,.4);
}
.slide-track.ready .slide-knob { background: var(--ok); box-shadow: 0 4px 16px rgba(34,197,94,.5); }

/* Botón cancelar */
.btn-cancelar { background: transparent; color: var(--muted); font-size: 15px; border: 1.5px solid var(--line); margin-top: 0; }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 16px; right: 16px; top: calc(16px + env(safe-area-inset-top));
  z-index: 21000; border-radius: 14px; padding: 15px 18px;
  font-weight: 700; font-size: 14px; text-align: center;
  background: #0d2d1a; color: #4ade80; border: 1px solid rgba(34,197,94,.3);
  box-shadow: var(--shadow);
  animation: toastIn 0.22s ease both;
}
@keyframes toastIn { from { transform: translateY(-12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast[hidden] { display: none !important; }
.toast.bad { background: #2d0d0d; color: #fca5a5; border-color: rgba(239,68,68,.3); }
