/*
 * Premium Table of Contents Styles
 * Brand: NguyenThaiMMO
 */

:root {
    --ntm-primary: #ff5a7a;
    --ntm-primary-light: #fff5f7;
    --ntm-text-dark: #1f2937;
    --ntm-text-gray: #6b7280;
    --ntm-border: #e5e7eb;
    --ntm-bg-light: #f9fafb;
    --ntm-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --ntm-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.ntm-static-toc,
.ntm-sticky-toc,
.ntm-static-toc *,
.ntm-sticky-toc * {
    box-sizing: border-box !important;
}

/* Static TOC */
.ntm-static-toc {
    border: 1px solid var(--ntm-border);
    border-radius: 16px;
    margin: 32px 0;
    background: var(--ntm-bg-light);
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--ntm-shadow);
}

.ntm-static-toc-header {
    background: #fff;
    padding: 16px 20px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--ntm-text-dark);
    font-size: 1.1rem;
    transition: background 0.2s ease;
}

.ntm-static-toc-header:hover {
    background: #fafafa;
}

.ntm-static-toc-header .ntm-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ntm-static-toc-header i.fa-list-ul {
    color: var(--ntm-primary);
}

.ntm-toggle-icon {
    transition: transform 0.3s ease;
    font-size: 0.9rem;
    color: var(--ntm-text-gray);
}

/* Collapsed State */
.ntm-static-toc.ntm-collapsed .ntm-static-toc-body {
    display: none;
}

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

.ntm-static-toc-body {
    max-height: 500px;
    overflow-y: auto;
    padding: 12px;
    border-top: 1px solid var(--ntm-border);
    background: #fff;
}

.ntm-static-toc-body ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.ntm-static-toc-body li {
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.ntm-static-toc-body li a {
    color: var(--ntm-text-gray);
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.4;
}

.ntm-static-toc-body li.h2 {
    font-weight: 600;
    color: var(--ntm-text-dark);
}

.ntm-static-toc-body li.h3 {
    padding-left: 24px;
    font-size: 14px;
}

.ntm-static-toc-body li:hover a {
    background: var(--ntm-primary-light);
    color: var(--ntm-primary);
    transform: translateX(4px);
}

.ntm-static-toc-body li.active a {
    background: var(--ntm-primary-light);
    color: var(--ntm-primary);
    border-left: 4px solid var(--ntm-primary);
    font-weight: 700;
}

/* Sticky TOC - Adjusted Position to avoid Header */
.ntm-sticky-toc {
    position: fixed;
    top: 90px;
    /* Increased to avoid covering header */
    left: 50%;
    transform: translateX(-50%);
    width: 880px;
    /* Match content area more closely */
    max-width: calc(100% - 32px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid var(--ntm-border);
    box-shadow: var(--ntm-shadow-lg);
    z-index: 9999;
    display: none;
    animation: ntmFadeInDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ntmFadeInDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.ntm-sticky-toc.active {
    display: block;
}

.ntm-sticky-header {
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.ntm-sticky-title {
    font-weight: 700;
    color: var(--ntm-text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 75%;
    font-size: 15px;
}

.ntm-sticky-toggle {
    background: var(--ntm-primary);
    color: #fff;
    border: none;
    padding: 5px 15px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ntm-sticky-toggle:hover {
    background: #e44d6a;
    transform: scale(1.05);
}

.ntm-sticky-body {
    display: none;
    padding: 0 16px 16px;
    max-height: 60vh;
    overflow-y: auto;
    border-top: 1px solid var(--ntm-border);
    margin-top: 4px;
}

.ntm-sticky-toc.open .ntm-sticky-body {
    display: block;
}

.ntm-sticky-body ul {
    list-style: none !important;
    padding: 8px 0 !important;
    margin: 0 !important;
}

.ntm-sticky-body li {
    padding: 4px 0;
}

.ntm-sticky-body li a {
    color: var(--ntm-text-gray);
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.ntm-sticky-body li.h3 {
    padding-left: 20px;
}

.ntm-sticky-body li:hover a,
.ntm-sticky-body li.active a {
    background: var(--ntm-primary-light);
    color: var(--ntm-primary);
    font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ntm-sticky-toc {
        top: 70px !important;
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        max-width: 100% !important;
    }

    .ntm-sticky-header {
        padding: 2px 15px !important;
    }

    .ntm-sticky-title {
        font-size: 13px;
        max-width: 70%;
    }

    .ntm-sticky-toggle {
        padding: 5px 12px;
        font-size: 11px;
    }
}