/* ═══════════════════════════════════════════════
   ROADSIGN EVALUATOR — main.css
   Tema: Industrial técnico, dark-first, amarillo señal
   ═══════════════════════════════════════════════ */

:root {
  /* Paleta principal */
  --bg-base:        #0a0e1a;
  --bg-surface:     #111827;
  --bg-elevated:    #1a2235;
  --bg-card:        #1e2a3d;

  /* Amarillo señal */
  --accent:         #f5c518;
  --accent-dim:     #c9a010;
  --accent-glow:    rgba(245, 197, 24, 0.15);

  /* Texto */
  --text-primary:   #f0f4ff;
  --text-secondary: #8899bb;
  --text-muted:     #4a5c7a;

  /* Colores de estado señales */
  --color-stop:      #ef4444;
  --color-info:      #3b82f6;
  --color-warning:   #f59e0b;
  --color-mandatory: #22c55e;
  --color-forbidden: #f97316;
  --color-yield:     #a855f7;
  --color-horizontal:#06b6d4;

  /* Bordes */
  --border:         rgba(255,255,255,0.07);
  --border-accent:  rgba(245,197,24,0.3);

  /* Radios */
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  /* Sombras */
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-float: 0 8px 40px rgba(0,0,0,0.6);

  /* Tipografía */
  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'Barlow', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Spacing */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
img, video, canvas { display: block; max-width: 100%; }

/* ── Pantallas ── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg-base);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.25s ease, transform 0.25s ease;
  opacity: 0;
  transform: translateX(20px);
}
.screen.active {
  display: flex;
  opacity: 1;
  transform: translateX(0);
}
.screen.screen-fullscreen {
  overflow: hidden;
}

/* ── Splash ── */
#screen-splash {
  justify-content: center;
  align-items: center;
}
.splash-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(245,197,24,0.08) 0%, transparent 70%);
}
.splash-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  padding: 40px 24px;
}
.splash-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.logo-mark {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 0 20px rgba(245,197,24,0.4));
}
.logo-mark svg { width: 100%; height: 100%; }
.logo-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.logo-road {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 4px;
}
.logo-sign {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 4px;
}
.logo-sub {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 8px;
  color: var(--text-muted);
  margin-top: 4px;
}
.splash-loading { width: 260px; display: flex; flex-direction: column; gap: 12px; }
.loading-bar {
  height: 2px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}
.loading-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 2px;
}
.loading-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.5px;
}
.splash-version {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ── Headers ── */
.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 16px) 16px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-primary);
}
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 20px) 20px 16px;
  background: var(--bg-base);
  flex-shrink: 0;
}
.header-logo {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
}
.header-actions { display: flex; gap: 8px; }

/* ── Icon buttons ── */
.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { background: var(--bg-card); color: var(--accent); }
.icon-btn-light { background: rgba(0,0,0,0.5); color: #fff; backdrop-filter: blur(8px); }
.icon-btn-light:active { background: rgba(0,0,0,0.7); }

/* ── Home ── */
.home-body {
  flex: 1;
  padding: 0 20px calc(var(--safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}
.home-greeting { padding-top: 8px; }
.greeting-sub { font-size: 13px; color: var(--text-muted); letter-spacing: 0.5px; text-transform: uppercase; }
.greeting-name { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: 1px; color: var(--text-primary); }
.home-stats-bar {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.stat-chip { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 14px 8px; gap: 2px; }
.stat-num { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-divider { width: 1px; background: var(--border); }
.home-modes { display: flex; flex-direction: column; gap: 12px; }
.mode-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  transition: border-color 0.2s, background 0.2s;
  text-align: left;
}
.mode-card:active { background: var(--bg-elevated); }
.mode-video { border-left: 3px solid var(--color-stop); }
.mode-photo { border-left: 3px solid var(--accent); }
.mode-icon {
  width: 48px; height: 48px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.mode-icon svg { width: 24px; height: 24px; }
.mode-text { flex: 1; }
.mode-text strong { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--text-primary); letter-spacing: 0.5px; }
.mode-text span { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.mode-arrow { font-size: 20px; color: var(--text-muted); }
.home-ai-status {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px; color: var(--text-secondary);
}
.ai-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-muted);
}
.ai-dot.loading { background: var(--accent); animation: pulse 1.2s infinite; }
.ai-dot.ready { background: var(--color-mandatory); }
.ai-dot.error { background: var(--color-stop); }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.3;} }
.section-title { font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--text-muted); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 12px; }
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.empty-state { font-size: 13px; color: var(--text-muted); text-align: center; padding: 24px 0; }

