/* Modo claro / oscuro — tokens en sj-brand.css; aquí reglas de superficie */
:root,
[data-bs-theme="light"] {
    color-scheme: light;
}

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

body {
    background: var(--sj-page-bg) !important;
    color: var(--sj-page-text);
    transition: background-color 0.25s ease, color 0.25s ease;
}

#app-page main {
    color: var(--sj-page-text);
}

/* Botón cambio de tema */
.sj-theme-toggle {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 2.25rem;
    line-height: 1;
    transition: color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.navbar .sj-theme-toggle {
    color: var(--sj-brand-white) !important;
    padding: 0.35rem 0.65rem !important;
    border-radius: 0.45rem;
}

.navbar .sj-theme-toggle:hover,
.navbar .sj-theme-toggle:focus {
    color: var(--sj-blue-glow) !important;
    background: rgba(255, 255, 255, 0.12) !important;
    transform: scale(1.05);
}

[data-bs-theme="light"] .sj-theme-icon-light,
[data-bs-theme="dark"] .sj-theme-icon-dark {
    display: none !important;
}

[data-bs-theme="dark"] .sj-theme-icon-light {
    display: inline-block !important;
}

.login-theme-toggle-wrap {
    position: fixed;
    top: 0.85rem;
    right: 0.85rem;
    z-index: 1080;
}

.login-theme-toggle {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    box-shadow: 0 0.2rem 0.65rem rgba(0, 0, 0, 0.12);
}

[data-bs-theme="dark"] .login-theme-toggle {
    border-color: var(--sj-border-solid) !important;
    color: var(--sj-brand-white) !important;
    background: var(--sj-surface-elevated) !important;
}

/* Superficies del panel */
[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .rounded-legacy.bg-white,
[data-bs-theme="dark"] .sj-panel-table-wrap {
    background-color: var(--sj-surface) !important;
}

[data-bs-theme="dark"] .panel-consultor-home,
[data-bs-theme="dark"] .panel-cliente-home,
[data-bs-theme="dark"] .panel-proveedor-home,
[data-bs-theme="dark"] .prov-solic-legado-scope,
[data-bs-theme="dark"] .import-masiva-page,
[data-bs-theme="dark"] .panel-solicitud-create,
[data-bs-theme="dark"] .panel-cliente-solicitudes-lista {
    background: var(--sj-page-bg) !important;
}

[data-bs-theme="dark"] .card-section,
[data-bs-theme="dark"] .stat-tile,
[data-bs-theme="dark"] .dash-widget,
[data-bs-theme="dark"] .cartel-card,
[data-bs-theme="dark"] .pv-card-proveedor,
[data-bs-theme="dark"] .pv-consejos,
[data-bs-theme="dark"] .dashboard-filters {
    background: var(--sj-surface) !important;
    border-color: var(--sj-border-solid) !important;
    color: var(--sj-page-text);
}

[data-bs-theme="dark"] .panel-consultor-home .dashboard-filters {
    background: var(--sj-surface-muted) !important;
}

[data-bs-theme="dark"] .stat-tile-label,
[data-bs-theme="dark"] .widget-title,
[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] .panel-solicitud-create .form-label {
    color: var(--sj-page-text) !important;
}

[data-bs-theme="dark"] .stat-tile-label,
[data-bs-theme="dark"] .sj-panel-footer,
[data-bs-theme="dark"] .panel-cli-solic-resumen,
[data-bs-theme="dark"] .sj-panel-footer__resumen {
    color: var(--sj-brand-gray) !important;
}

[data-bs-theme="dark"] .dashboard-filters .form-label {
    color: var(--sj-brand-gray) !important;
}

[data-bs-theme="dark"] .sj-panel-hero .form-label,
[data-bs-theme="dark"] .sj-panel-toolbar label,
[data-bs-theme="dark"] .sj-panel-toolbar .sj-panel-toolbar__page-size {
    color: var(--sj-brand-gray) !important;
}

[data-bs-theme="dark"] .sj-panel-hero .row .form-label {
    color: var(--sj-brand-gray) !important;
}

[data-bs-theme="dark"] .sj-panel-hero .form-control,
[data-bs-theme="dark"] .sj-panel-hero .form-select {
    background: var(--sj-surface-muted) !important;
    border-color: var(--sj-border-solid) !important;
    color: var(--sj-brand-white) !important;
}

[data-bs-theme="dark"] .sj-panel-hero .form-control:focus,
[data-bs-theme="dark"] .sj-panel-hero .form-select:focus {
    background: var(--sj-surface-elevated) !important;
    border-color: var(--sj-blue-light) !important;
    color: var(--sj-brand-white) !important;
    box-shadow: 0 0 0 0.15rem var(--sj-focus-ring) !important;
}

[data-bs-theme="dark"] .sj-panel-hero .form-select option {
    background: var(--sj-surface-elevated);
    color: var(--sj-brand-white);
}

[data-bs-theme="dark"] .table-legacy.sj-panel-table thead th {
    background: linear-gradient(180deg, var(--sj-brand-royal) 0%, var(--sj-navy) 100%) !important;
    color: var(--sj-brand-white) !important;
    border-color: var(--sj-border) !important;
}

[data-bs-theme="dark"] .table-secondary > td {
    background-color: var(--sj-surface-muted) !important;
    color: var(--sj-brand-gray) !important;
}

[data-bs-theme="dark"] .text-dark,
[data-bs-theme="dark"] .text-body {
    color: var(--sj-page-text) !important;
}

/* Tablas */
[data-bs-theme="dark"] .table-legacy tbody td,
[data-bs-theme="dark"] .table-legacy tbody th {
    background-color: var(--sj-table-body-bg);
    color: var(--sj-page-text);
    border-color: var(--sj-border-solid) !important;
}

[data-bs-theme="dark"] .table-legacy:not(.sj-panel-table) thead th {
    background: linear-gradient(180deg, var(--sj-brand-royal) 0%, var(--sj-navy) 100%) !important;
    color: var(--sj-brand-white) !important;
    border-color: var(--sj-border-solid) !important;
}

[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: var(--sj-table-striped);
    color: var(--sj-page-text);
}

[data-bs-theme="dark"] #app-page .card.border-0.shadow-sm,
[data-bs-theme="dark"] #app-page .table-responsive.rounded-legacy {
    border-color: var(--sj-border-solid) !important;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.35) !important;
}

