/* Sistema visual compartido por el panel, el móvil y la pantalla.
 *
 * El tema lo resuelve `static/js/theme.js` ANTES de pintar y lo deja en
 * `<html data-theme="light|dark">`, con la preferencia real (que puede ser «auto») en
 * `data-theme-pref`. Por eso aquí solo hay dos bloques de color y ninguno duplicado.
 *
 * Criterio de la paleta: grises fríos y neutros con un punto de azul (el del
 * logotipo), el azul corporativo para todo lo que es IDENTIDAD y selección, y un
 * naranja vivo, usado con cuentagotas, para lo que es ACCIÓN. El naranja nunca lleva
 * texto blanco encima: para llegar a 4.5:1 habría que oscurecerlo hasta que parece
 * marrón. Lleva tinta oscura, y así puede quedarse en naranja de verdad.
 */

/* Archivo (Omnibus-Type), fichero variable 100–900, subconjunto latino, 35 kB.
   Licencia SIL Open Font License 1.1 — https://github.com/Omnibus-Type/Archivo
   Servida desde aquí mismo: la CSP solo admite tipografías de 'self'. */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/archivo-latin-wght-normal.cd56e2ec63d7.woff2") format("woff2");
}

:root {
  color-scheme: light;

  /* --- Superficies: gris frío, la tarjeta en blanco --------------------------- */
  --bg: #f3f4f7;
  --surface: #ffffff;
  --sunken: #e9ebf0;

  /* --- Tinta ---------------------------------------------------------------
     Los tres tonos llevan texto real (etiquetas, encabezados, autores de
     comentario), así que los tres cumplen 4.5:1 sobre fondo, tarjeta y hundido.
     Un gris más claro se vería más «elegante» y sería ilegible para media oficina. */
  --ink: #14182b;
  --ink-2: #4a5068;
  --ink-3: #5f6680;

  /* `line` separa; `line-strong` dibuja el contorno de lo que se toca (casillas,
     campos) y por eso cumple 3:1 contra fondo y tarjeta. */
  --line: #d9dce5;
  --line-soft: #e8eaf0;
  --line-strong: #80869c;

  /* --- Marca del cliente ---------------------------------------------------
     Azul corporativo de Llumar, tomado del logotipo original. Da 9.9:1 sobre el
     fondo claro pero solo 1.7:1 sobre el oscuro, por eso hay dos versiones de cada
     imagen en static/img/ (la oscura va recoloreada a #9aa8f0) y este token cambia
     con el tema. Es el color de IDENTIDAD: enlaces, sección actual, foco, progreso. */
  --brand: #283582;
  --brand-soft: #e6e9f6;
  --on-brand: #ffffff;

  /* --- Acento naranja: el color de ACCIÓN ------------------------------------
     Solo como relleno (botón principal, marca de pendiente, «Hoy»), con `on-accent`
     encima. Cumple 3:1 contra el fondo, que es lo que pide un elemento de interfaz. */
  --accent: #e8590c;
  --accent-hover: #f4711f;
  --on-accent: #11152a;

  /* --- Señales ------------------------------------------------------------- */
  --ok: #1f7a4d;
  --on-ok: #ffffff;

  --alert: #c4223f;
  --alert-soft: #fbe9ec;
  --on-alert: #ffffff;
  /* En espera (falta material o que confirme el cliente): ámbar, texto sobre tinte. */
  --espera: #7a4a00;
  --espera-soft: #fff1d6;
  /* Etiquetas de técnico: 8 colores, relleno + texto, auditados en test_contraste.py.
     El técnico guarda solo el índice (1..8), nunca un color libre. */
  --tec-1: #dbe6ff;
  --on-tec-1: #1c3a86;
  --tec-2: #ccefec;
  --on-tec-2: #0b5753;
  --tec-3: #d6efd4;
  --on-tec-3: #1d5a28;
  --tec-4: #e9edc6;
  --on-tec-4: #4d5410;
  --tec-5: #fbe6b4;
  --on-tec-5: #654500;
  --tec-6: #f7d8ee;
  --on-tec-6: #7a1d60;
  --tec-7: #e5dbfb;
  --on-tec-7: #47288a;
  --tec-8: #e0e4ea;
  --on-tec-8: #2c3644;

  /* --- Formas: esquinas discretas, nada de píldoras ------------------------- */
  --r-sm: 4px;
  --r: 6px;
  --r-lg: 10px;

  --shadow-1: 0 1px 2px rgba(20, 24, 43, 0.06);
  --shadow-2: 0 6px 24px rgba(20, 24, 43, 0.14);

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --t-fast: 0.12s;
  --t: 0.2s;

  --font: "Archivo", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1118;
  --surface: #171b26;
  --sunken: #0a0c12;

  --ink: #eef0f6;
  --ink-2: #a9afc2;
  --ink-3: #8d94ab;

  --line: #2a3040;
  --line-soft: #1f2431;
  --line-strong: #6b7289;

  --brand: #9aa8f0;
  --brand-soft: #1e2440;
  --on-brand: #10142a;

  --accent: #ff8a3d;
  --accent-hover: #ffa468;
  --on-accent: #11152a;

  --ok: #5fd39a;
  --on-ok: #062414;

  /* Rojo coral y no rosa: el anterior (#ff8496) se leía como salmón en la pared. */
  --alert: #ff6b6b;
  --alert-soft: #2b161b;
  --on-alert: #2a0a12;
  --espera: #f6c868;
  --espera-soft: #2e2309;
  /* Etiquetas de técnico: 8 colores, relleno + texto, auditados en test_contraste.py.
     El técnico guarda solo el índice (1..8), nunca un color libre. */
  --tec-1: #223a72;
  --on-tec-1: #d6e3ff;
  --tec-2: #10504c;
  --on-tec-2: #c2f3ee;
  --tec-3: #1f5228;
  --on-tec-3: #cdf2cf;
  --tec-4: #4b5214;
  --on-tec-4: #eef2c4;
  --tec-5: #664a06;
  --on-tec-5: #fde9b3;
  --tec-6: #68204f;
  --on-tec-6: #fbd6f0;
  --tec-7: #452f7c;
  --on-tec-7: #e8deff;
  --tec-8: #394250;
  --on-tec-8: #e2e7ee;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 6px 24px rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------------------- base */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-kerning: normal;
  /* Archivo viene apretada de serie: un pelo de aire entre palabras la hace más legible. */
  word-spacing: 0.06em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
p { margin: 0; }

a { color: var(--brand); text-underline-offset: 0.18em; }

::selection {
  background: var(--brand);
  color: var(--on-brand);
}

/* Un único estilo de foco para todo: contorno en el azul de la marca. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

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

[hidden] { display: none !important; }

/* ------------------------------------------------------------- movimiento
   Poco y con motivo: el tablero de la pared funde al cambiar, el piloto de «sin
   conexión» respira y los formularios que se despliegan aparecen. Nada más. */

@keyframes surgir {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes respirar {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* Quien pide menos movimiento, no lo recibe. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------- botones */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:active:not(:disabled) { background: var(--sunken); }
.btn:disabled { color: var(--line-strong); border-color: var(--line); cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  align-self: flex-start;
}
.btn-primary:hover:not(:disabled),
.btn-primary:active:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:disabled { border-color: transparent; }
.btn-quiet:hover:not(:disabled) { background: var(--sunken); border-color: transparent; color: var(--ink); }

.btn-danger { background: transparent; color: var(--alert); border-color: transparent; }
.btn-danger:hover:not(:disabled) { border-color: var(--alert); background: var(--alert-soft); }

.btn-icon { min-height: 0; width: 1.9rem; height: 1.9rem; padding: 0; }

/* ---------------------------------------------------------------- señales */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  padding: 0.1rem 0.4rem;
  border-radius: var(--r-sm);
  vertical-align: 0.12em;
  white-space: nowrap;
  letter-spacing: 0;
}
.badge-today { background: var(--accent); color: var(--on-accent); }
.badge-carry { background: var(--alert-soft); color: var(--alert); }
.badge-urgent { background: var(--alert); color: var(--on-alert); }
.badge-rol { background: var(--sunken); color: var(--ink-2); }

/* ------------------------------------------------------- selector de tema
   Control segmentado: tres opciones dentro de un mismo marco. */

.tema {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  padding: 2px;
}

.tema-opcion {
  position: relative;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}
.tema-opcion:hover { color: var(--ink); }
.tema-opcion[aria-pressed="true"] {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}


/* ------------------------------------------------------- etiquetas de técnico */

.tec {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.35;
  white-space: nowrap;
}
.tec-c1 { background: var(--tec-1); color: var(--on-tec-1); }
.tec-c2 { background: var(--tec-2); color: var(--on-tec-2); }
.tec-c3 { background: var(--tec-3); color: var(--on-tec-3); }
.tec-c4 { background: var(--tec-4); color: var(--on-tec-4); }
.tec-c5 { background: var(--tec-5); color: var(--on-tec-5); }
.tec-c6 { background: var(--tec-6); color: var(--on-tec-6); }
.tec-c7 { background: var(--tec-7); color: var(--on-tec-7); }
.tec-c8 { background: var(--tec-8); color: var(--on-tec-8); }