/* ── Video screen ── */
#screen-video { background: #000; }
#video-feed { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#detection-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.video-overlay-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 16px) 16px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
}
.detection-counter {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(245,197,24,0.4);
  border-radius: var(--r-sm);
  padding: 6px 14px;
  backdrop-filter: blur(8px);
}
.detection-counter span:first-child {
  font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--accent); line-height: 1;
}
.counter-label { font-size: 10px; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: 1px; }
.video-controls-top { display: flex; gap: 8px; }
.video-overlay-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 20px 20px calc(var(--safe-bottom) + 24px);
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
}
.gps-badge {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.5);
  border-radius: 20px; padding: 6px 14px;
  font-family: var(--font-mono); font-size: 11px; color: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
}
.gps-badge svg { width: 12px; height: 12px; }
.btn-evaluate {
  display: flex; align-items: center; gap: 12px;
  background: var(--accent);
  color: #000;
  font-family: var(--font-display);
  font-size: 18px; font-weight: 800;
  letter-spacing: 2px;
  padding: 16px 32px;
  border-radius: var(--r-xl);
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 4px 24px rgba(245,197,24,0.4);
}
.btn-evaluate:disabled { opacity: 0.35; pointer-events: none; }
.btn-evaluate:active { transform: scale(0.97); }
.evaluate-count {
  background: rgba(0,0,0,0.3);
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.fps-counter {
  position: absolute; top: calc(var(--safe-top) + 80px); right: 12px;
  font-family: var(--font-mono); font-size: 10px;
  color: rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.3);
  padding: 2px 6px; border-radius: 3px;
}

/* ── Photo screen ── */
.photo-body { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 16px; overflow: hidden; }
.photo-canvas-container {
  flex: 1; position: relative;
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
}
.photo-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--text-muted);
}
.photo-placeholder svg { width: 48px; height: 48px; }
.photo-placeholder p { font-size: 14px; }
#photo-canvas { width: 100%; height: 100%; object-fit: contain; }
.photo-detection-info {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  border-radius: 20px; padding: 6px 16px;
  font-family: var(--font-mono); font-size: 12px; color: var(--accent);
  backdrop-filter: blur(8px);
}
.photo-actions { display: flex; gap: 10px; flex-shrink: 0; }
.photo-actions .btn-secondary { flex: 1; }
.photo-actions .btn-primary { flex: 1; }

/* ── Onboarding ── */
#screen-onboarding {
  background: var(--bg-base);
  justify-content: flex-end;
  padding-bottom: calc(var(--safe-bottom) + 40px);
  overflow: hidden;
}
.onboard-slides { flex: 1; position: relative; overflow: hidden; }
.onboard-slide {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 32px; gap: 20px; text-align: center;
  opacity: 0; transform: translateX(40px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.onboard-slide.active { opacity: 1; transform: translateX(0); pointer-events: auto; }
.onboard-icon { font-size: 64px; }
.onboard-slide h2 { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: 0.5px; }
.onboard-slide p { font-size: 16px; color: var(--text-secondary); line-height: 1.6; max-width: 280px; }
.onboard-form { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 280px; }
.onboard-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 24px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); transition: background 0.2s, width 0.2s; }
.dot.active { background: var(--accent); width: 20px; border-radius: 3px; }
.onboard-next {
  font-family: var(--font-display); font-size: 16px; font-weight: 600; letter-spacing: 1px;
  color: var(--text-secondary); padding: 8px 24px;
  border-radius: var(--r-md);
  transition: color 0.2s;
}
.onboard-next:active { color: var(--accent); }

/* ── Settings ── */
.settings-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.settings-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.settings-section h3 {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted);
}
.settings-field { display: flex; flex-direction: column; gap: 6px; }
.settings-field label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.settings-info-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.settings-info-row span { color: var(--text-secondary); }
.settings-info-row strong { color: var(--text-primary); font-weight: 500; }
.storage-bar-wrap { display: flex; flex-direction: column; gap: 6px; }
.storage-bar { height: 4px; background: var(--bg-base); border-radius: 2px; overflow: hidden; }
.storage-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s; }
.storage-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* ── History ── */
.history-filters {
  display: flex; gap: 8px; padding: 12px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.filter-btn {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 6px 14px; border-radius: 20px;
  color: var(--text-muted); background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.filter-btn.active { color: var(--accent); border-color: var(--border-accent); background: var(--accent-glow); }
.history-list { flex: 1; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }

/* ── Summary ── */
.summary-body {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 32px; padding: 32px 24px calc(var(--safe-bottom) + 32px);
}
.summary-hero { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.summary-check {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(34,197,94,0.15);
  border: 2px solid var(--color-mandatory);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--color-mandatory);
}
.summary-hero h2 { font-family: var(--font-display); font-size: 28px; font-weight: 700; }
.summary-hero p { font-size: 14px; color: var(--text-secondary); }
.summary-stats { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.summary-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-elevated);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 24px 24px calc(var(--safe-bottom) + 24px);
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column; gap: 20px;
}
.modal h3 { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.modal-field { display: flex; flex-direction: column; gap: 8px; }
.modal-field label { font-size: 13px; color: var(--text-secondary); }
.modal-actions { display: flex; gap: 12px; padding-top: 4px; }
.modal-actions button { flex: 1; }

/* ── Toast ── */
#toast-container {
  position: fixed; bottom: calc(var(--safe-bottom) + 20px); left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 13px; color: var(--text-primary);
  box-shadow: var(--shadow-float);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  white-space: nowrap;
}
.toast.success { border-color: rgba(34,197,94,0.4); color: var(--color-mandatory); }
.toast.error   { border-color: rgba(239,68,68,0.4);  color: var(--color-stop); }
.toast.warning { border-color: var(--border-accent);  color: var(--accent); }
@keyframes toastIn  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* ── Perfiles ── */
.profiles-body {
  flex: 1; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto;
}
.profile-card { cursor: default; }
.profile-active {
  border-color: var(--border-accent);
  background: var(--bg-elevated);
}
.profile-badge {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 6px; border-radius: 3px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--border-accent);
  vertical-align: middle;
  margin-left: 6px;
}
