/* =====================================================
   Thắng Tin Smart TOC - Frontend CSS
   v1.1.16
   Mục tiêu:
   - Tiêu đề luôn đồng bộ ở cả trạng thái ẩn/hiện.
   - Chỉ dòng mô tả "Xem nhanh nội dung bài viết" là chữ nhỏ/in nghiêng.
   - Mục con H3 lùi vào trong và nhỏ hơn H2, không làm H2 bị đậm quá.
===================================================== */

.tt-light-toc {
    --tt-toc-blue: #1e96f2;
    --tt-toc-blue-dark: #0b84e5;
    --tt-toc-orange: #ff642f;
    --tt-toc-text: #0f172a;
    --tt-toc-muted: #64748b;
    --tt-toc-soft: #f8fbff;
    --tt-toc-border: #d8eafe;

    position: relative;
    width: 100%;
    margin: 22px 0 24px;
    padding: 18px 20px 18px 24px;
    border: 1px solid var(--tt-toc-border);
    border-radius: 12px;
    background: linear-gradient(180deg, var(--tt-toc-soft) 0%, #ffffff 100%);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    transition: padding .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.tt-light-toc::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--tt-toc-blue), var(--tt-toc-orange));
}

.tt-toc__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 14px;
}

.tt-toc__title-wrap {
    min-width: 0;
    max-width: calc(100% - 170px);
}

.tt-toc__title {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 3px !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--tt-toc-text) !important;
    text-align: left !important;
    white-space: normal !important;
}

.tt-toc__title-main {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--tt-toc-text) !important;
    font-size: 18px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    letter-spacing: -0.01em;
}

.tt-toc__subtitle-inline {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--tt-toc-muted) !important;
    font-size: 13px !important;
    font-style: italic !important;
    font-weight: 400 !important;
    line-height: 1.35 !important;
}

/* Không dùng subtitle cũ để tránh trùng dòng. */
.tt-toc__subtitle {
    display: none !important;
}

.tt-toc__toggle,
.tt-toc__more {
    appearance: none;
    font-family: inherit;
    cursor: pointer;
}

