/* ============================================================
CSS VARIABLES — chỉnh màu/font tại đây là xong toàn bộ
============================================================ */
:root {
    --bg: #f8f6f1;
    --surface: #ffffff;
    --border: #e2ddd5;
    --accent: #2d5a8e;
    --accent2: #c17f3a;
    --text: #1a1a1a;
    --text-muted: #6b6560;
    --code-bg: #1e1e2e;
    --code-text: #cdd6f4;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
    --font-head: 'Lora', Georgia, serif;
    --font-body: 'DM Sans', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.7;
}

/* -------- LAYOUT -------- */
.page-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================
HEADER
============================================================ */
.site-header {
    background: var(--surface);
    border-bottom: 2px solid var(--accent);
    padding: 40px 0 28px;
    margin-bottom: 48px;
}

.site-header .page-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header-label {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent2);
}

.header-title {
    font-family: var(--font-head);
    font-size: clamp(22px, 4vw, 36px);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}

.header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.header-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.header-meta .dot {
    color: var(--accent2);
}

/* ============================================================
SECTION COMMON BASE
============================================================ */
.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 32px;
    overflow: hidden;
}

/* Section number badge + title */
.section-header {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 22px 28px 16px;
    border-bottom: 1px solid var(--border);
}

.sec-num {
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent2);
    min-width: 28px;
    letter-spacing: 0.05em;
}

.sec-title {
    font-family: var(--font-head);
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
}

.sec-subtitle {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}

.section-body {
    padding: 24px 28px;
}

/* ============================================================
MẪU TEMPLATE BADGE (chỉ hiện khi .show-labels bật)
Xóa class show-labels ở <body> để ẩn
============================================================ */
body.show-labels .template-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 2px 9px;
    border-radius: 20px;
    margin-left: auto;
}

.template-badge {
    display: none;
}

/* ============================================================
MẪU 1 — BASIC: tiêu đề + bullet list + công thức
============================================================ */
.m1-body {
    padding: 24px 28px;
}

.m1-intro {
    font-size: 14.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-style: italic;
    font-family: var(--font-head);
}

.m1-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.m1-list li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 14.5px;
}

.m1-list li::before {
    content: '▸';
    color: var(--accent2);
    flex-shrink: 0;
    margin-top: 2px;
}

.m1-list li strong {
    color: var(--accent);
}

/* Công thức căn giữa */
.formula-box {
    margin: 20px 0;
    padding: 16px 24px;
    background: #f0f4fa;
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    text-align: center;
}

.formula-box .formula {
    font-family: var(--font-code);
    font-size: 15px;
    color: var(--accent);
    letter-spacing: 0.04em;
}

.formula-box .formula-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ============================================================
MẪU 2 — SPLIT: giải thích trái + slider ảnh phải
============================================================ */
.m2-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    height: 340px; /* hoặc 600px tùy ý */
}

.m2-left {
    padding: 24px 24px 24px 28px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0;

    overflow-y: auto; /* bật cuộn dọc */
    overflow-x: hidden;
}

.m2-right {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafaf9;
}

/* explanation items — sync với ảnh */
.exp-item {
    display: none;
    animation: fadeIn .3s ease;
}

.exp-item.active {
    display: block;
}

.exp-item h4 {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
}

.exp-item p {
    font-size: 14px;
    line-height: 1.75;
    color: var(--text-muted);
}

/* Slider */
.slider-wrap {
    position: relative;
    flex: 1;
}

.slide {
    display: none;
    width: 100%;
}

.slide.active {
    display: block;
    animation: fadeIn .3s ease;
}

/* Image frame — fixed height, image fits inside */
.slide-img-frame {
    width: 100%;
    height: 240px;
    background: #eef0f4;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: zoom-in;
}

.slide-img-frame img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    transition: transform .2s;
}

.slide-img-frame:hover img {
    transform: scale(1.02);
}

.slide-img-frame .zoom-hint {
    position: absolute;
    bottom: 8px;
    right: 10px;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
}

.slide-img-frame:hover .zoom-hint {
    opacity: 1;
}

/* Placeholder khi chưa điền link */
.img-input-wrap {
    width: 100%;
    height: 240px;
    background: linear-gradient(135deg, #e8edf5 0%, #d5dce8 100%);
    border-radius: var(--radius);
    border: 2px dashed #b0bdd0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
}

.img-input-wrap .ph-icon {
    font-size: 28px;
    color: #7a8aaa;
}

.img-url-input {
    width: 100%;
    max-width: 320px;
    padding: 7px 12px;
    border: 1px solid #b0bdd0;
    border-radius: 6px;
    font-family: var(--font-code);
    font-size: 12px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color .15s;
}

.img-url-input:focus {
    border-color: var(--accent);
}

.img-url-input::placeholder {
    color: #aab;
}

.img-load-btn {
    padding: 6px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12.5px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: opacity .15s;
}

.img-load-btn:hover {
    opacity: .85;
}

.img-err {
    font-size: 12px;
    color: #c0392b;
    margin-top: 4px;
    display: none;
}

/* Slider controls */
.slider-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
}

