/**
 * Sistema de Temas Visuales Ergonómicos - ERP Ana Cuenca
 * Armonizado con la identidad corporativa (Marino & Turquesa) + modos de descanso visual
 */

:root,
html[data-theme="oceano"] {
    /* Paleta Principal: Marino Profundo & Turquesa Sereno (A juego con logo ANA CUENCA) */
    --brand-50-rgb: 238 249 250;
    --brand-100-rgb: 211 239 243;
    --brand-200-rgb: 168 222 230;
    --brand-300-rgb: 109 197 210;
    --brand-400-rgb: 46 168 184;
    --brand-500-rgb: 15 139 153;
    --brand-600-rgb: 12 114 130;
    --brand-700-rgb: 11 91 112;
    --brand-800-rgb: 12 69 96;
    --brand-900-rgb: 11 44 77;
    --brand-950-rgb: 7 29 52;

    --erp-bg: #eef4f7;
    --erp-surface: #ffffff;
    --erp-surface-2: #f4f8fa;
    --erp-sidebar-bg: #f7fafc;
    --erp-header-bg: rgba(255, 255, 255, 0.92);
    --erp-border: #dbe7ee;
    --erp-text: #182a3b;
    --erp-text-muted: #5a7084;
    --erp-active-from: #0b4a6f;
    --erp-active-to: #0f8b99;
    --erp-hero-from: #071e34;
    --erp-hero-via: #0b2c4d;
    --erp-hero-to: #0e586b;
    --erp-scroll-track: #e6eff4;
    --erp-scroll-thumb: #b4cad6;
    --erp-scroll-hover: #83a6b8;
    --erp-shadow-card: 0 4px 20px -4px rgba(11, 44, 77, 0.06), 0 1px 4px -1px rgba(11, 44, 77, 0.04);
}

html[data-theme="salvia"] {
    /* Paleta Descanso Visual: Verde Salvia & Bosque Suave */
    --brand-50-rgb: 239 248 244;
    --brand-100-rgb: 211 237 226;
    --brand-200-rgb: 169 219 199;
    --brand-300-rgb: 115 193 165;
    --brand-400-rgb: 58 163 132;
    --brand-500-rgb: 19 135 106;
    --brand-600-rgb: 15 110 88;
    --brand-700-rgb: 14 89 72;
    --brand-800-rgb: 15 70 58;
    --brand-900-rgb: 14 55 46;
    --brand-950-rgb: 8 36 30;

    --erp-bg: #eff5f1;
    --erp-surface: #ffffff;
    --erp-surface-2: #f4f9f6;
    --erp-sidebar-bg: #f6faf7;
    --erp-header-bg: rgba(255, 255, 255, 0.92);
    --erp-border: #d7e6dd;
    --erp-text: #192d26;
    --erp-text-muted: #587268;
    --erp-active-from: #0f5f53;
    --erp-active-to: #13876a;
    --erp-hero-from: #0b2e27;
    --erp-hero-via: #11473c;
    --erp-hero-to: #136c59;
    --erp-scroll-track: #e5efe9;
    --erp-scroll-thumb: #b4cec0;
    --erp-scroll-hover: #7ea894;
    --erp-shadow-card: 0 4px 20px -4px rgba(15, 70, 58, 0.06), 0 1px 4px -1px rgba(15, 70, 58, 0.04);
}

html[data-theme="marfil"] {
    /* Paleta Cálida Minimal: Arena, Marfil & Pizarra Azul */
    --brand-50-rgb: 242 245 249;
    --brand-100-rgb: 223 231 240;
    --brand-200-rgb: 191 207 224;
    --brand-300-rgb: 146 174 202;
    --brand-400-rgb: 98 137 175;
    --brand-500-rgb: 66 107 148;
    --brand-600-rgb: 51 87 125;
    --brand-700-rgb: 42 71 103;
    --brand-800-rgb: 36 58 84;
    --brand-900-rgb: 30 46 68;
    --brand-950-rgb: 19 30 45;

    --erp-bg: #f4f1ea;
    --erp-surface: #fffdf9;
    --erp-surface-2: #f9f6f0;
    --erp-sidebar-bg: #faf8f3;
    --erp-header-bg: rgba(255, 253, 249, 0.92);
    --erp-border: #e5dfd2;
    --erp-text: #272e38;
    --erp-text-muted: #696862;
    --erp-active-from: #2d4663;
    --erp-active-to: #466c95;
    --erp-hero-from: #1d2b3a;
    --erp-hero-via: #293e54;
    --erp-hero-to: #3a5b7c;
    --erp-scroll-track: #ece7dc;
    --erp-scroll-thumb: #c9c0ae;
    --erp-scroll-hover: #9f9480;
    --erp-shadow-card: 0 4px 20px -4px rgba(45, 55, 72, 0.06), 0 1px 4px -1px rgba(45, 55, 72, 0.03);
}

