/* ================================================================
   UNIVERSITY EXECUTIVE DASHBOARD — Dark / Light Theme
   ================================================================ */

/* ── Dark Theme (default) ─────────────────────────── */
:root,
[data-theme="dark"] {
    --sidebar-width: 260px;
    --bg-body: #131518;
    --bg-surface: #1c1e24;
    --bg-card: #21242b;
    --bg-card-hover: #292c34;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --text-primary: #f0f2f5;
    --text-secondary: #8b8fa3;
    --accent-primary: #dc2626;
    --accent-primary-glow: rgba(220, 38, 38, 0.25);
    --accent-info: #38bdf8;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --gradient-primary: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    --gradient-info: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    --gradient-success: linear-gradient(135deg, #22c55e 0%, #10b981 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-card-hover: 0 8px 25px rgba(0, 0, 0, 0.3);
    --shadow-chart-hover: 0 4px 15px rgba(0, 0, 0, 0.15);
    --scrollbar-thumb: rgba(255, 255, 255, 0.1);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.2);
    --table-hover-bg: rgba(220, 38, 38, 0.05);
}

/* ── Light Theme ──────────────────────────────────── */
[data-theme="light"] {
    --bg-body: #f5f5f4;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #fafaf9;
    --border-subtle: rgba(0, 0, 0, 0.08);
    --text-primary: #1a1d2e;
    --text-secondary: #64748b;
    --accent-primary: #b91c1c;
    --accent-primary-glow: rgba(185, 28, 28, 0.18);
    --accent-info: #0ea5e9;
    --accent-success: #16a34a;
    --accent-warning: #d97706;
    --accent-danger: #dc2626;
    --gradient-primary: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    --shadow-card-hover: 0 8px 25px rgba(0, 0, 0, 0.08);
    --shadow-chart-hover: 0 4px 15px rgba(0, 0, 0, 0.06);
    --scrollbar-thumb: rgba(0, 0, 0, 0.15);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.25);
    --table-hover-bg: rgba(185, 28, 28, 0.04);
}

/* ── Reset & Base ─────────────────────────────────── */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html {
        font-size: 15px;
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ──────────────────────────────────────── */

.sidebar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    z-index: 1000;
}

.sidebar-nav {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
}

.sidebar-brand>i {
    font-size: 1.8rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-title {
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 0 16px 8px;
}

.sidebar-menu {
    flex: 1;
    padding: 8px 12px;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition-fast);
    margin-bottom: 2px;
    text-decoration: none;
}

.sidebar-menu .nav-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
}

.sidebar-menu .nav-link:hover {
    background: rgba(220, 38, 38, 0.08);
    color: var(--text-primary);
    transform: translateX(2px);
}

.sidebar-menu .nav-link.active {
    background: var(--accent-primary-glow);
    color: var(--accent-primary);
    font-weight: 600;
}

.sidebar-menu .nav-link.active i {
    color: var(--accent-primary);
}

/* ── Submenu ─────────────────────────────────────── */

.has-submenu>.nav-link {
    justify-content: flex-start;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform var(--transition-fast);
}

.has-submenu>.nav-link[aria-expanded="true"] .submenu-arrow {
    transform: rotate(180deg);
}

.submenu {
    list-style: none;
    padding: 4px 0 4px 18px;
    margin: 0;
}

.submenu .nav-link {
    padding: 8px 14px;
    font-size: 0.82rem;
    gap: 10px;
    border-left: 2px solid var(--border-subtle);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 1px;
}

.submenu .nav-link i {
    font-size: 0.95rem;
    width: 18px;
}

.submenu .nav-link:hover {
    border-left-color: var(--accent-primary);
}

.submenu .nav-link.active {
    border-left-color: var(--accent-primary);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
}

/* ── Sync Indicator ───────────────────────────────── */

.sync-info {
    padding: 0;
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-success);
    display: inline-block;
    box-shadow: 0 0 6px var(--accent-success);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 6px var(--accent-success);
    }

    50% {
        opacity: 0.5;
        box-shadow: 0 0 2px var(--accent-success);
    }
}

.sync-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.sync-time {
    font-size: 0.75rem;
    color: var(--text-primary);
    padding-left: 16px;
    font-weight: 500;
}

/* ── Mobile Navbar & Offcanvas ────────────────────── */

.mobile-navbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 12px;
}

.sidebar-offcanvas {
    background: var(--bg-surface) !important;
    border-right: 1px solid var(--border-subtle) !important;
    width: var(--sidebar-width) !important;
}

/* ── Main Content ─────────────────────────────────── */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 28px;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 16px;
    }
}

/* ── Filter Bar ───────────────────────────────────── */

.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(12px);
}

