/* ===== TWO-DRAWER NAVIGATION SYSTEM ===== */

/* Container for both drawers */
.nav-container {
    display: flex;
    height: 100%;
    position: relative;
}

/* ===== LEVEL-1 DRAWER (LEFT) ===== */
.nav-level1-drawer {
    width: 200px;
    min-width: 200px;
    background: var(--sidebar-bg, #1e3a8a);
    color: var(--nav-text, white);
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    transition: width 0.3s ease, min-width 0.3s ease;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--nav-border, rgba(255, 255, 255, 0.1));
}

.nav-level1-drawer.collapsed {
    width: 60px;
    min-width: 60px;
}

/* Level-1 Item Button */
.nav-level1-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 8px;
    border: none;
    background: none;
    color: var(--nav-text, rgba(255, 255, 255, 0.9));
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 400;
    border-bottom: 1px solid var(--nav-border, rgba(255, 255, 255, 0.1));
    text-align: left;
    min-height: 42px;
}

.nav-level1-item:hover {
    background: var(--nav-hover-bg, rgba(255, 255, 255, 0.1));
    color: var(--nav-text, white);
}

.nav-level1-item.active,
.nav-level1-item.selected {
    background: var(--nav-active-bg, rgba(255, 255, 255, 0.15));
    color: var(--nav-text, white);
    font-weight: 500;
    border-left: 3px solid #60a5fa;
}

.nav-level1-item .nav-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.nav-level1-item .nav-icon-initials {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.nav-level1-item .nav-text {
    flex: 1;
    white-space: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
    line-height: 1.3;
}

.nav-level1-item .nav-chevron {
    flex-shrink: 0;
    margin-left: auto;
    opacity: 0.7;
    font-size: 10px;
}

/* Collapsed state */
.nav-level1-drawer.collapsed .nav-level1-item {
    padding: 16px 8px;
    justify-content: center;
}

.nav-level1-drawer.collapsed .nav-level1-item .nav-text {
    display: none;
}

.nav-level1-drawer.collapsed .nav-level1-item .nav-icon,
.nav-level1-drawer.collapsed .nav-level1-item .nav-icon-initials {
    margin: 0 auto;
}

/* ===== LEVEL-2 DRAWER (RIGHT) ===== */
.nav-level2-drawer {
    width: 250px;
    background: white;
    border-left: 1px solid #e5e7eb;
    border-right: 2px solid #d1d5db;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    animation: slideInFromRight 0.3s ease;
    transition: width 0.3s ease;
    position: relative;
    z-index: 10;
}

.nav-level2-drawer.collapsed {
    width: 60px;
    min-width: 60px;
    overflow-x: visible;
}

.nav-level2-drawer.collapsed .nav-level2-item {
    padding: 16px 8px;
    justify-content: center;
}

.nav-level2-drawer.collapsed .nav-level2-item .nav-text {
    display: none;
}

.nav-level2-drawer.collapsed .nav-level2-item .nav-icon-initials {
    margin: 0 auto;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    background: #e5e7eb;
    border-radius: 4px;
    color: #374151;
}

    .nav-level2-drawer.collapsed .nav-level2-item.active .nav-icon-initials {
        background: #1049AE;
        color: white;
    }

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Collapse button positioned on right edge of Level-2 drawer */

.nav-level2-collapse-btn {
    position: sticky;
    top: 12px;
    align-self: flex-end;
    margin-right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 10;
    flex-shrink: 0;
}
.nav-level2-collapse-btn:hover {
    background: white;
    color: #374151;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.nav-level2-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Level-2 Items Container */
.nav-level2-items {
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    padding: 8px 0; /* No extra top padding needed */
}

.nav-level2-drawer.collapsed .nav-level2-items {
    overflow: visible;
}

/* Level-2 Item Button */
.nav-level2-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 20px;
    border: none;
    background: none;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 400;
    text-align: left;
    border-left: 3px solid transparent;
}
    .nav-level2-item:hover {
        background: #e8f4fc;
        color: #1049AE;
    }

    .nav-level2-item.active {
        background: #e8f4fc;
        color: #1049AE;
        font-weight: 600;
        border-left-color: #1049AE;
    }
 
.nav-level2-item.expanded {
    background: #f9fafb;
    color: #374151;
    font-weight: 500;
}

.nav-level2-item .nav-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Level-2 Group (wrapper for level 2 button + its level 3 children) */
.nav-level2-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
}

