/* ===================================
    CSS CUSTOM PROPERTIES (VARIABLES)
    =================================== */
:root {
    --sidebar-width: 215px;
    --sidebar-collapsed-width: 60px;
    --header-height: 75px;
    --primary-color: #3b82f6;
    --sidebar-bg: #ffffff;
    --sidebar-text: #000000;
    --sidebar-hover: #f7f8f7;
    --sidebar-active: #f7f8f7;
    --sidebar-border: #e2e8f0;
    --uncg-blue: #0f2044;
}

/* ===================================
    BASE STYLES
    =================================== */
* {
    font-family: 'Inter', sans-serif;
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
    width: 3px;
    height: 3px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 1.5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #888 transparent;
}

/* Ensure content doesn't shift when scrollbar appears */
html {
    overflow-y: overlay;
}

body {
    background-color: #f0f0f0 !important;
    overflow-x: hidden;
}


/* Modal Backdrop and Modal Z-Index */
/* Ensure modal backdrop and modal have higher z-index than sidebar */
.modal-backdrop {
    z-index: 100000 !important;
}
.modal {
    z-index: 100001 !important;
}

.dropdown-toggle::after {
    border: none !important;
}


/* ===================================
    SIDEBAR COMPONENT
    =================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: white;
    transition: all 0.25s ease-out;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Header */
.sidebar-header {
    background-color: var(--uncg-blue);
    color: white;
    padding: .75rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    background-color: var(--uncg-blue);
}

.sidebar.collapsed .sidebar-header .brand-text {
    display: none;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn i {
    transition: transform 0.25s ease;
}

.sidebar.collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 0.5rem 0;
    padding-left: 5px;
    padding-right: 5px;
}

.sidebar.collapsed .sidebar-nav {
    padding-left: 0;
    padding-right: 0;
}

.nav-item {
    margin-bottom: 1px;
}

.nav-link-sidebar {
    display: flex;
    align-items: center;
    padding: 0.50rem 1rem;
    font-size: 0.9rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-radius: 0;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    border-top-right-radius: 0.4rem;
    border-bottom-right-radius: 0.4rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    background-color: transparent;
    border: none;
}

.sidebar.collapsed .nav-link-sidebar {
    border-radius: 0;
    justify-content: center;
    padding: 0.50rem;
}

.nav-link-sidebar:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.nav-link-sidebar.active {
    background-color: var(--sidebar-active);
    color: var(--sidebar-text);
}

.nav-link-sidebar::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: #a6b0b7;
    transition: top 0.2s ease-out, opacity 0.2s ease-out;
    opacity: 0;
}

.nav-link-sidebar:hover::before {
    top: 0;
    opacity: 0.5;
}

.nav-link-sidebar.active::before {
    top: 0;
    opacity: 1;
}

.nav-link-sidebar i {
    width: 20px;
    margin-right: 0.875rem;
    text-align: center;
    font-size: 1rem;
}

.sidebar.collapsed .nav-link-sidebar span {
    display: none;
}

.sidebar.collapsed .nav-link-sidebar i {
    margin-right: 0;
}

/* Hide section headers when sidebar is collapsed */
.sidebar.collapsed .sidebar-nav small {
    display: none;
}

/* ===================================
    MAIN CONTENT AREA
    =================================== */
.main-content {
    margin-left: var(--sidebar-width);
    transition: all 0.25s ease-out;
}

footer {
    padding: 10px 15px;
    text-align: right;
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: auto;
}

.main-content.collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

.top-header {
    background: var(--uncg-blue);
    color: white;
    height: var(--header-height);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: none; /* Hidden by default */
    align-items: center;
    padding: 0 1.5rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    transition: transform 0.3s ease;
}

.top-header.hidden {
    transform: translateY(-100%);
}

.content-area {
    padding: 1rem;
}

/* ===================================
    SIDEBAR OVERLAY
    =================================== */

