/* =============================================
   MỤC LỤC BÀI VIẾT (Table of Contents)
   File: themes/style2025/css/toc.css
   ============================================= */

/* --- Wrapper --- */
.nv-toc {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #ff6700;
    border-radius: 6px;
    margin: 0 0 24px 0;
    font-size: 14px;
    line-height: 1.6;
}

/* --- Header (click để toggle) --- */
.nv-toc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.nv-toc__header:hover {
    background: #f0f0f0;
    border-radius: 5px 5px 0 0;
}

.nv-toc__title {
    font-weight: 700;
    color: #333;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nv-toc__title::before {
    content: "☰";
    font-size: 16px;
    color: #ff6700;
}

.nv-toc__toggle {
    color: #888;
    font-size: 12px;
    transition: transform 0.3s ease;
    display: inline-block;
    flex-shrink: 0;
}

.nv-toc__toggle::after {
    content: "▲";
}

.nv-toc.is-collapsed .nv-toc__toggle::after {
    content: "▼";
}

/* --- Body (danh sách mục lục) --- */
.nv-toc__body {
    padding: 0 16px 14px 16px;
    border-top: 1px solid #e8e8e8;
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.3s ease;
    max-height: 1500px;
    opacity: 1;
}

.nv-toc.is-collapsed .nv-toc__body {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-color: transparent;
}

/* --- Danh sách --- */
.nv-toc__list {
    list-style: none;
    margin: 10px 0 0 0;
    padding: 0;
    counter-reset: toc-h2;
}

.nv-toc__list li {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* H2 - cấp 1 */
.nv-toc__item--h2 {
    counter-increment: toc-h2;
    counter-reset: toc-h3;
}

.nv-toc__item--h2 > a {
    display: block;
    padding: 5px 0 5px 4px;
    color: #222;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px dashed #e8e8e8;
    transition: color 0.2s;
}

.nv-toc__item--h2 > a::before {
    content: counter(toc-h2) ". ";
    color: #ff6700;
    font-weight: 700;
    min-width: 24px;
    display: inline-block;
}

.nv-toc__item--h2 > a:hover {
    color: #ff6700;
    text-decoration: none;
}

/* H3 - cấp 2 (sub-list) */
.nv-toc__sublist {
    list-style: none;
    margin: 0;
    padding: 0 0 0 20px;
    counter-reset: toc-h3;
}

.nv-toc__item--h3 {
    counter-increment: toc-h3;
}

.nv-toc__item--h3 > a {
    display: block;
    padding: 4px 0 4px 4px;
    color: #555;
    font-weight: 400;
    text-decoration: none;
    border-bottom: 1px dashed #efefef;
    transition: color 0.2s;
}

.nv-toc__item--h3 > a::before {
    content: counter(toc-h2) "." counter(toc-h3) " ";
    color: #aaa;
    font-size: 12px;
    min-width: 30px;
    display: inline-block;
}

.nv-toc__item--h3 > a:hover {
    color: #ff6700;
    text-decoration: none;
}

/* H4 - cấp 3 */
.nv-toc__subsublist {
    list-style: none;
    margin: 0;
    padding: 0 0 0 20px;
}

.nv-toc__item--h4 > a {
    display: block;
    padding: 3px 0 3px 4px;
    color: #888;
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s;
}

.nv-toc__item--h4 > a::before {
    content: "–  ";
    color: #ccc;
}

.nv-toc__item--h4 > a:hover {
    color: #ff6700;
    text-decoration: none;
}

/* --- Anchor highlight khi scroll đến --- */
.nv-toc-heading-anchor {
    display: block;
    position: relative;
    top: -80px; /* offset cho fixed header */
    visibility: hidden;
}

/* --- Responsive --- */
@media (max-width: 576px) {
    .nv-toc {
        font-size: 13px;
    }
    .nv-toc__item--h2 > a,
    .nv-toc__item--h3 > a {
        padding: 6px 0 6px 4px;
    }
}
