/* ============================================
   TOC Elementor Widget - Complete Styles
   ============================================ */

/* ── Base ── */
.toc-widget {
    --toc-accent: #2563eb;
    --toc-text: #2d3436;
    --toc-text-muted: #636e72;
    --toc-bg: #ffffff;
    --toc-header-bg: #ffffff;
    --toc-border: #e2e8e7;
    --toc-link: #2d3436;
    --toc-link-hover: var(--toc-accent);
    --toc-link-active: var(--toc-accent);
    --toc-radius: 8px;
    --toc-font-size: 13px;
    --toc-indent: 14px;

    direction: rtl;
    text-align: right;
    font-family: 'Vazirmatn', 'Vazir', 'IRANSans', Tahoma, sans-serif;
    background-color: var(--toc-bg);
    border: none;
    border-radius: var(--toc-radius);
    overflow: hidden;
    box-shadow: none !important;
    transition: none !important;
}

.toc-widget:hover {
    box-shadow: none !important;
}

/* ── Preset Themes ── */

.toc-preset-dark {
    --toc-bg: #1e2330;
    --toc-header-bg: #161b28;
    --toc-border: #2d3555;
    --toc-text: #e0e6f0;
    --toc-text-muted: #8892b0;
    --toc-link: #ccd6f6;
    --toc-link-hover: var(--toc-accent);
}

.toc-preset-green {
    --toc-accent: #2563eb;
    --toc-bg: #f0faf9;
    --toc-header-bg: #e0f5f3;
    --toc-border: #b2ddd9;
    --toc-link: #004d47;
    --toc-link-hover: #2563eb;
}

.toc-preset-blue {
    --toc-accent: #2980b9;
    --toc-bg: #f0f7ff;
    --toc-header-bg: #dbeafe;
    --toc-border: #bfdbfe;
    --toc-link: #1e3a5f;
    --toc-link-hover: #2980b9;
}

.toc-preset-minimal {
    --toc-bg: transparent;
    --toc-header-bg: transparent;
    --toc-border: transparent;
    --toc-link: #555;
    box-shadow: none !important;
}

.toc-preset-minimal .toc-header {
    border-bottom: 2px solid var(--toc-accent);
    padding: 0 0 8px 0;
}

.toc-preset-minimal:hover {
    box-shadow: none !important;
}

/* ── Progress Bar ── */
.toc-progress-bar {
    height: 3px;
    background: var(--toc-border);
    position: relative;
    overflow: hidden;
}

.toc-progress-fill {
    height: 100%;
    background: var(--toc-accent);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 0 3px 3px 0;
}

/* ── Header ── */
.toc-header {
    background-color: var(--toc-header-bg);
    border-bottom: 1px solid var(--toc-border);
}

.toc-header-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
}

.toc-header-icon {
    color: var(--toc-accent);
    font-size: 14px;
    flex-shrink: 0;
}

.toc-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--toc-text);
    flex: 1;
    letter-spacing: -0.01em;
}