html[data-theme="nocturno"] {
    /* Paleta Modo Oscuro Ejecutivo: Pizarra Profunda & Turquesa Suave */
    --brand-50-rgb: 19 42 58;
    --brand-100-rgb: 22 57 78;
    --brand-200-rgb: 28 79 107;
    --brand-300-rgb: 56 178 194;
    --brand-400-rgb: 45 200 212;
    --brand-500-rgb: 20 184 166;
    --brand-600-rgb: 13 148 136;
    --brand-700-rgb: 15 118 110;
    --brand-800-rgb: 17 94 89;
    --brand-900-rgb: 14 48 68;
    --brand-950-rgb: 9 20 35;

    --erp-bg: #0b1320;
    --erp-surface: #142033;
    --erp-surface-2: #19283f;
    --erp-sidebar-bg: #101a2b;
    --erp-header-bg: rgba(16, 26, 43, 0.92);
    --erp-border: #243652;
    --erp-text: #e2e8f0;
    --erp-text-muted: #94a3b8;
    --erp-active-from: #0f766e;
    --erp-active-to: #0284c7;
    --erp-hero-from: #091322;
    --erp-hero-via: #0f253c;
    --erp-hero-to: #114357;
    --erp-scroll-track: #0f1929;
    --erp-scroll-thumb: #2b3f5e;
    --erp-scroll-hover: #3e5982;
    --erp-shadow-card: 0 6px 24px -6px rgba(0, 0, 0, 0.45);
}

/* Base y Lienzo Principal */
body.erp-body {
    background-color: var(--erp-bg) !important;
    color: var(--erp-text);
    transition: background-color 0.2s ease, color 0.2s ease;
}

main.erp-main {
    background-color: var(--erp-bg) !important;
}

/* Header & Sidebar */
header.erp-header {
    background-color: var(--erp-header-bg) !important;
    border-bottom: 1px solid var(--erp-border) !important;
    box-shadow: 0 2px 14px -6px rgba(15, 35, 55, 0.10);
}

aside.erp-sidebar {
    background-color: var(--erp-sidebar-bg) !important;
    border-right: 1px solid var(--erp-border) !important;
}

.erp-sidebar-footer {
    background-color: var(--erp-surface-2) !important;
    border-top: 1px solid var(--erp-border) !important;
}

.erp-nav-active {
    background: linear-gradient(135deg, var(--erp-active-from), var(--erp-active-to)) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 14px -4px rgb(var(--brand-600-rgb) / 0.35);
}

.erp-btn-primary {
    background: linear-gradient(135deg, var(--erp-active-from), var(--erp-active-to)) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 16px -4px rgb(var(--brand-600-rgb) / 0.35);
}
.erp-btn-primary:hover {
    filter: brightness(1.06);
}

.erp-hero-banner {
    background: linear-gradient(135deg, var(--erp-hero-from) 0%, var(--erp-hero-via) 52%, var(--erp-hero-to) 100%) !important;
}

/* Logo legible incluso en Modo Oscuro */
html[data-theme="nocturno"] .erp-logo-badge {
    background: rgba(255, 255, 255, 0.94);
    padding: 3px 10px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

/* Scrollbar adaptada al tema */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: var(--erp-scroll-track);
}
::-webkit-scrollbar-thumb {
    background: var(--erp-scroll-thumb);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--erp-scroll-hover);
}

/* Suavizado general de tarjetas y formularios en todos los módulos */
.erp-main .bg-white.rounded-2xl,
.erp-main .bg-white.rounded-3xl,
.erp-main .bg-white.rounded-xl {
    box-shadow: var(--erp-shadow-card);
}

