/* ═══════════════════════════════════════════════════════════════
   Serpelo — Documentation Theme
   Version: 1.0.0  ·  Author: WebTown
   ═══════════════════════════════════════════════════════════════ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent: #06b6d4;
    --accent-dark: #0891b2;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --elite: linear-gradient(135deg, #f59e0b, #ef4444);
    --pro: linear-gradient(135deg, #6366f1, #8b5cf6);
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #6366f1;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.doc-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.doc-sidebar::-webkit-scrollbar { width: 4px; }
.doc-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.sidebar-brand h1 {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand .version {
    font-size: 10px;
    color: var(--primary-light);
    font-weight: 600;
}

.sidebar-search {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-search input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 34px;
    color: #fff;
    font-size: 13px;
    outline: none;
    transition: var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
}

.sidebar-search input:focus {
    border-color: var(--primary);
    background-color: rgba(255,255,255,0.1);
}

.sidebar-search input::placeholder { color: var(--text-light); }

.sidebar-section {
    padding: 16px 12px 8px;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-light);
    padding: 0 8px 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.sidebar-link .icon {
    width: 20px;
    text-align: center;
    font-size: 14px;
    opacity: 0.7;
}

.sidebar-link.active .icon { opacity: 1; }

.sidebar-badge {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-pro { background: var(--pro); color: #fff; }
.badge-elite { background: var(--elite); color: #fff; }
.badge-free { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-new { background: var(--elite); color: #fff; }

/* ── Content Area ─────────────────────────────────────────── */
.doc-content {
    margin-left: 280px;
    min-height: 100vh;
}

.doc-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(248,250,252,0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 14px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.doc-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.doc-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}

.doc-breadcrumb a:hover { color: var(--primary); }
.doc-breadcrumb .sep { opacity: 0.4; }
.doc-breadcrumb .current { color: var(--text); font-weight: 600; }

.doc-topbar-actions {
    display: flex;
    gap: 8px;
}

.doc-topbar-actions a {
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.btn-edit { background: rgba(99,102,241,0.1); color: var(--primary); }
.btn-edit:hover { background: rgba(99,102,241,0.2); }
.btn-github { background: var(--text); color: #fff; }
.btn-github:hover { opacity: 0.9; }

.doc-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 40px;
}

/* ── Typography ───────────────────────────────────────────── */
.doc-main h1 {
    font-size: 36px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.doc-main h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin: 48px 0 16px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    letter-spacing: -0.3px;
}

.doc-main h2:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 32px;
}

.doc-main h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 32px 0 12px;
}

.doc-main h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 24px 0 8px;
}

.doc-main p {
    margin: 0 0 16px;
    color: var(--text);
}

.doc-main a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.doc-main a:hover { color: var(--primary-dark); text-decoration: underline; }

.doc-subtitle {
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.6;
}

/* ── Cards ────────────────────────────────────────────────── */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.feature-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

.feature-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--primary-light);
    text-decoration: none;
    color: inherit;
}

.feature-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 14px;
}

.feature-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 6px;
}

.feature-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ── Info Boxes ───────────────────────────────────────────── */
.info-box {
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 20px 0;
    font-size: 14px;
    line-height: 1.6;
    display: flex;
    gap: 12px;
}

.info-box .icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