.toc-reading-time {
    font-size: 11px;
    color: var(--toc-text-muted);
    background: var(--toc-border);
    padding: 2px 7px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ── Toggle Button — دایره‌ای ── */
.toc-toggle {
    background: #00746a00;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2563eb;
    transition: background 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

.toc-toggle:hover {
   
    
}

.toc-toggle-icon {
    transition: transform 0.3s ease;
    flex-shrink: 0;
    display: block;
	color: #2563eb;
}

.toc-widget.toc-collapsed .toc-toggle-icon {
    transform: rotate(-90deg);
}

/* ── Body ── */
.toc-body {
    padding: 12px 14px;
    transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}

.toc-widget.toc-collapsed .toc-body {
    max-height: 0 !important;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

/* ── Nav ── */
.toc-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-nav li {
    margin-bottom: 4px;
    position: relative;
    transition: all 0.2s;
}

.toc-nav a {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    color: var(--toc-link);
    text-decoration: none;
    font-size: var(--toc-font-size);
    line-height: 1.6;
    padding: 4px 8px 4px 4px;
    border-radius: 5px;
    border-right: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.toc-nav a:hover {
    color: var(--toc-link-hover);
    background: #dbeafe;
    text-decoration: none;
}

/* ── Depth Indentation ── */
.toc-nav .toc-depth-2 a {
    padding-right: calc(var(--toc-indent) + 8px);
    font-size: calc(var(--toc-font-size) - 1px);
}

.toc-nav .toc-depth-3 a {
    padding-right: calc(var(--toc-indent) * 2 + 8px);
    font-size: calc(var(--toc-font-size) - 1px);
    color: var(--toc-text-muted);
}

.toc-nav .toc-depth-4 a {
    padding-right: calc(var(--toc-indent) * 3 + 8px);
    font-size: calc(var(--toc-font-size) - 1px);
    color: var(--toc-text-muted);
}

/* ── List Style: Bullet ── */
.toc-widget[data-list-style="bullet"] .toc-nav a::before {
    content: '●';
    color: var(--toc-accent);
    font-size: 6px;
    margin-top: 7px;
    flex-shrink: 0;
    opacity: 0.6;
}

.toc-widget[data-list-style="bullet"] .toc-nav .toc-depth-2 a::before {
    content: '○';
}

.toc-widget[data-list-style="bullet"] .toc-nav .toc-depth-3 a::before {
    content: '▸';
    font-size: 8px;
}

/* ── List Style: Arrow ── */
.toc-widget[data-list-style="arrow"] .toc-nav a::before {
    content: '◄';
    color: var(--toc-accent);
    font-size: 8px;
    margin-top: 5px;
    flex-shrink: 0;
}

/* ── List Style: Dash ── */
.toc-widget[data-list-style="dash"] .toc-nav a::before {
    content: '─';
    color: var(--toc-accent);
    font-size: 10px;
    flex-shrink: 0;
}

/* ── List Style: Dot ── */
.toc-widget[data-list-style="dot"] .toc-nav a::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--toc-accent);
    flex-shrink: 0;
    margin-top: 7px;
}

/* ── Numbering ── */
.toc-num {
    color: var(--toc-accent);
    font-weight: 600;
    flex-shrink: 0;
    font-size: 11px;
    margin-top: 1px;
    font-variant-numeric: tabular-nums;
}

/* ── Copy Link Button ── */
.toc-copy-btn {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    opacity: 0;
    color: var(--toc-text-muted);
    font-size: 11px;
    transition: opacity 0.2s;
    border-radius: 4px;
}

.toc-nav li:hover .toc-copy-btn {
    opacity: 1;
}

.toc-copy-btn:hover {
    background: var(--toc-border);
    color: var(--toc-accent);
}

.toc-copy-btn.copied::after {
    content: '✓';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toc-accent);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
}

/* ── Active Indicator: Border Right ── */
.toc-widget[data-active-indicator="border_right"] .toc-nav li.active > a {
    color: var(--toc-link-active);
    font-weight: 600;
    border-right-color: var(--toc-accent);
    background: rgba(0,116,107,0.06);
}

/* ── Active Indicator: Border Left ── */
.toc-widget[data-active-indicator="border_left"] .toc-nav li.active > a {
    color: var(--toc-link-active);
    font-weight: 600;
    border-left: 3px solid var(--toc-accent);
    border-right: none;
}

/* ── Active Indicator: Background ── */
.toc-widget[data-active-indicator="background"] .toc-nav li.active > a {
    color: var(--toc-link-active);
    background: rgba(0,116,107,0.10);
    border-radius: 5px;
}

/* ── Active Indicator: Bold ── */
.toc-widget[data-active-indicator="bold"] .toc-nav li.active > a {
    color: var(--toc-link-active);
    font-weight: 700;
}

/* ── Active Indicator: Underline ── */
.toc-widget[data-active-indicator="underline"] .toc-nav li.active > a {
    color: var(--toc-link-active);
    text-decoration: underline;
    text-decoration-color: var(--toc-accent);
}

/* ── Back to Top ── */
.toc-back-to-top {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    padding: 6px 10px;
    background: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: var(--toc-text-muted);
    font-size: 11px;
    font-family: inherit;
    transition: all 0.2s ease;
    width: 100%;
    justify-content: center;
}

.toc-back-to-top:hover {
    background: var(--toc-accent);
    color: #fff;
    border-color: var(--toc-accent);
}

/* ── Sticky ── */
.toc-sticky {
    position: sticky;
    z-index: 100;
}

/* ── Empty ── */
.toc-empty-msg {
    font-size: 12px;
    color: var(--toc-text-muted);
    text-align: center;
    padding: 8px 0;
    font-style: italic;
}

/* ── Animations ── */
@keyframes toc-fade-in {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.toc-nav li {
    animation: toc-fade-in 0.2s ease forwards;
}

.toc-nav li:nth-child(1)  { animation-delay: 0.02s; }
.toc-nav li:nth-child(2)  { animation-delay: 0.04s; }
.toc-nav li:nth-child(3)  { animation-delay: 0.06s; }
.toc-nav li:nth-child(4)  { animation-delay: 0.08s; }
.toc-nav li:nth-child(5)  { animation-delay: 0.10s; }
.toc-nav li:nth-child(6)  { animation-delay: 0.12s; }
.toc-nav li:nth-child(7)  { animation-delay: 0.14s; }
.toc-nav li:nth-child(8)  { animation-delay: 0.16s; }
.toc-nav li:nth-child(9)  { animation-delay: 0.18s; }
.toc-nav li:nth-child(10) { animation-delay: 0.20s; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .toc-body {
        padding: 10px 12px;
    }
    .toc-header-inner {
        padding: 9px 12px;
    }
}

/* ── Dark Mode ── */
@media (prefers-color-scheme: dark) {
    .toc-widget:not([class*="toc-preset-"]) {
        --toc-bg: #1a1f2e;
        --toc-header-bg: #141824;
        --toc-border: #2d3555;
        --toc-text: #e0e6f0;
        --toc-text-muted: #8892b0;
        --toc-link: #ccd6f6;
    }
}

/* ── Elementor Editor Preview ── */
.elementor-editor-active .toc-body {
    max-height: 9999px !important;
    opacity: 1 !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}
