/* Sidebar Styles */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    position: relative;
    min-height: 100vh;
}

#sidebar {
    min-width: 250px;
    max-width: 250px;
    background: white;
    color: var(--secondary-dark);
    transition: all 0.3s ease;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 999;
    overflow-y: auto;
    box-shadow: var(--box-shadow);
    border-right: 1px solid var(--border-color);
    display: block;
    visibility: visible;
    /* Prevent sidebar from scrolling when page content scrolls */
    scroll-behavior: auto;
    /* Ensure sidebar stays in position */
    transform: translateZ(0);
    will-change: transform;
}

#sidebar.active {
    margin-left: -250px;
    transform: translateX(0);
}

#sidebar .sidebar-header {
    padding: 1.5rem 1rem;
    background: var(--primary-color);
}

#sidebar .sidebar-header h3 {
    margin: 0;
    color: white;
    font-weight: var(--font-weight-bold);
    font-size: 1.25rem;
}

#sidebar ul.components {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    height: calc(100vh - 180px);
    overflow-y: auto;
    margin: 0;
    list-style: none;
}

#sidebar ul li {
    margin: 0;
    padding: 0;
    list-style: none;
}

#sidebar ul li a {
    color: var(--secondary-dark);
    border-radius: var(--border-radius-sm);
    margin: 0.25rem 0.75rem;
    padding: 0.75rem 1rem;
    display: block;
    font-size: 1.1em;
    text-decoration: none;
    transition: var(--transition-base);
    /* Prevent page scroll when clicking sidebar links */
    scroll-behavior: auto;
}

#sidebar ul li a:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

#sidebar ul li.active > a,
a[aria-expanded="true"],
#sidebar ul li a.active {
    background: var(--primary-light);
    color: var(--primary-color);
    font-weight: var(--font-weight-bold);
}

#sidebar ul ul a {
    font-size: 0.9em !important;
    padding-left: 2rem !important;
    background: transparent;
    color: var(--secondary-color);
}

.category-title {
    color: var(--secondary-color);
    font-size: 0.7rem;
    letter-spacing: 0.05rem;
    text-transform: uppercase;
    font-weight: var(--font-weight-bold);
    padding: 1.25rem 1.5rem 0.5rem;
    margin-top: 0.5rem;
}

#sidebar .sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 1rem;
    background: var(--light-color);
    border-top: 1px solid var(--border-color);
}

/* Content */
#content {
    width: calc(100% - 250px);
    min-height: 100vh;
    transition: var(--transition-base);
    position: absolute;
    top: 0;
    right: 0;
    left: 250px;
    padding-bottom: 2rem;
    overflow-x: hidden;
    margin-left: 0;
}

#content.active {
    width: 100%;
    left: 0;
}

/* Top navbar */
.top-navbar {
    background: white;
    padding: 0.75rem 1.5rem;
    box-shadow: var(--box-shadow);
    border-bottom: 1px solid var(--border-color);
}

.top-navbar .navbar-brand {
    color: var(--primary-color);
    font-weight: var(--font-weight-bold);
}

.top-navbar .user-info {
    color: var(--secondary-color);
}

/* Prevent page scroll when clicking sidebar links */
body.sidebar-page {
    scroll-behavior: auto;
}

/* Ensure sidebar stays fixed and doesn't move */
#sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    transition: margin-left 0.3s ease !important;
}

/* Prevent content from scrolling when sidebar is clicked */
#content {
    scroll-behavior: auto;
}

/* Prevent any automatic scrolling on the entire page when sidebar is present */
body.sidebar-page {
    scroll-behavior: auto !important;
    overflow-x: hidden;
}

/* Ensure sidebar links don't cause any scroll behavior */
#sidebar a {
    scroll-behavior: auto !important;
}

/* Prevent Bootstrap's smooth scrolling from interfering */
html {
    scroll-behavior: auto !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #sidebar {
        margin-left: -250px;
        z-index: 1050;
    }
    
    #sidebar.active {
        margin-left: 0;
        transform: translateX(0);
    }
    
    #content {
        width: 100%;
        left: 0;
    }
    
    #content.active {
        margin-left: 0;
        width: 100%;
    }
    
    .dashboard-card {
        margin-bottom: 1.5rem;
    }
    
    /* Ensure the sidebar toggle button is always visible */
    #sidebarCollapse {
        display: block !important;
        position: relative;
        z-index: 1060;
    }
}