/* TOC Styling */
.toc-wrapper { 
    transition: all 0.3s ease;
}
.toc-header { cursor: pointer; user-select: none; }
.toc-header:hover { background-color: #f1f3f4 !important; }
.toc-toggle-icon.collapsed { transform: rotate(180deg); }
.toc-body { transition: max-height 0.3s ease-out, opacity 0.3s ease; overflow: hidden; }
.toc-body.collapsed { max-height: 0; padding-top: 0 !important; padding-bottom: 0 !important; border-top: none !important; opacity: 0; }

/* Custom Scrollbar for TOC */
.toc-wrapper::-webkit-scrollbar { width: 4px; }
.toc-wrapper::-webkit-scrollbar-track { background: #f1f1f1; }
.toc-wrapper::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }
.toc-wrapper::-webkit-scrollbar-thumb:hover { background: #999; }

.toc-nav ul { list-style: none; padding-left: 0; margin-bottom: 0; }
.toc-nav ul ul { padding-left: 1.5rem; margin-top: 0.5rem; }
.toc-nav li { margin-bottom: 0.5rem; }
.toc-nav li:last-child { margin-bottom: 0; }

.toc-link { 
    display: block; 
    color: #5f6368; 
    text-decoration: none; 
    font-size: 14px; 
    line-height: 1.5;
    transition: all 0.2s ease;
    padding: 4px 8px;
    border-radius: 4px;
}
.toc-link:hover { color: var(--primary-color); background-color: rgba(var(--primary-color-rgb), 0.05); }
.toc-link.active { 
    color: var(--primary-color); 
    background-color: rgba(var(--primary-color-rgb), 0.08); 
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
    padding-left: 5px;
}

/* Scroll Margin to prevent header overlap */
h2, h3 { scroll-margin-top: 100px; }

@media (max-width: 991.98px) {
    .toc-wrapper {
        position: static;
        max-height: none;
        overflow: visible;
        margin-bottom: 2rem;
    }
}

/* Horizontal TOC Styling */
.horizontal-toc { 
    z-index: 1040; 
    transition: transform 0.3s ease-in-out;
    transform: translateY(-100%);
    background-color: var(--bg-white) !important;
}
.horizontal-toc.show { 
    transform: translateY(0);
    display: block !important;
}

@media (max-width: 991.98px) {
    .horizontal-toc {
        top: 85px; /* Sit below the mobile fixed header */
    }
}
@media (min-width: 992px) {
    .horizontal-toc {
        top: 0; /* Sit at very top since header is static on desktop */
    }
}

.noscrollbar::-webkit-scrollbar { display: none; }
.noscrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.toc-chip {
    white-space: nowrap;
    padding: 6px 16px;
    border-radius: 50px;
    border: 1px solid #dadce0;
    color: #3c4043;
    font-size: 14px;
    text-decoration: none !important;
    transition: all 0.2s ease;
}
.toc-chip:hover { background-color: #f8f9fa; border-color: #bdc1c6; color: var(--primary-color); }
.toc-chip.active { 
    background-color: rgba(var(--primary-color-rgb), 0.1); 
    border-color: var(--primary-color); 
    color: var(--primary-color);
    font-weight: 500;
}
