/* Sidebar Base Structure */
aside.user-sidebar-nav,
aside#sidebarNav.user-sidebar-nav {
    width: 240px !important; /* REDUCED WIDTH */
    height: calc(100vh - 70px);
    position: fixed;
    top: 70px; /* Below fixed navbar */
    left: 0;
    background-color: #ffffff;
    border-right: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    flex-direction: column;
    z-index: 900;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02) !important;
    overflow-y: hidden;
}

/* Sidebar Content Container */
.sidebar-nav-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0 !important; /* Removed global padding for full-width footer */
    overflow-y: auto;
}

/* Sidebar Header (Mobile close button) */
.sidebar-nav-header {
    display: none;
    padding: 1rem;
    justify-content: flex-end;
}

/* Navigation Menu */
.sidebar-nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem 0.75rem !important; /* Applied padding here */
    flex: 1 !important; /* Take up available space */
}

/* Footer Menu (Profile) */
.sidebar-footer-menu {
    margin-top: auto !important; /* Push to bottom */
    border-top: 1px solid #f1f5f9 !important; /* Full width divider */
    padding: 0.75rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background-color: #ffffff !important; /* Ensure bg covers anything behind */
}

/* Section Divider */
.sidebar-nav-divider {
    padding: 1rem 0.25rem 0.5rem;
    margin-top: 0.5rem;
    border-top: none;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.sidebar-nav-divider::before,
.sidebar-nav-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    border-bottom: 1px dashed #cbd5e1;
    background-color: transparent;
}

.sidebar-nav-divider span {
    background: transparent;
    padding: 0;
    color: #94a3b8;
    white-space: nowrap;
}

/* Navigation Item */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: transparent;
    border: 1px solid transparent;
    margin-bottom: 0.25rem;
    position: relative;
    overflow: hidden;
}

/* Profile Item specifics */
.sidebar-nav-item.profile-item {
    margin: 0 !important; /* Reset margins */
    border: 1px solid transparent !important; /* Reset borders */
}

/* Hover State */
.sidebar-nav-item:hover {
    background-color: #f8fafc; /* Very subtle, high-end gray */
    color: #1e293b; /* Darker slate */
    text-decoration: none;
    border-color: #e2e8f0;
    transform: none;
    box-shadow: none;
}

/* Icon Wrapper */
.nav-icon-wrapper {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    border-radius: 8px;
    margin-right: 1rem;
    font-size: 1rem;
    transition: all 0.2s ease; /* Smooth, standard transition */
    color: #64748b;
    border: 1px solid rgba(226, 232, 240, 0.8);
    flex-shrink: 0;
}

.sidebar-nav-item:hover .nav-icon-wrapper {
    background-color: #ffffff;
    color: #334155;
    border-color: #cbd5e1;
    transform: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); /* Extremely subtle depth */
}

/* Nav Item Content */
.nav-item-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.nav-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.2;
    white-space: normal;
    overflow: visible;
}

.sidebar-nav-item:hover .nav-item-title {
    color: #1e293b; /* Darker slate for high-end feel */
}

.nav-item-desc {
    font-size: 0.7rem;
    color: #94a3b8;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

/* Active State - Distinct styling */
.sidebar-nav-item.active {
    background-color: rgba(16, 14, 160, 0.04) !important; /* Brand tint */
    border-color: rgba(16, 14, 160, 0.1) !important;
    box-shadow: 0 2px 8px rgba(16, 14, 160, 0.05);
}

.sidebar-nav-item.active .nav-icon-wrapper {
    background-color: #100EA0; /* Brand Blue */
    color: #ffffff;
    border-color: #100EA0;
    box-shadow: 0 2px 4px rgba(16, 14, 160, 0.2);
}

.sidebar-nav-item.active .nav-item-title {
    color: #100EA0; /* Brand Blue */
}

.sidebar-nav-item.active .nav-item-desc {
    color: rgba(16, 14, 160, 0.7); /* Brand Blue with opacity */
}

/* Mobile Toggle Button */
.sidebar-toggle-btn {
    display: none;
    position: fixed;
    top: calc(70px + 1rem);
    right: 1rem; /* Moved to right */
    left: auto;
    z-index: 1001;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.05);
    background-color: #f8fafc;
}

/* Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 899;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Mobile Responsive */
@media (max-width: 992px) {
    aside.user-sidebar-nav,
    aside#sidebarNav.user-sidebar-nav {
        transform: translateX(-100%);
        box-shadow: none;
        top: 0;
        height: 100vh;
        width: 280px !important;
    }

    aside.user-sidebar-nav.show,
    aside#sidebarNav.user-sidebar-nav.show {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1) !important;
    }

    .sidebar-nav-header {
        display: flex;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .sidebar-toggle-btn {
        display: flex;
    }
}

    /* Desktop */
    @media (min-width: 993px) {
        aside.user-sidebar-nav,
        aside#sidebarNav.user-sidebar-nav {
            transform: none !important;
            display: flex !important;
            visibility: visible !important;
        }
        
        .sidebar-overlay {
            display: none !important;
        }

        main.has-sidebar {
            margin-left: 240px !important;
            width: auto !important;
            transition: margin-left 0.3s ease;
        }
    }

/* Hide user sidebar on home page */
.home-page aside.user-sidebar-nav,
.home-page aside#sidebarNav.user-sidebar-nav,
.home-page .sidebar-toggle-btn,
.home-page .sidebar-overlay {
    display: none !important;
}

.home-page main {
    margin-left: 0 !important;
}

.home-page .sidebar-nav:not(.user-sidebar-nav) {
    display: flex !important;
    position: sticky !important;
    top: 70px !important;
    height: calc(100vh - 70px) !important;
    max-height: calc(100vh - 70px) !important;
    width: 280px;
    background: #0f172a;
    overflow-y: auto;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    align-self: flex-start !important;
}
