/* ===== TOKENS (inherited from parent) ===== */
:root {
    --bg: #050510;
    --bg2: rgba(255, 255, 255, .04);
    --bg3: rgba(255, 255, 255, .02);
    --border: rgba(255, 255, 255, .08);
    --border-h: rgba(0, 229, 255, .25);
    --text: #ffffff;
    --dim: #8a8aaa;
    --dim2: #6a6a88;
    --orange: #ff6d00;
    --amber: #ffc45a;
    --green: #00e5ff;
    --red: #ff5f57;
    --r: 12px;
    --font: 'Outfit', 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Consolas', monospace;
    --sidebar-w: 280px;
    --nav-h: 56px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }

html { scroll-behavior: smooth; scroll-padding-top: 80px }

body {
    background: var(--bg);
    background-image:
        radial-gradient(circle 400px at 10% 20%, rgba(0, 229, 255, .04) 0%, transparent 70%),
        radial-gradient(circle 350px at 90% 80%, rgba(255, 109, 0, .03) 0%, transparent 70%);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* noise grain */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px;
}

a { color: inherit; text-decoration: none }
ul, ol { list-style: none }
.mono { font-family: var(--mono) }
.accent { background: linear-gradient(135deg, var(--green), var(--orange)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text }

/* ===== NAV ===== */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    height: var(--nav-h);
    padding: 0 1.5rem;
    background: rgba(5, 5, 16, .92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.nav-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    font-family: var(--mono);
    font-weight: 700;
    font-size: .9rem;
    letter-spacing: .06em;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-icon { width: 22px; height: 22px; border-radius: 4px }

.nav-right { display: flex; align-items: center; gap: 1rem }

.nav-right a {
    font-size: .8rem;
    color: var(--dim);
    transition: color .3s;
}
.nav-right a:hover { color: var(--orange) }

/* search bar in nav */
.nav-search {
    position: relative;
    width: 220px;
}
.nav-search input {
    width: 100%;
    padding: 6px 12px 6px 32px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font);
    font-size: .78rem;
    outline: none;
    transition: border-color .3s;
}
.nav-search input:focus { border-color: var(--border-h) }
.nav-search input::placeholder { color: var(--dim2) }
.nav-search i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--dim2);
    font-size: .72rem;
}

/* lang toggle */
.lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 138, 80, .06);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: .72rem;
    font-family: var(--mono);
    font-weight: 500;
    transition: all .3s;
}
.lang-toggle:hover { background: rgba(255, 138, 80, .14); border-color: var(--border-h) }

/* mobile menu btn */
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--dim);
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}

/* ===== LAYOUT ===== */
.layout {
    display: flex;
    padding-top: var(--nav-h);
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: rgba(5, 5, 16, .95);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1rem 0;
    z-index: 800;
    transition: transform .3s ease;
}

.sidebar::-webkit-scrollbar { width: 3px }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px }

.sidebar-section { margin-bottom: 0.5rem }

.sidebar-heading {
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--dim2);
    padding: 0.8rem 1.2rem 0.3rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 1.2rem;
    font-size: .8rem;
    font-weight: 500;
    color: var(--dim);
    transition: all .25s;
    border-left: 2px solid transparent;
    cursor: pointer;
}
.sidebar-link:hover { color: var(--text); background: var(--bg2) }
.sidebar-link.active {
    color: var(--orange);
    border-left-color: var(--orange);
    background: rgba(255, 109, 0, .06);
}

.sidebar-link i { font-size: .72rem; width: 16px; text-align: center }

/* sub items */
.sidebar-sub { padding-left: 1rem }
.sidebar-sub .sidebar-link { font-size: .75rem; padding: 5px 1.2rem 5px 2rem }

/* collapsible */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 7px 1.2rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--dim);
    cursor: pointer;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    transition: all .25s;
}
.sidebar-toggle:hover { color: var(--text); background: var(--bg2) }
.sidebar-toggle .caret {
    font-size: .6rem;
    transition: transform .3s;
    color: var(--dim2);
}
.sidebar-toggle.open .caret { transform: rotate(90deg) }
.sidebar-toggle.active-parent { color: var(--orange); border-left-color: var(--orange) }

