/* API docs page — loaded in <head> so layout paints correctly on first frame. */
.api-docs-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
    max-width: 1180px;
    margin: 0 auto;
    padding-bottom: 4rem;
}
.api-docs-sidebar {
    position: sticky;
    top: 5.5rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    max-height: calc(100vh - 6.5rem);
    overflow: auto;
}
.api-docs-side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.api-docs-side-link {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--text);
    transition: border-color var(--transition), background var(--transition);
}
.api-docs-side-link:hover {
    background: var(--surface-hover, var(--surface));
    border-color: var(--border);
}
.api-docs-side-link.is-active {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}
.api-docs-side-link .muted {
    font-size: 0.75rem;
}
.api-docs-page {
    min-width: 0;
    max-width: none;
    margin: 0;
    padding-bottom: 0;
}
@media (max-width: 900px) {
    .api-docs-layout {
        grid-template-columns: 1fr;
    }
    .api-docs-sidebar {
        position: static;
        max-height: none;
    }
    .api-docs-side-nav {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 0.5rem;
    }
}
.api-docs-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.api-meta-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.9rem;
}
.api-meta-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.api-purpose-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.api-purpose-name {
    font-weight: 600;
    font-size: 0.92rem;
}
.api-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
}
.api-section h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}
.endpoint-subhead {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.api-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.25rem;
}
.api-step {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}
.step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #041f12;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.step-content { flex: 1; }
.step-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.api-checklist {
    margin: 0.75rem 0 0 1.25rem;
    line-height: 1.8;
}
.is-rtl .api-checklist {
    margin: 0.75rem 1.25rem 0 0;
}
.endpoint-card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1.25rem;
}
.endpoint-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.endpoint-path {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.endpoint-desc {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.http-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.http-badge.get { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.http-badge.post { background: rgba(18, 214, 107, 0.15); color: var(--primary); border: 1px solid rgba(18, 214, 107, 0.3); }
.http-badge.patch { background: rgba(251, 191, 36, 0.15); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3); }
.http-badge.delete { background: rgba(248, 113, 113, 0.15); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.3); }

.param-group { margin-top: 1rem; }
.param-group h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}
.api-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
}
.api-table th {
    text-align: start;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.api-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.api-table code { font-size: 0.82rem; }

.code-tabs {
    margin: 1rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #020704;
}
.code-tab-header {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.tab-btn {
    padding: 0.55rem 1.1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.tab-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}
.tab-btn.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(18, 214, 107, 0.06);
}
.tab-pane { display: none; padding: 0; }
.tab-pane.is-active { display: block; }
.tab-pane pre {
    margin: 0;
    padding: 1.25rem;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.88rem;
    line-height: 1.5;
    background: transparent;
    color: #e2e8f0;
}
.api-docs-layout pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0.5rem 0;
}
.api-docs-layout code {
    font-family: var(--mono);
    background: var(--surface);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.88em;
}
.api-docs-layout pre code {
    background: transparent;
    padding: 0;
}
.api-docs-page pre,
.api-docs-page .code-tabs,
.api-docs-page .endpoint-path {
    direction: ltr;
    text-align: left;
}