[data-bs-theme="dark"] .panel-cli-solic-footer {
    background: var(--sj-surface-muted) !important;
    border-color: var(--sj-border) !important;
}

[data-bs-theme="dark"] .panel-cli-solic-pagination {
    background: linear-gradient(180deg, var(--sj-surface) 0%, var(--sj-surface-muted) 100%) !important;
}

[data-bs-theme="dark"] .panel-cli-solic-pagination .btn {
    color: var(--sj-brand-gray) !important;
    border-color: var(--sj-border-solid) !important;
    background: var(--sj-surface-elevated) !important;
}

[data-bs-theme="dark"] .panel-cli-solic-pagination .btn.btn-primary,
[data-bs-theme="dark"] .panel-cli-solic-pagination .btn.panel-cli-solic-pagina-actual {
    color: var(--sj-brand-white) !important;
    background: var(--sj-brand-royal) !important;
    border-color: var(--sj-brand-royal) !important;
}

/* Login */
[data-bs-theme="dark"] .login-form-pane,
[data-bs-theme="dark"] .login-card {
    background: var(--sj-surface) !important;
    border-color: var(--sj-border-solid) !important;
}

[data-bs-theme="dark"] .login-card .form-label,
[data-bs-theme="dark"] .login-tagline,
[data-bs-theme="dark"] .titulo-principal {
    color: var(--sj-page-text) !important;
}

[data-bs-theme="dark"] .login-brand-tagline {
    color: var(--sj-brand-gray) !important;
}

[data-bs-theme="dark"] .sj-conf-panel {
    background: var(--sj-surface) !important;
    border-color: var(--sj-border-solid) !important;
}

[data-bs-theme="dark"] .sj-conf-action-card,
[data-bs-theme="dark"] .sj-conf-social-box {
    background: var(--sj-surface-muted) !important;
    border-color: var(--sj-border-solid) !important;
}

[data-bs-theme="dark"] .sj-conf-action-title,
[data-bs-theme="dark"] .sj-conf-action-text,
[data-bs-theme="dark"] .sj-conf-social-label {
    color: var(--sj-page-text) !important;
}

[data-bs-theme="dark"] .sj-conf-action-text {
    color: var(--sj-brand-gray) !important;
}

/* Footer app */
[data-bs-theme="dark"] footer.border-top {
    background: var(--sj-footer-bg) !important;
    border-color: var(--sj-border-solid) !important;
    color: var(--sj-brand-gray) !important;
}

/* Perfil consultor */
[data-bs-theme="dark"] .perfil-consultor-page {
    background: linear-gradient(180deg, var(--sj-page-bg) 0%, var(--sj-surface) 50%, var(--sj-page-bg) 100%) !important;
}

[data-bs-theme="dark"] .perfil-consultor-card {
    background: linear-gradient(180deg, var(--sj-surface-muted) 0%, var(--sj-surface-elevated) 55%, var(--sj-surface) 100%) !important;
    border-color: var(--sj-border-solid) !important;
}

/* Navbar dropdown modo oscuro */
[data-bs-theme="dark"] .navbar .dropdown-menu {
    background: var(--sj-surface-elevated);
    border-color: var(--sj-border-solid);
}
[data-bs-theme="dark"] .navbar .dropdown-item {
    color: var(--sj-brand-white);
}
[data-bs-theme="dark"] .navbar .dropdown-item:hover {
    background: rgba(0, 80, 179, 0.25);
    color: var(--sj-brand-white);
}

@media (prefers-reduced-motion: reduce) {
    body,
    .sj-theme-toggle {
        transition: none;
    }
}
