/* ======= SIDENAV STYLES ======= */
.sidenav {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease, transform 0.3s ease;
    font-family: system-ui, -apple-system, sans-serif !important;
    line-height: 1.3 !important;
}

/* Collapsed state for desktop */
.sidenav.collapsed {
    width: 60px;
}

.sidenav.collapsed .sidenav-logo,
.sidenav.collapsed .sidenav-item span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Hide full title when collapsed, show abbreviated */
.sidenav.collapsed .sidenav-section-title {
    display: none;
}

.sidenav.collapsed .sidenav-section-abbrev {
    display: block;
}

.sidenav.collapsed .sidenav-item {
    justify-content: center;
    padding: 0.6rem 0;
    gap: 0;
}

.sidenav.collapsed .sidenav-item i {
    margin: 0;
    width: auto;
}

.sidenav-header {
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #4092cc;
    color: white;
    position: relative;
    min-height: 60px;
    max-height: 60px;
    flex-shrink: 0;
}

.sidenav-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.sidenav-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.4rem;
    width: 28px;
    height: 28px;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.sidenav-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidenav-toggle i {
    transition: transform 0.3s ease;
}

.sidenav-close {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
}

.sidenav-content {
    flex: 1 1 auto;
    padding: 0.75rem 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.sidenav-section {
    margin-bottom: 1rem;
}

.sidenav-section-title {
    padding: 0.4rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    line-height: 1.3 !important;
    display: block;
}

/* Abbreviated section title for collapsed state */
.sidenav-section-abbrev {
    padding: 0.5rem 0;
    margin: 0.25rem 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: #4092cc;
    background: #ebf5ff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    line-height: 1.3 !important;
    display: none; /* Hidden by default */
    border-radius: 4px;
}

.sidenav.dark-mode .sidenav-section-abbrev {
    color: #4092cc;
    background: #3a3a3c;
}

.sidenav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem !important;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    line-height: 1.3 !important;
    font-size: 0.9rem;
}

.sidenav-item span {
    transition: opacity 0.3s ease, width 0.3s ease;
    white-space: nowrap;
    line-height: 1.3 !important;
}

.sidenav-item:hover {
    background: #f8fbff;
    color: #4092cc;
}

.sidenav-item.active {
    background: #ebf5ff;
    color: #4092cc;
    font-weight: 600;
}

.sidenav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #4092cc;
}

.sidenav-item i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: margin 0.3s ease, width 0.3s ease;
    line-height: 1.3 !important;
}

.sidenav-footer {
    padding: 0.75rem 0;
    border-top: 1px solid #e2e8f0;
    background: white;
    flex-shrink: 0;
    flex-grow: 0;
}

/* Dark Mode Toggle Button - Mobile Style */
.dark-mode-toggle-container {
    cursor: pointer;
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem !important;
    position: relative;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    line-height: 1.3 !important;
    font-size: 0.9rem;
}

.dark-mode-toggle-container:hover {
    background: #f8fbff;
    color: #4092cc;
}

.sidenav.dark-mode .dark-mode-toggle-container {
    color: #ffffff;
}

.sidenav.dark-mode .dark-mode-toggle-container:hover {
    background: #3a3a3c;
    color: #4092cc;
}

.theme-toggle-switch {
    position: relative;
    width: 44px;
    height: 26px;
    background: #e5e5e7;
    border-radius: 13px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.theme-toggle-switch.active {
    background: #4092cc;
}

.theme-toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle-switch.active .theme-toggle-slider {
    transform: translateX(18px);
}

.theme-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    pointer-events: none;
}

.theme-icon-sun {
    left: 5px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.theme-icon-moon {
    right: 5px;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.theme-toggle-switch.active .theme-icon-sun {
    opacity: 0.3;
}

.theme-toggle-switch.active .theme-icon-moon {
    opacity: 1;
}

/* When collapsed, hide the toggle completely or show icon only */
.sidenav.collapsed .dark-mode-toggle-container span:not(.theme-icon) {
    opacity: 0;
    width: 0;
}

.sidenav.collapsed .theme-toggle-switch {
    display: none;
}

/* Dark Mode Styles - Softer Gray Theme */
.sidenav.dark-mode {
    background: #2c2c2e;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
}

.sidenav.dark-mode .sidenav-header {
    background: #3a3a3c;
    border-bottom: 1px solid #48484a;
}

.sidenav.dark-mode .sidenav-section-title {
    color: #a0a0a0;
}

.sidenav.dark-mode .sidenav-item {
    color: #ffffff;
}

.sidenav.dark-mode .sidenav-item:hover {
    background: #3a3a3c;
    color: #4092cc;
}

.sidenav.dark-mode .sidenav-item.active {
    background: #3a3a3c;
    color: #4092cc;
}

.sidenav.dark-mode .sidenav-footer {
    background: #2c2c2e;
    border-top: 1px solid #48484a;
}

/* Dark mode scrollbar */
.sidenav.dark-mode .sidenav-content::-webkit-scrollbar-track {
    background: #3a3a3c;
}

.sidenav.dark-mode .sidenav-content::-webkit-scrollbar-thumb {
    background: #48484a;
}

.sidenav.dark-mode .sidenav-content::-webkit-scrollbar-thumb:hover {
    background: #4092cc;
}

/* Overlay for mobile */
.sidenav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidenav-overlay.active {
    display: block;
    opacity: 1;
}

/* Hamburger menu button */
.hamburger-menu {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 998;
    background: #4092cc;
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1.3rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.hamburger-menu:hover {
    background: #357abd;
    transform: scale(1.05);
}

/* Adjust main content to accommodate sidenav */
body {
    margin-left: 240px;
    transition: margin-left 0.3s ease;
}

body.sidenav-collapsed {
    margin-left: 60px;
}

/* ======= RESPONSIVE DESIGN ======= */
@media (max-width: 768px) {
    /* Hide sidenav by default on mobile */
    .sidenav {
        transform: translateX(-100%);
        width: 240px;
    }

    .sidenav.active {
        transform: translateX(0);
    }

    .sidenav.collapsed {
        width: 240px; /* Reset width on mobile */
    }

    /* Hide toggle button on mobile, show close button */
    .sidenav-toggle {
        display: none;
    }

    .sidenav-close {
        display: flex;
    }

    /* Show hamburger menu */
    .hamburger-menu {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Reset body margin */
    body {
        margin-left: 0;
    }

    body.sidenav-collapsed {
        margin-left: 0;
    }

    /* Adjust dashboard container padding to account for hamburger */
    .dashboard-container {
        padding-top: 4.5rem;
    }

    /* Make sure text and logo are visible on mobile */
    .sidenav.active .sidenav-logo,
    .sidenav.active .sidenav-section-title,
    .sidenav.active .sidenav-item span {
        opacity: 1;
        width: auto;
    }
    
    /* Always show full titles on mobile, not abbreviated */
    .sidenav-section-abbrev {
        display: none !important;
    }
    
    .sidenav-section-title {
        display: block !important;
    }
}

@media (min-width: 769px) {
    /* Keep sidenav always visible on desktop */
    .sidenav-overlay {
        display: none !important;
    }
}

/* Custom scrollbar for sidenav */
.sidenav-content::-webkit-scrollbar {
    width: 5px;
}

.sidenav-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidenav-content::-webkit-scrollbar-thumb {
    background: #4092cc;
    border-radius: 3px;
}

.sidenav-content::-webkit-scrollbar-thumb:hover {
    background: #357abd;
}