/* ============================================================
   TOKENS DE DISEÑO — Sistema de Asuntos Religiosos - Táchira
   Paleta tomada del logo (manos moradas, "ASUNTOS RELIGIOSOS" en
   rojo, franja de 7 colores). Proporción aprox. 60% neutro / 30%
   morado / 10% acentos de franja.
   ============================================================ */

:root {
    color-scheme: light;

    /* --- Colores de marca (del logo) --- */
    --brand-purple: #5c2a8c;
    --brand-purple-dark: #46206b;
    --brand-purple-light: #8a5fb8;
    --brand-red: #c0172d;
    --brand-red-dark: #960f22;

    /* Franja de 7 colores del logo, usada para gráficas y detalles de marca */
    --stripe-1: #5bcfd8;
    --stripe-2: #158398;
    --stripe-3: #48a762;
    --stripe-4: #a265a6;
    --stripe-5: #c38f26;
    --stripe-6: #c92b67;
    --stripe-7: #f16081;

    /* --- Roles semánticos (modo claro) --- */
    --color-primary: var(--brand-purple);
    --color-primary-dark: var(--brand-purple-dark);
    --color-primary-light: var(--brand-purple-light);
    --color-primary-contrast: #ffffff;

    --color-secondary: var(--brand-red);
    --color-secondary-dark: var(--brand-red-dark);

    --color-success: #2f8a4f;
    --color-info: #158398;
    --color-warning: #a8730f;
    --color-danger: #c0172d;

    /* --- Fondos y superficies (neumorfismo suave) --- */
    --bg-body: #eef0f5;
    --bg-surface: #eef0f5;
    --bg-card: #f4f6fa;
    --bg-elevated: #ffffff;
    --bg-input: #eef0f5;

    /* Sombras limpias sin brillo blanco */
    --shadow-raised: 0 1px 3px rgba(0, 0, 0, .06), 0 4px 12px rgba(92, 42, 140, .06);
    --shadow-pressed: inset 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-soft: 0 2px 10px rgba(45, 30, 70, .08);

    /* --- Texto --- */
    --text-main: #2b2740;
    --text-muted: #555168;
    --text-on-primary: #ffffff;
    --border-subtle: rgba(92, 42, 140, 0.16);
    --border-strong: rgba(92, 42, 140, 0.35);
    --focus-ring: 0 0 0 .25rem rgba(92, 42, 140, 0.28);

    /* --- Tipografía --- */
    --font-base: 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-size-base: 17px;

    /* --- Espaciado y formas --- */
    --radius-sm: .5rem;
    --radius-md: .9rem;
    --radius-lg: 1.3rem;
    --radius-pill: 999px;

    /* --- Colores de eventos del calendario --- */
    --evento-nacional: #5c2a8c;
    --evento-regional: #0d6efd;
    --evento-local: #198754;
    --evento-propio: #ffc107;
    --evento-texto: #ffffff;
    --evento-propio-texto: #212529;

    --sidebar-width: 272px;
    --sidebar-width-collapsed: 84px;
    --topbar-height: 68px;

    --transition-fast: .15s ease;
    --transition-base: .25s ease;
}

/* --- Modo oscuro --- */
[data-theme="dark"] {
    color-scheme: dark;

    --bg-body: #181622;
    --bg-surface: #1f1c2c;
    --bg-card: #221f32;
    --bg-elevated: #26223a;
    --bg-input: #1c1929;

    --shadow-raised: 0 1px 3px rgba(0, 0, 0, .15), 0 4px 12px rgba(0, 0, 0, .12);
    --shadow-pressed: inset 0 1px 3px rgba(0, 0, 0, .2);
    --shadow-soft: 0 2px 14px rgba(0, 0, 0, .45);

    --color-primary: #9b6fd1;
    --color-primary-dark: #7c4fb3;
    --color-primary-light: #c3a3e6;
    --color-primary-contrast: #15121f;

    --color-secondary: #e85a70;
    --color-success: #4cb876;
    --color-info: #4fb8cf;
    --color-warning: #d9a53c;
    --color-danger: #e85a70;

    --text-main: #eee9fb;
    --text-muted: #aba6c4;
    --border-subtle: rgba(199, 170, 230, 0.16);
    --border-strong: rgba(199, 170, 230, 0.35);
    --focus-ring: 0 0 0 .25rem rgba(155, 111, 209, 0.35);

    --evento-nacional: #7c4fb3;
    --evento-regional: #3f9df7;
    --evento-local: #34a06b;
    --evento-propio: #d9a53c;
    --evento-texto: #ffffff;
    --evento-propio-texto: #15121f;

    --shadow-soft: 0 2px 14px rgba(0, 0, 0, .45);
}