.erp-main input:focus,
.erp-main select:focus,
.erp-main textarea:focus {
    outline: none;
    border-color: rgb(var(--brand-500-rgb)) !important;
    box-shadow: 0 0 0 3px rgb(var(--brand-500-rgb) / 0.16) !important;
}

/* Armonizar botón primario por defecto en formularios azul/indigo en temas claros y oscuros */
html[data-theme="oceano"] .erp-main .bg-blue-600,
html[data-theme="salvia"] .erp-main .bg-blue-600,
html[data-theme="marfil"] .erp-main .bg-blue-600 {
    background-color: rgb(var(--brand-600-rgb));
}
html[data-theme="oceano"] .erp-main .hover\:bg-blue-700:hover,
html[data-theme="salvia"] .erp-main .hover\:bg-blue-700:hover,
html[data-theme="marfil"] .erp-main .hover\:bg-blue-700:hover {
    background-color: rgb(var(--brand-700-rgb));
}

/* =========================================================
   REGLAS ADAPTATIVAS PARA MODO OSCURO EJECUTIVO (NOCTURNO)
   ========================================================= */
html[data-theme="nocturno"] .erp-main .bg-white,
html[data-theme="nocturno"] .erp-modal-surface {
    background-color: var(--erp-surface) !important;
    color: var(--erp-text);
}

html[data-theme="nocturno"] .erp-hero-banner .text-brand-100,
html[data-theme="nocturno"] .erp-hero-banner .text-brand-200 {
    color: #ccfbf1 !important;
}

html[data-theme="nocturno"] .erp-bcv-widget {
    background: rgba(16, 185, 129, 0.14) !important;
    border-color: rgba(16, 185, 129, 0.35) !important;
}

html[data-theme="nocturno"] .erp-main .bg-slate-50,
html[data-theme="nocturno"] .erp-main .bg-slate-50\/50,
html[data-theme="nocturno"] .erp-main .bg-slate-50\/60,
html[data-theme="nocturno"] .erp-main .bg-slate-50\/70,
html[data-theme="nocturno"] .erp-main .bg-slate-50\/80,
html[data-theme="nocturno"] .erp-main .bg-slate-100,
html[data-theme="nocturno"] .erp-main .bg-gray-50,
html[data-theme="nocturno"] .erp-main .bg-gray-100,
html[data-theme="nocturno"] .erp-main .bg-\[\#f8fafc\],
html[data-theme="nocturno"] .erp-modal-muted {
    background-color: var(--erp-surface-2) !important;
}

html[data-theme="nocturno"] .erp-main .hover\:bg-slate-50:hover,
html[data-theme="nocturno"] .erp-main .hover\:bg-slate-100:hover,
html[data-theme="nocturno"] .erp-sidebar .hover\:bg-slate-100:hover,
html[data-theme="nocturno"] .erp-header .hover\:bg-slate-100:hover {
    background-color: #1f314d !important;
}

html[data-theme="nocturno"] .erp-main .border-slate-200,
html[data-theme="nocturno"] .erp-main .border-slate-200\/80,
html[data-theme="nocturno"] .erp-main .border-slate-100,
html[data-theme="nocturno"] .erp-main .border-gray-200,
html[data-theme="nocturno"] .erp-main .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
html[data-theme="nocturno"] .erp-main .divide-slate-200 > :not([hidden]) ~ :not([hidden]),
html[data-theme="nocturno"] .erp-header .border-slate-200,
html[data-theme="nocturno"] .erp-header .border-slate-200\/80,
html[data-theme="nocturno"] .erp-modal-surface,
html[data-theme="nocturno"] .erp-modal-muted {
    border-color: var(--erp-border) !important;
}

html[data-theme="nocturno"] .erp-header .bg-slate-50,
html[data-theme="nocturno"] .erp-header .bg-slate-100 {
    background-color: var(--erp-surface-2) !important;
}

html[data-theme="nocturno"] .text-slate-900,
html[data-theme="nocturno"] .text-slate-800,
html[data-theme="nocturno"] .text-gray-900,
html[data-theme="nocturno"] .text-gray-800 {
    color: #f1f5f9 !important;
}

html[data-theme="nocturno"] .text-slate-700,
html[data-theme="nocturno"] .text-slate-600,
html[data-theme="nocturno"] .text-gray-700,
html[data-theme="nocturno"] .text-gray-600 {
    color: #cbd5e1 !important;
}

html[data-theme="nocturno"] .text-slate-500,
html[data-theme="nocturno"] .text-slate-400 {
    color: #94a3b8 !important;
}

html[data-theme="nocturno"] .erp-main input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-theme="nocturno"] .erp-main select,
html[data-theme="nocturno"] .erp-main textarea {
    background-color: #0e1726 !important;
    color: #f1f5f9 !important;
    border-color: #2b3f5e !important;
}

