/* Modern Layout CSS */
:root {
    --primary-color: #667eea;
    --text-color: #333;
    --bg-light: #f8f9fa;
    --header-height: 70px;
}

/* --- Header Branding --- */
.main-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: fixed;
    /* Changed from sticky to fixed for better robustness */
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--header-height);
    display: flex;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    width: 100%;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-color);
}

.brand-logo {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #1a202c;
}

/* --- Desktop Menu --- */
.desktop-menu {
    display: none;
}

@media (min-width: 769px) {
    .desktop-menu {
        display: block;
    }

    .nav-list {
        display: flex;
        gap: 25px;
        list-style: none;
        margin: 0;
        padding: 0;
        align-items: center;
    }

    .nav-item {
        position: relative;
    }

    .nav-link {
        color: #4a5568;
        text-decoration: none;
        font-weight: 500;
        padding: 8px 0;
        transition: color 0.2s;
        font-size: 0.95rem;
    }

    .nav-link:hover {
        color: var(--primary-color);
    }

    /* Submenu dropdown */
    .has-sub>.nav-link::after {
        content: ' ▾';
        font-size: 0.8em;
    }

    .sub-menu {
        position: absolute;
        top: 100%;
        left: 0;
        background: #fff;
        min-width: 200px;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        border-radius: 6px;
        padding: 8px 0;
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
        transition: all 0.2s ease;
        list-style: none;
        border: 1px solid #edf2f7;
    }

    .nav-item:hover .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .sub-menu li a {
        display: block;
        padding: 8px 16px;
        color: #4a5568;
        text-decoration: none;
        font-size: 0.9rem;
    }

    .sub-menu li a:hover {
        background: #f7fafc;
        color: var(--primary-color);
    }

    .mobile-toggle {
        display: none;
    }
}

/* --- Mobile Menu --- */
.mobile-toggle {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #4a5568;
    display: none;
    /* Default hidden */
}

@media (max-width: 768px) {
    .mobile-toggle {
        display: block;
        /* Show only on mobile */
    }
}

@media (min-width: 769px) {
    .mobile-toggle {
        display: none;
    }
}

/* Global Scroll Behavior */
html,
body {
    width: 100%;
    /* overflow-x: hidden; <-- Removed global lock to allow Sticky Sidebar on Desktop */
}

/* Prevent horizontal scroll from off-canvas menu on Mobile ONLY */
@media (max-width: 768px) {

    html,
    body {
        overflow-x: hidden;
        position: relative;
    }
}

/* Ensure mobile menu doesn't affect Desktop layout */
@media (min-width: 769px) {
    .mobile-menu-overlay {
        display: none !important;
    }
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: #fff;
    z-index: 2000;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    visibility: hidden;
    /* Hide completely when closed */
    transition: transform 0.3s ease-in-out, visibility 0.3s;
    display: flex;
    flex-direction: column;
}

.mobile-menu-overlay.active {
    transform: translateX(0);
    visibility: visible;
}

.mobile-header {
    padding: 20px;
    display: flex;
    justify-content: flex-end;
    border-bottom: 1px solid #eee;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #888;
}

.mobile-nav-list {
    list-style: none;
    padding: 20px;
    margin: 0;
    overflow-y: auto;
}

.mobile-nav-item {
    margin-bottom: 15px;
}

.mobile-nav-link {
    font-size: 1.1rem;
    color: #2d3748;
    text-decoration: none;
    font-weight: 500;
    display: block;
}

.mobile-sub-menu {
    margin-left: 15px;
    border-left: 2px solid #eee;
    padding-left: 15px;
    margin-top: 8px;
}

/* --- Sidebar --- */
/* --- Sidebar --- */
.sidebar-sticky {
    position: sticky;
    top: 90px;
    height: fit-content;
}

/* Disable sticky sidebar on mobile */
@media (max-width: 768px) {
    .sidebar-sticky {
        position: static;
        top: auto;
    }
}

.sidebar-widget {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid #edf2f7;
}

.sidebar-widget h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #edf2f7;
    color: #2d3748;
}

/* Widget Lists */
.widget-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget-list li {
    margin-bottom: 10px;
}

.widget-list a {
    text-decoration: none;
    color: #4a5568;
    transition: color 0.15s;
    display: flex;
    justify-content: space-between;
}

.widget-list a:hover {
    color: var(--primary-color);
}

.widget-list span.count {
    background: #edf2f7;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    color: #718096;
}