.modal-open {
    padding-right: 0 !important; /* Prevent horizontal scroll */
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ===================================
    TOOLTIPS & SMOOTH TRANSITIONS
    =================================== */
.sidebar.collapsed [data-bs-toggle="tooltip"] {
    pointer-events: auto;
}

.sidebar,
.main-content {
    transition: all 0.25s ease-out;
}

/* ===================================
    RESPONSIVE BREAKPOINTS
    =================================== */

/* Mobile Devices (< 768px) */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important; /* Force full width on mobile */
    }

    .sidebar.show {
        transform: translateX(0);
        width: var(--sidebar-width) !important; /* Ensure full width when shown */
    }

    /* Ensure mobile sidebar shows full navigation with text */
    .sidebar.show .nav-link-sidebar {
        justify-content: flex-start;
        padding: 0.75rem 1.25rem;
        border-top-right-radius: 0.4rem;
        border-bottom-right-radius: 0.4rem;
    }

    .sidebar.show .nav-link-sidebar span {
        display: inline;
    }

    .sidebar.show .nav-link-sidebar i {
        margin-right: 0.75rem;
    }

    .sidebar.show .sidebar-header .brand-text {
        display: inline;
    }

    .sidebar.show .sidebar-nav {
        padding-left: 5px;
        padding-right: 5px;
    }

    /* Force remove collapsed state on mobile */
    .sidebar.collapsed {
        width: var(--sidebar-width) !important;
    }

    .main-content {
        margin-left: 0;
        padding-top: var(--header-height);
    }

    .main-content.collapsed {
        margin-left: 0;
        padding-top: var(--header-height);
    }

    .top-header {
        display: flex !important; /* Show header only on mobile */
        left: 0;
        right: 0;
    }

    .mobile-header {
        display: flex !important;
    }

    .desktop-toggle {
        display: none !important;
    }

    .sidebar-toggle-btn {
        display: flex !important; /* Show header toggle on mobile */
    }

    /* Mobile toggle button rotation */
    .sidebar:not(.show) .sidebar-toggle-btn i {
        transform: rotate(0deg) !important;
    }

    .sidebar.show .sidebar-toggle-btn i {
        transform: rotate(0deg) !important;
    }
}

/* Tablet Devices (768px - 991.98px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .sidebar .nav-link-sidebar {
        justify-content: center;
        padding: 0.75rem;
        border-radius: 0;
    }

    .sidebar .nav-link-sidebar span {
        display: none;
    }

    .sidebar .nav-link-sidebar i {
        margin-right: 0;
    }

    .sidebar .sidebar-header .brand-text {
        display: none;
    }

    .sidebar .sidebar-nav {
        padding-left: 0;
        padding-right: 0;
    }

    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .mobile-header {
        display: none !important;
    }

    .desktop-toggle {
        display: none !important;
    }

    .top-header {
        display: none !important; /* Hide header on tablet */
    }

    .sidebar-toggle-btn {
        display: flex !important; /* Show header toggle on tablet */
    }

    /* When sidebar is shown as off-canvas on tablet */
    .sidebar.show {
        width: var(--sidebar-width);
        z-index: 1031;
    }

    .sidebar.show .nav-link-sidebar {
        justify-content: flex-start;
        padding: 0.75rem 1.25rem;
        border-top-right-radius: 0.4rem;
        border-bottom-right-radius: 0.4rem;
    }

    .sidebar.show .nav-link-sidebar span {
        display: inline;
    }

    .sidebar.show .nav-link-sidebar i {
        margin-right: 0.75rem;
    }

    .sidebar.show .sidebar-header .brand-text {
        display: inline;
    }

    .sidebar.show .sidebar-nav {
        padding-left: 5px;
        padding-right: 5px;
    }

    /* Tablet toggle button rotation */
    .sidebar.show .sidebar-header .sidebar-toggle-btn i {
        transform: rotate(0deg) !important;
    }

    .sidebar.show .sidebar-toggle-btn i {
        transform: rotate(0deg) !important;
    }
}

/* Desktop Devices (≥ 992px) */
@media (min-width: 992px) {
    .mobile-header {
        display: none !important;
    }

    .desktop-toggle {
        display: block !important; /* Show desktop toggle button */
    }

    .top-header {
        display: none !important; /* Hide header on desktop */
    }

    /* Position the desktop toggle button */
    .desktop-toggle {
        left: calc(var(--sidebar-width) + 10px) !important;
        transition: left 0.25s ease-out;
    }

    .main-content.collapsed .desktop-toggle {
        left: calc(var(--sidebar-collapsed-width) + 10px) !important;
    }
}