/* Tema oscuro con la paleta Catppuccin Mocha (https://catppuccin.com/palette, licencia MIT).
   Se activa con data-theme="dark" en <html> (ver tmsTema en index.html).
   Los colores de cada pantalla están en tema-colores.css; aquí van las variables base y los ajustes globales.

   Mocha: crust #11111b · mantle #181825 · base #1e1e2e · surface0 #313244 · surface1 #45475a
          surface2 #585b70 · overlay0 #6c7086 · overlay1 #7f849c · subtext0 #a6adc8 · subtext1 #bac2de
          text #cdd6f4 · mauve #cba6f7 · lavender #b4befe · blue #89b4fa · green #a6e3a1
          yellow #f9e2af · peach #fab387 · red #f38ba8 */

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

    --tms-bg: #181825;
    --tms-rail-bg: #11111b;
    --tms-panel-bg: #181825;
    --tms-surface: #1e1e2e;
    --tms-primary: #cba6f7;
    --tms-primary-glow: rgba(203, 166, 247, 0.28);
    --tms-accent: #cba6f7;
    --tms-accent-muted: rgba(203, 166, 247, 0.14);
    --tms-panel-border: #313244;
    --tms-text: #cdd6f4;
    --tms-text-muted: #a6adc8;
    --tms-text-dim: #7f849c;
    --tms-on-primary: #11111b;
    --tms-tint-rgb: 180, 190, 254;
    --tms-surface-rgb: 30, 30, 46;
    --tms-shadow-rgb: 0, 0, 0;

    --fx-bg: #181825;
    --fx-card: #1e1e2e;
    --fx-border: #313244;
    --fx-border-soft: #2a2b3c;
    --fx-field-border: #45475a;
    --fx-primary: #cba6f7;
    --fx-primary-hover: #b4befe;
    --fx-primary-soft: #2e2a42;
    --fx-primary-tint: #27253a;
    --fx-primary-line: #45475a;
    --fx-text: #cdd6f4;
    --fx-text-2: #bac2de;
    --fx-muted: #a6adc8;
    --fx-dim: #7f849c;
    --fx-head-bg: #181825;
    --fx-ok-bg: #233329;
    --fx-ok: #a6e3a1;
    --fx-cx-bg: #3a2433;
    --fx-cx: #f38ba8;
    --fx-cp-bg: #2b2d48;
    --fx-cp: #b4befe;
    --fx-lb-bg: #313244;
    --fx-lb: #bac2de;
    --fx-warn-bg: #3a3328;
    --fx-warn-line: #5c5240;
    --fx-warn: #f9e2af;
    --fx-focus: 0 0 0 3px rgba(203, 166, 247, 0.35);
}

:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #45475a;
}

/* Bordes: los translúcidos del azul primario casi no se ven sobre fondo oscuro; las superficies
   principales usan surface0. */
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .catalog-grid-wrap,
:root[data-theme="dark"] .user-menu-popover,
:root[data-theme="dark"] .user-chip,
:root[data-theme="dark"] .edocs-list-wrap,
:root[data-theme="dark"] .perfil-ident,
:root[data-theme="dark"] .app-header {
    border-color: #313244;
}

/* Sobre el primario (malva) el texto va oscuro: el blanco no se lee. */
:root[data-theme="dark"] .catalog-btn-new,
:root[data-theme="dark"] .date-range-btn-apply,
:root[data-theme="dark"] .user-avatar,
:root[data-theme="dark"] .user-menu-avatar-lg,
:root[data-theme="dark"] .perfil-avatar,
:root[data-theme="dark"] .purchase-state-tab.is-active > span,
:root[data-theme="dark"] .purchase-detail-tab.is-active > span,
:root[data-theme="dark"] .classification-tab.is-active > span,
:root[data-theme="dark"] .receipt-detail-tab.is-active > span,
:root[data-theme="dark"] .provider-tab.is-active .provider-tab-number,
:root[data-theme="dark"] .app-file-picker-button,
:root[data-theme="dark"] .purchase-order-action:hover,
:root[data-theme="dark"] .purchase-order-action.is-selected,
:root[data-theme="dark"] .btn-save,
:root[data-theme="dark"] .product-kit-action span,
:root[data-theme="dark"] .btn-selector-pick:hover,
:root[data-theme="dark"] .bitacora-avatar-initials,
:root[data-theme="dark"] .app-lookup-button:hover:not(:disabled),
:root[data-theme="dark"] .fx-tab.is-active .fx-count,
:root[data-theme="dark"] .fx-switch button.is-active,
:root[data-theme="dark"] .fx-btn-primary,
:root[data-theme="dark"] .fx-kpi.is-primary,
:root[data-theme="dark"] .fx-grid .e-pager .e-currentitem,
:root[data-theme="dark"] .fx-table tr.fx-fin-grand td,
:root[data-theme="dark"] .incidencia-dia.is-active,
:root[data-theme="dark"] a.mistil-opcion:hover .mistil-opcion-icono,
:root[data-theme="dark"] .reloj-btn.is-primary {
    color: var(--tms-on-primary);
}

