/*
 * GstDocs – Matches GST Landing Page & GSTDashboard Larkon theme.
 * Font: Hanken Grotesk | Primary: #DC3545
 * Full mobile optimization: viewport, touch targets, safe areas, overflow.
 */

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

:root {
    --gst-font: 'Hanken Grotesk', sans-serif;
    --primary: #DC3545;
    --primary-rgb: 220, 53, 69;
    --primary-hover: #b02a37;
    --bg: #1a1d26;
    --bg-alt: #222736;
    --bg-card: #272d3b;
    --bg-surface: #2a3040;
    --text: #e2e5ec;
    --text-muted: #8a94a6;
    --border: rgba(255,255,255,0.06);
    --border-light: rgba(255,255,255,0.1);
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --max-w: 1200px;
    --nav-h: 4rem;
    --sidebar-w: 260px;
}

html { scroll-behavior: smooth; color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--gst-font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: rgba(var(--primary-rgb), 0.15);
}
body.menu-open { overflow: hidden; }
a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: #ea868f; }
img { max-width: 100%; height: auto; display: block; }

::selection { background: rgba(var(--primary-rgb),0.4); color: #fff; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem; }
.container-full { max-width: 100%; padding: 0 1.5rem; }

/* ===== Navbar ===== */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--nav-h); background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
.navbar .container, .navbar .container-full {
    display: flex; align-items: center; justify-content: space-between; height: 100%;
}
.navbar-brand {
    font-weight: 700; font-size: 1.15rem; color: var(--text);
    display: flex; align-items: center; gap: 0.5rem;
}
.navbar-brand:hover { color: var(--text); }
.navbar-nav { display: flex; align-items: center; gap: 0.25rem; list-style: none; }
.navbar-nav a {
    padding: 0.5rem 0.85rem; border-radius: var(--radius);
    font-weight: 500; font-size: 0.9rem; color: var(--text-muted);
    transition: color .15s, background .15s;
}
.navbar-nav a:hover, .navbar-nav a.active { color: var(--primary); background: rgba(var(--primary-rgb),0.08); }
.navbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.btn { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--gst-font); font-weight: 600; font-size: 0.95rem; padding: 0.65rem 1.75rem; border: none; border-radius: var(--radius); cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-soft { background: rgba(var(--primary-rgb),0.12); color: var(--primary); }
.btn-soft:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 0.45rem 1.1rem; font-size: 0.85rem; }
.doc-nav-overlay { display: none; }
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

/* ===== Doc layout ===== */
.doc-layout {
    display: flex;
    min-height: calc(100vh - var(--nav-h));
    margin-top: var(--nav-h);
    padding-top: 0;
}
.doc-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-alt);
    border-right: 1px solid var(--border);
    position: sticky;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    overflow-y: auto;
}
.doc-sidebar-inner { padding: 1.5rem 0; }
.doc-nav-title {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--primary);
    padding: 0 1.25rem 0.75rem;
}
.doc-nav {
    display: flex; flex-direction: column; gap: 0.15rem;
}
.doc-nav-item {
    display: block;
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem; color: var(--text-muted);
    transition: color .15s, background .15s;
    border-left: 3px solid transparent;
}
.doc-nav-item:hover { color: var(--primary); background: rgba(var(--primary-rgb),0.06); }
.doc-nav-item.active { color: var(--primary); background: rgba(var(--primary-rgb),0.1); border-left-color: var(--primary); font-weight: 600; }
.doc-nav-indent { padding-left: 2rem; font-size: 0.85rem; }

.doc-main {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem 4rem;
}
.doc-content {
    max-width: 800px;
}

