.sidebar-navigation {
    position: fixed;
    left: 0;
    top: 72px;
    width: 240px;
    height: calc(100vh - 72px);
    border-right: 1px solid #e5e7eb;
    overflow: hidden;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    background-color: #eef4ff;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Sidebar open — works on all screen sizes */
.sidebar-navigation.open {
    transform: translateX(0);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

/* Close (X) button inside the sidebar */
.sidebar-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: #6b7280;
    font-size: 18px;
    transition: background-color 0.2s ease, color 0.2s ease;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-close-btn:hover {
    background-color: #e9f4ff;
    color: #1f2937;
}

.sidebar-close-btn:focus-visible {
    outline: 2px solid #0b66c3;
    outline-offset: 2px;
}

/* Backdrop overlay when sidebar is open (all screen sizes) */
body.sidebar-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 998;
        background: rgba(0,0,0,0.01); /* transparent overlay, adjust if needed */
        pointer-events: none; /* default: do not block input */
}

@media (max-width: 991px) {
    body.sidebar-open::before {
        pointer-events: auto; /* block input only on mobile */
        background: rgba(0,0,0,0.2); /* optional: dim background on mobile */
    }
}

/* Main container — transition margin when sidebar pushes on desktop */
.pcoded-main-container {
    transition: margin-left 0.3s ease;
    margin-left: 80px;
}

body.sidebar-open .pcoded-main-container {
    margin-left: 264px;
 
}

.sub-page-sb {
    top: 0px !important;
    height: 100vh;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 0 12px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 8px 12px;
    margin: 0 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    background: none;
    border: none;
    color: #6b7280;
    text-align: left;
    width: calc(100% - 24px);

}

.menu-item:hover {
    background-color: #e9f4ff;
    color: #1f2937;
    transform: translateX(4px);
}

.menu-item.active {
    color: #0b66c3;
    background-color: #eff6ff;
}

.menu-item.expandable {
    justify-content: space-between;
}

.menu-item-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-icon {
    font-size: 16px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}

.expand-icon {
    font-size: 14px;
    transition: transform 0.2s ease;
}

.menu-section-title {
    color: #9ca3af;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 16px 24px 8px 24px;
}

.submenu {
    border-left: 2px solid #e5e7eb;
    padding-left: 12px;
    margin: 4px 0 0 36px;
    display: none;
}

.submenu.open {
    display: block;
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    margin-bottom: 2px;
    background: none;
    border: none;
    color: #6b7280;
    text-align: left;
    width: 100%;
}

.submenu-item:hover {
    background-color: #f3f4f6;
    color: #1f2937;
    transform: translateX(2px);
}

.submenu-item.active {
    color: #0b66c3;
    background-color: #eff6ff;
}

.sidebar-external-links {
    flex-shrink: 0;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
}

.sidebar-external-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.sidebar-external-btn:hover {
    background-color: #f9fafb;
    color: #1f2937;
    border-color: #d1d5db;
}

.sidebar-external-btn.active {
    background-color: #eff6ff;
    color: #0b66c3;
    border-color: #bfdbfe;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
}

/* On desktop: float the hamburger as a fixed toggle button */
@media (min-width: 992px) {
    .sidebar-header {
        position: fixed;
        top: 14px;
        left: 14px;
        padding: 4px;
        z-index: 1001;
    }

    /* Hide the logo in sidebar-header on desktop (sidebar has its own logo) */
    .sidebar-header > a {
        display: none;
    }
}

/* Prevent hamburger from overlapping page headings on desktop when sidebar is closed */
@media (min-width: 992px) {
    /* Only apply offset when sidebar is not open (hamburger visible) */
    body:not(.sidebar-open) .pcoded-main-container .page-header,
    body:not(.sidebar-open) .pcoded-main-container .main-title,
    body:not(.sidebar-open) .pcoded-main-container .page-block {
        margin-left: 0px; /* hamburger width (36px) + spacing */
    }

    /* Also nudge the page content wrapper to keep consistent alignment */
    body:not(.sidebar-open) .pcoded-main-container .pcoded-wrapper {
        padding-left: 0; /* ensure wrapper doesn't add unexpected padding */
    }
}

/* Hide sidebar-header when sidebar is open — X button inside handles close */
body.sidebar-open .sidebar-header {
    display: none;
}

/* Hamburger toggle button — always visible */
.mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    padding: 6px;
    z-index: 1001;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: background-color 0.2s ease;
}

.mobile-menu-toggle:hover {
    background-color: #f3f4f6;
}

.mobile-menu-toggle:focus-visible {
    outline: 2px solid #0b66c3;
    outline-offset: 2px;
}


.hamburger-line {
    width: 18px;
    height: 2px;
    background-color: #0B66C3;
    border-radius: 2px;
    display: block;
    transition: all 0.3s ease;
}

@media (max-width: 991px) {
    .sidebar-header {
        padding: 16px;
        position: static;
    }

    .sidebar-header > a {
        display: inline-block;
    }

    /* Prevent body scroll when sidebar is open on mobile */
    body.sidebar-open {
        overflow: hidden;
    }

    /* No margin shift on mobile — sidebar overlays */
    body.sidebar-open .pcoded-main-container {
        margin-left: 0 !important;
    }

    .pcoded-main-container {
        margin-left: 0 !important;
    }
}