/* Tintes translúcidos suaves para badges y alertas en Modo Oscuro */
html[data-theme="nocturno"] .bg-emerald-50,
html[data-theme="nocturno"] .bg-emerald-100,
html[data-theme="nocturno"] .bg-green-50,
html[data-theme="nocturno"] .bg-green-100 {
    background-color: rgba(16, 185, 129, 0.14) !important;
    border-color: rgba(16, 185, 129, 0.30) !important;
}
html[data-theme="nocturno"] .bg-blue-50,
html[data-theme="nocturno"] .bg-blue-100,
html[data-theme="nocturno"] .bg-sky-50,
html[data-theme="nocturno"] .bg-sky-100 {
    background-color: rgba(56, 189, 248, 0.14) !important;
    border-color: rgba(56, 189, 248, 0.30) !important;
}
html[data-theme="nocturno"] .bg-indigo-50,
html[data-theme="nocturno"] .bg-indigo-100 {
    background-color: rgba(99, 102, 241, 0.15) !important;
    border-color: rgba(99, 102, 241, 0.30) !important;
}
html[data-theme="nocturno"] .bg-amber-50,
html[data-theme="nocturno"] .bg-amber-100 {
    background-color: rgba(245, 158, 11, 0.15) !important;
    border-color: rgba(245, 158, 11, 0.32) !important;
}
html[data-theme="nocturno"] .bg-rose-50,
html[data-theme="nocturno"] .bg-red-50,
html[data-theme="nocturno"] .bg-red-100 {
    background-color: rgba(244, 63, 94, 0.15) !important;
    border-color: rgba(244, 63, 94, 0.32) !important;
}
html[data-theme="nocturno"] .bg-purple-50,
html[data-theme="nocturno"] .bg-purple-100 {
    background-color: rgba(168, 85, 247, 0.15) !important;
    border-color: rgba(168, 85, 247, 0.30) !important;
}

html[data-theme="nocturno"] .text-emerald-800,
html[data-theme="nocturno"] .text-emerald-700,
html[data-theme="nocturno"] .text-green-700 { color: #6ee7b7 !important; }
html[data-theme="nocturno"] .text-blue-800,
html[data-theme="nocturno"] .text-blue-700,
html[data-theme="nocturno"] .text-sky-700 { color: #7dd3fc !important; }
html[data-theme="nocturno"] .text-indigo-800,
html[data-theme="nocturno"] .text-indigo-700,
html[data-theme="nocturno"] .text-indigo-600 { color: #a5b4fc !important; }
html[data-theme="nocturno"] .text-amber-800,
html[data-theme="nocturno"] .text-amber-700 { color: #fcd34d !important; }
html[data-theme="nocturno"] .text-purple-800,
html[data-theme="nocturno"] .text-purple-700,
html[data-theme="nocturno"] .text-purple-600 { color: #d8b4fe !important; }
html[data-theme="nocturno"] .text-red-700,
html[data-theme="nocturno"] .text-rose-700 { color: #fda4af !important; }

/* SweetAlert2 en Modo Oscuro */
html[data-theme="nocturno"] .swal2-popup {
    background: #142033 !important;
    color: #e2e8f0 !important;
    border: 1px solid #243652;
}
html[data-theme="nocturno"] .swal2-title,
html[data-theme="nocturno"] .swal2-html-container {
    color: #e2e8f0 !important;
}

/* Selector de Tema (Popover) */
.erp-theme-menu {
    background-color: var(--erp-surface);
    border: 1px solid var(--erp-border);
    box-shadow: 0 18px 40px -10px rgba(10, 25, 47, 0.25);
}

/* Impresión limpia siempre en fondo blanco */
@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    body.erp-body,
    main.erp-main {
        background: #ffffff !important;
        color: #000000 !important;
    }
}
