/**
 * Smart TOC - Frontend Styles
 *
 * @package Anik_Smart_TOC
 */

/* TOC Container */
.smart-toc {
    background: #f8f9fa;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    margin: 20px 0 30px;
    max-width: 100%;
    font-size: 15px;
    line-height: 1.6;
}

/* TOC Header */
.smart-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #e2e4e7;
    border-radius: 8px 8px 0 0;
    border-left: 4px solid #0073aa;
}

.smart-toc.collapsed .smart-toc-header {
    border-bottom: none;
    border-radius: 8px;
}

.smart-toc-title {
    font-weight: 600;
    font-size: 16px;
    color: #1e1e1e;
    margin: 0;
}

/* Toggle Button */
.smart-toc-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.smart-toc-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.smart-toc-toggle:hover .toggle-icon {
    border-top-color: #0073aa;
}

.smart-toc-toggle:focus {
    outline: none;
    box-shadow: none;
}

.smart-toc-toggle:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.toggle-icon {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #555;
    transition: transform 0.3s ease, border-top-color 0.2s ease;
}

.smart-toc.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* TOC Body */
.smart-toc-body {
    padding: 15px 20px;
    transition: all 0.3s ease;
}

.smart-toc.collapsed .smart-toc-body {
    display: none;
}

/* TOC List */
.smart-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.smart-toc-list .toc-item {
    margin: 0;
    padding: 0;
}

.smart-toc-list .toc-item > a {
    display: block;
    padding: 8px 12px;
    color: #0073aa;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.smart-toc-list .toc-item > a:hover {
    background: rgba(0, 115, 170, 0.08);
    color: #005177;
}

.smart-toc-list .toc-item > a:focus {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

.smart-toc-list .toc-item > a.active {
    background: #0073aa;
    color: #fff;
    font-weight: 500;
}

/* Heading Level Indentation */
.toc-level-2 > a {
    padding-left: 12px;
}

.toc-level-3 > a {
    padding-left: 28px;
    font-size: 14px;
}

.toc-level-4 > a {
    padding-left: 44px;
    font-size: 13px;
}

.toc-level-5 > a {
    padding-left: 60px;
    font-size: 13px;
}

.toc-level-6 > a {
    padding-left: 76px;
    font-size: 12px;
}

/* TOC Numbers */
.toc-number {
    font-weight: 600;
    color: inherit;
    margin-right: 4px;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .smart-toc {
        margin: 15px 0 25px;
        font-size: 14px;
    }

    .smart-toc-header {
        padding: 12px 15px;
    }

    .smart-toc-title {
        font-size: 15px;
    }

    .smart-toc-body {
        padding: 12px 15px;
        max-height: 350px;
    }

    .smart-toc-list .toc-item > a {
        padding: 7px 10px;
    }

    .toc-level-3 > a {
        padding-left: 22px;
    }

    .toc-level-4 > a {
        padding-left: 34px;
    }

    .toc-level-5 > a {
        padding-left: 46px;
    }

    .toc-level-6 > a {
        padding-left: 58px;
    }
}

/* Print Styles */
@media print {
    .smart-toc {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .smart-toc-toggle {
        display: none;
    }

    .smart-toc.collapsed .smart-toc-body {
        display: block;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .smart-toc-body,
    .toggle-icon,
    .smart-toc-list .toc-item > a {
        transition: none;
    }
}

/* ===================== */
/* TOC Theme: Light      */
/* ===================== */
.smart-toc.toc-theme-light {
    background: #fff;
    border: 1px solid #e8e8e8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.smart-toc.toc-theme-light .smart-toc-header {
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.smart-toc.toc-theme-light .smart-toc-body {
    background: #fff;
}

/* ===================== */
/* TOC Theme: Dark       */
/* ===================== */
.smart-toc.toc-theme-dark {
    background: #1e1e2e;
    border: 1px solid #2d2d3f;
}

.smart-toc.toc-theme-dark .smart-toc-header {
    background: #252537;
    border-bottom: 1px solid #2d2d3f;
}

.smart-toc.toc-theme-dark .smart-toc-title {
    color: #e0e0e0;
}

.smart-toc.toc-theme-dark .toggle-icon {
    border-top-color: #a0a0b0;
}

.smart-toc.toc-theme-dark .smart-toc-list .toc-item > a {
    color: #8ec8f0;
}

.smart-toc.toc-theme-dark .smart-toc-list .toc-item > a:hover {
    background: rgba(142, 200, 240, 0.1);
    color: #b0dcf8;
}

.smart-toc.toc-theme-dark .smart-toc-list .toc-item > a.active {
    background: #3a7bd5;
    color: #fff;
}

/* ===================== */
/* TOC Theme: Minimal    */
/* ===================== */
.smart-toc.toc-theme-minimal {
    background: transparent;
    border: none;
    border-radius: 0;
}

.smart-toc.toc-theme-minimal .smart-toc-header {
    background: transparent;
    border-bottom: 1px solid #ddd;
    border-left: none;
    border-radius: 0;
    padding-left: 0;
}

.smart-toc.toc-theme-minimal.collapsed .smart-toc-header {
    border-bottom: none;
}

.smart-toc.toc-theme-minimal .smart-toc-body {
    padding-left: 0;
    padding-right: 0;
}

.smart-toc.toc-theme-minimal .smart-toc-list .toc-item > a {
    border-radius: 0;
    border-left: none;
}