/* ===== Doc content (markdown-rendered) ===== */
.doc-content h1 { font-size: 1.85rem; font-weight: 800; margin: 0 0 1rem; color: var(--text); line-height: 1.25; }
.doc-content h2 { font-size: 1.35rem; font-weight: 700; margin: 2rem 0 0.75rem; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 0.35rem; }
.doc-content h3 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; color: var(--text); }
.doc-content h4, .doc-content h5 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.5rem; color: var(--text); }
.doc-content p { margin: 0 0 1rem; color: var(--text-muted); line-height: 1.7; }
.doc-content ul, .doc-content ol { margin: 0 0 1rem; padding-left: 1.5rem; color: var(--text-muted); }
.doc-content li { margin-bottom: 0.35rem; line-height: 1.6; }
.doc-content a { color: var(--primary); }
.doc-content a:hover { color: #ea868f; }
.doc-content strong { color: var(--text); font-weight: 600; }
.doc-content code { background: var(--bg-card); padding: 0.15rem 0.4rem; border-radius: 0.25rem; font-size: 0.88em; color: var(--primary); border: 1px solid var(--border); }
.doc-content pre { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; overflow-x: auto; margin: 1rem 0; }
.doc-content pre code { background: none; padding: 0; border: none; color: var(--text); }
.doc-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}
.doc-content th, .doc-content td { padding: 0.6rem 0.75rem; text-align: left; border: 1px solid var(--border); }
.doc-content th { background: var(--bg-surface); color: var(--primary); font-weight: 600; }
.doc-content td { color: var(--text-muted); }
/* Mobile: horizontal scroll for wide tables */
@media (max-width: 768px) {
    .doc-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
    .doc-content table thead { display: table-header-group; }
    .doc-content table tbody { display: table-row-group; }
    .doc-content table tr { display: table-row; }
    .doc-content table th, .doc-content table td { display: table-cell; white-space: nowrap; }
}
.doc-content figure { margin: 1.25rem 0; }
.doc-content figure img { border-radius: var(--radius); border: 1px solid var(--border); max-width: 100%; }
.doc-content figcaption { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }

/* GitBook-style hints */
.doc-hint {
    margin: 1rem 0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border-left: 4px solid;
    font-size: 0.92rem; line-height: 1.6;
}
.doc-hint-label { font-weight: 700; margin-right: 0.5rem; }
.doc-hint-success { background: rgba(34, 197, 94, 0.08); border-color: #22c55e; color: #86efac; }
.doc-hint-success .doc-hint-label { color: #22c55e; }
.doc-hint-info { background: rgba(59, 130, 246, 0.08); border-color: #3b82f6; color: #93c5fd; }
.doc-hint-info .doc-hint-label { color: #3b82f6; }
.doc-hint-warning { background: rgba(234, 179, 8, 0.08); border-color: #eab308; color: #fde047; }
.doc-hint-warning .doc-hint-label { color: #eab308; }
.doc-hint-danger { background: rgba(239, 68, 68, 0.08); border-color: #ef4444; color: #fca5a5; }
.doc-hint-danger .doc-hint-label { color: #ef4444; }

/* ===== Footer ===== */
.footer {
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}
.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.footer-bottom a { color: var(--text-muted); }
.footer-bottom a:hover { color: var(--primary); }

/* ===== Responsive – full mobile optimization ===== */
@media (max-width: 768px) {
    .navbar-nav { display: none; }
    .navbar-toggle { display: flex; }
    .navbar-nav.open {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: var(--nav-h);
        right: 0;
        bottom: 0;
        width: min(280px, 100vw - 2rem);
        max-width: 100%;
        background: var(--bg-alt);
        border-left: 1px solid var(--border);
        padding: 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        z-index: 99;
        box-shadow: -4px 0 24px rgba(0,0,0,0.3);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
        .doc-nav-overlay {
        display: none;
        position: fixed;
        inset: 0;
        top: var(--nav-h);
        background: rgba(0,0,0,0.4);
        z-index: 98;
        -webkit-tap-highlight-color: transparent;
    }
    body.menu-open .doc-nav-overlay { display: block; }
    .navbar-nav.open a {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 0.65rem 1rem;
    }
    .navbar-actions {
        gap: 0.35rem;
    }
    .navbar-actions .btn {
        min-height: 44px;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    .doc-layout { flex-direction: column; }
    .doc-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .doc-sidebar-inner { padding: 1rem; }
    .doc-nav { flex-direction: row; flex-wrap: wrap; gap: 0.35rem; }
    .doc-nav-item {
        padding: 0.5rem 0.85rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        border-left: none;
        border-radius: var(--radius);
        -webkit-tap-highlight-color: transparent;
    }
    .doc-nav-indent { padding-left: 0.85rem; }
    .doc-main { padding: 1.5rem 1.25rem 3rem; }
    .doc-content h1 { font-size: 1.5rem; }
    .doc-content h2 { font-size: 1.2rem; }
    .doc-content pre { padding: 0.75rem; font-size: 0.8rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .doc-hint { padding: 0.85rem 1rem; font-size: 0.88rem; }
}
@media (max-width: 480px) {
    .container, .container-full { padding: 0 1rem; padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
    .doc-main { padding: 1.25rem 1rem 2.5rem; }
    .doc-content h1 { font-size: 1.35rem; }
    .doc-content h2 { font-size: 1.1rem; }
    .doc-content h3 { font-size: 1rem; }
    .footer-bottom { flex-direction: column; text-align: center; justify-content: center; }
    .navbar-brand { font-size: 1rem; min-width: 0; }
    .navbar-actions .btn-sm { padding: 0.45rem 0.75rem; font-size: 0.8rem; }
}