/* Flyout panel for level 3 items in collapsed mode */
.nav-level3-flyout {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 180px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    flex-direction: column;
    overflow: hidden;
}

.nav-level2-group.has-children:hover .nav-level3-flyout {
    display: flex;
}

.nav-level3-flyout-header {
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    /*text-transform: uppercase;*/
    letter-spacing: 0.05em;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

/* Level-3 items inside flyout use same button style */
.nav-level3-flyout .nav-level3-item {
    padding: 10px 16px;
    border-left: none;
    font-size: 12px;
    color: #374151;
}

.nav-level3-flyout .nav-level3-item:hover {
    background: #eff6ff;
    color: #2563eb;
}

/* Root-level flyout for collapsed L2 drawer — uses position:fixed to escape overflow clipping */
.nav-level3-root-flyout {
    position: fixed;
    grid-column: unset !important;
    grid-row: unset !important;
    left: 120px; /* overridden by inline style */
    top: 0; /* overridden by inline style */
    min-width: 180px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.nav-level3-root-flyout .nav-level3-flyout-header {
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
   /* text-transform: uppercase;*/
    letter-spacing: 0.05em;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.nav-level3-root-flyout .nav-level3-item {
    padding: 10px 16px;
    border-left: 3px solid transparent;
    font-size: 12px;
    color: #374151;
    display: flex;
    align-items: center;
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.nav-level3-root-flyout .nav-level3-item:hover {
    background: #e8f0fe;
    color: #1d4ed8;
    border-left-color: #93c5fd;
}

.nav-level3-root-flyout .nav-level3-item.active {
    background: #e8f0fe;
    color: #1d4ed8;
    font-weight: 600;
    border-left-color: #2563eb;
}

/* Chevron icon for expandable level 2 items */
.nav-level2-item .nav-chevron {
    margin-left: auto;
    font-size: 10px;
    color: #9ca3af;
    transition: transform 0.2s;
}

.nav-level2-item.expanded .nav-chevron {
    color: #1049AE;
}

/* Level-3 Items Container */
.nav-level3-items {
    display: flex;
    flex-direction: column;
    background: #f3f4f6;
    border-left: 3px solid #e5e7eb;
    margin-left: 16px;
}

/* Level-3 Item Button */
.nav-level3-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 9px 16px 9px 20px;
    border: none;
    background: none;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 400;
    text-align: left;
    border-left: 3px solid transparent;
}

.nav-level3-item:hover {
    background: #e8f0fe;
    color: #1d4ed8;
    border-left-color: #93c5fd;
}

.nav-level3-item.active {
    background: #e8f0fe;
    color: #1d4ed8;
    font-weight: 600;
    border-left-color: #2563eb;
}

.nav-level3-item .nav-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== HIERARCHICAL MENU FILTERING — DISABLED STATE ===== */
.nav-level3-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    color: #9ca3af;
}

.nav-level3-item:disabled:hover {
    background: none;
    border-left-color: transparent;
    color: #9ca3af;
}

.nav-level2-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    color: #9ca3af;
}

.nav-level2-item:disabled:hover {
    background: none;
    border-left-color: transparent;
    color: #9ca3af;
}
/* ===== END HIERARCHICAL MENU FILTERING ===== */

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .nav-level1-drawer {
        position: fixed;
        top: 64px;
        left: 0;
        z-index: 1000;
        height: calc(100vh - 64px);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .nav-level1-drawer.mobile-visible {
        transform: translateX(0);
    }

    .nav-level2-drawer {
        position: fixed;
        top: 64px;
        left: 200px;
        z-index: 999;
        height: calc(100vh - 64px);
    }

    .nav-level1-drawer.collapsed + .nav-level2-drawer {
        left: 60px;
    }
}

/* ===== SCROLLBAR STYLING ===== */
.nav-level1-drawer::-webkit-scrollbar,
.nav-level2-drawer::-webkit-scrollbar,
.nav-level2-items::-webkit-scrollbar {
    width: 6px;
}

.nav-level1-drawer::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.nav-level1-drawer::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.nav-level1-drawer::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav-level2-drawer::-webkit-scrollbar-track,
.nav-level2-items::-webkit-scrollbar-track {
    background: #f9fafb;
}

.nav-level2-drawer::-webkit-scrollbar-thumb,
.nav-level2-items::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.nav-level2-drawer::-webkit-scrollbar-thumb:hover,
.nav-level2-items::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}
