/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0d0f17;
    --bg-secondary: #141622;
    --bg-card: #1a1d2e;
    --bg-code: #12141f;
    --bg-sidebar: #111320;
    --text-primary: #e2e4ed;
    --text-secondary: #9ca3b8;
    --text-muted: #626a80;
    --accent: #6c5ce7;
    --accent-glow: rgba(108, 92, 231, 0.15);
    --green: #00d68f;
    --red: #ff6b6b;
    --yellow: #ffd93d;
    --blue: #4ecdc4;
    --border: #1e2235;
    --border-light: #2a2d42;
    --sidebar-width: 260px;
    --radius: 10px;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    display: flex;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-code);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.85em;
    color: var(--yellow);
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 1.3rem; }
.logo-text { font-weight: 700; font-size: 1rem; }
.version-badge {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}
.sidebar-nav { padding: 16px 0; flex: 1; }
.nav-section { margin-bottom: 8px; }
.nav-section-title {
    padding: 6px 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.nav-link {
    display: block;
    padding: 7px 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all 0.15s;
    border-left: 3px solid transparent;
    cursor: pointer;
}
.nav-link:hover {
    color: var(--text-primary);
    background: var(--accent-glow);
    text-decoration: none;
}
.nav-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-glow);
    font-weight: 500;
}

/* ===== Mobile Toggle ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px 48px;
    max-width: 900px;
}

/* ===== API Key Bar ===== */
.api-key-bar {
    background: linear-gradient(135deg, var(--bg-card), #1e2240);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 32px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}
.api-key-bar-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}
.api-key-icon { font-size: 1rem; }
.api-key-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s;
}
.api-key-input:focus { border-color: var(--accent); }
.api-key-save-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
    transition: opacity 0.2s;
}
.api-key-save-btn:hover { opacity: 0.85; }

/* ===== Page Content ===== */
.doc-section { margin-bottom: 48px; }
.doc-section h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}
.doc-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.doc-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 24px 0 8px;
    color: var(--text-secondary);
}
.section-desc {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.7;
}

/* ===== Info Cards ===== */
.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 24px 0;
}
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.2s;
}
.info-card:hover { border-color: var(--accent); }
.info-card-icon { font-size: 1.3rem; margin-bottom: 8px; }
.info-card-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.info-card code, .info-card span {
    font-size: 0.85rem;
    color: var(--yellow);
}

/* ===== Callout ===== */
.callout {
    background: var(--accent-glow);
    border-left: 3px solid var(--accent);
    padding: 14px 18px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 16px 0;
    font-size: 0.9rem;
}

/* ===== Code Blocks ===== */
.code-block {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 16px 0;
}
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
}
.code-lang {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}
.copy-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
}
.copy-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.code-block pre {
    padding: 16px;
    overflow-x: auto;
    margin: 0;
}
.code-block code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.6;
}

/* ===== Tables ===== */
.docs-table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 0.85rem;
}
.docs-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.docs-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.docs-table tr:hover td { background: rgba(108, 92, 231, 0.03); }

/* ===== Endpoints ===== */
.endpoint {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
}
.endpoint-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.method {
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    font-family: 'JetBrains Mono', monospace;
}
.method.get { background: rgba(0, 214, 143, 0.12); color: var(--green); }
.method.post { background: rgba(108, 92, 231, 0.12); color: var(--accent); }
.method.delete { background: rgba(255, 107, 107, 0.12); color: var(--red); }
.method.put { background: rgba(255, 217, 61, 0.12); color: var(--yellow); }
.endpoint-path {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 500;
    background: none;
    padding: 0;
    color: var(--text-primary);
}

/* ===== Try-it Forms ===== */
.try-it-box {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-light);
}
.try-it-title {
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 12px;
    font-weight: 600;
}
.try-it-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.try-field {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}
.try-field:focus { border-color: var(--accent); }
.try-textarea {
    min-height: 60px;
    resize: vertical;
    font-family: 'Inter', sans-serif;
}
select.try-field {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
select.try-field option { background: var(--bg-card); color: var(--text-primary); }
.try-btn {
    background: linear-gradient(135deg, var(--accent), #5a4bcc);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: transform 0.1s, opacity 0.2s;
}
.try-btn:hover { opacity: 0.9; transform: scale(1.02); }
.try-btn:active { transform: scale(0.98); }
.try-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.try-result { margin-top: 12px; display: none; }
.try-result.show { display: block; }
.try-result pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.try-result .try-error { color: var(--red); }
.try-result .try-success { color: var(--green); }
.try-result audio { width: 100%; margin-top: 8px; border-radius: 8px; }
.try-result img { max-width: 100%; border-radius: 8px; margin-top: 8px; }

/* ===== Footer ===== */
.docs-footer {
    padding: 24px 0;
    margin-top: 48px;
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===== Loading spinner ===== */
.page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .mobile-toggle { display: block; }
    .main-content { margin-left: 0; padding: 16px 20px; padding-top: 56px; }
    .api-key-bar { position: relative; }
    .api-key-bar-inner { flex-direction: column; }
    .info-cards { grid-template-columns: 1fr; }
}