.sidebar-sub.collapsed { display: none }

/* ===== MAIN CONTENT ===== */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 2rem 3rem 4rem;
    max-width: 1100px;
    min-width: 0;
}

/* ===== CONTENT SECTIONS ===== */
.doc-section { margin-bottom: 3rem; display: none }
.doc-section.active { display: block }

.doc-section h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: .3rem;
    line-height: 1.2;
}
.doc-section h1 .emoji { margin-right: 8px }

.doc-section .section-desc {
    color: var(--dim);
    font-size: .88rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.doc-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 2rem 0 .8rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.doc-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5rem 0 .6rem;
    color: var(--amber);
}

.doc-section h4 {
    font-size: .9rem;
    font-weight: 600;
    margin: 1.2rem 0 .5rem;
    color: var(--dim);
}

.doc-section p {
    font-size: .88rem;
    color: var(--dim);
    line-height: 1.7;
    margin-bottom: .8rem;
}

.doc-section strong { color: var(--text); font-weight: 600 }
.doc-section em { font-style: italic }

.doc-section a.inline-link {
    color: var(--green);
    text-decoration: underline;
    text-decoration-color: rgba(0, 229, 255, .3);
    text-underline-offset: 2px;
    transition: all .2s;
}
.doc-section a.inline-link:hover {
    color: var(--orange);
    text-decoration-color: var(--orange);
}

/* ul/ol */
.doc-section ul, .doc-section ol {
    padding-left: 1.2rem;
    margin-bottom: .8rem;
}
.doc-section ul { list-style: disc }
.doc-section ol { list-style: decimal }
.doc-section li {
    font-size: .85rem;
    color: var(--dim);
    line-height: 1.7;
    margin-bottom: .3rem;
}
.doc-section li strong { color: var(--text) }

/* ===== TABLES ===== */
.table-wrap {
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
    table-layout: fixed;
}

