/* Left navigation and navigation tree styles */

/* Left navigation container */
.left-nav {
    position: sticky;
    top: 6rem;
    align-self: start;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-soft);
    padding: 0 1rem;
}

.left-nav ul li,
.left-nav ol li {
    list-style: none;
}

.left-nav h6 {
    margin: 4px 0 .75rem 0;
    font-weight: 600;
}

/* Tree */
.toc-tree {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.toc-tree li {
    margin: .125rem 0;
}

/* Wrapper to align link text and chevron */
.toc-item-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toc-tree a {
    font-size: 14px;
    display: block;
    padding: .375rem .5rem;
    color: inherit;
    text-decoration: none;
    /* take remaining space, keep chevron on the right */
    flex: 1 1 auto;
}

.toc-tree a:hover {
    background: rgba(127, 127, 127, .10);
}

.toc-tree a.active {
    background: rgba(127, 127, 127, .18);
    border-left: 3px solid var(--brand-color);
}

/* Chevron icon */
.toc-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 16px;
    color: var(--pico-muted-color, #6b7280);
    margin-bottom: 1px;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .2s ease;
}

.toc-chevron.expanded {
    transform: rotate(90deg);
}

/* Nested groups are hidden by default; shown when parent is expanded */
.toc-tree .toc-group {
    margin-left: 0.75rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--border-soft);
    display: none;
}

.toc-tree li:has(.toc-chevron.expanded)>.toc-group,
.toc-tree li:has(.toc-chevron.expanded)>ul.toc-tree {
    display: block;
}

.toc-tree .chevron-icon {
    width: 20px;
    height: 20px;
}

/* Mobile Navigation Toggle Button */
.mobile-nav-toggle {
    display: none;
    position: sticky;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    box-shadow: var(--pico-box-shadow);
    transition: all 0.2s ease;
    color: var(--pico-primary);
    width: max-content;
}

.mobile-nav-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--pico-primary);
}

/* Responsive */
@media (max-width: 768px) {

    /* Show mobile toggle button */
    .mobile-nav-toggle {
        display: block;
    }

    /* Hide navigation panel by default on mobile */
    .left-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-panel);
        border-right: 1px solid var(--border-soft);
        padding: 1rem;
        z-index: 999;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    /* Show navigation when active */
    .left-nav.active {
        left: 0;
    }

    /* Add overlay when navigation is open */
    .nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Adjust main container for mobile */
    .main-container {
        grid-template-columns: 1fr;
        padding-left: 0;
    }

    /* Add padding to content when navigation is open */
    .content-body {
        transition: margin-left 0.3s ease;
    }
}