/* Table of Contents and Reading Progress Styles */

/* Reading Progress Bar */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
    transition: width 0.1s ease;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    z-index: 9999;
}

/* Table of Contents Container - Fixed Position */
#toc-container {
    position: fixed;
    top: 6rem;
    right: 2rem;
    width: 16rem;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #4b5563 #1f2937;
    z-index: 40;
    animation: fadeInRight 0.5s ease-out;
}

/* RTL - Fixed on the left side */
html[lang="ar"] #toc-container {
    right: auto;
    left: 2rem;
    animation: fadeInLeft 0.5s ease-out;
}

/* Fade in animations */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#toc-container::-webkit-scrollbar {
    width: 6px;
}

#toc-container::-webkit-scrollbar-track {
    background: #1f2937;
    border-radius: 3px;
}

#toc-container::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
}

#toc-container::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* TOC Links */
#table-of-contents a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #9ca3af;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.2s;
    font-size: 0.875rem;
    line-height: 1.4;
    border-radius: 0.25rem;
}

#table-of-contents a:hover {
    color: #60a5fa;
    background-color: rgba(59, 130, 246, 0.1);
    border-left-color: #60a5fa;
}

#table-of-contents a.active {
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.15);
    border-left-color: #3b82f6;
    font-weight: 600;
}

/* Indent for different heading levels */
#table-of-contents a.toc-h2 {
    padding-left: 0.75rem;
}

#table-of-contents a.toc-h3 {
    padding-left: 1.5rem;
    font-size: 0.8125rem;
}

#table-of-contents a.toc-h4 {
    padding-left: 2.5rem;
    font-size: 0.75rem;
    color: #6b7280;
}

/* RTL Support for TOC */
#table-of-contents.rtl a {
    border-left: none;
    border-right: 2px solid transparent;
    text-align: right;
}

#table-of-contents.rtl a:hover,
#table-of-contents.rtl a.active {
    border-left: none;
    border-right-color: #60a5fa;
}

#table-of-contents.rtl a.active {
    border-right-color: #3b82f6;
}

/* RTL Indent */
#table-of-contents.rtl a.toc-h2 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

#table-of-contents.rtl a.toc-h3 {
    padding-left: 0.75rem;
    padding-right: 1.5rem;
}

#table-of-contents.rtl a.toc-h4 {
    padding-left: 0.75rem;
    padding-right: 2.5rem;
}

/* TOC Background */
.toc-sidebar {
    background-color: rgba(17, 24, 39, 0.7);
    border: 1px solid rgba(75, 85, 99, 0.3);
    backdrop-filter: blur(10px);
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Responsive adjustments */
@media (max-width: 1280px) {
    #toc-container {
        display: none !important;
    }
}

/* On larger screens, add margin to content to avoid overlap with fixed TOC */
@media (min-width: 1280px) {
    .article-main-content {
        margin-right: 18rem; /* Make space for fixed TOC on the right */
    }
    
    html[lang="ar"] .article-main-content {
        margin-right: 0;
        margin-left: 18rem; /* Make space for fixed TOC on the left (RTL) */
    }
}

