/* ============================================================
   Kode Docs — GitBook-inspired stylesheet
   Only loaded on docs.php
   ============================================================ */

:root {
    --sidebar-w:  268px;
    --toc-w:      220px;
    --content-w:  740px;
    --topnav-h:   56px;
}

body.docs-page {
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* ── Top nav ─────────────────────────────────────────────── */
.docs-topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topnav-h);
    background: rgba(9,9,11,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 200;
}
.docs-topnav-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 100%;
    padding: 0 20px;
    max-width: 100%;
}
.docs-logo {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
    width: calc(var(--sidebar-w) - 20px);
}
.docs-logo:hover { color: var(--text); }
.logo-bracket { color: var(--accent); }

/* Search */
.docs-search-wrap {
    position: relative;
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: 11px;
    color: var(--text-dim);
    pointer-events: none;
}
.docs-search-input {
    width: 100%;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 36px 7px 32px;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    font-family: var(--font);
    transition: border-color .15s, box-shadow .15s;
}
.docs-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.docs-search-input::placeholder { color: var(--text-dim); }
.docs-search-wrap kbd {
    position: absolute;
    right: 9px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: .7rem;
    color: var(--text-dim);
    pointer-events: none;
}
.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
    z-index: 300;
}
.search-result-item {
    display: block;
    padding: 10px 14px;
    font-size: .875rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-soft);
    transition: background .1s, color .1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-raised); color: var(--text); }
.search-empty { padding: 12px 14px; font-size: .875rem; color: var(--text-dim); }

.docs-topnav-links {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-shrink: 0;
}
.docs-gh-link { color: var(--text-muted); display: flex; align-items: center; }
.docs-gh-link:hover { color: var(--text); }
.docs-mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
}
.docs-mobile-toggle span { display: block; width: 20px; height: 2px; background: var(--text-muted); border-radius: 2px; }

/* ── Shell layout ────────────────────────────────────────── */
.docs-shell {
    display: flex;
    margin-top: var(--topnav-h);
    min-height: calc(100vh - var(--topnav-h));
}

/* ── Sidebar ─────────────────────────────────────────────── */
.docs-sidebar-gb {
    position: fixed;
    top: var(--topnav-h);
    left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - var(--topnav-h));
    overflow-y: auto;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.docs-sidebar-gb::-webkit-scrollbar { width: 4px; }
.docs-sidebar-gb::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.docs-sidebar-inner {
    padding: 20px 12px 40px;
}

/* Section groups */
.sidebar-section-group { margin-bottom: 4px; }
.sidebar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 7px 10px;
    border-radius: var(--radius);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    font-family: var(--font);
    transition: color .15s, background .15s;
}
.sidebar-section-toggle:hover { color: var(--text-muted); background: var(--bg-raised); }
.toggle-chevron {
    transition: transform .2s ease;
    flex-shrink: 0;
}
.sidebar-section-group.open .toggle-chevron { transform: rotate(90deg); }
.sidebar-section-group .sidebar-list-nested { display: none; }
.sidebar-section-group.open .sidebar-list-nested { display: block; }

/* Links */
.sidebar-list { list-style: none; margin: 0; padding: 0; margin-bottom: 8px; }
.sidebar-link {
    display: block;
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-muted);
    transition: color .15s, background .15s;
    position: relative;
}
.sidebar-link:hover { color: var(--text); background: var(--bg-raised); }
.sidebar-link.active {
    color: var(--accent);
    background: var(--accent-glow);
    font-weight: 600;
}
.sidebar-empty { font-size: .875rem; color: var(--text-dim); padding: 8px 10px; }

/* ── Content ─────────────────────────────────────────────── */
.docs-content-gb {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    padding: 48px 48px 80px;
    max-width: calc(var(--sidebar-w) + var(--content-w) + var(--toc-w) + 96px);
}

/* ── Right ToC ───────────────────────────────────────────── */
.docs-toc {
    position: sticky;
    top: var(--topnav-h);
    width: var(--toc-w);
    height: calc(100vh - var(--topnav-h));
    overflow-y: auto;
    padding: 32px 16px 40px 8px;
    flex-shrink: 0;
    align-self: flex-start;
}
.toc-inner { position: sticky; top: 0; }
.toc-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-dim);
    margin-bottom: 10px;
    padding: 0 6px;
}
.toc-links { display: flex; flex-direction: column; }
.toc-link {
    display: block;
    padding: 4px 6px;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-left: 2px solid transparent;
    transition: color .15s, border-color .15s;
    line-height: 1.4;
}
.toc-link:hover { color: var(--text-muted); }
.toc-link.active { color: var(--accent); border-left-color: var(--accent); }
.toc-link.toc-h3 { padding-left: 16px; font-size: 0.75rem; }

