/* css/layout.css */
/* Estructura de pantallas, navegación, header y modales. */

/* ─── APP SHELL ─────────────────────────────────────────────────────────────── */
#app {
  position: relative;
  min-height: 100vh;
}

/* ─── SCREENS ───────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + var(--space-5) + var(--safe-bottom));
}

.screen.active {
  display: flex;
}

/* Login: pantalla completa, sin barra nav de la app */
#auth-screen.screen {
  align-items: center;
  justify-content: center;
  padding-top: max(48px, calc(var(--space-12) + var(--safe-top)));
  padding-bottom: calc(var(--space-10) + var(--safe-bottom));
  padding-left: calc(var(--space-6) + var(--safe-left));
  padding-right: calc(var(--space-6) + var(--safe-right));
}

#auth-screen .auth-brand {
  text-align: center;
  margin-bottom: var(--space-10);
  width: min(100%, 400px);
  align-self: center;
}

#auth-screen .auth-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: min(100%, 360px);
  align-self: center;
}

/* ─── HEADER ────────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: calc(48px + var(--safe-top)) var(--space-5) var(--space-4);
  background: linear-gradient(180deg, rgba(10,10,10,0.98) 70%, transparent 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.app-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-1);
}

.app-logo {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.app-logo span { color: var(--green-light); }

.app-header-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 300;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ─── CONTENIDO ─────────────────────────────────────────────────────────────── */
.screen-content {
  flex: 1;
  padding: var(--space-2) 0;
}

/* Mi Auto: aire bajo el header sticky (evita stats / títulos “comidos”) */
#screen-profile .screen-content {
  padding-top: var(--space-5);
}

/* Padding horizontal estándar para secciones */
.px {
  padding-left:  var(--space-4);
  padding-right: var(--space-4);
}

/* Spacing entre secciones */
.section-gap {
  margin-bottom: var(--space-5);
}

/* ─── BOTTOM NAV ────────────────────────────────────────────────────────────── */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  min-height: var(--nav-height);
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  box-sizing: border-box;
  background: rgba(12, 12, 12, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: stretch;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: color var(--transition-fast);
  color: var(--text-subtle);
  padding: var(--space-2) 0 var(--space-3);
  border: none;
  background: none;
  font-family: var(--font-body);
  position: relative;
}

.nav-item.active {
  color: var(--green-light);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.nav-item-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Indicador activo — línea en la parte superior */
.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  width: 50%;
  height: 2px;
  background: var(--green-light);
  border-radius: 0 0 3px 3px;
}

/* Badge de notificación en nav */
.nav-badge {
  position: absolute;
  top: 10px;
  right: calc(50% - 14px);
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ─── MODALES ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-6) var(--space-5) calc(var(--space-8) + env(safe-area-inset-bottom));
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--transition-spring);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 0 auto var(--space-6);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 800;
  margin-bottom: var(--space-5);
  letter-spacing: -0.3px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* ─── TOAST ─────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-4) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
  width: calc(100% - var(--space-8));
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 12px var(--space-5);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: all var(--transition-spring);
  pointer-events: all;
  white-space: nowrap;
  max-width: 100%;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { background: var(--success);  color: white; }
.toast-error   { background: var(--danger);   color: white; }
.toast-warning { background: var(--warning);  color: #1a1a1a; }
.toast-info    { background: var(--info);     color: white; }
.toast-default { background: var(--surface3); color: var(--text); border: 1px solid var(--border2); }

/* ─── HERO CARD (pantalla de inicio) ────────────────────────────────────────── */
.hero-card {
  margin: 0 var(--space-4) var(--space-4);
  background: linear-gradient(135deg, #0d1e14 0%, #0a1a10 60%, #061008 100%);
  border: 1px solid rgba(15, 110, 86, 0.25);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(15,110,86,0.18) 0%, transparent 65%);
  border-radius: 50%;
  pointer-events: none;
}

/* ─── LISTAS DE ITEMS ───────────────────────────────────────────────────────── */
.item-list {
  display: flex;
  flex-direction: column;
}

.item-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.item-row:last-child { border-bottom: none; }
.item-row:active     { opacity: 0.65; }

.item-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.item-icon-blue   { background: rgba(59,130,246,0.12); }
.item-icon-green  { background: rgba(16,185,129,0.12); }
.item-icon-gold   { background: rgba(245,158,11,0.12); }
.item-icon-red    { background: rgba(239,68,68,0.12);  }
.item-icon-purple { background: rgba(139,92,246,0.12); }

.item-body { flex: 1; min-width: 0; }
.item-title  { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub    { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.item-end    { flex-shrink: 0; text-align: right; }
.item-value  { font-family: var(--font-heading); font-size: 13px; font-weight: 600; color: var(--green-light); }

/* ─── Secciones con título (home, historial, perfil) ───────────────────────── */
.section-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4) var(--space-2);
  gap: var(--space-3);
}

.section-hd-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-header-action {
  font-size: 12px;
  color: var(--green-light);
  cursor: pointer;
  font-weight: 600;
}

/* ─── Perfil / Mi Auto ─────────────────────────────────────────────────────── */
.profile-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.profile-avatar {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.profile-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}

.profile-email {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-word;
}

.profile-edit {
  font-size: 13px;
  color: var(--green-light);
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.vehicle-selector {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding: 0 var(--space-4) var(--space-4);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.vs-card {
  flex: 0 0 140px;
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.vs-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(15, 110, 86, 0.35);
}

.vs-icon { font-size: 22px; margin-bottom: 6px; }

.vs-plate {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.06em;
}

.vs-model {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 4px;
}

.vs-badge {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.vsb-verified {
  background: var(--verified-dim);
  color: var(--verified);
}

.vsb-manual {
  background: var(--surface3);
  color: var(--text-muted);
}

.vs-add {
  flex: 0 0 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border2);
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 120px;
  color: var(--text-muted);
}

.vs-add-icon { font-size: 24px; font-weight: 300; line-height: 1; }

.vs-add-label { font-size: 12px; margin-top: 4px; }

.vehicle-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  overflow: hidden;
}

.vh-main {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: flex-start;
  justify-content: space-between;
}

.vh-info {
  flex: 1 1 200px;
  min-width: 0;
}

.vh-make {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 20px;
  line-height: 1.25;
  color: var(--text);
}

.vh-model {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.vh-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.vh-detail-chip {
  font-size: 11px;
  padding: 4px 8px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.vh-plate-block {
  flex-shrink: 0;
  text-align: right;
}

.vh-plate {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: rgba(245, 166, 35, 0.12);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  display: inline-block;
}

.vh-plate-country {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 4px;
}

.vh-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.vh-stat { text-align: center; }

.vh-stat-val {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.vh-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.action-row:active {
  background: var(--surface3);
}

.ar-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.ar-icon-amber { background: rgba(245, 166, 35, 0.12); }
.ar-icon-green { background: rgba(34, 197, 94, 0.12); }
.ar-icon-blue { background: rgba(59, 130, 246, 0.12); }
.ar-icon-red { background: rgba(239, 68, 68, 0.12); }

.ar-body {
  flex: 1;
  min-width: 0;
}

.ar-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  word-break: break-word;
}

.ar-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.45;
}

.ar-arrow {
  color: var(--text-subtle);
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}

.ar-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.link-status-verified {
  background: var(--verified-dim);
  color: var(--verified);
}

.link-status-none {
  background: var(--surface3);
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 40px 24px;
}

.empty-state-icon { font-size: 40px; margin-bottom: 12px; }

.empty-state-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}
