/* ============================================================
   TABLE OF CONTENTS
   ============================================================ */

.toc-aside {
    /* توی سایدبار */
    flex-shrink: 0;
}

.toc-sticky {
    position: sticky;
    top: 90px;
    background: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
	font-size: 12.5px;
}

.toc-sticky::-webkit-scrollbar {
    width: 6px;
}
.toc-sticky::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

.toc-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #F1F5F9;
}

.toc-icon {
    font-size: 18px;
}

.toc-title {
    font-size: 14px;
    font-weight: 700;
    color: #0F172A;
    margin: 0;
    flex: 1;
}

.toc-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #94A3B8;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.toc-toggle:hover {
    background: #F1F5F9;
    color: #0F172A;
}

.toc-arrow {
    display: inline-block;
    transition: transform 0.2s;
}

.toc-collapsed .toc-arrow {
    transform: rotate(-90deg);
}

.toc-collapsed .toc-nav {
    display: none;
}

.toc-nav {
    font-size: 13px;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: toc-counter;
}

.toc-item {
    margin: 0;
    counter-increment: toc-counter;
}

.toc-item a {
    display: block;
    padding: 6px 8px;
    border-radius: 6px;
    color: #475569;
    text-decoration: none;
    line-height: 1.5;
    transition: all 0.15s;
    border-left: 2px solid transparent;
	font-size: 12.5px;
}

.toc-item a:hover {
    background: #F8FAFC;
    color: #2563EB;
}

.toc-item a.toc-active {
    background: #EFF6FF;
    color: #2563EB;
    border-left-color: #2563EB;
    font-weight: 600;
}

/* Level 2 */
.toc-h2 a {
    padding-left: 10px;
    font-weight: 600;
    color: #1E293B;
}

.toc-h2 a::before {
    content: counter(toc-counter) ". ";
    color: #94A3B8;
    font-weight: 700;
    margin-right: 4px;
}

/* Level 3 */
.toc-h3 a {
    padding-left: 24px;
    font-size: 12px;
    color: #64748B;
}

.toc-h3 a::before {
    content: "○ ";
    color: #CBD5E1;
    margin-right: 4px;
}

/* RTL support */
[dir="rtl"] .toc-item a {
    border-left: none;
    border-right: 2px solid transparent;
}

[dir="rtl"] .toc-item a.toc-active {
    border-right-color: #2563EB;
}

[dir="rtl"] .toc-h3 a {
    padding-left: 10px;
    padding-right: 28px;
}

/* Mobile: hide sticky */
@media (max-width: 900px) {
    .toc-aside {
        display: none;
    }
}