.doc-table th,
.doc-table td {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.doc-table th:first-child,
.doc-table td:first-child {
    width: 18%;
}

.doc-table th {
    background: rgba(255, 138, 80, .06);
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    color: var(--amber);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.doc-table td {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .03);
    color: var(--dim);
    vertical-align: top;
}

.doc-table tr:last-child td { border-bottom: none }
.doc-table tr:hover td { background: rgba(255, 255, 255, .02) }

.doc-table code {
    background: rgba(255, 138, 80, .08);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: .75rem;
    color: var(--orange);
}

/* ===== CODE BLOCKS ===== */
.code-block {
    position: relative;
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(0, 229, 255, .03);
    border-bottom: 1px solid var(--border);
}

.code-block-lang {
    font-family: var(--mono);
    font-size: .65rem;
    font-weight: 600;
    color: var(--dim2);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.code-copy {
    background: none;
    border: 1px solid var(--border);
    color: var(--dim);
    font-size: .65rem;
    font-family: var(--mono);
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.code-copy:hover { color: var(--orange); border-color: var(--border-h) }
.code-copy.copied { color: var(--green); border-color: rgba(0, 229, 255, .3) }

.code-block pre {
    padding: 14px 16px;
    overflow-x: auto;
    background: rgba(0, 0, 0, .3);
}

.code-block code {
    font-family: var(--mono);
    font-size: .78rem;
    line-height: 1.6;
    color: var(--dim);
}

/* inline code */
.doc-section code:not(.code-block code) {
    background: rgba(255, 138, 80, .08);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: .8rem;
    color: var(--orange);
}


/* <pre> trần (không bọc .code-block): 52 khối kiểu này nằm rải rác trong
   webhook-api, n8n-integration, workflow-editor… Không có rule nào cho chúng
   nên dòng curl dài đẩy cả trang tràn ngang. Cho cuộn trong chính nó. */
.doc-section pre:not(.code-block pre) {
    margin: 1rem 0;
    padding: 14px 16px;
    max-width: 100%;
    overflow-x: auto;
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: .78rem;
    line-height: 1.6;
    color: var(--dim);
}
.doc-section pre:not(.code-block pre) code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
    white-space: pre;
}

/* ===== CALLOUT / ALERT BOXES ===== */
.callout {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: .83rem;
    line-height: 1.6;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.callout-icon { font-size: .9rem; flex-shrink: 0; margin-top: 2px }
.callout-text { color: var(--dim) }
.callout-text strong { color: var(--text) }

.callout.warning {
    background: rgba(255, 188, 46, .06);
    border: 1px solid rgba(255, 188, 46, .15);
}
.callout.warning .callout-icon { color: var(--amber) }

.callout.info {
    background: rgba(0, 229, 255, .04);
    border: 1px solid rgba(0, 229, 255, .12);
}
.callout.info .callout-icon { color: var(--green) }

.callout.tip {
    background: rgba(110, 232, 152, .04);
    border: 1px solid rgba(110, 232, 152, .12);
}
.callout.tip .callout-icon { color: #6ee898 }

.callout.danger {
    background: rgba(255, 95, 87, .05);
    border: 1px solid rgba(255, 95, 87, .12);
}
.callout.danger .callout-icon { color: var(--red) }

.callout.important {
    background: rgba(255, 109, 0, .05);
    border: 1px solid rgba(255, 109, 0, .15);
}
.callout.important .callout-icon { color: var(--orange) }

/* ===== STEPS ===== */
.steps { counter-reset: step-counter; margin: 1rem 0 }
.step {
    display: flex;
    gap: 12px;
    margin-bottom: .8rem;
    counter-increment: step-counter;
}
.step::before {
    content: counter(step-counter);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    background: rgba(255, 109, 0, .1);
    border: 1px solid rgba(255, 109, 0, .2);
    border-radius: 6px;
    font-family: var(--mono);
    font-size: .7rem;
    font-weight: 700;
    color: var(--orange);
}
.step-content { font-size: .85rem; color: var(--dim); line-height: 1.6 }
.step-content strong { color: var(--text) }

/* ===== BADGE / TAG ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 100px;
    font-family: var(--mono);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
}
.badge.basic { background: rgba(138, 138, 170, .1); color: var(--dim); border: 1px solid rgba(138, 138, 170, .15) }
.badge.plus { background: rgba(0, 229, 255, .08); color: var(--green); border: 1px solid rgba(0, 229, 255, .15) }
.badge.max { background: rgba(255, 109, 0, .08); color: var(--orange); border: 1px solid rgba(255, 109, 0, .15) }
.badge.required { background: rgba(255, 95, 87, .08); color: var(--red); border: 1px solid rgba(255, 95, 87, .15) }

/* ===== DIVIDER ===== */
.doc-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 2rem 0;
}

/* ===== COLLAPSIBLE DETAILS ===== */
.doc-details {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 1rem 0;
    overflow: hidden;
}

.doc-details-summary {
    padding: 10px 14px;
    background: var(--bg2);
    cursor: pointer;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background .2s;
    user-select: none;
}
.doc-details-summary:hover { background: rgba(255, 255, 255, .06) }
.doc-details-summary .caret {
    font-size: .55rem;
    color: var(--dim2);
    transition: transform .3s;
}
.doc-details.open .doc-details-summary .caret { transform: rotate(90deg) }

.doc-details-content {
    padding: 14px;
    display: none;
}
.doc-details.open .doc-details-content { display: block }

/* ===== ENDPOINT CARD ===== */
.endpoint-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 1rem 0;
    overflow: hidden;
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg2);
}

.method-badge {
    font-family: var(--mono);
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}
.method-badge.get { background: rgba(0, 229, 255, .1); color: var(--green); border: 1px solid rgba(0, 229, 255, .2) }
.method-badge.post { background: rgba(255, 138, 80, .1); color: var(--orange); border: 1px solid rgba(255, 138, 80, .2) }

.endpoint-path {
    font-family: var(--mono);
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
}

.endpoint-auth {
    margin-left: auto;
    font-size: .65rem;
    color: var(--dim2);
}

.endpoint-body { padding: 14px }

/* ===== SEARCH RESULTS ===== */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 15, 30, .98);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 320px;
    overflow-y: auto;
    display: none;
    z-index: 999;
    backdrop-filter: blur(14px);
}
.search-results.visible { display: block }

