/* ===== AutoLog — Design System "tablero de instrumentos" ===== */
:root {
  --bg-base: #0D1117;
  --bg-card: #161B22;
  --bg-elevated: #1C232C;
  --accent: #F59E0B;       /* ámbar — acciones primarias, datos destacados */
  --accent-dim: #F59E0B22;
  --success: #22C55E;
  --warning: #EF4444;
  --info: #3B82F6;
  --text-primary: #F0F3F6;
  --text-muted: #8B949E;
  --border: #2A313C;

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-full: 9999px;

  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;
  --sp-xxl: 40px;

  --nav-h: 64px;
  --maxw: 520px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}

.tabular { font-variant-numeric: tabular-nums; }

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100%;
  position: relative;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

/* ===== Screens ===== */
.screen { display: none; padding: var(--sp-lg); padding-top: calc(var(--sp-lg) + env(safe-area-inset-top, 0px)); }
.screen.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.screen-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-lg); }
.screen-title { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.screen-sub { color: var(--text-muted); font-size: 14px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-sm);
  border: none; border-radius: var(--r-md); padding: 14px 18px;
  font-size: 16px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: transform .08s, opacity .15s; color: var(--bg-base);
  background: var(--accent);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn--full { width: 100%; }
.btn--ghost { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn--danger { background: var(--warning); color: #fff; }
.btn--icon { width: 44px; height: 44px; padding: 0; border-radius: var(--r-full); }

/* ===== Cards ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-lg); margin-bottom: var(--sp-md);
}
.card--tap { cursor: pointer; transition: border-color .15s, transform .08s; }
.card--tap:active { transform: scale(0.99); }
.card--tap:hover { border-color: var(--accent); }

/* ===== Inputs ===== */
.field { margin-bottom: var(--sp-md); }
.field label { display: block; color: var(--text-muted); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input, .select, textarea.input {
  width: 100%; background: var(--bg-base); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 13px 14px; font-size: 16px; font-family: inherit; outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); }
.input.mono { font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.field-error { color: var(--warning); font-size: 13px; margin-top: 4px; }
.row { display: flex; gap: var(--sp-md); }
.row > * { flex: 1; }

/* ===== Chips ===== */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-sm); }
.chip {
  padding: 8px 14px; border-radius: var(--r-full); background: var(--bg-card);
  border: 1px solid var(--border); color: var(--text-muted);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .12s;
}
.chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ===== Stat / Gauge ===== */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-md); margin-bottom: var(--sp-md); }
.stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-lg);
}
.stat__label { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat__value { font-size: 30px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat__unit { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.stat__value.accent { color: var(--accent); }
.stat__value.success { color: var(--success); }
.stat__value.warning { color: var(--warning); }

/* ===== Vehicle card legacy (kept for compatibility) ===== */
.patente { background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px 8px; font-size: 13px; font-weight: 700; letter-spacing: 1px; font-variant-numeric: tabular-nums; }

/* ===== 3D Garage card ===== */
.garage-hero { margin-bottom: var(--sp-md); }
.veh-3d-card {
  border-radius: var(--r-xl); overflow: hidden; background: var(--bg-card);
  border: 1px solid var(--border); position: relative;
  cursor: grab; will-change: transform; user-select: none; -webkit-user-select: none;
  box-shadow: 0 24px 56px rgba(0,0,0,.55);
  transform-origin: center center;
}
.veh-3d-card:active { cursor: grabbing; }
.card-shine { position: absolute; inset: 0; pointer-events: none; z-index: 5; border-radius: inherit; }
.veh-3d-img { width: 100%; height: 220px; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.veh-3d-placeholder { font-size: 88px; opacity: .25; }
.veh-3d-info { padding: 16px 20px 10px; }
.veh-3d-name { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.veh-3d-sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.veh-3d-tire { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.veh-3d-hint { text-align: center; font-size: 11px; color: var(--text-muted); padding: 6px 0 14px; opacity: .5; letter-spacing: .5px; }
.veh-3d-shadow {
  height: 18px; background: radial-gradient(ellipse, rgba(0,0,0,.55) 0%, transparent 70%);
  margin: -2px 28px 16px; border-radius: 50%;
}

/* Model viewer / Sketchfab embed */
.veh-model-card { cursor: pointer; }
.sf-embed {
  width: 100%; height: 280px;
  border: 0; display: block;
  background: var(--bg-elevated);
}
.mv-main {
  width: 100%; height: 280px;
  background: transparent;
  --poster-color: transparent;
  --progress-bar-color: var(--accent);
  display: block;
}
.veh-del-overlay {
  position: absolute; top: 10px; right: 10px; z-index: 20;
  width: 36px; height: 36px; font-size: 14px;
  background: rgba(13,17,23,.75); backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.12);
}

/* Body type chips — wider to fit emoji + label */
.body-chip { padding: 8px 12px; font-size: 13px; }

/* ===== Mini vehicle list ===== */
.veh-mini { display: flex; align-items: center; gap: var(--sp-md); padding: var(--sp-md); cursor: pointer; transition: border-color .15s; }
.veh-mini:hover { border-color: var(--accent); }
.veh-mini__thumb { width: 56px; height: 44px; border-radius: var(--r-sm); background: var(--bg-elevated); flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.veh-mini__info b { font-size: 15px; font-weight: 700; }

/* ===== Timeline ===== */
.tl-item { display: flex; gap: var(--sp-md); margin-bottom: var(--sp-md); }
.tl-icon { width: 40px; height: 40px; border-radius: var(--r-full); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; background: var(--bg-elevated); }
.tl-body { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-md); }
.tl-body .tl-top { display: flex; justify-content: space-between; align-items: baseline; }
.tl-body h4 { font-size: 15px; font-weight: 700; }
.tl-date { color: var(--text-muted); font-size: 12px; }
.tl-detail { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ===== Empty state ===== */
.empty { text-align: center; padding: var(--sp-xxl) var(--sp-lg); color: var(--text-muted); }
.empty .ico { font-size: 48px; opacity: .5; }
.empty h3 { color: var(--text-primary); margin: var(--sp-md) 0 var(--sp-xs); font-size: 18px; }
.empty p { font-size: 14px; margin-bottom: var(--sp-lg); }

/* ===== Bottom nav ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--maxw); height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-card); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around; z-index: 50;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-muted); font-size: 11px; font-weight: 600; background: none; border: none; cursor: pointer; flex: 1; height: 100%; justify-content: center; }
.tab .ico { font-size: 22px; }
.tab.active { color: var(--accent); }
.tab--fab .ico { background: var(--accent); color: var(--bg-base); width: 52px; height: 52px; border-radius: var(--r-full); display: flex; align-items: center; justify-content: center; font-size: 28px; margin-top: -22px; box-shadow: 0 4px 16px var(--accent-dim); }
.tab--fab { color: var(--accent); }

/* ===== Modal / sheet ===== */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; display: none; }
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--maxw); max-height: 92vh; overflow-y: auto;
  background: var(--bg-base); border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--border); z-index: 101;
  padding: var(--sp-lg); padding-bottom: calc(var(--sp-xl) + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 100%); transition: transform .25s ease;
}
.sheet.open { transform: translate(-50%, 0); }
.sheet__handle { width: 40px; height: 4px; background: var(--border); border-radius: var(--r-full); margin: 0 auto var(--sp-lg); }
.sheet__title { font-size: 20px; font-weight: 800; margin-bottom: var(--sp-lg); }

/* ===== Auth ===== */
.auth { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; padding: var(--sp-xl); gap: var(--sp-xl); max-width: var(--maxw); margin: 0 auto; }
.auth__hero { text-align: center; }
.auth__logo { width: 80px; height: 80px; border-radius: var(--r-full); background: var(--bg-card); border: 1px solid var(--accent-dim); display: flex; align-items: center; justify-content: center; font-size: 40px; margin: 0 auto var(--sp-md); }
.auth__name { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.auth__tag { color: var(--text-muted); margin-top: var(--sp-xs); }
.auth__toggle { text-align: center; color: var(--text-muted); font-size: 14px; margin-top: var(--sp-md); }
.auth__toggle a { color: var(--accent); font-weight: 700; cursor: pointer; }

/* ===== Chat ===== */
#chat-list { display: flex; flex-direction: column; gap: var(--sp-sm); padding-bottom: var(--sp-lg); }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: var(--r-lg); font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--bg-base); border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-input-bar { position: fixed; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--maxw); background: var(--bg-card); border-top: 1px solid var(--border); padding: var(--sp-sm) var(--sp-md); display: flex; gap: var(--sp-sm); z-index: 51; }
.chat-input-bar .input { flex: 1; }

/* ===== Misc ===== */
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: flex; align-items: center; justify-content: center; padding: var(--sp-xxl); color: var(--text-muted); }
.toast { position: fixed; bottom: calc(var(--nav-h) + 20px); left: 50%; transform: translateX(-50%); background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-primary); padding: 12px 18px; border-radius: var(--r-full); font-size: 14px; font-weight: 600; z-index: 200; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; }
.confidence { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-full); }
.confidence.high { background: #22C55E22; color: var(--success); }
.confidence.low { background: #EF444422; color: var(--warning); }
.photo-preview { width: 100%; border-radius: var(--r-md); margin-top: var(--sp-sm); }
.hidden { display: none !important; }
.hint { color: var(--text-muted); font-size: 13px; margin-top: var(--sp-xs); }
.section-label { color: var(--text-muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin: var(--sp-lg) 0 var(--sp-sm); }
.badge-soon { font-size: 10px; background: var(--bg-elevated); color: var(--text-muted); padding: 2px 6px; border-radius: var(--r-full); font-weight: 700; }

/* Splash */
.splash { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg-base); z-index: 999; gap: 6px; }

/* Reminder status */
.rem-overdue { color: var(--warning); font-weight: 700; }
.rem-soon { color: var(--accent); font-weight: 700; }

/* Avatar */
.avatar { width: 48px; height: 48px; border-radius: var(--r-full); background: var(--accent-dim); border: 2px solid var(--accent); color: var(--accent); font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Vehicle version badge */
.veh-version { font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-dim); padding: 1px 7px; border-radius: var(--r-full); margin-left: 4px; }

/* Fuel photo preview thumbnail */
.fuel-prev { width: 80px; border-radius: var(--r-sm); overflow: hidden; background: var(--bg-elevated); border: 1px solid var(--border); font-size: 10px; }
.fuel-prev img { height: 56px; width: 100%; }

/* stat value color helpers */
.stat__value.success { color: var(--success); }
.accent { color: var(--accent); }
.success { color: var(--success); }
.warning { color: var(--warning); }
