/**
 * TOC Widget – Frontend CSS
 * Include file này trong trang bài viết để mục lục hiển thị đẹp.
 * Frontend cần thêm JS (toc.js) để xử lý scan heading, smooth scroll.
 *
 * Ẩn toolbar overlay (.toc-tools) trên frontend.
 */

/* === Container === */
.toc-widget {
    position: relative;
    width: 100%;
    /* max-width: 720px; */
    margin: 24px auto;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.toc-widget * {
    box-sizing: border-box;
}

/* Ẩn toolbar overlay trên frontend */
.toc-tools {
    display: none !important;
}

/* === Header === */
.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
}

.toc-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toc-title::before {
    content: "📑";
    font-size: 18px;
}

.toc-toggle {
    background: none;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: #64748b;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toc-toggle:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

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

/* === Body === */
.toc-body {
    padding: 12px 20px 16px;
    transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.35s ease;
    overflow: hidden;
}

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

/* === List === */
.toc-list {
    list-style: none;
    margin: 0 !important;
    padding: 0 !important;
}

.toc-list li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.toc-list>li {
    margin-bottom: 2px;
}

.toc-list a {
    display: block;
    padding: 6px 12px;
    border-radius: 6px;
    color: #334155;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.15s;
}

.toc-list a:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.toc-list a.active {
    background: #eef2ff;
    color: #4a7dff;
    font-weight: 600;
}

/* Nested */
.toc-list ul {
    list-style: none;
    margin: 2px 0 2px 0;
    padding-left: 20px;
}

.toc-list ul>li>a {
    font-size: 13px;
    color: #64748b;
    padding: 4px 12px;
}

.toc-list ul>li>a:hover {
    color: #334155;
    background: #f1f5f9;
}

/* H4 nested */
.toc-list ul ul>li>a {
    font-size: 12.5px;
    color: #78859b;
    padding: 3px 12px;
}

/* H5 nested */
.toc-list ul ul ul>li>a {
    font-size: 12px;
    color: #8c96a6;
    padding: 3px 12px;
}

/* H6 nested */
.toc-list ul ul ul ul>li>a {
    font-size: 11.5px;
    color: #97a0ae;
    padding: 2px 12px;
}

/* Empty state */
.toc-empty {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
    font-size: 13px;
    font-style: italic;
}

/* === Responsive === */
@media (max-width: 640px) {
    .toc-widget {
        margin: 16px 8px;
        border-radius: 8px;
    }

    .toc-header {
        padding: 14px 16px 10px;
    }

    .toc-title {
        font-size: 15px;
    }

    .toc-body {
        padding: 10px 16px 14px;
    }

    .toc-list a {
        font-size: 13px;
        padding: 5px 10px;
    }

    .toc-list ul>li>a {
        font-size: 12px;
    }
}