.blue-sticky-toc {
    background: #fff;
    border-radius: 8px;
    padding-top: 20px;
    margin: 20px 0;
    transition: all 0.3s ease;
    z-index: 999;
    width: 300px;
}

/* Position styles */
.blue-sticky-toc.position-inline {
    position: relative;
    display: block;
    clear: both;
}

.blue-sticky-toc.position-fixed {
    position: sticky;
    top: var(--sticky-offset, 100px);
    align-self: flex-start;
    max-height: calc(100vh - var(--sticky-offset, 100px));
}

.blue-sticky-toc.position-fixed.position-left {
    left: 30px;
    right: auto;
}

.blue-sticky-toc.position-fixed.position-right {
    right: 30px;
    left: auto;
}

.blue-sticky-toc-title {
    font-size: 30px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.blue-sticky-toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.blue-sticky-toc-list::-webkit-scrollbar {
    width: 4px;
}

.blue-sticky-toc-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.blue-sticky-toc-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.blue-sticky-toc-item {
    position: relative;
    margin: 8px 0;
    padding-left: 15px;
    transition: all 0.2s ease;
}

.blue-sticky-toc-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: transparent;
    transition: background-color 0.2s ease;
}

.blue-sticky-toc-item a {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    display: block;
    padding: 5px 0;
    transition: color 0.2s ease;
}

.blue-sticky-toc-item a:hover {
    color: #333;
}

.blue-sticky-toc-item.active a {
    color: var(--active-color, #3174cc);
    font-weight: 600;
}

.blue-sticky-toc-item.active::before {
    background-color: var(--active-color, #3174cc);
}

/* Indent levels */
.blue-sticky-toc-item[data-level="2"] { padding-left: 25px; }
.blue-sticky-toc-item[data-level="3"] { padding-left: 35px; }
.blue-sticky-toc-item[data-level="4"] { padding-left: 45px; }
.blue-sticky-toc-item[data-level="5"] { padding-left: 55px; }
.blue-sticky-toc-item[data-level="6"] { padding-left: 65px; }

/* Smooth scroll behavior for the entire page */
html {
    scroll-behavior: smooth;
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
    .blue-sticky-toc {
        width: 100% !important;
    }
    .blue-sticky-toc-title {
    font-size: 18px;
    }
    
    .blue-sticky-toc.position-fixed {
        position: relative;
        top: 0;
        left: 0 !important;
        right: 0 !important;
        margin: 20px 0;
        max-height: none;
    }
}

/* Responsive styles */
@media (max-width: 1024px) {
    .blue-sticky-toc {
        width: 250px !important;
    }
}

@media (max-width: 768px) {
    .blue-sticky-toc {
        width: 100% !important;
    }

    .toc-sticky {
        max-height: inherit !important;
        height: auto !important; /* Override the height:100% for mobile */
    }
    
    .blue-sticky-toc.position-fixed {
        position: relative;
        top: 0;
        left: 0 !important;
        right: 0 !important;
        margin: 20px 0;
        max-height: none;
        height: auto !important; /* Override the height:100% for mobile */
    }
}

.blue-toc-sticky-container {
    display: flex;
    align-items: flex-start;
}

.blue-toc-sticky-container .blue-sticky-toc.position-fixed {
    position: sticky;
    top: var(--sticky-offset, 100px);
    align-self: flex-start;
    height: 100%; /* Keep this for desktop */
}

.toc-sticky-container {
    display: flex;
    align-items: flex-start;
    position: relative;
    width: 100%;
    gap: 32px;
}

.toc-sticky {
    position: sticky;
    height: 100%; /* Keep this for desktop */
    flex: 0 0 290px;
    z-index: 2;
    background: #fff;
    border-radius: 8px;
    top: 16px;
}

.toc-sticky::-webkit-scrollbar {
    width: 1px;
    background: transparent;
}

.toc-sticky::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 0.5px;
}

.toc-sticky:not(:hover)::-webkit-scrollbar-thumb {
    background: transparent;
}

.toc-sticky:hover::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
}

.toc-sticky {
    scrollbar-width: none;
}

.toc-content {
    flex: 1 1 0%;
}

@media (max-width: 767px) {
    .toc-sticky-container {
        display: block;
    }

    .toc-sticky {
        position: relative;
        top: 0;
        width: 100%;
        height: auto !important; /* Override height:100% for mobile */
        max-height: none !important; /* Remove height restrictions on mobile */
    }

    .toc-content {
        margin-top: 20px;
    }
    
    /* Additional mobile override to ensure no height conflicts */
    .blue-toc-sticky-container .blue-sticky-toc.position-fixed {
        height: auto !important; /* Override height:100% for mobile */
    }
    
}
.blue-sticky-toc-list.stopped {
    position:static !important;
}
.blue-sticky-toc-list.visible{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #fff;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding: 10px;
    gap: 10px;
    scrollbar-width: thin;
    z-index: 999;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 26px !important;
    transition: top 0.3s ease, margin-top 0.3s ease;
}

/* Dynamic positioning when search bar is visible */
.blue-sticky-toc-list.visible.search-bar-active {
    top: 130px !important; /* Decreased from 150px to 130px to reduce gap */
    margin-top: 0 !important;
    z-index: 998; /* Below search bar but above other content */
}

/* Ensure smooth transitions for position changes */
.blue-sticky-toc-list.visible {
    transition: top 0.3s ease, margin-top 0.3s ease;
}

/* Mobile-specific adjustments for search bar interaction */
@media (max-width: 767px) {
    .blue-sticky-toc-list.visible.search-bar-active {
        top: 130px !important; /* Decreased from 140px to 130px */
        margin-top: 0 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    
 /* Hide TOC when search is active on mobile */
    body.global-search-active .blue-sticky-toc-list.visible {
        top: 130px !important;
        margin-top: 0 !important;
        visibility: hidden;
}
    
    /* Prevent layout shifts during transitions */
    .blue-sticky-toc-list.visible {
        will-change: top, margin-top;
        transform: translateZ(0); /* Force hardware acceleration */
    }
}

.blue-sticky-toc-list.visible .blue-sticky-toc-item[data-level="2"]{
    display: inline-block;
    flex: 0 0 auto;
    padding: 5px 10px;
    background: #f5f5f5;
    border-radius: 4px;
    white-space: nowrap;
    margin: 0 5px;
}

.blue-sticky-toc-list.stopped {
    display: none !important; /* Use !important if necessary to override other styles */
    /* Or, if you want it to smoothly slide out, you could use: */
    /* opacity: 0; */
    /* pointer-events: none; */
    /* transition: opacity 0.3s ease-out; */
}

/* Fix mobile menu overlap with horizontal TOC */
@media (max-width: 767px) {
 /* When hamburger menu is open, hide the horizontal TOC */
    body.ast-main-header-nav-open .blue-sticky-toc-list.visible {
        display: none !important;
    }
}