/* =========================================================
   🎨 Synaris — Theme layer (tokens)
   ---------------------------------------------------------
   • MODO CLARO por defecto (:root)
   • MODO OSCURO opcional  (html[data-theme="dark"])
   • El usuario decide con el switch del header. La preferencia
     se guarda en localStorage ("synaris.theme").
   • Este archivo debe cargarse ANTES de app.css / index.css /
     admin.css: define las variables que todos consumen.
   ========================================================= */

:root {
    color-scheme: light;

    /* ---------- Marca — tomada del logo -------------------------
       naranja #F06515 → ámbar #F38912 sobre azul carbón #131D2A
       ------------------------------------------------------------ */
    --brand: #ef6115;
    --brand-strong: #d4520b;
    --brand2: #f38912;
    --brand2-strong: #e07a0c;
    --ink-navy: #131d2a;
    --ink-navy-soft: #2b3a4f;

    /* Componentes sueltos para tintes */
    --brand-rgb: 239 97 21;
    --brand2-rgb: 243 137 18;
    --navy-rgb: 19 29 42;

    /* Verde solo para WhatsApp; no es color de marca */
    --wa: #22c55e;
    --wa-strong: #16a34a;

    --warn: #eab308;
    --danger: #e11d48;
    --info: #3c5a7a;

    /* ---------- Marca legible sobre la superficie actual ---------- */
    --brand-ink: #b8460a;
    --brand2-ink: #a35c06;
    --warn-ink: #a16207;
    --danger-ink: #be123c;
    --info-ink: #2b4a6b;
    --ok-ink: #15803d;

    /* ---------- Base para tintes translúcidos ---------- */
    /* En claro el "frente" es tinta oscura; en oscuro, blanco. */
    --fg-rgb: 15 23 42;

    /* Base de las sombras: color + factor de intensidad.
       En claro las sombras son más suaves que en oscuro. */
    --sh-rgb: 19 29 42;
    --sh-k: .55;

    /* ---------- Fondos y superficies ---------- */
    --bg: #f7f7f6;
    --bg-rgb: 247 247 246;
    --bg-2: #efeeec;

    /* Superficie de tarjeta (.card usa panel/panel2) */
    --panel: #ffffff;
    --panel2: #ffffff;
    --surface-grad: linear-gradient(180deg, #ffffff, #fdfcfb);

    /* Superficies anidadas: 1 = apenas visible … 3 = más marcada */
    --surface-1: #fbfaf9;
    --surface-2: #f4f3f1;
    --surface-3: #eae8e5;

    /* Superficie "cristal" (menús flotantes, toasts) */
    --glass: rgba(255, 255, 255, .88);
    --glass-solid: #ffffff;

    /* Un menú flotante que cuelga del header hereda los tokens invertidos
       de la barra sobre el hero oscuro y su texto se vuelve blanco sobre
       blanco. Estos NO los pisa ningún ámbito: siempre son los del tema. */
    --pop-text: #131d2a;
    --pop-muted: #4d5765;
    --pop-faint: #626c7a;
    --pop-surface: #f4f3f1;
    --pop-surface-2: #fbfaf9;
    --pop-border: rgba(19, 29, 42, .11);
    --pop-border-2: rgba(19, 29, 42, .18);

    /* Filas de tabla: sólidas, para que la columna fija de acciones
       pueda taparlas sin transparencias que dejen ver el texto debajo. */
    --table-row: #ffffff;
    --table-zebra: #faf9f7;
    --table-hover: #fdf0e7;

    /* Barra superior */
    --header-bg: rgba(255, 255, 255, .90);
    --header-border: rgba(19, 29, 42, .09);

    /* Velo de modales */
    --scrim: rgba(19, 29, 42, .48);

    /* ---------- Texto ---------- */
    --text: #131d2a;
    --muted: #4d5765;
    --faint: #626c7a;
    --on-brand: #ffffff;
    /* texto sobre botones/íconos de color sólido */

    /* ---------- Bordes ---------- */
    --border: rgba(19, 29, 42, .11);
    --border-2: rgba(19, 29, 42, .18);

    /* ---------- Sombras ---------- */
    --shadow-sm: 0 1px 2px rgba(19, 29, 42, .05), 0 2px 8px rgba(19, 29, 42, .04);
    --shadow: 0 2px 6px rgba(19, 29, 42, .05), 0 14px 34px rgba(19, 29, 42, .08);
    --shadow-lg: 0 6px 18px rgba(19, 29, 42, .07), 0 30px 66px rgba(19, 29, 42, .13);
    --shadow-brand: 0 12px 28px rgba(239, 97, 21, .26);
    --shadow-green: 0 12px 28px rgba(22, 163, 74, .22);

    /* ---------- Luces decorativas (halos de fondo) ---------- */
    /* Halos: naranja / ámbar / azul carbón — los tres del logo */
    --glow-violet: rgba(239, 97, 21, .12);
    --glow-green: rgba(243, 137, 18, .11);
    --glow-amber: rgba(19, 29, 42, .07);
    --glow-violet-soft: rgba(239, 97, 21, .10);
    --glow-green-soft: rgba(243, 137, 18, .09);
    --glow-amber-soft: rgba(19, 29, 42, .05);
    /* Opacidad de los orbes borrosos del hero */
    --orb-opacity: .30;

    /* Fondo del hero: los dos arcos del logo (naranja + azul carbón) */
    /* El hero es una banda azul carbón en ambos temas: es el disco
       oscuro del logo, con el arco naranja encima. */
    --hero-bg: #101b28;
    --hero-bg-2: #17273a;
    --hero-line: rgb(255 255 255 / .05);
    --arc-brand-a: .55;
    --arc-navy-a: .34;
    --hero-veil: rgba(19, 29, 42, .05);
    --hero-grain: .30;
    --hero-grid: rgb(var(--navy-rgb) / .05);
    /* Brillo que recorre el CTA final */
    --shine: rgba(255, 255, 255, .55);

    /* ---------- Gradientes de marca ---------- */
    /* Texto degradado del hero */
    /* El arco naranja del logo */
    --grad-1: linear-gradient(135deg, #ef6115, #d4520b);
    /* El arco oscuro del logo */
    --grad-2: linear-gradient(135deg, #f9a03f, #e07a0c);
    /* Números de métricas */
    --grad-stat: linear-gradient(135deg, #131d2a, #d4520b);
    /* Chips de íconos */
    --chip-grad: linear-gradient(135deg, #f38912, #ef6115);
    --chip-grad-warm: linear-gradient(135deg, #2b3a4f, #131d2a);

    /* ---------- Estados suaves (chips, badges) ---------- */
    --ok-bg: rgba(34, 197, 94, .12);
    --ok-border: rgba(22, 163, 74, .28);
    --warn-bg: rgba(234, 179, 8, .16);
    --warn-border: rgba(161, 98, 7, .30);
    --bad-bg: rgba(225, 29, 72, .10);
    --bad-border: rgba(190, 18, 60, .26);
    --brand-bg: rgba(239, 97, 21, .10);
    --brand-border: rgba(239, 97, 21, .28);

    /* ---------- Geometría ---------- */
    --radius: 18px;
    --max: 1180px;

    /* Compat con el CSS anterior */
    --shadow-legacy: var(--shadow);
}

/* =========================================================
   🌙 MODO OSCURO — opcional, solo si el usuario lo activa
   ========================================================= */
html[data-theme="dark"] {
    color-scheme: dark;

    /* Sobre fondo oscuro el naranja del logo se aclara un punto */
    --brand: #ff7a33;
    --brand-strong: #ef6115;
    --brand2: #f9a03f;
    --brand2-strong: #f38912;
    --ink-navy: #0d141d;
    --ink-navy-soft: #223142;

    --brand-rgb: 255 122 51;
    --brand2-rgb: 249 160 63;
    --navy-rgb: 143 176 205;

    --wa: #22c55e;
    --wa-strong: #16a34a;

    --warn: #eab308;
    --danger: #fb7185;
    --info: #7aa2c8;

    --brand-ink: #ffa76b;
    --brand2-ink: #fbbf6e;
    --warn-ink: #fcd34d;
    --danger-ink: #fda4af;
    --info-ink: #9dc0e0;
    --ok-ink: #6ee7a0;

    --fg-rgb: 255 255 255;
    --sh-rgb: 0 0 0;
    --sh-k: 1;

    /* El azul carbón del logo como fondo */
    --bg: #0d141d;
    --bg-rgb: 13 20 29;
    --bg-2: #111a25;

    --panel: rgba(255, 255, 255, .055);
    --panel2: rgba(255, 255, 255, .085);
    --surface-grad: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .025));

    --surface-1: rgba(255, 255, 255, .035);
    --surface-2: rgba(255, 255, 255, .065);
    --surface-3: rgba(255, 255, 255, .11);

    --glass: rgba(14, 21, 30, .84);
    --glass-solid: #121c27;

    --pop-text: rgba(255, 255, 255, .94);
    --pop-muted: rgba(255, 255, 255, .70);
    --pop-faint: rgba(255, 255, 255, .55);
    --pop-surface: rgba(255, 255, 255, .065);
    --pop-surface-2: rgba(255, 255, 255, .035);
    --pop-border: rgba(255, 255, 255, .12);
    --pop-border-2: rgba(255, 255, 255, .24);

    /* Sólidos: la celda fija de acciones tiene que tapar lo que pasa
       por detrás, y --panel en oscuro es translúcido. */
    --table-row: #19212b;
    --table-zebra: #1e2731;
    --table-hover: #2a2018;

    --header-bg: rgba(13, 20, 29, .82);
    --header-border: rgba(255, 255, 255, .08);

    --scrim: rgba(0, 0, 0, .64);

    --text: rgba(255, 255, 255, .94);
    --muted: rgba(255, 255, 255, .70);
    --faint: rgba(255, 255, 255, .55);
    --on-brand: #ffffff;

    --border: rgba(255, 255, 255, .12);
    --border-2: rgba(255, 255, 255, .24);

    --shadow-sm: 0 2px 10px rgba(0, 0, 0, .35);
    --shadow: 0 18px 50px rgba(0, 0, 0, .45);
    --shadow-lg: 0 30px 80px rgba(0, 0, 0, .55);
    --shadow-brand: 0 14px 34px rgba(239, 97, 21, .34);
    --shadow-green: 0 14px 34px rgba(34, 197, 94, .30);

    --glow-violet: rgba(239, 97, 21, .30);
    --glow-green: rgba(243, 137, 18, .22);
    --glow-amber: rgba(60, 90, 122, .20);
    --glow-violet-soft: rgba(239, 97, 21, .20);
    --glow-green-soft: rgba(243, 137, 18, .16);
    --glow-amber-soft: rgba(60, 90, 122, .14);
    --orb-opacity: .34;
    --hero-bg: #0e1823;
    --hero-bg-2: #142334;
    --hero-line: rgb(255 255 255 / .045);
    --arc-brand-a: .50;
    --arc-navy-a: .30;
    --hero-veil: rgba(6, 11, 18, .40);
    --hero-grain: .22;
    --hero-grid: rgb(255 255 255 / .045);
    --shine: rgba(255, 255, 255, .08);

    --ok-bg: rgba(34, 197, 94, .14);
    --ok-border: rgba(34, 197, 94, .35);
    --warn-bg: rgba(234, 179, 8, .16);
    --warn-border: rgba(234, 179, 8, .38);
    --bad-bg: rgba(251, 113, 133, .14);
    --bad-border: rgba(251, 113, 133, .35);
    --brand-bg: rgba(239, 97, 21, .18);
    --brand-border: rgba(239, 97, 21, .42);

    --grad-1: linear-gradient(135deg, #ffb066, #ff7a33 55%, #ef6115);
    --grad-2: linear-gradient(135deg, #ffc48a, #f9a03f);
    --grad-stat: linear-gradient(135deg, #ffffff, #ffa76b);
    --chip-grad: linear-gradient(135deg, #f9a03f, #ef6115);
    --chip-grad-warm: linear-gradient(135deg, #3c5a7a, #223142);
}

/* =========================================================
   Base / tipografía
   ========================================================= */
html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
    color: var(--text);
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

/* Transición suave al cambiar de tema (se desactiva en el primer pintado
   y con prefers-reduced-motion, ver theme.js) */
html.theme-anim body,
html.theme-anim body * {
    transition:
        background-color .28s ease,
        border-color .28s ease,
        color .28s ease,
        box-shadow .28s ease !important;
}

/* Foco accesible consistente */
:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 12px;
}

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

/* Barras de scroll acordes al tema */
* {
    scrollbar-color: rgb(var(--fg-rgb) / .28) transparent;
}

/* =========================================================
   🌗 Switch de tema
   ========================================================= */
.themeToggle {
    --tt-size: 44px;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tt-size);
    height: var(--tt-size);
    flex: 0 0 auto;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: transform .16s ease, background .2s ease, border-color .2s ease, color .2s ease;
}

.themeToggle:hover {
    transform: translateY(-1px);
    color: var(--text);
    border-color: var(--border-2);
    background: var(--surface-3);
}

.themeToggle:active {
    transform: translateY(0) scale(.96);
}

.themeToggle i {
    position: absolute;
    font-size: 16px;
    line-height: 1;
    transition: transform .38s cubic-bezier(.2, .8, .2, 1), opacity .24s ease;
}

/* Claro activo → se ve el sol; el switch ofrece pasar a oscuro */
.themeToggle .tt-sun {
    color: var(--warn-ink);
    transform: none;
    opacity: 1;
}

.themeToggle .tt-moon {
    transform: rotate(-90deg) scale(.4);
    opacity: 0;
}

html[data-theme="dark"] .themeToggle .tt-sun {
    transform: rotate(90deg) scale(.4);
    opacity: 0;
}

html[data-theme="dark"] .themeToggle .tt-moon {
    color: var(--brand-ink);
    transform: none;
    opacity: 1;
}

/* Variante flotante para páginas sin barra de navegación */
.themeToggle.themeToggle-float {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 940;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}

/* En el menú móvil se muestra como fila completa */
.themeToggleRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-1);
    margin-top: 10px;
    color: var(--text);
    font-weight: 800;
    width: 100%;
    cursor: pointer;
    text-align: left;
}

.themeToggleRow small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

@media (prefers-reduced-motion: reduce) {

    html.theme-anim body,
    html.theme-anim body * {
        transition: none !important;
    }

    .themeToggle i {
        transition: none;
    }
}

/* =========================================================
   SweetAlert2 — acorde al tema activo
   (las llamadas heredadas pasan colores oscuros en línea;
   estas reglas ganan y mantienen la coherencia)
   ========================================================= */
.swal2-container {
    backdrop-filter: blur(3px);
}

.swal2-container.swal2-backdrop-show {
    background: var(--scrim) !important;
}

.swal2-popup {
    background: var(--glass-solid) !important;
    color: var(--text) !important;
    border: 1px solid var(--border);
    border-radius: 20px !important;
    box-shadow: var(--shadow-lg);
}

.swal2-title,
.swal2-html-container,
.swal2-content {
    color: var(--text) !important;
}

.swal2-html-container {
    color: var(--muted) !important;
}

.swal2-input,
.swal2-textarea,
.swal2-select {
    background: var(--surface-1) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    box-shadow: none !important;
}

.swal2-styled.swal2-confirm {
    background: linear-gradient(135deg, var(--brand), var(--brand2-strong)) !important;
    color: var(--on-brand) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-brand) !important;
}

.swal2-styled.swal2-cancel,
.swal2-styled.swal2-deny {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
}

.swal2-timer-progress-bar {
    background: var(--brand) !important;
}
