.custom-toc-wrapper {
    position: sticky;
    top: 120px;
    z-index: 999;
   font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}
.custom-toc-wrapper.custom-toc-right {
    right: 20px;
}
.custom-toc-container {
    direction: rtl;
}
#sidebar .custom-toc-sublist{
    /* margin-left: -15px; */
}
#sidebar .custom-toc-sublist li a{
/*     padding-left: 30px; */
}
.custom-toc-header {
    display: none;
    align-items: center;
    padding: 16px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    cursor: pointer;
    user-select: none;
}
.custom-toc-icon {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    color: #ffffff;
    flex-shrink: 0;
}
.custom-toc-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex-grow: 1;
    color: #ffffff;
}
.custom-toc-toggle {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}
.custom-toc-toggle:hover {
    transform: scale(1.1);
}
.custom-toc-container.collapsed .custom-toc-toggle .toggle-icon {
    transform: rotate(90deg);
}
.custom-toc-list{
    position: relative;
}
.custom-toc-list::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 100%;
    background: #E9E9E9;
    border-radius: 50px;
}
.custom-toc-link.active::before {
    content: '';
    position: absolute;
    left: -17px;
    top: 1px;
    transform: translateY(-50%);
    width: 6px;
    height: 100%;
    background: #2A2A2A;
    animation: pulse 2s infinite;
    border-radius: 50px;
}
.custom-toc-list::-webkit-scrollbar {
    width: 8px;
    background: #E9E9E9;
}
.custom-toc-list::-webkit-scrollbar-track {
    border-radius: 10px;
    margin-top: 15px;
}
.custom-toc-list::-webkit-scrollbar-thumb{
    background: #191919;
    height: 40px;
    border-radius: 10px;
}
.custom-toc-container.collapsed .custom-toc-content {
    max-height: 0;
    padding: 0 18px;
    overflow: hidden;
}
/* Custom scrollbar */
.custom-toc-content::-webkit-scrollbar {
    width: 6px;
}
.custom-toc-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}
.custom-toc-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}
.custom-toc-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
.custom-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    direction: ltr;
}
.custom-toc-item {
    margin: 0;
    padding: 0;
    line-height: 1.6;
}
.custom-toc-link {
    display: block;
    padding: 8px 0;
    padding-left: 12px;
    color: #4b5563;
    text-decoration: none;
    font-size: 14px;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}
.custom-toc-link:hover {
    color: #667eea;
    background-color: #f9fafb;
    padding-left: 16px;
}
.custom-toc-link.active {
    color: #667eea;
    font-weight: 600;
    background-color: transparent;
}
/* Nested levels */
.custom-toc-sublist {
    list-style: none;
    margin: 0;
    padding: 0;
    padding-left: 16px;
}
.custom-toc-level-3 .custom-toc-link {
    font-size: 13px;
    font-weight: 400;
}
.custom-toc-level-4 .custom-toc-link,
.custom-toc-level-5 .custom-toc-link,
.custom-toc-level-6 .custom-toc-link {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.9;
}
/* Mobile responsive */
@media (max-width: 1400px) {
    .custom-toc-wrapper {
        position: relative;
        width: 100%;
        max-width: 100%;
        top: 0;
        right: 0;
        left: 0;
        margin: 20px 0;
    }    
    .custom-toc-container {
        max-width: 100%;
    }
}
@media (max-width: 768px) {
    .custom-toc-wrapper {
        margin: 15px 0;
    }    
    .custom-toc-header {
        padding: 14px 16px;
    }    
    .custom-toc-content {
        padding: 14px 16px;
    }    
    .custom-toc-link {
        font-size: 13px;
        padding: 6px 0;
        padding-left: 10px;
    }
}
/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}
/* Animation for active state */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}
/* Print styles */
@media print {
    .custom-toc-wrapper {
        display: none;
    }
}
