/* ============================================================
   CarPlus-EC  —  Estilos globales  v2
   ============================================================ */

:root {
  --bg-base:      #0a0e1a;
  --bg-card:      #111827;
  --bg-card-hover:#161f35;
  --bg-input:     #1a2340;
  --border:       #1e2d4a;
  --border-focus: #00d4ff;
  --cyan:         #00d4ff;
  --green:        #00ff88;
  --amber:        #fbbf24;
  --red:          #f87171;
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --text-dim:     #94a3b8;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,.5);
  --transition:   .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { opacity: .85; }

/* ── UTILIDADES ─────────────────────────────────────────────── */
.hidden    { display: none !important; }
.container { width: 100%; max-width: 700px; margin: 0 auto; padding: 0 16px; }
.text-muted { color: var(--text-muted); font-size: .85rem; }
.text-center { text-align: center; }

/* ── PRELOADER ──────────────────────────────────────────────── */
.preloader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-base);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .4s ease, visibility .4s ease;
}
.preloader-hide { opacity: 0; visibility: hidden; }
.preloader-inner {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.preloader-brand {
  font-size: 1.6rem; font-weight: 900; letter-spacing: 4px;
}
.preloader-brand-car  { color: var(--text-dim); }
.preloader-brand-plus { color: var(--cyan); }
.preloader-bar {
  width: 120px; height: 2px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.preloader-fill {
  height: 100%; background: linear-gradient(90deg, var(--cyan), var(--green));
  border-radius: 2px;
  animation: loadBar 1s ease-in-out infinite;
}
@keyframes loadBar {
  0%   { width: 0%; margin-left: 0; }
  50%  { width: 55%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

/* ── HEADER ─────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,14,26,.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  /* iOS safe area — evita que el notch tape el header */
  padding: env(safe-area-inset-top, 0) 16px 0 16px;
  padding-top: max(env(safe-area-inset-top), 0px);
}
.header-inner {
  max-width: 960px; margin: 0 auto;
  height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 env(safe-area-inset-right, 0) 0 env(safe-area-inset-left, 0);
}

/* iOS standalone: ocupa el área segura completa */
@media all and (display-mode: standalone) {
  .app-header { padding-top: max(env(safe-area-inset-top), 8px); }
  .app-main   { padding-bottom: max(env(safe-area-inset-bottom), 16px); }
}
.brand { display: flex; align-items: center; overflow: hidden; max-width: 200px; }
.brand-logo {
  height: 36px !important; width: auto !important; max-width: 160px !important;
  max-height: 36px !important;
  object-fit: contain; border-radius: 6px; display: block;
}

/* Ocultar banner nativo de OneSignal */
#onesignal-slidedown-container,
#onesignal-bell-container,
.onesignal-bell-launcher,
#onesignal-popover-container { display: none !important; }

.nav-menu { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.nav-link {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-dim); font-size: .82rem; font-weight: 500;
  padding: 7px 11px; border-radius: var(--radius-sm);
  transition: var(--transition); white-space: nowrap; position: relative;
}
.nav-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-link span:not(#notif-badge) { display: none; }
.nav-link:hover, .nav-link.active { background: var(--bg-input); color: var(--cyan); opacity: 1; }
.nav-link-danger:hover { background: rgba(248,113,113,.1); color: var(--red); }

/* Badge notificaciones */
#notif-badge {
  background: var(--red); color: #fff;
  font-size: .62rem; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1; margin-left: 2px;
}

/* ── MAIN ───────────────────────────────────────────────────── */
.app-main { flex: 1; padding: 28px 16px; }

/* ── FOOTER ─────────────────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 16px; text-align: center;
  color: var(--text-muted); font-size: .78rem;
}
.app-footer a { color: var(--cyan); }
.footer-sep { margin: 0 6px; }

/* ── PWA BANNER ─────────────────────────────────────────────── */
.pwa-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 -4px 24px rgba(0,0,0,.4);
  animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.pwa-banner-content { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pwa-banner-content > div { display: flex; flex-direction: column; }
.pwa-banner-content strong { font-size: .9rem; color: var(--text); }
.pwa-banner-content span   { font-size: .75rem; color: var(--text-muted); }
.pwa-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; }
.pwa-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── MODAL iOS INSTALACIÓN ───────────────────────────────────── */
#ios-install-modal { display: none; position: fixed; inset: 0; z-index: 9000; }
.ios-modal-overlay {
  width: 100%; height: 100%; background: rgba(0,0,0,.7);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; padding-bottom: max(env(safe-area-inset-bottom), 16px);
}
.ios-modal-card {
  background: var(--bg-card); border-radius: 20px 20px 16px 16px;
  width: 100%; max-width: 480px;
  border: 1px solid var(--border);
  overflow: hidden; animation: slideUp .3s ease;
}
.ios-modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.ios-modal-icon { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.ios-modal-header h3 { flex: 1; font-size: 1rem; font-weight: 700; }
.ios-modal-close {
  background: var(--bg-input); border: none; color: var(--text-dim);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.ios-modal-steps { padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; }
.ios-step { display: flex; align-items: flex-start; gap: 14px; }
.ios-step-num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--cyan); color: #0a0e1a; font-weight: 800; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.ios-step > div { display: flex; flex-direction: column; gap: 2px; }
.ios-step strong { font-size: .9rem; color: var(--text); }
.ios-step span { font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.ios-modal-note {
  background: rgba(0,212,255,.06); border-top: 1px solid var(--border);
  padding: 14px 20px; font-size: .78rem; color: var(--text-dim); line-height: 1.5;
}
.ios-modal-note strong { color: var(--cyan); }

/* Flecha indicadora iOS (señala la barra de Safari) */
.ios-modal-card::after {
  content: '▼  Botón compartir está en la barra inferior de Safari';
  display: block; text-align: center; padding: 10px;
  font-size: .72rem; color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── BOTONES ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: .88rem; font-weight: 600; border-radius: var(--radius-sm);
  padding: 10px 20px; cursor: pointer; border: none;
  transition: var(--transition); text-decoration: none; white-space: nowrap;
}
.btn-primary  { background: var(--cyan); color: #0a0e1a; }
.btn-primary:hover  { background: #33ddff; opacity: 1; }
.btn-success  { background: var(--green); color: #0a0e1a; }
.btn-danger   { background: var(--red); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-input); color: var(--text); opacity: 1; }
.btn-sm       { padding: 6px 14px; font-size: .8rem; }
.btn-full     { width: 100%; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── FORMULARIOS ─────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.form-control {
  width: 100%; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px; font-size: .9rem; outline: none;
  transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(0,212,255,.12); }
.form-control::placeholder { color: var(--text-muted); }
.form-hint { font-size: .76rem; color: var(--text-muted); margin-top: 4px; }

/* ── ALERTAS ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .87rem; margin-bottom: 16px; border-left: 3px solid;
}
.alert-error   { background: rgba(248,113,113,.1); border-color: var(--red);   color: #fca5a5; }
.alert-success { background: rgba(0,255,136,.08);  border-color: var(--green); color: #6ee7b7; }
.alert-info    { background: rgba(0,212,255,.08);  border-color: var(--cyan);  color: #67e8f9; }

/* ── AUTH PAGES ──────────────────────────────────────────────── */
.auth-wrapper {
  min-height: calc(100vh - 62px - 56px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px;
  background: radial-gradient(ellipse at 50% 0%, rgba(0,212,255,.07) 0%, transparent 70%);
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
  animation: fadeUp .4s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-img {
  width: 88px; height: 88px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 24px rgba(0,212,255,.3);
  margin-bottom: 14px;
}
.auth-logo h1 { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.auth-logo h1 span { color: var(--cyan); }
.auth-logo p  { color: var(--text-muted); font-size: .83rem; margin-top: 5px; }
.auth-footer-link { text-align: center; margin-top: 20px; font-size: .85rem; color: var(--text-muted); }
.auth-footer-link a { color: var(--cyan); font-weight: 600; }

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-title {
  font-size: 1.3rem; font-weight: 800; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.page-subtitle { font-size: .82rem; color: var(--text-muted); margin-top: 3px; }

/* ── CARDS DE NOTIFICACIÓN ───────────────────────────────────── */
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif-empty {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.notif-empty svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 12px; display: block; margin: 0 auto 12px; }

.notif-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer; text-decoration: none; color: inherit;
  transition: var(--transition);
}
.notif-card:hover { background: var(--bg-card-hover); border-color: rgba(0,212,255,.25); transform: translateY(-1px); opacity: 1; }
.notif-card.unread { border-left: 3px solid var(--cyan); }

/* Fila superior: evento + tiempo */
.notif-card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.notif-evento { font-weight: 700; font-size: .93rem; color: var(--text); flex: 1; min-width: 0; }
.notif-card.unread .notif-evento { color: var(--cyan); }
.notif-time { font-size: .74rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }

/* Fila del vehículo */
.notif-card-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap; margin-bottom: 6px;
}
.notif-device {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(0,212,255,.1); color: var(--cyan);
  border-radius: 20px; padding: 3px 10px; font-size: .77rem; font-weight: 600;
}
.notif-speed-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(251,191,36,.12); color: var(--amber);
  border-radius: 6px; padding: 3px 9px; font-size: .77rem; font-weight: 700;
  flex-shrink: 0;
}
.notif-address { font-size: .81rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── DETALLE DE NOTIFICACIÓN ─────────────────────────────────── */
.notif-detail {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.notif-detail-header {
  background: linear-gradient(135deg, #111827 0%, #0d1830 100%);
  border-bottom: 1px solid var(--border); padding: 24px;
}
.notif-detail-header .evento-title { font-size: 1.25rem; font-weight: 800; color: var(--cyan); margin-bottom: 6px; }
.notif-detail-header .evento-time  { font-size: .82rem; color: var(--text-muted); }
.detail-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 1.2rem;
}
.detail-icon.cyan  { background: rgba(0,212,255,.12); }
.detail-icon.green { background: rgba(0,255,136,.1); }
.detail-icon.amber { background: rgba(251,191,36,.1); }
.detail-icon.blue  { background: rgba(99,179,237,.1); }
.detail-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); font-weight: 600; margin-bottom: 3px; }
.detail-value { font-size: .95rem; color: var(--text); font-weight: 500; word-break: break-word; }
.detail-value a { color: var(--cyan); }
.map-embed { width: 100%; height: 220px; border: 0; display: block; border-top: 1px solid var(--border); }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: .85rem; margin-bottom: 20px;
  padding: 6px 12px; border-radius: var(--radius-sm); transition: var(--transition);
}
.back-btn:hover { background: var(--bg-card); color: var(--text); opacity: 1; }
.back-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── SETTINGS ─────────────────────────────────────────────────── */
.settings-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.settings-section-title { padding: 14px 20px; background: var(--bg-input); border-bottom: 1px solid var(--border); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row-info strong { font-size: .9rem; display: block; color: var(--text); }
.settings-row-info small  { font-size: .78rem; color: var(--text-muted); }

.toggle { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--border); border-radius: 26px; transition: var(--transition); }
.toggle-slider::before { position: absolute; content: ''; width: 20px; height: 20px; border-radius: 50%; left: 3px; bottom: 3px; background: var(--text-muted); transition: var(--transition); }
.toggle input:checked + .toggle-slider { background: var(--cyan); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: #0a0e1a; }

/* ── TOAST ────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 80px; right: 16px; z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--cyan); border-radius: var(--radius-sm); padding: 12px 16px; font-size: .85rem; color: var(--text); box-shadow: var(--shadow); animation: toastIn .25s ease; max-width: 300px; }
@keyframes toastIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Nav: solo íconos en móvil */
  .nav-link span { display: none; }
  .nav-link { padding: 8px 10px; }
  .nav-link svg { width: 18px; height: 18px; }
  /* Logo más pequeño */
  .brand-logo { max-width: 110px; height: 30px; }
}

@media (max-width: 520px) {
  .auth-card { padding: 24px 18px; }
  .brand-logo { max-width: 90px; height: 26px; }
  .detail-row { padding: 12px 14px; }
  .notif-detail-header { padding: 16px 14px; }
  .page-title { font-size: 1.1rem; }
  .header-inner { height: 54px; }
}

/* ── SCROLLBAR ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