.slider-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--accent);
    transition: background .15s, border-color .15s;
}

.slider-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.slider-dots {
    display: flex;
    gap: 6px;
}

.slider-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border);
    cursor: pointer;
    transition: background .15s;
}

.slider-dot.active {
    background: var(--accent);
}

.slide-counter {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 38px;
    text-align: center;
}

/* ---- LIGHTBOX ---- */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .88);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
    animation: fadeIn .2s ease;
}

.lightbox.open {
    display: flex;
}

.lightbox img {
    max-width: 90vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .6);
}

.lightbox-caption {
    color: rgba(255, 255, 255, .7);
    font-size: 13px;
    font-family: var(--font-body);
}

.lightbox-close {
    position: absolute;
    top: 18px;
    right: 22px;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    opacity: .75;
    transition: opacity .15s;
}

.lightbox-close:hover {
    opacity: 1;
}

/* ============================================================
MẪU 3 — SPLIT: giải thích trái + code viewer phải
============================================================ */
.m3-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    height: 380px; /* Định hình chiều cao cố định */
}

.m3-left {
    padding: 24px 24px 24px 28px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.m3-right {
    display: flex;
    flex-direction: column;
    background: var(--code-bg);
    height: 100%;
    overflow: hidden; 
}

/* File tabs */
.code-tabs {
    display: flex;
    gap: 0;
    background: #161622;
    border-bottom: 1px solid #313145;
    overflow-x: auto;
    flex-shrink: 0;
}

.code-tab {
    padding: 8px 16px;
    font-family: var(--font-code);
    font-size: 12px;
    color: #888;
    cursor: pointer;
    border-right: 1px solid #313145;
    white-space: nowrap;
    transition: color .15s, background .15s;
    user-select: none;
}

.code-tab.active {
    color: var(--code-text);
    background: var(--code-bg);
}

.code-tab:hover:not(.active) {
    color: #ccc;
}

/* Code pane — Bố cục chuẩn giúp ghim chân footer */
.code-pane {
    display: none;
    flex: 1;
    overflow: auto; /* Chỉ cuộn nội dung bên trong pane này */
    width: 100%;
}

.code-pane.active {
    display: block;
}

.code-pane pre {
    margin: 0;
    padding: 18px 20px;
    font-family: var(--font-code);
    font-size: 11.5px; /* Kích thước chữ vừa vặn, dễ nhìn */
    line-height: 1.65;
    color: var(--code-text);
    white-space: pre;
    word-wrap: normal;
}

/* Khung bọc dữ liệu đang tải */
.code-input-wrap {
    padding: 0px 0px;
    color: #666;
} 

.code-url-row {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 360px;
}

.code-url-input {
    flex: 1;
    padding: 7px 11px;
    border: 1px solid #3a3a55;
    border-radius: 6px;
    background: #16162a;
    color: var(--code-text);
    font-family: var(--font-code);
    font-size: 12px;
    outline: none;
    transition: border-color .15s;
}

.code-url-input:focus {
    border-color: #89b4fa;
}

.code-url-input::placeholder {
    color: #555;
}

.code-load-btn {
    padding: 7px 14px;
    background: #313145;
    color: #cdd6f4;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-family: var(--font-body);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}

.code-load-btn:hover {
    background: #4a4a6a;
}

.code-err {
    font-size: 11.5px;
    color: #f38ba8;
    margin-top: 4px;
    display: none;
}

.code-loading {
    font-size: 12px;
    color: #888;
    display: none;
}

/* Syntax highlight */
.kw {
    color: #cba6f7;
}

.fn {
    color: #89b4fa;
}

.str {
    color: #a6e3a1;
}

.num {
    color: #fab387;
}

.cm {
    color: #585b70;
}

.tp {
    color: #f9e2af;
}

/* Code footer with expand button */
.code-footer {
    padding: 7px 14px;
    background: #161622;
    border-top: 1px solid #313145;
    font-family: var(--font-code);
    font-size: 11px;
    color: #555;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.code-expand-btn {
    background: #2a2a3e;
    border: 1px solid #3a3a55;
    color: #89b4fa;
    font-size: 11px;
    font-family: var(--font-body);
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s;
}

.code-expand-btn:hover {
    background: #3a3a55;
}

/* ---- CODE FULLSCREEN MODAL ---- */
.code-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .92);
    z-index: 9999;
    flex-direction: column;
    animation: fadeIn .2s ease;
}

.code-modal.open {
    display: flex;
}

.code-modal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: #161622;
    border-bottom: 1px solid #313145;
    flex-shrink: 0;
}

.code-modal-title {
    font-family: var(--font-code);
    font-size: 13px;
    color: #cdd6f4;
}

.code-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    opacity: .7;
    line-height: 1;
    transition: opacity .15s;
}

.code-modal-close:hover {
    opacity: 1;
}

.code-modal-body {
    flex: 1;
    overflow: auto;
    background: var(--code-bg);
}

