/*
 * Tokens de diseño comunes (D1.1). Se cargan en TODAS las páginas, antes de la
 * hoja propia de cada una. El tema lo fija static/js/theme.js en
 * <html data-theme="light|dark"> antes de pintar.
 *
 * Regla para las hojas de cada página:
 *   - colores de la paleta → var(--bg), var(--text), …
 *   - transparencias sobre el fondo (antes rgba(255,255,255,a)) →
 *       rgb(var(--ink-rgb) / a)   (blanco en oscuro, azul marino en claro)
 *   - lo que solo deba cambiar en claro → html[data-theme="light"] .selector { … }
 *
 * (Paleta movida tal cual desde style.css: el modo oscuro no cambia de color.
 *  Unificar las paletas propias de tren_linea.css y auth.css es parte de D1.3.)
 */

:root {
  color-scheme: dark;

  --bg:           #0c1a2e;
  --surface:      #1e3658;
  --surface-2:    #243f68;
  --surface-3:    #2c4d7a;
  --surface-4:    #35598a;
  --border:       rgba(255,255,255,0.1);
  --border-hover: rgba(255,255,255,0.22);
  --text:         #e8eef8;
  /* Contraste AA (D2.1): ≥ 4.5:1 sobre --bg, --surface y --surface-2. */
  --text-muted:   #a3b4cf;
  --text-dim:     #9aadca;

  --accent:       #ec483b;
  --accent-glow:  rgba(236,72,59,0.3);
  --accent-2:     #f0a500;
  --accent-2-glow:rgba(240,165,0,0.25);
  --danger:       #ff4135;
  --warning:      #f59e0b;
  --warning-text: #fbbf24;  /* ámbar para TEXTO: AA sobre --bg, --surface y --surface-2 */
  --danger-text:  #ffa49b;  /* rojo para TEXTO (--danger no llega a 4.5:1 sobre --surface) */
  --success:      #22c55e;

  --sidebar-w:    300px;
  --navbar-h:     56px;
  /* Lo que la barra le quita al contenido: su alto, o 0 con la barra oculta (D3.8, navbar.css). */
  --navbar-space: var(--navbar-h);
  --radius:       12px;
  --radius-sm:    8px;
  --radius-xs:    5px;
  --transition:   0.2s ease;

  --c0:#ec483b; --c1:#f0a500; --c2:#22c55e; --c3:#4fd8f7;
  --c4:#c84ff7; --c5:#4285f4; --c6:#f74fa3; --c7:#fb7c3c;
  --c8:#a3e635; --c9:#10c9a3; --c10:#f96262; --c11:#8b5cf6;

  /* Tinta de las transparencias: rgb(var(--ink-rgb) / 0.05). */
  --ink-rgb: 255 255 255;
}

html[data-theme="light"] {
  color-scheme: light;

  --bg:           #edf1f7;
  --surface:      #ffffff;
  --surface-2:    #e4ebf5;
  --surface-3:    #cdd9ed;
  --surface-4:    #b8cadf;
  --border:       rgba(30,54,88,0.12);
  --border-hover: rgba(30,54,88,0.25);
  --text:         #0f1e30;
  --text-muted:   #3a5070;
  --text-dim:     #536987;
  --accent:       #ec483b;
  --accent-glow:  rgba(236,72,59,0.2);
  --accent-2:     #c47800;
  --accent-2-glow:rgba(196,120,0,0.18);
  --danger:       #dc2626;
  --warning:      #d97706;
  --warning-text: #a35200;
  --danger-text:  #b42318;
  --success:      #16a34a;

  --ink-rgb: 15 30 48;
}

/* Utilidades comunes (D1.5): en lugar de style="…" en el HTML. Con !important,
   como hacía el estilo en línea al que reemplazan: tokens.css se carga antes que
   la hoja de cada página y, sin él, p. ej. .detail-value { color } les ganaría. */
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-warning { color: var(--warning-text) !important; }

/* Íconos SVG (static/icons.svg, D2.2): 1em, color del texto. */
.icon {
  width: 1em; height: 1em;
  flex: none;
  vertical-align: -0.125em;
  overflow: visible;
}

/* Confirmación propia (static/js/ui/dialog.js, D2.4): reemplaza window.confirm(). */
.ui-confirm {
  position: fixed; inset: 0; z-index: 5000;
  display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}
.ui-confirm[hidden] { display: none; }
.ui-confirm-box {
  width: min(440px, 100%);
  padding: 20px 22px;
  border-radius: 14px;
  border: 1px solid rgb(var(--ink-rgb) / 0.16);
  background: var(--surface, #1e3658);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  font-family: inherit;
}
.ui-confirm-title { margin: 0 0 8px; font-size: 1.05rem; font-weight: 700; }
.ui-confirm-message { margin: 0 0 18px; line-height: 1.5; color: var(--text-muted, var(--text)); }
.ui-confirm-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.ui-confirm-btn {
  padding: 9px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid rgb(var(--ink-rgb) / 0.2);
  background: transparent; color: var(--text);
  font: inherit; font-weight: 700;
}
.ui-confirm-btn:hover { background: rgb(var(--ink-rgb) / 0.08); }
/* #c0392b y no --accent (#ec483b): con texto blanco, 5.4:1 frente a 3.6:1. */
.ui-confirm-btn--primary { background: #c0392b; border-color: transparent; color: #fff; }
.ui-confirm-btn--primary:hover { background: #c0392b; filter: brightness(1.08); }
.ui-confirm-btn--danger { background: #b42318; }
.ui-confirm-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html[data-theme="light"] .ui-confirm { background: rgba(15, 30, 48, 0.4); }
html[data-theme="light"] .ui-confirm-box { box-shadow: 0 24px 60px rgba(15, 30, 48, 0.25); }

/* Estados de carga, vacío y error (static/js/ui/state.js, D3.2). */
.ui-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  padding: 18px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.45;
}
.ui-state[hidden] { display: none; }
.ui-state-body { display: flex; flex-direction: column; gap: 2px; }
.ui-state-text { color: inherit; }
.ui-state-hint { font-size: 0.78rem; color: var(--text-dim); }
.ui-state--error .ui-state-text { color: var(--danger-text); font-weight: 600; }
.ui-state--inline {
  flex-direction: row; flex-wrap: wrap; justify-content: flex-start;
  padding: 0; text-align: left; gap: 8px;
}
.ui-state-spinner {
  width: 16px; height: 16px; flex: none;
  border-radius: 50%;
  border: 2px solid rgb(var(--ink-rgb) / 0.18);
  border-top-color: var(--text-muted);
  animation: ui-state-spin 0.8s linear infinite;
}
@keyframes ui-state-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ui-state-spinner { animation: none; border-top-color: rgb(var(--ink-rgb) / 0.18); border-right-color: var(--text-muted); }
}
.ui-state-action {
  padding: 5px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgb(var(--ink-rgb) / 0.25);
  background: rgb(var(--ink-rgb) / 0.06); color: var(--text);
  font: inherit; font-size: 0.8rem; font-weight: 700;
}
.ui-state-action:hover { background: rgb(var(--ink-rgb) / 0.12); }
.ui-state-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-state-row > td { padding: 0 !important; }

