/* src/ui/tema-oscuro.css — tema oscuro de AppPK.
 *
 * Se carga como <link id="fc-tema-oscuro"> con un atributo media que decide si
 * aplica, sin duplicar reglas por cada vía de selección:
 *   Sistema → media="screen and (prefers-color-scheme: dark)" (también sin JS)
 *   Oscuro  → media="screen"
 *   Claro   → media="not all"
 * Nunca aplica al imprimir: la vista impresa, los informes y el PDF quedan en
 * claro. src/ui/tema_inicial.js y src/ui/tema.js cambian el media según la
 * preferencia guardada. El modo de alto contraste conserva su paleta propia.
 *
 * Contrastes (WCAG 2.2, luminancia relativa sRGB) comprobados por
 * scripts/pwa/test_tema_oscuro.mjs: texto ≥ 4,5:1, bordes de controles y series
 * de los gráficos ≥ 3:1 frente a su fondo, y series de un mismo gráfico
 * separadas entre sí. Las reglas de componentes van al final, con los mismos
 * selectores que src/ui/visual-system.css, y dependen de que este archivo se
 * cargue después de las demás hojas (index.html; web/clinical.mjs inserta las
 * suyas antes de este enlace).
 */

:root:not(.high-contrast) {
  color-scheme: dark;

  /* ---- Tokens del sistema visual (theme.css, visual-system.css) ---- */
  --native-select-bg: #23211d;
  --native-select-text: #f2eee6;
  --bg-base: #121110;
  --bg-base-2: #0d0c0b;
  --bg-gradient: #121110;
  --surface-content: #1c1a17;
  --surface-soft: #27241f;
  --surface-hover: #2d2a25;
  --surface-selected: #37332d;
  --surface-sunken: #0d0c0b;
  --glass-bg: #1c1a17;
  --glass-bg-strong: #1c1a17;
  --control-border: #8c8577;
  --glass-border: rgba(242, 238, 230, 0.18);
  --glass-border-soft: rgba(242, 238, 230, 0.11);
  --glass-highlight: transparent;
  --glass-shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  --panel-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --accent: #f2eee6;
  --accent-strong: #e4dfd4;
  --accent-contrast: #171717;
  --accent-soft: rgba(242, 238, 230, 0.10);
  --accent-glow: rgba(242, 238, 230, 0.18);
  --ok: #6ee7a0;
  --ok-bg: rgba(74, 222, 128, 0.16);
  --warn: #f8c35a;
  --warn-bg: rgba(251, 191, 36, 0.16);
  --danger: #ff9b9b;
  --danger-bg: rgba(248, 113, 113, 0.18);
  --text-primary: #f2eee6;
  --heading-color: #f2eee6;
  --text-secondary: #d4cdc0;
  --text-muted: #bab2a4;
  --text-on-accent: #171717;

  /* ---- Módulo de farmacocinética (src/modules/farmacocinetica/tema_tokens.css) ---- */
  --fc-tema-canvas: #121110;
  --fc-tema-superficie: #1c1a17;
  --fc-tema-blanco: #211f1b;
  --fc-tema-suave: #27241f;
  --fc-tema-suave-2: #2d2a25;
  --fc-tema-pista: #2d2a25;
  --fc-tema-esqueleto: #2d2a25;
  --fc-tema-borde: #4b463e;
  --fc-tema-borde-suave: #37332d;
  --fc-tema-borde-campo: #8c8577;
  --fc-tema-texto: #f2eee6;
  --fc-tema-texto-2: #d4cdc0;
  --fc-tema-texto-3: #bab2a4;
  --fc-tema-texto-4: #b0a899;
  --fc-tema-texto-switch: #c9c2b5;
  --fc-tema-acento: #f2eee6;
  --fc-tema-acento-fuerte: #e4dfd4;
  --fc-tema-sobre-acento: #171717;
  --fc-tema-cabecera: #080807;
  --fc-tema-sobre-cabecera: #ffffff;
  --fc-tema-sobre-cabecera-2: #fffdf7;
  --fc-tema-cabecera-inactiva: #c9c3b8;
  --fc-tema-cabecera-hover: #ffffff1a;
  --fc-tema-cabecera-barra: #8a8376;
  --fc-tema-pestana-activa: #f2eee6;
  --fc-tema-pestana-activa-texto: #171717;
  --fc-tema-switch-activo: #46413a;
  --fc-tema-sombra: #000000;
  --fc-tema-sombra-negra: #000000;
  --fc-tema-sombra-fria: #000000;
  --fc-tema-error: #ff9b9b;
  --fc-tema-aviso-borde: #8a6d2a;
  --fc-tema-aviso-fondo: #2b2412;
  --fc-tema-aviso-texto: #f0d48a;
  --fc-tema-sugerencia-borde: #5fa36f;
  --fc-tema-sugerencia-fondo: #1b261d;
  --fc-tema-si-fondo: #1f3a26;
  --fc-tema-si-texto: #a7e3b4;
  --fc-tema-renal: #f0b37e;
  --fc-tema-ingreso-borde: #4b463e;
  --fc-tema-ingreso-campo: #8c8577;
  --fc-tema-ingreso-etiqueta: #d4cdc0;
  --fc-tema-ingreso-texto: #bab2a4;
  --fc-tema-ingreso-zebra: #24221e;
  --fc-tema-ingreso-linea: #37332d;
  --fc-tema-ingreso-borde-campo: #8c8577;
  --fc-tema-ingreso-ayuda: #bab2a4;
  --fc-tema-predicho-pob: #ff8b73;
  --fc-tema-predicho-ind: #7ddc9f;
  --fc-tema-leyenda-rango: #3b4a35;
  --fc-tema-leyenda-tox-monitor: #f0c419;
  --fc-tema-leyenda-hd: #a8a090;
  --fc-tema-grafico-fondo: #1c1a17;
  --fc-tema-grafico-texto: #f2eee6;

  /* ---- Series y ejes de los gráficos SVG (FC_COLORES_GRAFICO) ---- */
  --fc-g-pob: #ff7438;
  --fc-g-ind: #8be6b1;
  --fc-g-nivel: #2fae68;
  --fc-g-nivel-borde: #f2eee6;
  --fc-g-terapeutico: #a8773d;
  --fc-g-hd: #b8b0a0;
  --fc-g-guia: #9a9284;
  --fc-g-marca: #c9c2b5;
  --fc-g-cruz: #8c8577;
  --fc-g-fondo: #1c1a17;
  --fc-g-blanco: #1c1a17;
  --fc-g-rojo: #ff5c8a;
  --fc-g-verde: #7ddc9f;
  --fc-g-granate: #ffa361;
  --fc-g-oliva: #e6d36a;
  --fc-g-violeta: #d2b0ec;
  --fc-g-turquesa: #6cc4ff;
  --fc-g-neutro: #a8a090;
  --fc-g-azul: #8ea2ff;
  --fc-g-ambar: #ffb84d;
  --fc-g-esmeralda: #45d483;
  --fc-g-carmin: #ff6b7d;
  --fc-g-barra-principal: #4fc27f;
  --fc-g-barra: #9aa3b0;
  --fc-g-ventana: #6fb3f0;
  --fc-g-error: #ff9db6;
  --fc-g-pta-1: #8ea2ff;
  --fc-g-pta-2: #ffa04d;
  --fc-g-pta-3: #4fd18a;
  --fc-g-pta-4: #ff6f91;
  --fc-g-pta-5: #e08cff;
  --fc-g-pta-6: #45d0d8;
  --fc-g-pta-7: #e0b35a;
  --fc-g-pta-8: #a9b6dd;
  --fc-g-pta-9: #f08ad0;
  --fc-g-pta-10: #b5d66a;
  --fc-g-pta-11: #a6bcc6;
  --fc-g-pta-12: #ff8a70;
  --fc-g-rejilla-pta-2: #3d3a34;
  --fc-g-rejilla-pta-3: #35322d;
  --fc-g-referencia: #ff6b7d;
  --fc-g-marco-pta: #8c8577;
  --fc-g-rejilla-pta: #3d3a34;
  --fc-g-rejilla: #3d3a34;
  --fc-g-rejilla-calida: #3d3a34;
  --fc-g-pista: #2d2a25;
  --fc-g-marco: #8c8577;
  --fc-g-texto-eje: #c9c2b5;
  --fc-g-texto-etiqueta: #ddd6ca;
  --fc-g-texto-valor: #ece7dd;
  --fc-g-texto: #f2eee6;
  --fc-g-texto-eje-calido: #c9c2b5;
  --fc-g-texto-calido: #ece7dd;

  /* ---- Acceso web (web/style.css) ---- */
  --ink: #f2eee6;
  --brand: #f2eee6;
  --line: #4b463e;
  --web-fondo: #121110;
  --web-tarjeta: #1c1a17;
  --web-texto-2: #d4cdc0;
  --web-texto-3: #bab2a4;
  --web-campo: #8c8577;
  --web-tabla: #27241f;
  --web-esqueleto: #2d2a25;
  --web-cabecera: #080807;
  --web-sobre-cabecera: #fffdf7;
  --web-cabecera-borde: #37332d;
  --web-cabecera-linea: #d3cec2;
  --web-sobre-marca: #171717;
  --web-alerta-fondo: #2b2412;
  --web-alerta-borde: #d08a45;
  --web-exito-fondo: #17291f;
  --web-exito-borde: #4fb383;
  --web-fallo-borde: #d08a45;
  --web-fallo-fondo: #2b2015;
  --web-error: #ff9b9b;
  --web-sombra: #000000;

  /* ---- Vista previa local (dev/preview.css) ---- */
  --dev-fondo: #121110;
  --dev-texto: #f2eee6;
  --dev-texto-2: #d4cdc0;
  --dev-cabecera: #080807;
  --dev-cabecera-borde: #37332d;
  --dev-sobre-cabecera: #fffdf7;
  --dev-boton: #fffdf7;
  --dev-boton-texto: #171717;
  --dev-boton-borde: #8a8376;
}