/* ── Breadcrumb ──────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-dim); }
.breadcrumb a:hover { color: var(--accent); }
.bc-sep { color: var(--text-dim); }

/* ── Doc header ──────────────────────────────────────────── */
.doc-header { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border-soft); }
.doc-header h1 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 8px;
}
.doc-updated { font-size: 0.8rem; color: var(--text-dim); }
.doc-lead { font-size: 1.1rem; color: var(--text-muted); margin-top: 10px; line-height: 1.7; }

/* ── Doc body (rendered markdown) ────────────────────────── */
.doc-body { color: var(--text); line-height: 1.8; }
.doc-body h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 40px 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
    scroll-margin-top: calc(var(--topnav-h) + 16px);
}
.doc-body h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 28px 0 12px;
    scroll-margin-top: calc(var(--topnav-h) + 16px);
}
.doc-body h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 20px 0 8px;
    color: var(--text-muted);
}
.doc-body p { margin-bottom: 16px; }
.doc-body ul, .doc-body ol { margin: 0 0 16px 20px; }
.doc-body li { margin-bottom: 6px; }
.doc-body a { color: var(--accent); }
.doc-body a:hover { color: #a78bfa; text-decoration: underline; }
.doc-body strong { font-weight: 700; }
.doc-body em { font-style: italic; color: var(--text-muted); }
.doc-body hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

/* Inline code */
.doc-body code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    color: #c4b5fd;
}

/* Code blocks */
.doc-body pre {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 22px;
    overflow-x: auto;
    margin: 20px 0;
    position: relative;
}
.doc-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.875rem;
    color: #e2e8f0;
    line-height: 1.7;
}

/* Tables */
.doc-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.9rem;
}
.doc-body th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
}
.doc-body td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-muted);
    vertical-align: top;
}
.doc-body tr:last-child td { border-bottom: none; }
.doc-body tr:hover td { background: var(--bg-raised); }

/* Blockquote → callout style */
.doc-body blockquote {
    background: var(--accent-glow);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 14px 18px;
    margin: 20px 0;
    color: var(--text-muted);
}
.doc-body blockquote p { margin: 0; }

/* ── Landing grid ────────────────────────────────────────── */
.docs-landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 32px;
}
.landing-section-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: border-color .15s;
}
.landing-section-card:hover { border-color: var(--accent); }
.landing-section-card h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    margin-bottom: 14px;
}
.landing-section-card ul { list-style: none; }
.landing-section-card li { margin-bottom: 8px; }
.landing-section-card a { font-size: 0.9rem; color: var(--text-muted); }
.landing-section-card a:hover { color: var(--accent); }

/* ── Prev / Next ─────────────────────────────────────────── */
.doc-prevnext {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 56px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}
.prevnext-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    color: var(--text);
    transition: border-color .15s, background .15s;
}
.prevnext-card:hover { border-color: var(--accent); background: var(--bg-raised); color: var(--text); }
.prevnext-next { text-align: right; }
.prevnext-dir { font-size: 0.75rem; color: var(--text-dim); }
.prevnext-title { font-size: 0.9rem; font-weight: 600; }

/* ── Not found / empty ───────────────────────────────────── */
.doc-notfound { text-align: center; padding: 64px 0; }
.doc-notfound h1 { font-size: 2rem; margin-bottom: 12px; }
.doc-notfound p { color: var(--text-muted); }
.doc-empty { color: var(--text-dim); font-style: italic; }

/* callout reuse from main style */
.callout {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 24px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.callout-warn { border-left-color: #eab308; }
.callout-icon { font-size: 1rem; flex-shrink: 0; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1200px) {
    .docs-toc { display: none; }
}
@media (max-width: 900px) {
    .docs-sidebar-gb {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 150;
    }
    .docs-sidebar-gb.open { transform: translateX(0); }
    .docs-content-gb { margin-left: 0; padding: 32px 24px 64px; }
    .docs-mobile-toggle { display: flex; }
    .docs-logo { width: auto; }
}
@media (max-width: 580px) {
    .docs-content-gb { padding: 24px 16px 48px; }
    .doc-prevnext { grid-template-columns: 1fr; }
    .docs-search-wrap kbd { display: none; }
}
