/* assets/css/app.css — RideCMP */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600&family=Space+Mono:wght@700&display=swap');

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

:root {
  --bg: #0a0a0a;
  --bg2: #141414;
  --bg3: #1c1c1c;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text: #f0f0f0;
  --text2: #888;
  --text3: #555;
  --accent: #e8ff47;
  --accent-dim: rgba(232,255,71,0.12);
  --uber: #ffffff;
  --cabify: #a78bfa;
  --didi: #ff8c42;
  --ok: #4ade80;
  --err: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --font: 'DM Sans', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --nav-h: 64px;
  --header-h: 56px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Corrección crítica: algunos estilos con display:flex pisaban el atributo hidden. */
[hidden], .is-hidden { display: none !important; }
body.modal-open { overflow: hidden; }


/* ── Layout ───────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.header-logo {
  font-family: var(--font-mono);
  font-size: 17px;
  letter-spacing: -0.5px;
  color: var(--text);
}
.header-logo span { color: var(--accent); }

.header-actions { display: flex; gap: 8px; align-items: center; }

.btn-header {
  height: 34px;
  padding: 0 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.btn-header:hover { background: var(--bg3); border-color: var(--border2); }
.btn-header.primario { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-header.primario:hover { opacity: 0.9; }

#btn-user { display: flex; align-items: center; gap: 6px; }
.user-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-h) + 16px);
}

/* ── Vistas ───────────────────────────────────────────────── */
.vista { padding: 16px; }

/* ── Search Card ──────────────────────────────────────────── */
.search-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.route-inputs { display: flex; gap: 12px; align-items: stretch; margin-bottom: 14px; }
.route-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10px;
  gap: 0;
  flex-shrink: 0;
}
.pin { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pin.azul { background: #60a5fa; }
.pin.naranja { background: var(--didi); }
.route-dashed {
  flex: 1;
  width: 1px;
  border-left: 1.5px dashed var(--border2);
  min-height: 20px;
}
.route-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.campo-busqueda { position: relative; }
.campo-busqueda label {
  display: block;
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.input-dir {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 36px 9px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.input-dir::placeholder { color: var(--text3); }
.input-dir:focus { border-color: var(--accent); }

.btn-geo {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  background: transparent;
  border-radius: 6px;
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s;
  margin-top: 9px;
}
.btn-geo:hover { color: var(--accent); }
.btn-geo.cargando { animation: pulse 0.8s infinite; }

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

/* Sugerencias */
.sugerencias {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  z-index: 200;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.sugerencia {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.sugerencia:last-child { border-bottom: none; }
.sugerencia:hover { background: var(--bg); color: var(--text); }
.sug-icon { color: var(--text3); flex-shrink: 0; }
.sug-texto { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Multiplicador chips */
.mult-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.chip.activo {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Botón comparar */
.btn-comparar {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #000;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-comparar:hover { opacity: 0.92; }
.btn-comparar:active { transform: scale(0.99); }
.btn-comparar:disabled { opacity: 0.5; cursor: not-allowed; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Resultados ───────────────────────────────────────────── */
#resultados { margin-top: 4px; }

.ruta-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.stat-pill {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.stat-pill .val {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text);
  display: block;
}
.stat-pill .lbl { font-size: 11px; color: var(--text3); display: block; margin-top: 2px; }

.apps-lista { display: flex; flex-direction: column; gap: 8px; }

.app-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideUp 0.3s ease both;
}
.app-card.cheapest { border-color: var(--ok); }

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

.app-logo {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.app-info { flex: 1; min-width: 0; }
.app-nombre { font-size: 15px; font-weight: 500; color: var(--text); }
.app-tipo { font-size: 12px; color: var(--text3); font-weight: 400; }
.badge-ok {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(74,222,128,0.15);
  color: var(--ok);
  letter-spacing: 0.3px;
  margin-top: 2px;
}
.badge-warn {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(251,191,36,0.15);
  color: var(--warn);
  margin-top: 2px;
}

.app-precio { text-align: right; flex-shrink: 0; }
.precio-val {
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--text);
}
.precio-diff { font-size: 11px; color: var(--text3); margin-top: 1px; }

.btn-abrir {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: white;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: opacity 0.15s;
}
.btn-abrir:hover { opacity: 0.85; }

/* ── Navegación inferior ──────────────────────────────────── */
.nav-bottom {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.nav-tab {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  color: var(--text3);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
  border: none;
}
.nav-tab svg { transition: transform 0.15s; }
.nav-tab.activo { color: var(--accent); }
.nav-tab.activo svg { transform: scale(1.1); }

/* ── Historial ────────────────────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.hist-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 8px;
  align-items: center;
}
.hist-ruta { grid-column: 1; }
.hist-origen { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-dest { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-meta { grid-column: 1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hist-precios { display: flex; gap: 6px; flex-wrap: wrap; }
.hist-precios span { font-size: 11px; color: var(--text3); background: var(--bg3); padding: 2px 7px; border-radius: 20px; }
.hist-fecha { font-size: 11px; color: var(--text3); }
.btn-repetir {
  grid-column: 2;
  grid-row: 1 / 3;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.btn-repetir:hover { border-color: var(--accent); color: var(--accent); }

/* ── Favoritos ────────────────────────────────────────────── */
.fav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.fav-icono { font-size: 18px; flex-shrink: 0; }
.fav-info { flex: 1; cursor: pointer; min-width: 0; }
.fav-nombre { font-size: 14px; font-weight: 500; color: var(--text); }
.fav-dir { font-size: 12px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-fav-borrar {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
  font-size: 12px;
  flex-shrink: 0;
}
.btn-fav-borrar:hover { border-color: var(--err); color: var(--err); }

.vacio { font-size: 13px; color: var(--text3); text-align: center; padding: 24px; }

/* ── Modales ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-sheet {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 480px;
  max-height: min(90dvh, 720px);
  overflow-y: auto;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.45);
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.modal-titulo { font-size: 18px; font-weight: 600; margin-bottom: 20px; }

/* Auth tabs */
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.auth-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text3);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.auth-tab.activo { color: var(--accent); border-bottom-color: var(--accent); }

/* Formularios */
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 12px; color: var(--text3); margin-bottom: 5px; }
.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text3); }

.btn-form {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #000;
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
  transition: opacity 0.15s;
}
.btn-form:hover { opacity: 0.9; }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-ok { border-color: var(--ok); }
.toast.toast-error { border-color: var(--err); color: var(--err); }

/* ── Vista perfil ─────────────────────────────────────────── */
.perfil-header {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.perfil-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-family: var(--font-mono);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.perfil-nombre { font-size: 17px; font-weight: 600; }
.perfil-email { font-size: 13px; color: var(--text3); }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.stat-card .num { font-family: var(--font-mono); font-size: 24px; font-weight: 700; color: var(--accent); }
.stat-card .desc { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ── Responsivo ────────────────────────────────────────────── */
@media (min-width: 481px) {
  .modal-overlay { padding: 0 16px; }
  .modal-sheet { border-radius: var(--radius) var(--radius) 0 0; }
}

@media (min-width: 481px) {
  .app-shell {
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
  }
  .nav-bottom { left: 50%; }
}

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

/* ── Ajustes modo prueba / debug ─────────────────────────── */
.btn-header.secundario {
  background: var(--bg3);
  border-color: var(--border2);
  color: var(--accent);
}
.btn-header.secundario:hover {
  border-color: var(--accent);
}
.btn-demo-login {
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.btn-demo-login:hover {
  background: var(--accent-dim);
}
@media (max-width: 360px) {
  .btn-header { padding: 0 10px; }
  .header-logo { font-size: 15px; }
}
