/* DECA TRACKER · sistema base (tokens, tipografía, componentes compartidos) */

@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope-var.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-var.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* Marca */
  --blue: #0757c9;
  --blue-700: #0649aa;
  --blue-50: #eef4fd;
  --blue-100: #dde9fb;
  --navy: #082b5c;
  --navy-900: #061f44;
  --yellow: #ffc400;
  --yellow-600: #f2b700;
  --yellow-50: #fff8e0;
  --white: #ffffff;
  --soft: #f5f8fc;
  --border: #dce4ef;
  --border-strong: #c7d3e3;

  /* Texto */
  --text: #0f1e36;
  --muted: #5b6b82;
  --faint: #8494aa;

  /* Estados */
  --ok: #12805c;
  --ok-50: #e8f6f0;
  --warn: #9a6a00;
  --warn-50: #fff6db;
  --err: #c62a2f;
  --err-50: #fdecec;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(8, 43, 92, 0.06);
  --shadow: 0 1px 2px rgba(8, 43, 92, 0.05), 0 8px 24px -12px rgba(8, 43, 92, 0.18);
  --shadow-lg: 0 2px 4px rgba(8, 43, 92, 0.04), 0 24px 48px -20px rgba(8, 43, 92, 0.28);

  --font-brand: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Semánticos (cambian con el tema) */
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: var(--navy);
  --text-soft: #3c4c64;
  --header-bg: rgba(255, 255, 255, 0.86);
  --topbar-bg: rgba(245, 248, 252, 0.9);
  --toast-bg: var(--navy);
  --err-ink: #8f1d21;
  --err-border: #f4cfd0;
  --ok-ink: #0b5c42;
  --ok-border: #c7eadb;
  --warn-ink: #6d4c00;
  --warn-border: #f5dea0;
  --skeleton-a: #eef2f8;
  --skeleton-b: #f7f9fc;

  --icon-accent: var(--yellow);
  color-scheme: light;
}

/* ---------------------------------------------------------------- Modo oscuro
   theme.js pone data-theme en <html> (preferencia guardada o la del sistema). */
:root[data-theme="dark"] {
  --blue: #4a8ff5;
  --blue-700: #3a7be0;
  --blue-50: #15294a;
  --blue-100: #1f3a66;
  --navy: #0c2a55;
  --navy-900: #081d3d;
  --yellow-50: #3a2f0a;
  --soft: #0f1c2f;
  --border: #23344d;
  --border-strong: #364a69;

  --text: #d9e3f1;
  --muted: #9aabc4;
  --faint: #6f819b;

  --ok: #3ecf9a;
  --ok-50: #0f2e25;
  --warn: #f0c14a;
  --warn-50: #33290a;
  --err: #ff7b7f;
  --err-50: #3a1618;

  --bg: #0b1626;
  --surface: #132238;
  --ink: #f2f6fc;
  --text-soft: #b9c6da;
  --header-bg: rgba(11, 22, 38, 0.86);
  --topbar-bg: rgba(15, 28, 47, 0.9);
  --toast-bg: #24426f;
  --err-ink: #ffb3b5;
  --err-border: #6b2a2d;
  --ok-ink: #8fe5c3;
  --ok-border: #1f5a46;
  --warn-ink: #f6d98a;
  --warn-border: #6a5417;
  --skeleton-a: #15263d;
  --skeleton-b: #1c3050;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 24px 48px -20px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* Logotipo: versión clara u oscura según el tema */
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }

/* Botón de cambio de tema */
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
img, svg { display: block; max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 {
  font-family: var(--font-brand);
  color: var(--ink);
  margin: 0;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
p { margin: 0; text-wrap: pretty; }
::selection { background: var(--yellow); color: #082b5c; }

:focus-visible {
  outline: 3px solid rgba(7, 87, 201, 0.35);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Iconos (sprite externo) */
.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 28px; height: 28px; }

/* ---------------------------------------------------------------- Botones */
.btn {
  --h: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--h);
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: -0.005em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none !important;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 19px; height: 19px; }
.btn-sm { --h: 38px; padding: 0 14px; font-size: 14px; border-radius: 9px; }
.btn-lg { --h: 56px; padding: 0 28px; font-size: 16.5px; border-radius: 12px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--yellow); color: var(--navy); box-shadow: 0 1px 0 rgba(8, 43, 92, 0.12), inset 0 -2px 0 rgba(8, 43, 92, 0.08); --icon-accent: var(--navy); }
.btn-primary:hover { background: var(--yellow-600); }
.btn-secondary { background: #0757c9; color: #fff; --icon-accent: var(--yellow); }
.btn-secondary:hover { background: #0649aa; }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; color: var(--blue); padding: 0 6px; }
.btn-ghost:hover { color: var(--blue-700); }
.btn-ghost .icon { transition: transform 0.2s; }
.btn-ghost:hover .icon { transform: translateX(3px); }
.btn-danger { background: var(--surface); color: var(--err); border-color: var(--err-border); }
.btn-danger:hover { background: var(--err-50); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn-icon:hover { border-color: var(--blue); color: var(--blue); }

/* ---------------------------------------------------------------- Formularios */
.field { display: grid; gap: 7px; }
.field > label, .field > .row-between > label, .label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.label-hint { font-weight: 400; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 15.5px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(7, 87, 201, 0.12);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--err);
  box-shadow: 0 0 0 4px rgba(198, 42, 47, 0.08);
}
.select {
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6B82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input-plate {
  font-family: var(--font-brand);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.input-group { position: relative; }
.input-group > .icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--blue);
  pointer-events: none;
}
.input-group > .input { padding-left: 44px; }
.input-group .input-action {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted);
  width: 38px; height: 38px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center;
}
.input-group .input-action:hover { color: var(--blue); background: var(--soft); }
.field-error { font-size: 13px; color: var(--err); display: flex; gap: 6px; align-items: center; }
.field-help { font-size: 13px; color: var(--muted); }
.field-ok { font-size: 13px; color: var(--ok); display: flex; gap: 6px; align-items: center; }

.check {
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 14px; color: var(--muted); cursor: pointer;
}
.check input {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px; flex: none; margin: 1px 0 0;
  border: 1.5px solid var(--border-strong); border-radius: 6px; background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
}
.check input:checked { background: #0757c9; border-color: #0757c9; }
.check input:checked::after {
  content: ""; width: 10px; height: 6px;
  border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}

/* Selector segmentado */
.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); gap: 8px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; min-height: 52px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  font-size: 14.5px; font-weight: 600; color: var(--ink); cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.segmented label .icon { color: var(--blue); }
.segmented label:hover { border-color: var(--border-strong); }
.segmented input:checked + label { border-color: var(--blue); background: var(--blue-50); box-shadow: inset 0 0 0 1px var(--blue); }
.segmented input:focus-visible + label { outline: 3px solid rgba(7, 87, 201, 0.35); outline-offset: 2px; }

/* ---------------------------------------------------------------- Superficies */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1;
  white-space: nowrap;
}
.chip-ok { background: var(--ok-50); color: var(--ok); }
.chip-muted { background: var(--soft); color: var(--muted); border: 1px solid var(--border); }
.chip-blue { background: var(--blue-50); color: var(--blue); }
.chip-yellow { background: var(--yellow-50); color: var(--warn); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.plate {
  display: inline-flex; align-items: stretch;
  border: 1.5px solid #082b5c; border-radius: 6px; overflow: hidden;
  font-family: var(--font-brand); font-weight: 800; font-size: 13.5px; letter-spacing: 0.06em;
  color: #082b5c; background: #fff; line-height: 1;
}
.plate::before {
  content: "E"; display: grid; place-items: center;
  width: 16px; background: #1f4fb4; color: #fff; font-size: 9px; letter-spacing: 0;
}
.plate span { padding: 5px 7px 4px; }

.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: 10px; font-size: 14.5px;
  border: 1px solid transparent;
}
.alert .icon { margin-top: 1px; }
.alert-err { background: var(--err-50); color: var(--err-ink); border-color: var(--err-border); --icon-accent: var(--err); }
.alert-ok { background: var(--ok-50); color: var(--ok-ink); border-color: var(--ok-border); --icon-accent: var(--ok); }
.alert-info { background: var(--blue-50); color: var(--ink); border-color: var(--blue-100); }
.alert-warn { background: var(--warn-50); color: var(--warn-ink); border-color: var(--warn-border); --icon-accent: var(--warn); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Separador "carretera": línea con tramos amarillos */
.road-rule {
  display: flex; gap: 6px; align-items: center; height: 4px;
}
.road-rule i { display: block; height: 4px; border-radius: 2px; background: var(--yellow); }
.road-rule i:nth-child(1) { width: 44px; }
.road-rule i:nth-child(2) { width: 16px; }
.road-rule i:nth-child(3) { width: 7px; }

/* Toast */
.toast-host {
  position: fixed; z-index: 1000; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: grid; gap: 8px; width: min(440px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px; border-radius: 12px;
  background: var(--toast-bg); color: #fff; font-size: 14.5px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease-out;
}
.toast .icon { color: var(--yellow); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