.search-result-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: .8rem;
    color: var(--dim);
    border-bottom: 1px solid rgba(255, 255, 255, .03);
    transition: background .2s;
}
.search-result-item:hover { background: var(--bg2); color: var(--text) }
.search-result-item:last-child { border-bottom: none }
.search-result-item .result-section {
    font-size: .65rem;
    color: var(--dim2);
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ===== NO RESULTS ===== */
.no-results {
    display: none;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--dim2);
}
.no-results.visible { display: block }
.no-results i { font-size: 2rem; margin-bottom: 1rem; display: block; color: var(--dim) }

/* ===== SECTION NAV (Prev / Next) ===== */
.section-nav {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.section-nav-btn {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 20px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all .3s ease;
    min-width: 0;
    max-width: 48%;
    text-decoration: none;
}
.section-nav-btn:hover {
    border-color: var(--border-h);
    background: rgba(255, 255, 255, .06);
    transform: translateY(-2px);
}

.section-nav-btn.next { margin-left: auto; text-align: right }

.section-nav-label {
    font-size: .65rem;
    font-family: var(--mono);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--dim2);
}

.section-nav-title {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}
.section-nav-btn:hover .section-nav-title { color: var(--orange) }

.section-nav-btn.prev .section-nav-title::before { content: '←'; color: var(--dim2); transition: transform .2s }
.section-nav-btn.next .section-nav-title::after  { content: '→'; color: var(--dim2); transition: transform .2s }
.section-nav-btn.prev:hover .section-nav-title::before { transform: translateX(-3px); color: var(--orange) }
.section-nav-btn.next:hover .section-nav-title::after  { transform: translateX(3px); color: var(--orange) }

@media (max-width: 520px) {
    .section-nav { flex-direction: column }
    .section-nav-btn { max-width: 100% }
    .section-nav-btn.next { text-align: left }
}

/* ===== FOOTER ===== */
.doc-footer {
    margin-left: var(--sidebar-w);
    padding: 2rem 3rem;
    border-top: 1px solid var(--border);
    text-align: center;
}
.doc-footer p { font-size: .75rem; color: var(--dim2) }
.doc-footer a { color: var(--dim); transition: color .2s }
.doc-footer a:hover { color: var(--orange) }

/* ===== REVEAL ANIMATION ===== */
.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .5s ease, transform .5s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0) }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px }
::-webkit-scrollbar-track { background: transparent }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .08); border-radius: 3px }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .15) }

/* ===== MOBILE OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 790;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0) }
    .sidebar-overlay.open { display: block }

    .main { margin-left: 0; padding: 1.5rem 1.2rem 3rem }
    .doc-footer { margin-left: 0; padding: 1.5rem 1.2rem }

    .menu-toggle { display: block }
    .nav-search { width: 160px }

    .doc-section h1 { font-size: 1.4rem }
    .doc-section h2 { font-size: 1.1rem }

    .table-wrap { margin-left: -0.5rem; margin-right: -0.5rem }
}

@media (max-width: 520px) {
    .nav-search { display: none }
    .nav-right a:not(.lang-toggle) { display: none }
}

/* ===== PRINT ===== */
@media print {
    .sidebar, .nav, .sidebar-overlay { display: none !important }
    .main { margin-left: 0; padding: 0 }
    .doc-section { display: block !important }
}

/* ═══ Ảnh minh hoạ chụp từ app ═══ */
.doc-fig { margin: 1.4rem 0 1.8rem }
.doc-fig img {
    width: 100%; height: auto; display: block; border-radius: 10px;
    border: 1px solid var(--border); box-shadow: 0 12px 34px rgba(0, 0, 0, .45);
}
.doc-fig figcaption {
    margin-top: .65rem; font-size: .85rem; color: var(--dim); line-height: 1.6;
}
.doc-fig figcaption strong { color: var(--text) }
