/**
 * Dark Mode Override — Azul Profundo (brand sheet section 2.3)
 * --------------------------------------------------------------
 * Mapea las variables internas de Tabler a la paleta dark brand:
 * deep navy (--background = oklch(0.13 0.035 268)) en lugar de
 * grays neutrales (#1e1e1e / #252525 / #3a3a3a).
 *
 * Cargar ANTES de brand-overrides.css (brand-overrides gana en cascada).
 * El theming editorial (cards, buttons, inputs, etc.) vive en
 * brand-overrides.css; este archivo sólo mapea variables Tabler
 * para que componentes legacy que las consumen directamente queden
 * coherentes con el brand.
 */

[data-bs-theme='dark'] {
    /* Backgrounds — derivados de --background / --card del brand sheet */
    --tblr-bg-surface: oklch(0.18 0.035 268);
    --tblr-bg-surface-dark: oklch(0.13 0.035 268);
    --tblr-bg-surface-secondary: oklch(0.22 0.04 268);
    --tblr-bg-surface-tertiary: oklch(0.26 0.04 268);

    /* Body */
    --tblr-body-bg: oklch(0.13 0.035 268);
    --tblr-body-color: oklch(0.97 0.005 240);
    --tblr-emphasis-color: oklch(1 0 0);
    --tblr-secondary-color: oklch(0.78 0.012 235);
    --tblr-tertiary-color: oklch(0.65 0.015 235);

    /* Card */
    --tblr-card-bg: oklch(0.18 0.035 268);
    --tblr-card-cap-bg: oklch(0.18 0.035 268);

    /* Borders — hairlines mist sobre dark */
    --tblr-border-color: oklch(0.97 0.005 240 / 0.1);
    --tblr-border-color-translucent: oklch(0.97 0.005 240 / 0.1);
    --tblr-border-color-light: oklch(0.97 0.005 240 / 0.06);

    /* Muted */
    --tblr-muted: oklch(0.78 0.012 235);
    --tblr-muted-bg: oklch(0.16 0.04 270);

    /* Active / hover */
    --tblr-active-bg: oklch(0.22 0.04 268);
    --tblr-hover-bg: oklch(0.22 0.04 268);

    /* Form controls */
    --tblr-form-control-bg: oklch(0.18 0.035 268);
    --tblr-form-control-disabled-bg: oklch(0.16 0.04 270);

    /* Dropdown */
    --tblr-dropdown-bg: oklch(0.18 0.035 268);
    --tblr-dropdown-border-color: oklch(0.97 0.005 240 / 0.1);
    --tblr-dropdown-link-hover-bg: oklch(0.22 0.04 268);

    /* Modal */
    --tblr-modal-bg: oklch(0.18 0.035 268);
    --tblr-modal-border-color: oklch(0.97 0.005 240 / 0.1);

    /* Navbar / Sidebar */
    --tblr-navbar-bg: oklch(0.16 0.04 270);
    --tblr-navbar-border-color: oklch(0.97 0.005 240 / 0.1);
    --tblr-sidebar-bg: oklch(0.16 0.04 270);
    --tblr-sidebar-border-color: oklch(0.97 0.005 240 / 0.1);

    /* Table */
    --tblr-table-bg: transparent;
    --tblr-table-striped-bg: oklch(0.97 0.005 240 / 0.03);
    --tblr-table-hover-bg: oklch(0.97 0.005 240 / 0.05);
    --tblr-table-border-color: oklch(0.97 0.005 240 / 0.1);

    /* Code */
    --tblr-code-bg: oklch(0.22 0.04 268);
    --tblr-code-color: oklch(0.97 0.005 240);
}

body[data-bs-theme='dark'] {
    background-color: oklch(0.13 0.035 268);
    color: oklch(0.97 0.005 240);
}

/* Legacy classes que pintan border directo — coherente con grid-line dark */
[data-bs-theme='dark'] .border,
[data-bs-theme='dark'] .border-top,
[data-bs-theme='dark'] .border-end,
[data-bs-theme='dark'] .border-right,
[data-bs-theme='dark'] .border-bottom,
[data-bs-theme='dark'] .border-start,
[data-bs-theme='dark'] .border-left {
    border-color: oklch(0.97 0.005 240 / 0.1) !important;
}

[data-bs-theme='dark'] .border-light {
    border-color: oklch(0.97 0.005 240 / 0.06) !important;
}

[data-bs-theme='dark'] .border-dark {
    border-color: oklch(0.16 0.04 270) !important;
}

/* Form-selectgroup (theme picker etc.) */
[data-bs-theme='dark'] .form-selectgroup-check,
[data-bs-theme='dark'] .form-selectgroup-label {
    background-color: oklch(0.18 0.035 268);
    border-color: oklch(0.97 0.005 240 / 0.1);
    color: oklch(0.97 0.005 240);
}

[data-bs-theme='dark'] .form-selectgroup-label:hover {
    background-color: oklch(0.22 0.04 268);
    color: oklch(1 0 0);
}

[data-bs-theme='dark'] .form-selectgroup-input:checked + .form-selectgroup-label {
    color: oklch(0.97 0.005 240);
    border-color: var(--color-brand-green, oklch(0.73 0.18 148));
    background-color: oklch(0.22 0.04 268);
}

[data-bs-theme='dark'] .form-selectgroup-input:checked + .form-selectgroup-label .form-selectgroup-check {
    background-color: var(--color-brand-green, oklch(0.73 0.18 148));
    border-color: var(--color-brand-green, oklch(0.73 0.18 148));
}

/* Skeleton */
[data-bs-theme='dark'] .placeholder,
[data-bs-theme='dark'] .placeholder:not(.btn):not([class*='bg-']) {
    background-color: oklch(0.97 0.005 240 / 0.07) !important;
    color: oklch(0.97 0.005 240 / 0.07) !important;
}

[data-bs-theme='dark'] .pending {
    color: oklch(0.97 0.005 240 / 0.06) !important;
    background-color: oklch(0.97 0.005 240 / 0.06) !important;
    border-color: oklch(0.97 0.005 240 / 0.06) !important;
}

[data-bs-theme='dark'] .pending_el {
    color: oklch(0.97 0.005 240 / 0.05) !important;
    background-color: oklch(0.97 0.005 240 / 0.05) !important;
}

/* Flatpickr — restos legacy que no podían leer var() de brand-overrides */
[data-bs-theme='dark'] .flatpickr-current-month .numInputWrapper span:hover {
    background-color: oklch(0.97 0.005 240 / 0.08);
}

[data-bs-theme='dark'] .flatpickr-current-month .numInputWrapper span svg path {
    fill: oklch(0.97 0.005 240);
}

/* Tabs legacy */
[data-bs-theme='dark'] .nav-tabs .nav-link:hover {
    border-color: transparent transparent oklch(0.97 0.005 240 / 0.15);
}

/* DataTables dark mode */
[data-bs-theme='dark'] .dataTables_wrapper {
    color: oklch(0.97 0.005 240);
}

[data-bs-theme='dark'] .dataTables_filter input,
[data-bs-theme='dark'] .dataTables_length select {
    background-color: oklch(0.18 0.035 268);
    border-color: oklch(0.97 0.005 240 / 0.1);
    color: oklch(0.97 0.005 240);
}

[data-bs-theme='dark'] .dataTables_info {
    color: oklch(0.78 0.012 235);
}

/* bg-*-lt fix */
[data-bs-theme='dark'] .bg-github-lt {
    color: oklch(0.97 0.005 240) !important;
    background-color: oklch(0.97 0.005 240 / 0.06) !important;
}
