:root {
    --aybs-navy-900: #091427;
    --aybs-navy-800: #0f1e36;
    --aybs-navy-700: #1a3154;
    --aybs-primary: #1e40af;
    --aybs-primary-light: #3b82f6;
    --aybs-teal: #0d9488;
    --aybs-bg: #f8fafc;
    --aybs-border: #e2e8f0;
    --sidebar-width: 290px;
    --sidebar-mini-width: 78px;
    --topbar-height: 70px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--aybs-bg);
    color: #334155;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh; 
}

/* =========================================================
       SIDEBAR & MOBILE SCROLL FIX (100dvh, flex-column, scrollbar)
       ========================================================= */
#sidebar-wrapper {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background-color: var(--aybs-navy-900);
    color: #f1f5f9;
    display: flex;
    flex-direction: column;
    z-index: 1060;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.25);
}

/* Fixed Sidebar Header */
.sidebar-header {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background-color: var(--aybs-navy-900);
    flex-shrink: 0;
}

/* SCROLLABLE INNER MENU AREA (The Mobile Scroll Fix) */
.sidebar-scrollable-content {
    flex: 1 1 auto;
    height: calc(100% - var(--topbar-height) - 80px);
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* iOS smooth inertia scroll */
    overscroll-behavior-y: contain; /* Prevent body scroll pull */
    padding: 1rem 0.85rem 2.5rem 0.85rem;
}

    /* Custom Sleek Scrollbar */
    .sidebar-scrollable-content::-webkit-scrollbar {
        width: 5px;
    }

    .sidebar-scrollable-content::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.02);
    }

    .sidebar-scrollable-content::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 999px;
    }

        .sidebar-scrollable-content::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.4);
        }

/* Fixed Sidebar Footer */
.sidebar-footer {
    height: 80px;
    min-height: 80px;
    background: var(--aybs-navy-800);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

/* Menu Section Categorization */
.menu-section-header {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    padding: 0.9rem 0.85rem 0.35rem 0.85rem;
}

.nav-academic-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 0.85rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    margin-bottom: 2px;
    transition: all 0.2s ease;
    position: relative;
}

    .nav-academic-link:hover {
        color: #ffffff;
        background: rgba(255, 255, 255, 0.06);
    }

    .nav-academic-link.active {
        color: #ffffff;
        background: linear-gradient(135deg, var(--aybs-primary), #2563eb);
        box-shadow: 0 4px 14px rgba(30, 64, 175, 0.35);
        font-weight: 600;
    }

    .nav-academic-link i {
        font-size: 1.15rem;
        min-width: 22px;
        text-align: center;
    }

.badge-menu {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
}

/* Backdrop for Mobile */
#sidebar-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1055;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

    #sidebar-backdrop.active {
        opacity: 1;
        visibility: visible;
    }

/* Topbar and Main Layout */
#page-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--aybs-border);
    position: sticky;
    top: 0;
    z-index: 1040;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.card-academic {
    border: 1px solid var(--aybs-border);
    border-radius: 0.85rem;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .card-academic:hover {
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    }

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

/* Soft Color Badges */
.bg-soft-primary {
    background: #eff6ff;
    color: #1d4ed8;
}

.bg-soft-success {
    background: #f0fdf4;
    color: #15803d;
}

.bg-soft-warning {
    background: #fefce8;
    color: #b45309;
}

.bg-soft-danger {
    background: #fef2f2;
    color: #b91c1c;
}

.bg-soft-teal {
    background: #f0fdfa;
    color: #0f766e;
}

/* Desktop Collapsed Sidebar (Mini-mode) */
@media (min-width: 992px) {
    body.sidebar-mini #sidebar-wrapper {
        width: var(--sidebar-mini-width);
    }

    body.sidebar-mini #page-wrapper {
        margin-left: var(--sidebar-mini-width);
    }

    body.sidebar-mini .brand-text,
    body.sidebar-mini .menu-section-header,
    body.sidebar-mini .nav-academic-link span,
    body.sidebar-mini .badge-menu,
    body.sidebar-mini .user-details {
        display: none !important;
    }

    body.sidebar-mini .nav-academic-link {
        justify-content: center;
        padding: 0.75rem 0;
    }

        body.sidebar-mini .nav-academic-link i {
            font-size: 1.35rem;
        }

    body.sidebar-mini .sidebar-header {
        justify-content: center;
        padding: 0;
    }

    body.sidebar-mini .sidebar-footer {
        justify-content: center;
        padding: 0.75rem 0;
    }
}

/* Mobile Screen Adjustments */
@media (max-width: 991.98px) {
    #sidebar-wrapper {
        transform: translateX(-100%);
    }

        #sidebar-wrapper.mobile-show {
            transform: translateX(0);
        }

    #page-wrapper {
        margin-left: 0 !important;
    }
    /* Prevent background body scroll when mobile menu is active */
    body.mobile-nav-open {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}