.tt-toc__toggle {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 13px;
    border: 1px solid var(--tt-toc-border);
    border-radius: 9px;
    background: #ffffff;
    color: #334155;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.10);
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.tt-toc__toggle:hover {
    background: #eef7ff;
    border-color: #b9dcff;
    color: var(--tt-toc-blue-dark);
    box-shadow: 0 5px 14px rgba(30, 150, 242, 0.16);
    transform: translateY(-1px);
}

.tt-toc__toggle-icon {
    position: relative;
    display: inline-block;
    width: 15px;
    height: 15px;
}

.tt-toc__toggle-icon::before,
.tt-toc__toggle-icon::after {
    content: "";
    position: absolute;
    left: 2px;
    top: 7px;
    width: 11px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform .18s ease;
}

.tt-toc__toggle-icon::after {
    transform: rotate(90deg);
}

.tt-light-toc:not(.tt-toc--closed) .tt-toc__toggle-icon::after {
    transform: rotate(0deg);
}

.tt-toc__body {
    display: block;
    margin-top: 8px;
}

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

.tt-toc__item {
    margin: 0;
    padding: 0;
}

.tt-toc__link {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border-radius: 8px;
    color: #26364d;
    text-decoration: none;
    line-height: 1.45;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.tt-toc__link:hover {
    background: #eef7ff;
    color: var(--tt-toc-blue-dark);
    transform: translateX(3px);
}

.tt-toc__number {
    flex: 0 0 32px;
    min-width: 32px;
    color: #475569;
    font-weight: 400;
    text-align: right;
}

.tt-toc__text {
    min-width: 0;
    font-weight: 400;
}

/* H2: mục chính */
.tt-toc__item--h2 .tt-toc__link {
    padding-left: 10px;
    font-size: 15px;
}

.tt-toc__item--h2 .tt-toc__text {
    color: #1f2f46;
    font-weight: 400;
}

/* H3: mục con dạng flat, lùi nhẹ vào trong, không dùng border-left */
.tt-toc__item--h3 .tt-toc__link {
    margin-left: 34px;
    width: calc(100% - 34px);
    padding: 5px 10px;
    border: 0;
    background: transparent;
    font-size: 13.5px;
    color: #53647a;
}

.tt-toc__item--h3 .tt-toc__number {
    flex-basis: 36px;
    min-width: 36px;
    color: #64748b;
    font-size: 13px;
    font-weight: 400;
}

.tt-toc__item--h3 .tt-toc__text {
    color: #53647a;
    font-size: 13.5px;
    font-weight: 400;
}

.tt-toc__item--extra {
    display: none;
}

.tt-light-toc.tt-toc--expanded .tt-toc__item--extra {
    display: list-item;
}

.tt-toc__footer {
    margin-top: 10px;
}

.tt-toc__more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid #b9dcff;
    border-radius: 999px;
    background: #eef7ff;
    color: var(--tt-toc-blue-dark);
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
}

.tt-toc__more:hover {
    background: #e3f2ff;
}

/* Trạng thái ẩn: vẫn giữ đủ title + subtitle, chỉ ẩn body/footer. */
.tt-light-toc.tt-toc--closed {
    padding-top: 14px;
    padding-bottom: 14px;
}

.tt-light-toc.tt-toc--closed .tt-toc__head {
    align-items: center;
    margin-bottom: 0;
}

.tt-light-toc.tt-toc--closed .tt-toc__body,
.tt-light-toc.tt-toc--closed .tt-toc__footer {
    display: none !important;
}

/* Tùy chọn ẩn Easy TOC cũ nếu còn bật plugin cũ. */
body.tt-smart-toc-hide-old #ez-toc-container,
body.tt-smart-toc-hide-old .ez-toc-container,
body.tt-smart-toc-hide-old .lwptoc,
body.tt-smart-toc-hide-old .rank-math-toc-block,
body.tt-smart-toc-hide-old .wp-block-rank-math-toc-block {
    display: none !important;
}

/* Offset khi bấm anchor để không bị header che. */
.tt-toc-anchor-target {
    scroll-margin-top: 110px;
}

@media (max-width: 849px) {
    .tt-light-toc {
        margin: 20px 0 22px;
        padding: 16px 14px 16px 18px;
        border-radius: 10px;
    }

    .tt-toc__head {
        gap: 12px;
    }

    .tt-toc__title-wrap {
        max-width: calc(100% - 128px);
    }

    .tt-toc__title-main {
        font-size: 17px !important;
    }

    .tt-toc__subtitle-inline {
        font-size: 12.5px !important;
    }

    .tt-toc__toggle {
        min-height: 32px;
        padding: 0 11px;
        font-size: 12.5px;
    }

    .tt-toc__item--h2 .tt-toc__link {
        font-size: 14px;
        padding: 7px 8px;
    }

    .tt-toc__item--h3 .tt-toc__link {
        margin-left: 24px;
        width: calc(100% - 24px);
        padding: 5px 8px;
        border: 0;
        font-size: 13.5px;
    }

    .tt-toc__number {
        flex-basis: 28px;
        min-width: 28px;
    }

    .tt-toc__item--h3 .tt-toc__number {
        flex-basis: 34px;
        min-width: 34px;
    }
}

@media (max-width: 549px) {
    .tt-toc__head {
        align-items: flex-start;
    }

    .tt-toc__title-wrap {
        max-width: calc(100% - 104px);
    }

    .tt-toc__toggle-text {
        max-width: 70px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}


/* =====================================================
   v1.1.16 - Chuẩn hóa tiêu đề/mô tả + căn giữa khối
   Mục tiêu:
   - Chỉ "Mục lục" là chữ lớn/đậm.
   - "Xem nhanh nội dung bài viết" luôn là chữ nhỏ, mảnh, in nghiêng.
   - Căn giữa theo chiều dọc phần nội dung và nút ở cả trạng thái ẩn/hiện.
===================================================== */
body .tt-light-toc {
    padding: 16px 20px 16px 24px !important;
}

body .tt-light-toc .tt-toc__head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
    min-height: 42px !important;
    margin: 0 0 14px 0 !important;
}

body .tt-light-toc.tt-toc--closed .tt-toc__head {
    margin-bottom: 0 !important;
}

body .tt-light-toc .tt-toc__title-wrap {
    display: flex !important;
    align-items: center !important;
    min-height: 42px !important;
    max-width: calc(100% - 170px) !important;
}

body .tt-light-toc .tt-toc__title {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 3px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left !important;
    white-space: normal !important;
}

body .tt-light-toc .tt-toc__title-main {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #0f172a !important;
    font-size: 18px !important;
    font-style: normal !important;
    font-weight: 800 !important;
    line-height: 1.16 !important;
    letter-spacing: -0.01em !important;
}

body .tt-light-toc .tt-toc__subtitle-inline,
body .tt-light-toc .tt-toc__title .tt-toc__subtitle-inline {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #64748b !important;
    font-size: 13px !important;
    font-style: italic !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

body .tt-light-toc .tt-toc__toggle {
    align-self: center !important;
    min-height: 34px !important;
    height: 34px !important;
    margin: 0 !important;
}

body .tt-light-toc.tt-toc--closed {
    padding-top: 14px !important;
    padding-bottom: 14px !important;
}

body .tt-light-toc.tt-toc--closed .tt-toc__title-wrap,
body .tt-light-toc.tt-toc--closed .tt-toc__title {
    min-height: 40px !important;
}

@media (max-width: 849px) {
    body .tt-light-toc {
        padding: 14px 14px 14px 18px !important;
    }

    body .tt-light-toc .tt-toc__head {
        min-height: 40px !important;
        gap: 12px !important;
    }

    body .tt-light-toc .tt-toc__title-wrap {
        min-height: 40px !important;
        max-width: calc(100% - 126px) !important;
    }

    body .tt-light-toc .tt-toc__title {
        min-height: 40px !important;
    }

    body .tt-light-toc .tt-toc__title-main {
        font-size: 17px !important;
        line-height: 1.16 !important;
    }

    body .tt-light-toc .tt-toc__subtitle-inline,
    body .tt-light-toc .tt-toc__title .tt-toc__subtitle-inline {
        font-size: 12.5px !important;
        line-height: 1.25 !important;
    }

    body .tt-light-toc .tt-toc__toggle {
        height: 32px !important;
        min-height: 32px !important;
    }
}

@media (max-width: 549px) {
    body .tt-light-toc .tt-toc__head {
        align-items: center !important;
    }

    body .tt-light-toc .tt-toc__title-wrap {
        max-width: calc(100% - 98px) !important;
    }
}


/* =====================================================
   v1.1.16 - Critical fallback
   Các rule này cố ý có độ ưu tiên cao để chống Flatsome/WP Rocket cache.
===================================================== */
html body.single-product .entry-content nav.tt-light-toc .tt-toc__title,
html body .entry-content nav.tt-light-toc .tt-toc__title,
html body nav.tt-light-toc .tt-toc__title {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 3px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
}
html body.single-product .entry-content nav.tt-light-toc .tt-toc__title-main,
html body .entry-content nav.tt-light-toc .tt-toc__title-main,
html body nav.tt-light-toc .tt-toc__title-main {
    display: block !important;
    width: 100% !important;
    font-size: 18px !important;
    font-weight: 800 !important;
    font-style: normal !important;
    line-height: 1.16 !important;
    color: #0f172a !important;
    margin: 0 !important;
    padding: 0 !important;
}
html body.single-product .entry-content nav.tt-light-toc .tt-toc__subtitle-inline,
html body .entry-content nav.tt-light-toc .tt-toc__subtitle-inline,
html body nav.tt-light-toc .tt-toc__subtitle-inline {
    display: block !important;
    width: 100% !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    font-style: italic !important;
    line-height: 1.25 !important;
    color: #64748b !important;
    margin: 0 !important;
    padding: 0 !important;
    text-transform: none !important;
}

/* Chống CSS cũ/cache: mục con H3 luôn flat, không có vạch dọc */
.tt-light-toc .tt-toc__item--h3 > .tt-toc__link,
.tt-light-toc.tt-toc--expanded .tt-toc__item--h3 > .tt-toc__link,
.tt-light-toc.tt-toc--closed .tt-toc__item--h3 > .tt-toc__link {
    border-left: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background-image: none !important;
}


/* v1.1.16 - H2 giữ độ đậm bình thường, H3 nhỏ hơn để phân cấp tự nhiên */
html body .tt-light-toc .tt-toc__item--h2 > .tt-toc__link {
    color: #1f2f46 !important;
    font-size: 15px !important;
    font-weight: 400 !important;
}

html body .tt-light-toc .tt-toc__item--h2 > .tt-toc__link .tt-toc__number,
html body .tt-light-toc .tt-toc__item--h2 > .tt-toc__link .tt-toc__text {
    color: #1f2f46 !important;
    font-weight: 400 !important;
}

html body .tt-light-toc .tt-toc__item--h3 > .tt-toc__link {
    color: #53647a !important;
    font-size: 13.5px !important;
    font-weight: 400 !important;
    border: 0 !important;
    border-left: 0 !important;
    background: transparent !important;
}

html body .tt-light-toc .tt-toc__item--h3 > .tt-toc__link .tt-toc__number {
    color: #64748b !important;
    font-size: 13px !important;
    font-weight: 400 !important;
}

html body .tt-light-toc .tt-toc__item--h3 > .tt-toc__link .tt-toc__text {
    color: #53647a !important;
    font-size: 13.5px !important;
    font-weight: 400 !important;
}
