/* 
   Refined Professional Sidebar System
   Level 3: Ultimate Polish & High-Fidelity Nesting
*/

/* Core Layout Reset - Absolute No Horizontal Movement */
html, body, .main-wrapper, .page-wrapper {
    overflow-x: hidden !important;
    width: 100% !important;
    touch-action: pan-y !important;
}

/* Sidebar Base Styling - The 280px Sweet Spot */
.sidebar {
    width: 280px !important; 
    min-width: 280px !important;
    max-width: 280px !important;
    background: #fff !important;
    border-right: 1px solid #f3f4f6 !important;
    box-shadow: 1px 0 10px rgba(0, 0, 0, 0.02) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important; 
    z-index: 1050 !important;
    position: fixed !important;
    height: 100vh !important;
    transition: width 0.3s ease !important;
    touch-action: pan-y !important;
}

/* Sidebar Header - Professional Branding */
.sidebar .sidebar-header {
    height: 75px !important;
    width: 280px !important;
    background: #fff !important;
    border-bottom: 1px solid #f3f4f6 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 1.5rem !important;
    box-sizing: border-box !important;
}

.sidebar-brand img {
    max-height: 42px !important;
    width: auto !important;
    object-fit: contain !important;
    transition: transform 0.3s ease;
}

/* Sidebar Body Styling */
.sidebar .sidebar-body {
    width: 280px !important;
    height: calc(100vh - 75px) !important;
    padding: 15px 0 !important;
    margin: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* Nav Item Refinement - Level 1 */
.sidebar .nav-item {
    margin: 1px 0 !important;
    padding: 0 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.sidebar .nav-link {
    padding: 10px 14px !important;
    color: #4b5563 !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    border-radius: 10px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    position: relative;
}

/* Active & Hover Aesthetics */
.sidebar .nav-link:hover {
    background: #f9fafb !important;
    color: #e82e5f !important;
}

.sidebar .nav-item.active > .nav-link {
    background: #fdf2f5 !important;
    color: #e82e5f !important;
    font-weight: 600 !important;
}

.sidebar .nav-item.active > .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 4px;
    background: #e82e5f;
    border-radius: 0 40px 40px 0;
}

/* Icon & Title Alignment */
.sidebar .nav-link .link-icon {
    width: 19px !important;
    height: 19px !important;
    margin-right: 12px !important;
    stroke-width: 2px !important;
    color: #9ca3af !important;
    flex-shrink: 0 !important;
    transition: color 0.2s ease;
}

.sidebar .nav-item.active .link-icon,
.sidebar .nav-link:hover .link-icon {
    color: #e82e5f !important;
}

/* Dropdown Arrow Fix */
.sidebar .link-arrow {
    width: 14px !important;
    height: 14px !important;
    margin-left: auto !important;
    transition: transform 0.2s ease !important;
    color: #9ca3af !important;
}

/* Sub-Menu Level Styling (Premium Tree View) */
.sidebar .nav.sub-menu {
    width: 100% !important;
    padding: 0 0 0 35px !important; /* Indent sub-links */
    margin: 5px 0 !important;
    position: relative;
    list-style: none !important;
}

/* Vertical Tree Line */
.sidebar .nav.sub-menu::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #f1f5f9;
}

.sidebar .nav.sub-menu .nav-link {
    padding: 8px 12px !important;
    font-size: 0.825rem !important;
    font-weight: 400 !important;
    background: transparent !important;
    color: #64748b !important;
}

.sidebar .nav.sub-menu .nav-link:hover {
    color: #e82e5f !important;
    padding-left: 15px !important; /* Subtle shift on hover */
}

.sidebar .nav.sub-menu .nav-item.active .nav-link {
    color: #e82e5f !important;
    font-weight: 600 !important;
}

/* Category Formatting */
.sidebar .nav-category {
    font-size: 10px !important;
    font-weight: 800 !important;
    letter-spacing: 1.5px !important;
    color: #94a3b8 !important;
    text-transform: uppercase;
    padding: 24px 1.5rem 8px !important;
    width: 100% !important;
    display: block !important;
    box-sizing: border-box !important;
}

/* Desktop Synchronization */
@media (min-width: 992px) {
    body:not(.sidebar-folded) .page-wrapper { margin-left: 280px !important; }
    body:not(.sidebar-folded) .navbar { left: 280px !important; width: calc(100% - 280px) !important; }

    body.sidebar-folded .sidebar { width: 80px !important; min-width: 80px !important; }
    body.sidebar-folded .sidebar .link-title,
    body.sidebar-folded .sidebar .sub-menu,
    body.sidebar-folded .sidebar .nav-category,
    body.sidebar-folded .sidebar .link-arrow { display: none !important; }
    body.sidebar-folded .page-wrapper { margin-left: 80px !important; }
}

/* Mobile Interaction */
@media (max-width: 991px) {
    .sidebar { position: fixed; left: 0; width: 280px !important; transform: translateX(-100%); transition: transform 0.3s ease; visibility: hidden; }
    body.sidebar-open .sidebar { transform: translateX(0); visibility: visible; }
}

/* Zero Scroll Interference */
.ps__rail-y, .ps__rail-x { display: none !important; visibility: hidden !important; }
.sidebar::-webkit-scrollbar { width: 4px !important; }
.sidebar::-webkit-scrollbar-thumb { background: #f1f5f9 !important; border-radius: 10px !important; }