/* ============================================================
   TEMA GLOBAL - Tokens de color
   Modo claro = apariencia actual
   Modo oscuro = [data-theme="dark"] en <html>
   ============================================================ */

:root {
    /* Superficies */
    --bg-app: #f4f6f9;
    --bg-surface: #ffffff;
    --bg-surface-2: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-sidebar: #050b10;
    --bg-header: #f0f0f0;

    /* Texto */
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-inverse: #ffffff;

    /* Bordes e inputs */
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-focus: #39a900;

    /* Estados e interacción */
    --hover-bg: #f1f5f9;
    --active-bg: #e2e8f0;
    --accent: #39a900;
    --accent-hover: #2f7a00;
    --accent-soft: rgba(57, 169, 0, 0.12);
    --accent-text: #2f7a00;

    --danger: #dc3545;
    --danger-text: #b91c1c;
    --danger-bg: #fff5f5;
    --warning: #f59e0b;
    --warning-text: #92400e;
    --warning-bg: #fffbeb;
    --success: #28a745;
    --success-text: #166534;
    --success-bg: #f0fdf4;
    --info: #0d6efd;
    --info-text: #0c5460;
    --info-bg: #eff6ff;

    /* Tablas */
    --table-head-bg: #f8fafc;
    --table-row-bg: #ffffff;
    --table-row-hover: #f1f5f9;

    /* Sombras y overlays */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.18);
    --overlay: rgba(15, 23, 42, 0.55);

    /* Scrollbar */
    --scrollbar-track: #f0f0f0;
    --scrollbar-thumb: #c1c1c1;

    /* Variantes heredadas usadas por CSS antiguo */
    --verde-sena: #39a900;
    --verde-hover: #2f7a00;
    --verde-sidebar-bg: #e6f4ef;
    --gris-borde: #d1d1d1;
    --gris-fondo: #f4f4f4;
    --gris-texto: #333333;
    --blanco: #ffffff;
    --sombra: 0 2px 16px rgba(57, 169, 0, 0.15);
    --verde-fondo-icon: #ecfdf5;
    --gris-fondo-tarjeta: #f8fafc;
    --gris-titulo-card: #a6afbc;
    --gris-azulado-texto: #64748b;
    --borde-suave: #e2e8f0;
    --texto-oscuro: #0f172a;
    --rojo-salida: #e11d48;
    --rojo-fondo: #ffe4e6;
    --gris-punto: #cbd5e1;
    --error-color: #ff8080;
}

html {
    color-scheme: light;
    background-color: var(--bg-app);
}

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

    --bg-app: #0a0e14;
    --bg-surface: #10161f;
    --bg-surface-2: #16202c;
    --bg-elevated: #1a2533;
    --bg-sidebar: #050b10;
    --bg-header: #10161f;

    --text-primary: #e8edf5;
    --text-secondary: #aab6c8;
    --text-muted: #8b98ad;
    --text-inverse: #ffffff;

    --border-color: #2a3648;
    --border-strong: #3a4a60;
    --input-bg: #0f1724;
    --input-border: #334155;
    --input-focus: #4ade80;

    --hover-bg: #1e2a3a;
    --active-bg: #263447;
    --accent: #39a900;
    --accent-hover: #4ade80;
    --accent-soft: rgba(57, 169, 0, 0.18);
    --accent-text: #6ee7a0;

    --danger: #f87171;
    --danger-text: #fca5a5;
    --danger-bg: rgba(220, 53, 69, 0.14);
    --warning: #fbbf24;
    --warning-text: #fcd34d;
    --warning-bg: rgba(245, 158, 11, 0.14);
    --success: #4ade80;
    --success-text: #86efac;
    --success-bg: rgba(34, 197, 94, 0.14);
    --info: #60a5fa;
    --info-text: #93c5fd;
    --info-bg: rgba(59, 130, 246, 0.14);

    --table-head-bg: #16202c;
    --table-row-bg: #10161f;
    --table-row-hover: #1c2838;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 46px rgba(0, 0, 0, 0.55);
    --overlay: rgba(0, 0, 0, 0.68);

    --scrollbar-track: #0d141d;
    --scrollbar-thumb: #334155;

    /* Compatibilidad con CSS antiguo */
    --verde-sena: #39a900;
    --verde-hover: #4ade80;
    --verde-sidebar-bg: #0b1220;
    --gris-borde: #2a3648;
    --gris-fondo: #0a0e14;
    --gris-texto: #e8edf5;
    --blanco: #10161f;
    --sombra: 0 2px 16px rgba(0, 0, 0, 0.45);
    --verde-fondo-icon: rgba(57, 169, 0, 0.16);
    --gris-fondo-tarjeta: #16202c;
    --gris-titulo-card: #93a4b8;
    --gris-azulado-texto: #aab6c8;
    --borde-suave: #2a3648;
    --texto-oscuro: #e8edf5;
    --rojo-salida: #fb7185;
    --rojo-fondo: rgba(225, 29, 72, 0.16);
    --gris-punto: #475569;
    --error-color: #fca5a5;

    /* Variables heredadas de people_index.css y otras tablas legacy */
    --card-bg: #10161f;
    --bg-card: #10161f;
    --bg-body: #0a0e14;
    --table-bg: #10161f;
    --table-row-alt: #16202c;
    --text-main: #e8edf5;
    --text-muted: #8b98ad;

    /* Páginas de cambio de contraseña */
    --cp-bg: #0a0e14;
    --cp-surface: #10161f;
    --cp-surface-strong: #10161f;
    --cp-border: #2a3648;
    --cp-border-strong: #3a4a60;
    --cp-text: #e8edf5;
    --cp-muted: #aab6c8;
    --cp-accent: #4ade80;
    --cp-accent-dark: #22c55e;
    --cp-accent-soft: rgba(34, 197, 94, 0.16);
    --cp-warning: #fbbf24;
    --cp-danger: #f87171;
    --cp-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
    --cp-shadow-soft: 0 8px 18px rgba(0, 0, 0, 0.32);
}

/* Transición suave al alternar el tema */
html,
body,
.header,
.sidebar,
.content,
.main-layout,
.card,
.modal-content,
table,
input,
select,
textarea,
button,
a {
    transition-property: background-color, border-color, color, box-shadow;
    transition-duration: 0.22s;
    transition-timing-function: ease;
}

@media (prefers-reduced-motion: reduce) {
    html,
    body,
    .header,
    .sidebar,
    .content,
    .main-layout,
    .card,
    .modal-content,
    table,
    input,
    select,
    textarea,
    button,
    a {
        transition: none;
    }
}
