/**
 * CAMPUS INTELIGENTE v3.1 — SISTEMA DE TEMAS VISUALES
 * Modos:
 *  - light  (Modo Claro)
 *  - medium (Modo Medio / Gris Neutro)
 *  - dark   (Modo Oscuro)
 */

:root,
html[data-campus-theme="light"] {
    --ci-bg: #f4f7fa;
    --ci-surface: #ffffff;
    --ci-surface-alt: #f8fafc;
    --ci-border: #e2e8f0;
    --ci-text: #0f172a;
    --ci-text-muted: #64748b;
    --ci-sidebar-bg: #0f172a;
    --ci-sidebar-border: rgba(255, 255, 255, 0.08);
    --ci-input-bg: #ffffff;
    --ci-input-border: #cbd5e1;
    --ci-table-head: #f1f5f9;
    --ci-table-hover: #f8fafc;
    --ci-shadow: 0 4px 15px rgba(15, 23, 42, 0.05);
}

/* ==================== MODO MEDIO (GRIS NEUTRO) ==================== */
html[data-campus-theme="medium"] {
    --ci-bg: #cfd6e0;
    --ci-surface: #e4e9f0;
    --ci-surface-alt: #d8dfe9;
    --ci-border: #b6c2d1;
    --ci-text: #182230;
    --ci-text-muted: #475569;
    --ci-sidebar-bg: #2b3545;
    --ci-sidebar-border: rgba(255, 255, 255, 0.12);
    --ci-input-bg: #eef2f7;
    --ci-input-border: #aebac9;
    --ci-table-head: #d4dce7;
    --ci-table-hover: #dce3ed;
    --ci-shadow: 0 4px 14px rgba(15, 23, 42, 0.09);
}

/* ==================== MODO OSCURO ==================== */
html[data-campus-theme="dark"] {
    --ci-bg: #0b1120;
    --ci-surface: #131c2e;
    --ci-surface-alt: #1b263b;
    --ci-border: #28354a;
    --ci-text: #e2e8f0;
    --ci-text-muted: #94a3b8;
    --ci-sidebar-bg: #070c17;
    --ci-sidebar-border: rgba(148, 163, 184, 0.12);
    --ci-input-bg: #0f172a;
    --ci-input-border: #334155;
    --ci-table-head: #1b263b;
    --ci-table-hover: rgba(56, 189, 248, 0.07);
    --ci-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* Aplicación global coherente */
body {
    background-color: var(--ci-bg) !important;
    color: var(--ci-text);
    transition: background-color 0.2s ease, color 0.2s ease;
}

#sidebar,
#mobileTopbar {
    background: var(--ci-sidebar-bg) !important;
    border-color: var(--ci-sidebar-border) !important;
}

.stat-card,
.card {
    background-color: var(--ci-surface) !important;
    color: var(--ci-text);
    border-color: var(--ci-border) !important;
    box-shadow: var(--ci-shadow);
}

.card-header,
.card-footer {
    border-color: var(--ci-border) !important;
}

.badge-nodo {
    background: var(--ci-surface) !important;
    color: var(--ci-text) !important;
    border-color: var(--ci-border) !important;
}

/* Sobrescrituras finas para Modo Medio */
html[data-campus-theme="medium"] .bg-white {
    background-color: var(--ci-surface) !important;
}
html[data-campus-theme="medium"] .bg-light,
html[data-campus-theme="medium"] .table-light {
    background-color: var(--ci-surface-alt) !important;
    --bs-table-bg: var(--ci-table-head);
}
html[data-campus-theme="medium"] .form-control,
html[data-campus-theme="medium"] .form-select,
html[data-campus-theme="medium"] .input-group-text {
    background-color: var(--ci-input-bg) !important;
    border-color: var(--ci-input-border) !important;
    color: var(--ci-text) !important;
}
html[data-campus-theme="medium"] .table {
    --bs-table-bg: var(--ci-surface);
    --bs-table-hover-bg: var(--ci-table-hover);
    --bs-table-border-color: var(--ci-border);
    color: var(--ci-text);
}
html[data-campus-theme="medium"] .list-group-item:not(.active) {
    background-color: var(--ci-surface);
    border-color: var(--ci-border);
    color: var(--ci-text);
}
html[data-campus-theme="medium"] .modal-content,
html[data-campus-theme="medium"] .dropdown-menu {
    background-color: var(--ci-surface);
    border-color: var(--ci-border);
    color: var(--ci-text);
}

/* Sobrescrituras finas para Modo Oscuro */
html[data-campus-theme="dark"] .bg-white,
html[data-campus-theme="dark"] .card-header.bg-white,
html[data-campus-theme="dark"] .card-footer.bg-white {
    background-color: var(--ci-surface) !important;
    color: var(--ci-text) !important;
}
html[data-campus-theme="dark"] .bg-light,
html[data-campus-theme="dark"] .table-light {
    background-color: var(--ci-surface-alt) !important;
    color: var(--ci-text) !important;
    --bs-table-bg: var(--ci-table-head);
    --bs-table-color: var(--ci-text);
}
html[data-campus-theme="dark"] .text-dark {
    color: #f1f5f9 !important;
}
html[data-campus-theme="dark"] .text-muted,
html[data-campus-theme="dark"] .text-secondary {
    color: var(--ci-text-muted) !important;
}
html[data-campus-theme="dark"] .border,
html[data-campus-theme="dark"] .border-bottom,
html[data-campus-theme="dark"] .border-top {
    border-color: var(--ci-border) !important;
}
html[data-campus-theme="dark"] .form-control,
html[data-campus-theme="dark"] .form-select,
html[data-campus-theme="dark"] .input-group-text {
    background-color: var(--ci-input-bg) !important;
    border-color: var(--ci-input-border) !important;
    color: var(--ci-text) !important;
}
html[data-campus-theme="dark"] .form-control::placeholder {
    color: #64748b !important;
}
html[data-campus-theme="dark"] .table {
    --bs-table-bg: var(--ci-surface);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-hover-bg: var(--ci-table-hover);
    --bs-table-border-color: var(--ci-border);
    color: var(--ci-text);
}
html[data-campus-theme="dark"] .list-group-item:not(.active) {
    background-color: var(--ci-surface);
    border-color: var(--ci-border);
    color: var(--ci-text);
}
html[data-campus-theme="dark"] .modal-content,
html[data-campus-theme="dark"] .dropdown-menu {
    background-color: var(--ci-surface);
    border-color: var(--ci-border);
    color: var(--ci-text);
}
html[data-campus-theme="dark"] .nav-pills.bg-white {
    background-color: var(--ci-surface) !important;
    border-color: var(--ci-border) !important;
}
html[data-campus-theme="dark"] .nav-pills .nav-link:not(.active) {
    color: #cbd5e1;
}
html[data-campus-theme="dark"] .btn-light {
    background-color: var(--ci-surface-alt);
    border-color: var(--ci-border);
    color: var(--ci-text);
}
html[data-campus-theme="dark"] .badge.bg-light {
    background-color: var(--ci-surface-alt) !important;
    color: var(--ci-text) !important;
}

/* Selector compacto de 3 modos */
.theme-switcher-pill {
    display: inline-flex;
    align-items: center;
    background: var(--ci-surface);
    border: 1px solid var(--ci-border);
    border-radius: 999px;
    padding: 2px;
    gap: 2px;
}
.theme-switcher-pill button {
    border: 0;
    background: transparent;
    color: var(--ci-text-muted);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.theme-switcher-pill button.active {
    background: #0d6efd;
    color: #ffffff;
}