.info-box-info { background: #eff6ff; }
.info-box-warning { background: #fffbeb; }
.info-box-success { background: #f0fdf4; }
.info-box-danger { background: #fef2f2; }
.info-box-pro { background: #faf5ff; }

/* ── Tables ───────────────────────────────────────────────── */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 14px;
    background: var(--bg-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.doc-table thead { background: #f1f5f9; }

.doc-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.doc-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.doc-table tr:last-child td { border-bottom: none; }
.doc-table tr:hover { background: #f8fafc; }
.doc-table code { font-size: 12px; }

/* ── Code Blocks ──────────────────────────────────────────── */
code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary-dark);
}

pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 20px 24px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 20px 0;
    font-size: 13px;
    line-height: 1.6;
}

pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ── Image Placeholders ───────────────────────────────────── */
.img-placeholder {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    margin: 24px 0;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.img-placeholder .icon { font-size: 36px; opacity: 0.4; }
.img-placeholder .label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}
.img-placeholder .hint {
    font-size: 11px;
    color: var(--text-light);
}

/* Loaded doc screenshots (replaces .img-placeholder when the
   referenced asset exists on disk — see docs.js) */
.doc-figure {
    margin: 24px 0;
    text-align: center;
}
.doc-figure img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    display: block;
    margin: 0 auto;
}
.doc-figure figcaption {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Tier Badges ──────────────────────────────────────────── */
.tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 6px;
    text-transform: uppercase;
    vertical-align: middle;
}

.tier-free { background: rgba(34,197,94,0.12); color: #16a34a; }
.tier-pro { background: rgba(99,102,241,0.12); color: #6366f1; }
.tier-elite { background: linear-gradient(135deg,#fef3c7,#fde68a); color: #b45309; }

/* ── Steps ────────────────────────────────────────────────── */
.steps {
    counter-reset: step;
    margin: 24px 0;
}

.step {
    counter-increment: step;
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.step::before {
    content: counter(step);
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-content h4 { margin: 0 0 6px; }
.step-content p { margin: 0; font-size: 14px; color: var(--text-muted); }

/* ── TOC (Right side) ────────────────────────────────────── */
.doc-toc {
    position: fixed;
    right: 24px;
    top: 120px;
    width: 200px;
    font-size: 12px;
}

.doc-toc-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: 12px;
}

.doc-toc a {
    display: block;
    padding: 4px 0 4px 12px;
    border-left: 2px solid var(--border);
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    line-height: 1.5;
}

.doc-toc a:hover, .doc-toc a.active {
    color: var(--primary);
    border-color: var(--primary);
}

/* ── Footer ───────────────────────────────────────────────── */
.doc-footer {
    margin-top: 64px;
    padding: 32px 0;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.doc-footer-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
}

.doc-footer-nav a:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}

/* ── Mobile Toggle ────────────────────────────────────────── */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 22px;
    cursor: pointer;
    z-index: 200;
    box-shadow: var(--shadow-lg);
}

@media (max-width: 1024px) {
    .doc-sidebar { transform: translateX(-100%); }
    .doc-sidebar.open { transform: translateX(0); }
    .doc-content { margin-left: 0; }
    .doc-toc { display: none; }
    .mobile-toggle { display: flex; align-items: center; justify-content: center; }
    .doc-main { padding: 24px 20px; }
}

@media (max-width: 768px) {
    .feature-grid { grid-template-columns: 1fr; }
    .doc-main h1 { font-size: 28px; }
}

/* ── Global Search Overlay ─────────────────────────────────── */
.search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.search-trigger:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99,102,241,0.04);
}

.search-trigger .search-icon {
    width: 14px; height: 14px;
    opacity: 0.5;
}

.search-trigger kbd {
    display: inline-flex;
    align-items: center;
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.04);
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-light);
    line-height: 1.4;
    margin-left: 4px;
}

.search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(4px);
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 16px 16px;
}

.search-overlay.open {
    display: flex;
}

.search-modal {
    width: 100%;
    max-width: 640px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 65px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
    overflow: hidden;
    animation: searchSlideIn 0.2s ease-out;
}

@keyframes searchSlideIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.search-modal-header svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
}

.search-modal-header input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: transparent;
}

.search-modal-header input::placeholder { color: var(--text-light); }

.search-modal-close {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
}

.search-results {
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px;
}

.search-results::-webkit-scrollbar { width: 6px; }
.search-results::-webkit-scrollbar-track { background: transparent; }
.search-results::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }

.search-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.search-empty .search-empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.search-empty .search-empty-hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 8px;
}

.search-result-group {
    margin-bottom: 4px;
}

.search-result-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.search-result-item {
    display: block;
    padding: 10px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    cursor: pointer;
}

.search-result-item:hover,
.search-result-item.active {
    background: rgba(99,102,241,0.06);
}

.search-result-item:hover .search-result-title,
.search-result-item.active .search-result-title {
    color: var(--primary);
}

.search-result-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    transition: var(--transition);
}

.search-result-title mark {
    background: rgba(99,102,241,0.15);
    color: var(--primary);
    padding: 1px 2px;
    border-radius: 3px;
}

.search-result-snippet {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-snippet mark {
    background: rgba(99,102,241,0.12);
    color: var(--primary-dark);
    padding: 0 1px;
    border-radius: 2px;
}

.search-result-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(99,102,241,0.08);
    color: var(--primary);
    margin-left: 6px;
    vertical-align: middle;
}

.search-modal-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-light);
}

.search-modal-footer kbd {
    display: inline-flex;
    align-items: center;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.03);
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    margin: 0 2px;
}

.search-modal-footer .search-footer-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Utility ──────────────────────────────────────────────── */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
