/* Fix right sidebar (table of contents) scrolling */
.md-sidebar--secondary {
    height: calc(100vh - 5.6rem) !important;
}

.md-sidebar__scrollwrap {
    max-height: 100% !important;
    overflow-y: auto !important;
}

/* Ensure TOC is scrollable */
.md-nav__list {
    overflow-y: auto !important;
}

/* Add padding to bottom of TOC to ensure last items are visible */
.md-sidebar--secondary .md-sidebar__scrollwrap {
    padding-bottom: 2rem;
}

/* Smooth scrolling for TOC */
.md-sidebar__scrollwrap {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.md-sidebar__scrollwrap::-webkit-scrollbar {
    width: 6px;
}

.md-sidebar__scrollwrap::-webkit-scrollbar-track {
    background: transparent;
}

.md-sidebar__scrollwrap::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.md-sidebar__scrollwrap::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Fix for dark mode */
[data-md-color-scheme="slate"] .md-sidebar__scrollwrap {
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

[data-md-color-scheme="slate"] .md-sidebar__scrollwrap::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
}

[data-md-color-scheme="slate"] .md-sidebar__scrollwrap::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}