/* --- Alinear las variables de Bootstrap 5.3 con la paleta del logo ---
   Al sobrescribir estas variables, botones, badges, alertas, bg-*, text-*
   y border-* heredan el color automáticamente en todas las vistas. */
:root {
    --bs-primary: var(--color-primary);
    --bs-primary-rgb: 92, 42, 140;
    --bs-secondary: #635f78;
    --bs-secondary-rgb: 99, 95, 120;
    --bs-success: var(--color-success);
    --bs-success-rgb: 47, 138, 79;
    --bs-info: var(--color-info);
    --bs-info-rgb: 21, 131, 152;
    --bs-warning: var(--color-warning);
    --bs-warning-rgb: 168, 115, 15;
    --bs-danger: var(--color-danger);
    --bs-danger-rgb: 192, 23, 45;
    --bs-light: var(--bg-card);
    --bs-light-rgb: 244, 246, 250;
    --bs-dark: var(--text-main);
    --bs-dark-rgb: 43, 39, 64;
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-main);
    --bs-border-color: var(--border-subtle);
    --bs-link-color: var(--color-primary);
    --bs-link-hover-color: var(--color-primary-dark);
    --bs-link-color-rgb: 92, 42, 140;
    --bs-body-font-family: var(--font-base);
}

[data-theme="dark"] {
    --bs-primary-rgb: 155, 111, 209;
    --bs-secondary-rgb: 171, 166, 196;
    --bs-success-rgb: 76, 184, 118;
    --bs-info-rgb: 79, 184, 207;
    --bs-warning-rgb: 217, 165, 60;
    --bs-danger-rgb: 232, 90, 112;
    --bs-light-rgb: 38, 34, 58;
    --bs-dark-rgb: 238, 233, 251;
    --bs-link-color-rgb: 155, 111, 209;

    /* DataTables: fondo/texto que la librería usa para cabeceras y pies */
    --dt-html-background: #221f32;
    --dt-html-color: #eee9fb;

    /* Acordeones Bootstrap */
    --bs-accordion-bg: #221f32;
    --bs-accordion-color: #eee9fb;
    --bs-accordion-btn-bg: #26223a;
    --bs-accordion-btn-color: #eee9fb;
    --bs-accordion-border-color: rgba(199, 170, 230, 0.16);
    --bs-accordion-active-bg: #2c2444;
    --bs-accordion-active-color: #c3a3e6;
    --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23eee9fb' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23c3a3e6' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m2 5 6 6 6-6'/%3e%3c/svg%3e");

    /* Menús desplegables */
    --bs-dropdown-bg: #26223a;
    --bs-dropdown-color: #eee9fb;
    --bs-dropdown-link-color: #eee9fb;
    --bs-dropdown-link-hover-bg: rgba(155, 111, 209, 0.18);
    --bs-dropdown-link-hover-color: #eee9fb;
    --bs-dropdown-link-active-bg: #9b6fd1;
    --bs-dropdown-link-active-color: #15121f;
    --bs-dropdown-border-color: rgba(199, 170, 230, 0.16);
    --bs-dropdown-header-color: #aba6c4;

    /* Modales, listas y navs */
    --bs-modal-bg: #221f32;
    --bs-modal-color: #eee9fb;
    --bs-list-group-bg: #221f32;
    --bs-list-group-color: #eee9fb;
    --bs-list-group-border-color: rgba(199, 170, 230, 0.16);
    --bs-nav-tabs-border-color: rgba(199, 170, 230, 0.25);
    --bs-nav-tabs-link-active-bg: #221f32;
    --bs-nav-tabs-link-active-color: #eee9fb;

    /* Variantes sutiles (alertas, badges suaves, fondos bg-subtle) */
    --bs-primary-bg-subtle: #332550;
    --bs-primary-border-subtle: #4b3a72;
    --bs-primary-text-emphasis: #c3a3e6;
    --bs-secondary-bg-subtle: #26233a;
    --bs-secondary-border-subtle: rgba(199, 170, 230, 0.25);
    --bs-secondary-text-emphasis: #aba6c4;
    --bs-info-bg-subtle: #123240;
    --bs-info-border-subtle: #1e5a6d;
    --bs-info-text-emphasis: #7fd2e2;
    --bs-success-bg-subtle: #153a26;
    --bs-success-border-subtle: #1f5c39;
    --bs-success-text-emphasis: #7fd6a3;
    --bs-warning-bg-subtle: #3d3117;
    --bs-warning-border-subtle: #6b571f;
    --bs-warning-text-emphasis: #eec86a;
    --bs-danger-bg-subtle: #42181f;
    --bs-danger-border-subtle: #73232f;
    --bs-danger-text-emphasis: #f18ea0;
    --bs-light-bg-subtle: #26223a;
    --bs-light-border-subtle: rgba(199, 170, 230, 0.16);
    --bs-light-text-emphasis: #eee9fb;
    --bs-dark-bg-subtle: #15121f;
    --bs-dark-border-subtle: rgba(199, 170, 230, 0.25);
    --bs-dark-text-emphasis: #eee9fb;
}

