/**
 * Component: Table of Contents (TOC)
 * Premium SaaS UI/UX
 */

.content-toc-wrapper {
    margin: var(--space-6) 0;
    width: 100%;
}

.content-toc {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition-base);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    /* Reduced width for cleaner SaaS look */
    max-width: 500px;
    width: 100%;
}

.toc-header-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 18px;
    /* More compact */
    background: rgba(255, 255, 255, 0.02);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    color: var(--text-primary);
}

.toc-header-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.toc-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.toc-header-left strong {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
}

.toc-icon {
    width: 18px;
    height: 18px;
    color: var(--brand-primary);
    flex-shrink: 0;
}

.toc-chevron {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: transform var(--transition-base);
    flex-shrink: 0;
}

.toc-header-toggle[aria-expanded="true"] .toc-chevron {
    transform: rotate(180deg);
}

.toc-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.toc-body.expanded {
    /* Max height to prevent hero pushing */
    max-height: 240px;
    overflow-y: auto;
}

/* Custom Scrollbar for TOC */
.toc-body::-webkit-scrollbar {
    width: 4px;
}

.toc-body::-webkit-scrollbar-track {
    background: transparent;
}

.toc-body::-webkit-scrollbar-thumb {
    background: var(--brand-primary);
    border-radius: 10px;
    opacity: 0.5;
}

.toc-list {
    list-style: none;
    padding: 0 var(--space-4) var(--space-4);
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* More compact */
}

.toc-link {
    display: block;
    padding: 6px 10px;
    /* More compact */
    color: var(--text-secondary);
    font-size: 13px;
    /* Slightly smaller */
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-link:hover {
    background: var(--glass-bg-hover);
    color: var(--brand-primary);
    padding-left: 14px;
}

/* Visibility Control in Hero */
.toc-desktop-only {
    display: block;
    margin-top: var(--space-6);
}

.toc-mobile-only {
    display: none;
}

@media (max-width: 1024px) {
    .toc-desktop-only {
        display: none;
    }

    .toc-mobile-only {
        display: block;
        margin-top: var(--space-2);
        margin-bottom: var(--space-6);
    }

    .content-toc-wrapper {
        margin: 0;
    }

    .content-toc {
        max-width: none;
        background: var(--bg-surface);
        border: 1px solid var(--border-subtle);
        border-radius: 14px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    }

    .toc-header-toggle {
        padding: 12px 16px;
        background: transparent;
    }

    .toc-header-left strong {
        font-size: 14px;
        font-weight: 700;
        color: var(--text-primary);
    }

    .toc-icon {
        width: 14px;
        height: 14px;
        opacity: 0.7;
    }

    .toc-list {
        padding: 4px 8px 12px;
        gap: 0;
    }

    .toc-link {
        padding: 12px 14px;
        font-size: 13.5px;
        font-weight: 500;
        border-radius: 10px;
        margin: 0;
        border-bottom: 1px solid var(--border-subtle);
    }

    .toc-list li:last-child .toc-link {
        border-bottom: none;
    }

    .toc-link:hover {
        background: var(--bg-surface-hover);
        padding-left: 16px;
    }

    /* Light Mode Specifics for Mobile TOC */
    [data-theme="light"] .content-toc {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.08);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02), 0 10px 20px -5px rgba(0, 0, 0, 0.03);
    }

    [data-theme="light"] .toc-header-toggle {
        background: #ffffff;
    }

    [data-theme="light"] .toc-header-left strong {
        color: #0f172a;
    }

    [data-theme="light"] .toc-link {
        color: #64748b;
        border-color: #f8fafc;
    }

    [data-theme="light"] .toc-link:hover {
        background: #f8fafc;
        color: var(--brand-primary);
        border-color: rgba(168, 85, 247, 0.1);
    }
}

/* Sidebar Specifics */
.single-content-sidebar .content-toc-wrapper {
    position: sticky;
    top: calc(70px + var(--space-8));
    width: 100%;
    margin-top: 0;
}