.filter-select {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    min-width: 160px;
    font-size: 0.85rem;
    padding: 6px 30px 6px 10px;
}

.filter-select:focus {
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 3px var(--accent-primary-glow) !important;
}

/* ── KPI Cards ────────────────────────────────────── */

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
    height: 100%;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition-fast);
}

.kpi-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
    border-color: rgba(220, 38, 38, 0.15);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 6px;
}

.kpi-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
}

.badge-up {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-success);
}

.badge-down {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ── Chart Cards ──────────────────────────────────── */

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: var(--transition-smooth);
}

/* Use this class when you want the card to fill 100% of its grid column height */
.chart-card.h-100 {
    height: 100%;
}

.chart-card:hover {
    border-color: rgba(220, 38, 38, 0.1);
    box-shadow: var(--shadow-chart-hover);
}

.chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
}

.chart-title i {
    color: var(--accent-primary);
}

/* ── Tables ───────────────────────────────────────── */

.table-dark {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: var(--table-hover-bg);
    --bs-table-border-color: var(--border-subtle);
    --bs-table-color: var(--text-primary);
}

.table-dark thead tr {
    border-bottom: 2px solid var(--border-subtle);
}

.table-dark th {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 10px 12px;
    letter-spacing: 0.5px;
}

.table-dark td {
    font-size: 0.85rem;
    padding: 6px 12px;
    vertical-align: middle;
}

.table-dark.table-sm td,
.table-dark.table-sm th {
    padding: 4px 10px;
}

.table-dark .badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 4px 8px;
}

/* ── Bootstrap Overrides (Dark theme helpers) ─────── */

.bg-primary-subtle {
    background: rgba(220, 38, 38, 0.15) !important;
}

.bg-info-subtle {
    background: rgba(56, 189, 248, 0.15) !important;
}

.bg-success-subtle {
    background: rgba(34, 197, 94, 0.15) !important;
}

.bg-warning-subtle {
    background: rgba(245, 158, 11, 0.15) !important;
}

.bg-danger-subtle {
    background: rgba(239, 68, 68, 0.15) !important;
}

.text-primary {
    color: var(--accent-primary) !important;
}

.text-info {
    color: var(--accent-info) !important;
}

.text-success {
    color: var(--accent-success) !important;
}

.text-warning {
    color: var(--accent-warning) !important;
}

.text-danger {
    color: var(--accent-danger) !important;
}

/* ── Animations ───────────────────────────────────── */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi-card,
.chart-card,
.filter-bar {
    animation: fadeInUp 0.5s ease-out backwards;
}

.row>.col-lg-3:nth-child(1) .kpi-card,
.row>.col-lg-2:nth-child(1) .kpi-card {
    animation-delay: 0.05s;
}

.row>.col-lg-3:nth-child(2) .kpi-card,
.row>.col-lg-2:nth-child(2) .kpi-card {
    animation-delay: 0.1s;
}

.row>.col-lg-3:nth-child(3) .kpi-card,
.row>.col-lg-2:nth-child(3) .kpi-card {
    animation-delay: 0.15s;
}

.row>.col-lg-3:nth-child(4) .kpi-card,
.row>.col-lg-2:nth-child(4) .kpi-card {
    animation-delay: 0.2s;
}

.row>.col-lg-2:nth-child(5) .kpi-card {
    animation-delay: 0.25s;
}

.row>.col-lg-2:nth-child(6) .kpi-card {
    animation-delay: 0.3s;
}

.row>.col-lg-4:nth-child(1) .kpi-card {
    animation-delay: 0.25s;
}

.row>.col-lg-4:nth-child(2) .kpi-card {
    animation-delay: 0.3s;
}

.row>.col-lg-4:nth-child(3) .kpi-card {
    animation-delay: 0.35s;
}

/* ── Theme Toggle Button ──────────────────────────── */

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 0;
}

.theme-toggle:hover {
    background: var(--accent-primary-glow);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: rotate(30deg);
}

/* Hide/show icons based on theme */
[data-theme="dark"] .theme-icon-dark,
[data-theme="light"] .theme-icon-light {
    display: none;
}

/* ── Light mode specific overrides ────────────────── */

[data-theme="light"] .mobile-navbar {
    background: var(--bg-surface);
}

[data-theme="light"] .mobile-navbar .btn-outline-light {
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

[data-theme="light"] .btn-close-white {
    filter: none;
}

[data-theme="light"] .sidebar-brand>i {
    -webkit-text-fill-color: unset;
    background: none;
    color: var(--accent-primary);
}

/* ── Scrollbar ────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ── Responsive fine-tuning ───────────────────────── */

@media (max-width: 575.98px) {
    .kpi-value {
        font-size: 1.3rem;
    }

    .filter-bar h4 {
        font-size: 1rem;
    }
}