/* ---- Componentes de AppPK que visual-system.css pinta con blancos fijos ---- */
::selection { background: rgba(242, 238, 230, 0.28); }
.fc-panel:has(> .fc-inicio-grid:empty) { box-shadow: var(--panel-shadow); }
:where(.btn):not(.btn-primario, .btn-primary, .btn-peligro) { background: var(--surface-content); border-color: rgba(242, 238, 230, 0.30); box-shadow: none; }
.btn-primario,
.btn-primary { box-shadow: none; }
:where(.campo-input, .input, input:not([type="checkbox"]):not([type="radio"]), select, textarea) { box-shadow: none; }
input::placeholder,
textarea::placeholder { color: var(--text-muted); }
:where(button, a[href], input, select, textarea, summary, [tabindex]):focus-visible { box-shadow: 0 0 0 4px rgba(242, 238, 230, 0.20); }
:where(.timeline-pestanas-lista, .fc-barra) { background: var(--surface-content); }
:where(.timeline-pestana[aria-selected="true"], .fc-pestana[aria-selected="true"]) { background: var(--surface-selected); border-color: var(--glass-border); box-shadow: none; }

/* La comparación del espacio PTA comparte su SVG con el informe impreso, que
   fija en línea fondo blanco y texto negro; en pantalla se adapta al tema. */
.fc-pta-grafico-scroll svg[role=img] { background: var(--fc-tema-grafico-fondo) !important; color: var(--fc-tema-grafico-texto) !important; }
.fc-pta-grafico-scroll svg[role=img] text:not([fill]) { fill: var(--fc-tema-grafico-texto); }
