/* ===================================
   TABLE OF CONTENTS (TOC)
   Sticky sidebar navigation
   =================================== */

#toc-container {
    position: sticky;
    top: 100px;
    background: var(--bg-secondary);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    margin: 2rem 0;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: none; /* Hidden by default, shown by JS if enough headings */
}

#toc-container.toc-closed .toc-content {
    display: none;
}

.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toc-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-title i {
    color: var(--primary-color);
}

.toc-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
}

.toc-toggle:hover {
    background: rgba(0, 229, 255, 0.1);
    border-color: rgba(0, 229, 255, 0.3);
    color: var(--primary-color);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin: 0;
}

.toc-item-nested {
    margin-left: 1.25rem;
}

.toc-link {
    display: block;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.3s ease;
    border-radius: 6px;
    margin-bottom: 0.25rem;
}

.toc-link:hover {
    color: var(--primary-color);
    background: rgba(0, 229, 255, 0.08);
    border-left-color: var(--primary-color);
    transform: translateX(4px);
}

.toc-link.active {
    color: var(--primary-color);
    background: rgba(0, 229, 255, 0.12);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

/* Custom Scrollbar for TOC */
#toc-container::-webkit-scrollbar {
    width: 6px;
}

#toc-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 3px;
}

#toc-container::-webkit-scrollbar-thumb {
    background: rgba(0, 229, 255, 0.3);
    border-radius: 3px;
}

#toc-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 229, 255, 0.5);
}

/* ===================================
   Responsive
   =================================== */

@media (max-width: 1024px) {
    #toc-container {
        display: none !important; /* Hide on smaller screens */
    }
}

/* ===================================
   Light Mode
   =================================== */

body.light-mode #toc-container {
    background: #ffffff;
    border-color: rgba(0, 133, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

body.light-mode .toc-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .toc-title {
    color: #050505;
}

body.light-mode .toc-toggle {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
    color: #4a5568;
}

body.light-mode .toc-toggle:hover {
    background: rgba(0, 133, 255, 0.1);
    border-color: rgba(0, 133, 255, 0.3);
    color: #0085ff;
}

body.light-mode .toc-link {
    color: #4a5568;
}

body.light-mode .toc-link:hover {
    color: #0085ff;
    background: rgba(0, 133, 255, 0.08);
    border-left-color: #0085ff;
}

body.light-mode .toc-link.active {
    color: #0085ff;
    background: rgba(0, 133, 255, 0.12);
    border-left-color: #0085ff;
}

body.light-mode #toc-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}

body.light-mode #toc-container::-webkit-scrollbar-thumb {
    background: rgba(0, 133, 255, 0.3);
}

body.light-mode #toc-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 133, 255, 0.5);
}

