/* Restablece la paleta del sistema después de cargar los estilos de Bootstrap. */
:root {
    --bg-subtle: #f8fafc;
}

body,
.main-wrapper,
.content {
    color: var(--text-main);
    background-color: var(--bg-body);
}

.navbar {
    background-color: var(--bg-navbar);
    border-color: var(--border);
}

.card {
    color: var(--text-main);
    background-color: var(--bg-card);
    border-color: var(--border);
}

.bg-light {
    background-color: var(--bg-subtle) !important;
}

/* Organiza las opciones visuales del módulo de Configuración. */
.theme-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    max-width: 980px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px;
    color: var(--text-main);
    text-align: left;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.theme-option:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.theme-option.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(242, 180, 65, 0.22);
}

.theme-preview {
    display: flex;
    width: 100%;
    min-height: 190px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.theme-preview-light {
    background: #f8fafc;
}

.theme-preview-dark {
    background: #0f172a;
}

.theme-preview-sidebar {
    width: 28%;
    background: #1e293b;
}

.theme-preview-dark .theme-preview-sidebar {
    background: #080f1d;
}

.theme-preview-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    padding: 42px 16px 16px;
    position: relative;
}

.theme-preview-navbar {
    position: absolute;
    inset: 0 0 auto;
    height: 28px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

.theme-preview-dark .theme-preview-navbar {
    background: #111827;
    border-color: #334155;
}

.theme-preview-card {
    display: block;
    width: 100%;
    height: 58px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.08);
}

.theme-preview-card-small {
    width: 72%;
    height: 38px;
}

.theme-preview-dark .theme-preview-card {
    background: #172033;
    border-color: #334155;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.theme-option-copy {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.theme-option-title {
    font-size: 18px;
    font-weight: 700;
}

.theme-option-title i {
    width: 24px;
    color: var(--primary);
}

.theme-option-description {
    min-height: 42px;
    color: var(--text-muted);
    font-size: 14px;
}

.theme-option-status {
    align-self: flex-start;
    padding: 5px 10px;
    color: var(--text-muted);
    background: var(--bg-body);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.theme-option.active .theme-option-status {
    color: #713f12;
    background: #fef3c7;
}

.theme-save-note {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 980px;
    margin-top: 24px;
    padding: 14px 16px;
    color: var(--text-muted);
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.theme-save-note i {
    color: var(--success);
}

/* Redefine las variables generales cuando se selecciona el modo oscuro. */
html[data-theme="dark"] {
    --primary-light: rgba(242, 180, 65, 0.18);
    --bg-body: #0f172a;
    --bg-sidebar: #080f1d;
    --bg-card: #172033;
    --bg-navbar: #111827;
    --text-main: #f1f5f9;
    --text-muted: #cbd5e1;
    --text-light: #a8b4c7;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
    --bg-spacer: #172033;
    --bg-subtle: #172033;
}

/* Adapta los componentes generales y de Bootstrap al modo oscuro. */
html[data-theme="dark"] body,
html[data-theme="dark"] .main-wrapper,
html[data-theme="dark"] .content {
    background-color: var(--bg-body);
    color: var(--text-main);
}

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

html[data-theme="dark"] .bg-secondary.bg-opacity-10 {
    background-color: #1e293b !important;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] label,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .text,
html[data-theme="dark"] .text-gray-800 {
    color: var(--text-main) !important;
}

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

html[data-theme="dark"] hr,
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom {
    border-color: var(--border) !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .estatus-select {
    color: var(--text-main);
    background-color: #0f172a;
    border-color: var(--border);
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] .form-group input:focus,
html[data-theme="dark"] .form-group select:focus {
    color: var(--text-main);
    background-color: #111827;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(242, 180, 65, 0.2);
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .form-group input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #94a3b8;
    opacity: 1;
}

html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="month"] {
    color-scheme: dark;
}

html[data-theme="dark"] .table {
    --bs-table-color: var(--text-main);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border);
    --bs-table-striped-color: var(--text-main);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.035);
    --bs-table-hover-color: var(--text-main);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

html[data-theme="dark"] thead,
html[data-theme="dark"] .table-light {
    --bs-table-bg: #111827;
    --bs-table-color: var(--text-muted);
    color: var(--text-muted);
    background-color: #111827 !important;
}

html[data-theme="dark"] th,
html[data-theme="dark"] td {
    color: inherit;
    border-color: var(--border);
}

html[data-theme="dark"] tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-outline-secondary {
    color: var(--text-main);
    background-color: #334155;
    border-color: #475569;
}

html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-outline-secondary:hover {
    color: #ffffff;
    background-color: #475569;
}

html[data-theme="dark"] .alert-error {
    color: #fecaca;
    background: #451a1a;
    border-color: #7f1d1d;
}

html[data-theme="dark"] .alert-success {
    color: #a7f3d0;
    background: #064e3b;
    border-color: #047857;
}

html[data-theme="dark"] .alert-warning {
    color: #fde68a;
    background: #451a03;
    border-color: #92400e;
}

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

@media (max-width: 768px) {
    .theme-options {
        grid-template-columns: 1fr;
    }

    .theme-preview {
        min-height: 155px;
    }
}