.code-modal-body pre {
    padding: 24px 28px;
    font-family: var(--font-code);
    font-size: 13px;
    line-height: 1.7;
    color: var(--code-text);
    white-space: pre;
    min-width: max-content;
}

/* ============================================================
MẪU 4 — BẢNG SO SÁNH
============================================================ */
.m4-body {
    padding: 24px 28px;
}

.m4-desc-top {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 18px;
    font-family: var(--font-head);
    font-style: italic;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    margin-bottom: 20px;
}

.compare-table th {
    background: var(--accent);
    color: #fff;
    padding: 10px 14px;
    text-align: left;
    font-weight: 500;
    font-family: var(--font-body);
}

.compare-table th:first-child {
    border-radius: 6px 0 0 0;
}

.compare-table th:last-child {
    border-radius: 0 6px 0 0;
}

.compare-table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.compare-table tr:last-child td {
    border-bottom: none;
}

.compare-table tr:nth-child(even) td {
    background: #f7f5f0;
}

.compare-table .highlight td {
    background: #fff8ee;
    font-weight: 500;
}

.compare-table .badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green {
    background: #dcf5e7;
    color: #207a45;
}

.badge-red {
    background: #fde8e8;
    color: #8b2020;
}

.badge-blue {
    background: #ddeeff;
    color: #1a4a80;
}

.badge-gray {
    background: #ebebeb;
    color: #555;
}

.m4-desc-bottom {
    padding: 14px 18px;
    background: #f5f8ff;
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    font-size: 13.5px;
    color: var(--text);
    line-height: 1.75;
}

/* ============================================================
MẪU 5 — TIMELINE / QUY TRÌNH
============================================================ */
.m5-body {
    padding: 24px 28px;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 18px;
    top: 24px;
    bottom: 24px;
    width: 2px;
    background: var(--border);
}

.tl-item {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding: 0 0 28px;
    position: relative;
}

.tl-item:last-child {
    padding-bottom: 0;
}

.tl-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    z-index: 1;
    position: relative;
    border: 3px solid var(--surface);
    box-shadow: 0 0 0 2px var(--accent);
}

.tl-dot.done {
    background: #207a45;
    box-shadow: 0 0 0 2px #207a45;
}

.tl-dot.current {
    background: var(--accent2);
    box-shadow: 0 0 0 2px var(--accent2);
}

.tl-content {
    padding-top: 6px;
    flex: 1;
}

.tl-title {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.tl-meta {
    font-size: 11.5px;
    color: var(--accent2);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.tl-desc {
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.7;
}

/* ============================================================
MẪU 6 — KẾT QUẢ / METRIC CARDS
============================================================ */
.m6-body {
    padding: 24px 28px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.metric-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px;
    text-align: center;
    transition: box-shadow .2s;
}

.metric-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.metric-value {
    font-family: var(--font-head);
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 6px;
}

.metric-value.good {
    color: #207a45;
}

.metric-value.warn {
    color: var(--accent2);
}

.metric-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-delta {
    font-size: 11px;
    margin-top: 5px;
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-block;
}

.delta-up {
    background: #dcf5e7;
    color: #207a45;
}

.delta-down {
    background: #fde8e8;
    color: #8b2020;
}

.m6-note {
    padding: 14px 18px;
    background: #fffbf2;
    border: 1px solid #f5dfa0;
    border-radius: var(--radius);
    font-size: 13.5px;
    color: #5c4a10;
}

/* ============================================================
MẪU 7 — FULL WIDTH: intro / kết luận / abstract
============================================================ */
.m7-body {
    padding: 28px 40px;
}

.m7-body.narrow {
    max-width: 720px;
    margin: 0 auto;
}

.m7-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent2);
    margin-bottom: 12px;
}

.m7-text {
    font-family: var(--font-head);
    font-size: 15.5px;
    line-height: 1.9;
    color: var(--text);
}

.m7-text+.m7-text {
    margin-top: 14px;
}

.m7-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.kw-tag {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}

/* ============================================================
FOOTER
============================================================ */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 28px 0;
    margin-top: 48px;
    color: var(--text-muted);
    font-size: 12.5px;
}

.site-footer .page-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-brand {
    font-family: var(--font-head);
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

.footer-links {
    display: flex;
    gap: 18px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--accent);
}

/* ============================================================
UTILITIES
============================================================ */
@keyframes fadeIn {
    from {
    opacity: 0;
    transform: translateY(4px);
    }

    to {
    opacity: 1;
    }
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

.text-muted {
    color: var(--text-muted);
    font-size: 13.5px;
}

@media (max-width: 700px) {

    .m2-layout,
    .m3-layout {
    grid-template-columns: 1fr;
    }

    .m2-left,
    .m3-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
    }

    .metrics-grid {
    grid-template-columns: 1fr 1fr;
    }

    .m7-body {
    padding: 22px 20px;
    }

    .site-header {
    padding: 28px 0 20px;
    }
}