/* El logotipo de Apolo es azul marino sobre transparente: en oscuro va sobre una placa clara
   (pantalla de carga e inicio de sesión) para que se lea. */
:root[data-theme="dark"] .tms-splash-brand,
:root[data-theme="dark"] .login-brand-logo {
    background: #cdd6f4;
    border-radius: 16px;
    padding: 14px 20px;
    box-sizing: border-box;
}

/* Avatares con degradado azul: en Mocha, de malva a lavanda. */
:root[data-theme="dark"] .user-avatar,
:root[data-theme="dark"] .user-menu-avatar-lg,
:root[data-theme="dark"] .perfil-avatar {
    background: linear-gradient(135deg, #cba6f7, #b4befe);
}

/* Variables del tema fluent2-dark de Syncfusion llevadas a Mocha. Todos sus controles (calendario,
   listas, menús, grids, pestañas, botones) toman de aquí sus colores. :root[data-theme] gana sobre :root. */
:root[data-theme="dark"] {
    --color-sf-content-bg-color: #1e1e2e;
    --color-sf-content-bg-color-alt1: #282839;
    --color-sf-content-bg-color-alt2: #181825;
    --color-sf-content-bg-color-alt3: #313244;
    --color-sf-content-bg-color-alt4: #11111b;
    --color-sf-content-bg-color-alt5: #11111b;
    --color-sf-content-bg-color-alt6: #11111b;
    --color-sf-content-bg-color-selected: #313244;
    --color-sf-content-bg-color-dragged: #2e2a42;
    --color-sf-content-bg-color-disabled: #181825;
    --color-sf-flyout-bg-color-hover: #313244;
    --color-sf-flyout-bg-color-selected: #45475a;
    --color-sf-table-bg-color-hover: #2a2b3c;
    --color-sf-table-bg-color-pressed: #313244;
    --color-sf-table-bg-color-selected: #2e2a42;
    --color-sf-content-text-color: #cdd6f4;
    --color-sf-content-text-color-alt1: #bac2de;
    --color-sf-content-text-color-alt2: #a6adc8;
    --color-sf-content-text-color-alt3: #9399b2;
    --color-sf-content-text-color-disabled: #6c7086;
    --color-sf-icon-color: #bac2de;
    --color-sf-border-light: #313244;
    --color-sf-border: #45475a;
    --color-sf-border-alt: #7f849c;
    --color-sf-border-dark: #585b70;
    --color-sf-border-hover: #585b70;
    --color-sf-border-pressed: #45475a;
    --color-sf-border-selected: #6c7086;
    --color-sf-border-disabled: #313244;
    --color-sf-border-warning: #fab387;
    --color-sf-border-error: #f38ba8;
    --color-sf-border-success: #a6e3a1;
    --color-sf-border-info: #89dceb;
    --color-sf-flyout-border: #45475a;
    --color-sf-primary: #cba6f7;
    --color-sf-primary-text-color: #11111b;
    --color-sf-primary-light: #3b3354;
    --color-sf-primary-lighter: #2e2a42;
    --color-sf-primary-dark: #cba6f7;
    --color-sf-primary-darker: #b4befe;
    --color-sf-primary-label-color: #cba6f7;
    --color-sf-primary-bg-color-hover: #b4befe;
    --color-sf-primary-bg-color-pressed: #a98bd6;
    --color-sf-primary-bg-color-disabled: #181825;
    --color-sf-primary-bg-color-selected: #b79bea;
    --color-sf-secondary-bg-color: #313244;
    --color-sf-secondary-bg-color-hover: #45475a;
    --color-sf-secondary-bg-color-focus: #45475a;
    --color-sf-secondary-bg-color-selected: #45475a;
    --color-sf-secondary-border-color-hover: #585b70;
    --color-sf-secondary-border-color-pressed: #6c7086;
    --color-sf-secondary-border-color-focus: #cba6f7;
    --color-sf-secondary-border-color-selected: #6c7086;
    --color-sf-success: #a6e3a1;
    --color-sf-info: #89dceb;
    --color-sf-warning: #fab387;
    --color-sf-danger: #f38ba8;
    --color-sf-success-light: #233329;
    --color-sf-info-light: #1e3340;
    --color-sf-warning-light: #3a2e28;
    --color-sf-danger-light: #3a2433;
    --color-sf-success-light-alt: #1d2a23;
    --color-sf-info-light-alt: #1a2b35;
    --color-sf-warning-light-alt: #33281f;
    --color-sf-danger-light-alt: #33202c;
    --color-sf-danger-bg-color: #f38ba8;
    --color-sf-success-bg-color: #a6e3a1;
    --color-sf-warning-bg-color: #fab387;
    --color-sf-info-bg-color: #89dceb;
    --color-sf-link-button-hover: #b4befe;
    --color-sf-link-button-pressed: #cba6f7;
    --color-sf-link-button-focus: #cba6f7;
    --color-sf-chip-bg-color: #313244;
    --color-sf-chip-border-color: #313244;
    --color-sf-calendar-icon-color: #cba6f7;
    --color-sf-calendar-header-text-color-pressed: #cba6f7;
    --color-sf-calendar-today-bg-color: #cba6f7;
    --color-sf-dialog-border: #313244;
    --color-sf-badge-light-bg-color: #313244;
    --color-sf-secondary-badge-border-color: #313244;
    --color-sf-secondary-badge-bg-color: #313244;
    --color-sf-skeleton-bg-color: #45475a;
    --color-sf-tab-selected-bg-color-disabled: #cba6f7;
    --color-sf-toolbar-icon-color: #cba6f7;
    --color-sf-cell-selection-bg-color: #2e2a42;
    --color-sf-holiday-bg-color: #181825;
    --color-sf-sort-bg-color: #313244;
}

/* Diálogos de Syncfusion (el tema fluent2-dark ya los pinta; se alinean a Mocha). */
:root[data-theme="dark"] .e-dialog,
:root[data-theme="dark"] .e-dialog .e-dlg-content,
:root[data-theme="dark"] .e-dialog .e-footer-content {
    background: #1e1e2e;
    color: #cdd6f4;
}

:root[data-theme="dark"] .e-dialog .e-dlg-header-content {
    background: #181825;
    border-bottom-color: #313244;
}

:root[data-theme="dark"] .e-dialog .e-dlg-header {
    color: #cdd6f4;
}

/* Velo detrás de los modales: translúcido (crust al 55 %) para que se siga viendo la pantalla. */
:root[data-theme="dark"] .e-dlg-overlay {
    background-color: rgba(17, 17, 27, 0.55);
}

/* Grids de Syncfusion */
:root[data-theme="dark"] .e-grid,
:root[data-theme="dark"] .e-grid .e-gridcontent,
:root[data-theme="dark"] .e-grid .e-content,
:root[data-theme="dark"] .e-grid .e-table,
:root[data-theme="dark"] .e-grid .e-gridpager,
:root[data-theme="dark"] .e-pager {
    background: #1e1e2e;
}

:root[data-theme="dark"] .e-grid .e-gridheader,
:root[data-theme="dark"] .e-grid .e-headercell,
:root[data-theme="dark"] .e-grid .e-headercontent {
    background: #181825;
    color: #bac2de;
}

:root[data-theme="dark"] .e-grid .e-altrow {
    background: #222234;
}

:root[data-theme="dark"] .e-grid .e-rowcell {
    border-color: #313244;
}

:root[data-theme="dark"] .e-grid tr.e-row:hover .e-rowcell:not(.e-cellselectionbackground) {
    background: #2a2b3c !important;
}

/* Campos de Syncfusion y nativos */
:root[data-theme="dark"] .e-input-group,
:root[data-theme="dark"] .e-input-group.e-control-wrapper,
:root[data-theme="dark"] .e-float-input,
:root[data-theme="dark"] .e-ddl.e-popup,
:root[data-theme="dark"] .e-popup.e-multi-select-list-wrapper {
    background: #181825;
    border-color: #45475a;
}

:root[data-theme="dark"] .e-dropdownbase .e-list-item.e-active,
:root[data-theme="dark"] .e-dropdownbase .e-list-item.e-item-focus {
    background: #313244;
    color: #cba6f7;
}

:root[data-theme="dark"] a:not(.e-link):not(.e-numericitem):not(.e-currentitem),
:root[data-theme="dark"] .btn-link {
    color: #89b4fa;
}

/* Paginador de los grids: botones sin caja propia, número actual en malva con texto oscuro. */
:root[data-theme="dark"] .e-pager .e-numericitem,
:root[data-theme="dark"] .e-pager div.e-icons.e-pager-default,
:root[data-theme="dark"] .e-pager .e-prevpagedisabled,
:root[data-theme="dark"] .e-pager .e-nextpagedisabled,
:root[data-theme="dark"] .e-pager .e-firstpagedisabled,
:root[data-theme="dark"] .e-pager .e-lastpagedisabled {
    background: transparent;
    color: #bac2de;
}

:root[data-theme="dark"] .e-pager div.e-icons.e-disable {
    color: #585b70;
}

:root[data-theme="dark"] .e-pager .e-numericitem:hover,
:root[data-theme="dark"] .e-pager div.e-icons.e-pager-default:not(.e-disable):hover {
    background: #313244;
    color: #cdd6f4;
}

/* !important: el tema de Syncfusion y .fx-grid pintan el número con reglas más específicas o posteriores. */
:root[data-theme="dark"] .e-pager .e-currentitem,
:root[data-theme="dark"] .e-pager .e-currentitem:hover,
:root[data-theme="dark"] .e-pager .e-currentitem.e-numericitem.e-focused,
:root[data-theme="dark"] .fx-grid .e-pager .e-currentitem,
:root[data-theme="dark"] .fx-grid .e-pager .e-currentitem:hover {
    background: #cba6f7 !important;
    color: #11111b !important;
    -webkit-text-fill-color: #11111b;
    font-weight: 700;
    opacity: 1 !important;
}

:root[data-theme="dark"] .e-pager .e-pagesizes,
:root[data-theme="dark"] .e-pager .e-parentmsgbar {
    color: #a6adc8;
}