/* Clases fijas de Bootstrap usadas en las vistas: se mapean al tema */
[data-theme="dark"] .bg-white {
    background-color: var(--bg-elevated) !important;
    color: var(--text-main);
}

[data-theme="dark"] .bg-light {
    background-color: var(--bg-card) !important;
    color: var(--text-main);
}

[data-theme="dark"] .text-dark {
    color: var(--text-main) !important;
}

/* bg-dark queda claro en modo oscuro (--bs-dark-rgb remapeado): su texto debe ser oscuro */
[data-theme="dark"] .bg-dark {
    color: #15121f !important;
}

/* Estos fondos quedan claros en modo oscuro: su texto debe ser oscuro */
[data-theme="dark"] .bg-secondary,
[data-theme="dark"] .bg-warning,
[data-theme="dark"] .bg-info {
    color: #15121f !important;
}

/* Los badges informativos usan la variante sutil: fondo oscuro + texto claro */
[data-theme="dark"] .badge.bg-secondary {
    background-color: var(--bs-secondary-bg-subtle) !important;
    color: var(--bs-secondary-text-emphasis) !important;
    border: 1px solid var(--bs-secondary-border-subtle);
}

[data-theme="dark"] .form-control-plaintext {
    color: var(--text-main);
}

/* Cabeceras/pies de DataTables (la librería usa --dt-html-background) */
[data-theme="dark"] table.dataTable thead th,
[data-theme="dark"] table.dataTable thead td,
[data-theme="dark"] table.dataTable tfoot th,
[data-theme="dark"] table.dataTable tfoot td {
    background-color: var(--bg-surface) !important;
    color: var(--text-main) !important;
    border-bottom-color: var(--border-subtle) !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_length select option {
    background: var(--bg-elevated);
    color: var(--text-main);
}

[data-theme="dark"] .dataTables_wrapper .page-item.disabled .page-link {
    background-color: var(--bg-card);
    color: var(--text-muted);
}

/* Botones sólidos: Bootstrap calcula hover/active a partir de --bs-*-rgb,
   pero el texto debe mantenerse blanco sobre estos colores de marca */
.btn-primary, .btn-success, .btn-info, .btn-warning, .btn-danger, .btn-secondary {
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
}

[data-theme="dark"] .btn-warning,
[data-theme="dark"] .btn-info {
    --bs-btn-color: #15121f;
    --bs-btn-hover-color: #15121f;
    --bs-btn-active-color: #15121f;
}

/* Reducir movimiento si el usuario lo pide */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
