/* ============================================================
   CloudFran Agents — API Documentation Stylesheet
   Stripe-inspired dark sidebar + light content layout
   ============================================================ */

/* --- Imports --- */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* --- CSS Variables --- */
:root {
    --cf-sidebar-bg: #0a0e1a;
    --cf-sidebar-text: #a1a7bb;
    --cf-sidebar-heading: #ffffff;
    --cf-sidebar-active: #635bff;
    --cf-sidebar-hover: rgba(99,91,255,.12);
    --cf-sidebar-width: 280px;

    --cf-content-bg: #ffffff;
    --cf-content-text: #334155;
    --cf-content-heading: #0f172a;
    --cf-content-border: #e2e8f0;

    --cf-accent: #635bff;
    --cf-accent-light: #818cf8;
    --cf-accent-bg: #eef2ff;
    --cf-success: #22c55e;
    --cf-warning: #f59e0b;
    --cf-danger: #ef4444;
    --cf-info: #06b6d4;

    --cf-code-bg: #1e293b;
    --cf-code-text: #e2e8f0;
    --cf-code-border: #334155;

    --cf-get: #22c55e;
    --cf-post: #3b82f6;
    --cf-put: #f59e0b;
    --cf-delete: #ef4444;
    --cf-patch: #a855f7;

    --cf-font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --cf-mono: 'IBM Plex Mono', 'Fira Code', monospace;

    --cf-radius: 8px;
    --cf-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --cf-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
}

/* --- Reset & Base --- */
.apidocs-page * { box-sizing: border-box; margin: 0; padding: 0; }
.apidocs-page {
    font-family: var(--cf-font);
    color: var(--cf-content-text);
    background: var(--cf-content-bg);
    line-height: 1.65;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.apidocs-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--cf-sidebar-width);
    background: var(--cf-sidebar-bg);
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,.06);
}

.apidocs-sidebar::-webkit-scrollbar { width: 4px; }
.apidocs-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    margin-bottom: 14px;
}

.sidebar-logo-icon {
    width: 32px; height: 32px;
    background: var(--cf-accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; font-size: 14px;
}

.sidebar-logo-text {
    font-weight: 700;
    font-size: 16px;
    color: var(--cf-sidebar-heading);
    letter-spacing: -.02em;
}

.sidebar-logo-badge {
    font-size: 10px;
    font-weight: 600;
    background: var(--cf-accent);
    color: #fff;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: auto;
}

.sidebar-search {
    position: relative;
}

.sidebar-search input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    font-family: var(--cf-font);
    outline: none;
    transition: border-color .2s, background .2s;
}

.sidebar-search input::placeholder { color: rgba(255,255,255,.35); }
.sidebar-search input:focus {
    border-color: var(--cf-accent);
    background: rgba(255,255,255,.09);
}

.sidebar-search-icon {
    position: absolute;
    left: 10px; top: 50%; transform: translateY(-50%);
    color: rgba(255,255,255,.35);
    font-size: 14px;
    pointer-events: none;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 4px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,.4);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 16px 20px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 20px;
    color: var(--cf-sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 450;
    border-left: 2px solid transparent;
    transition: all .15s;
    cursor: pointer;
}

.sidebar-link:hover {
    color: #fff;
    background: var(--cf-sidebar-hover);
}

.sidebar-link.active {
    color: #fff;
    background: var(--cf-sidebar-hover);
    border-left-color: var(--cf-accent);
}

.sidebar-link .method-badge-sm {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    font-family: var(--cf-mono);
    letter-spacing: .03em;
    flex-shrink: 0;
}

.badge-get { background: rgba(34,197,94,.15); color: var(--cf-get); }
.badge-post { background: rgba(59,130,246,.15); color: var(--cf-post); }
.badge-put { background: rgba(245,158,11,.15); color: var(--cf-put); }
.badge-delete { background: rgba(239,68,68,.15); color: var(--cf-delete); }
.badge-patch { background: rgba(168,85,247,.15); color: var(--cf-patch); }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-footer a {
    display: block;
    font-size: 12px;
    color: var(--cf-sidebar-text);
    text-decoration: none;
    padding: 4px 0;
    transition: color .15s;
}

.sidebar-footer a:hover { color: #fff; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.apidocs-main {
    margin-left: var(--cf-sidebar-width);
    flex: 1;
    min-width: 0;
}

/* --- Hero Header --- */
.apidocs-hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
    padding: 64px 48px 56px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.apidocs-hero::before {
    content: '';
    position: absolute;
    top: -50%; right: -20%;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99,91,255,.2) 0%, transparent 70%);
    pointer-events: none;
}

.apidocs-hero h1 {
    font-size: 38px;
    font-weight: 700;
    letter-spacing: -.03em;
    margin-bottom: 12px;
    position: relative;
}

.apidocs-hero p {
    font-size: 17px;
    color: rgba(255,255,255,.7);
    max-width: 640px;
    line-height: 1.7;
    position: relative;
}

.hero-stats {
    display: flex;
    gap: 32px;
    margin-top: 28px;
    position: relative;
}

.hero-stat {
    text-align: center;
}

.hero-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--cf-accent-light);
}

.hero-stat-label {
    font-size: 12px;
    color: rgba(255,255,255,.5);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: 2px;
}

/* --- Content Container --- */
.apidocs-content {
    max-width: 960px;
    padding: 40px 48px 80px;
}

/* --- Section --- */
.api-section {
    padding-top: 48px;
    margin-bottom: 0;
    scroll-margin-top: 24px;
}

.api-section + .api-section {
    border-top: 1px solid var(--cf-content-border);
}

.section-header {
    margin-bottom: 28px;
}

.section-header h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--cf-content-heading);
    letter-spacing: -.02em;
    margin-bottom: 8px;
}

.section-header p {
    font-size: 15px;
    color: #64748b;
    max-width: 680px;
}

/* --- Endpoint Block --- */
.endpoint-block {
    background: #fff;
    border: 1px solid var(--cf-content-border);
    border-radius: var(--cf-radius);
    margin-bottom: 32px;
    overflow: hidden;
    box-shadow: var(--cf-shadow);
    transition: box-shadow .2s;
}

.endpoint-block:hover {
    box-shadow: var(--cf-shadow-lg);
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--cf-content-border);
    cursor: pointer;
    user-select: none;
}

.endpoint-header:hover { background: #f1f5f9; }

.method-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    font-family: var(--cf-mono);
    letter-spacing: .03em;
    flex-shrink: 0;
}

.method-get { background: #dcfce7; color: #15803d; }
.method-post { background: #dbeafe; color: #1d4ed8; }
.method-put { background: #fef3c7; color: #b45309; }
.method-delete { background: #fee2e2; color: #b91c1c; }
.method-patch { background: #f3e8ff; color: #7c3aed; }

.endpoint-path {
    font-family: var(--cf-mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--cf-content-heading);
}

.endpoint-desc-short {
    margin-left: auto;
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.endpoint-toggle {
    font-size: 18px;
    color: #94a3b8;
    transition: transform .2s;
    flex-shrink: 0;
}

.endpoint-block.open .endpoint-toggle { transform: rotate(180deg); }

.endpoint-body {
    display: none;
    padding: 24px;
}

.endpoint-block.open .endpoint-body { display: block; }

/* --- Use Case Description --- */
.use-case-desc {
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--cf-accent-bg);
    border-left: 3px solid var(--cf-accent);
    border-radius: 0 var(--cf-radius) var(--cf-radius) 0;
    font-size: 14px;
    line-height: 1.7;
    color: #334155;
}

.use-case-desc strong { color: var(--cf-content-heading); }

/* --- Parameters Table --- */
.params-heading {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
    margin-bottom: 10px;
}

.params-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
    font-size: 14px;
}

.params-table th {
    text-align: left;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 2px solid var(--cf-content-border);
    font-weight: 600;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.params-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.params-table tr:last-child td { border-bottom: none; }

.param-name {
    font-family: var(--cf-mono);
    font-weight: 500;
    color: var(--cf-content-heading);
    font-size: 13px;
}

.param-required {
    font-size: 10px;
    font-weight: 700;
    color: var(--cf-danger);
    text-transform: uppercase;
    margin-left: 4px;
}

.param-optional {
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    margin-left: 4px;
}

.param-type {
    font-family: var(--cf-mono);
    font-size: 12px;
    color: var(--cf-accent);
    background: var(--cf-accent-bg);
    padding: 1px 6px;
    border-radius: 3px;
}

/* --- Code Tabs --- */
.code-section { margin-bottom: 20px; }

.code-tabs {
    display: flex;
    background: #1e293b;
    border-radius: var(--cf-radius) var(--cf-radius) 0 0;
    border-bottom: 1px solid #334155;
    overflow: hidden;
}

.code-tab {
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--cf-font);
    transition: all .15s;
    border-bottom: 2px solid transparent;
}

.code-tab:hover { color: #e2e8f0; background: rgba(255,255,255,.04); }

.code-tab.active {
    color: #fff;
    border-bottom-color: var(--cf-accent);
    background: rgba(99,91,255,.1);
}

.code-panel {
    display: none;
    position: relative;
}

.code-panel.active { display: block; }

.code-block {
    background: var(--cf-code-bg);
    color: var(--cf-code-text);
    padding: 20px;
    border-radius: 0 0 var(--cf-radius) var(--cf-radius);
    overflow-x: auto;
    font-family: var(--cf-mono);
    font-size: 13px;
    line-height: 1.65;
    white-space: pre;
    tab-size: 2;
}

.copy-btn {
    position: absolute;
    top: 8px; right: 12px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    color: #94a3b8;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--cf-font);
    transition: all .15s;
    z-index: 2;
}

.copy-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.copy-btn.copied { background: rgba(34,197,94,.2); color: var(--cf-success); border-color: rgba(34,197,94,.3); }

/* --- Response Example --- */
.response-section {
    margin-top: 20px;
}

.response-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.response-status {
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--cf-mono);
}

.status-200 { background: #dcfce7; color: #15803d; }
.status-201 { background: #dbeafe; color: #1d4ed8; }
.status-400 { background: #fef3c7; color: #b45309; }
.status-401 { background: #fee2e2; color: #b91c1c; }
.status-404 { background: #f1f5f9; color: #64748b; }

.response-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* --- Syntax Highlighting (Minimal) --- */
.code-block .kw { color: #c084fc; }
.code-block .str { color: #86efac; }
.code-block .num { color: #fbbf24; }
.code-block .cmt { color: #64748b; font-style: italic; }
.code-block .fn { color: #67e8f9; }
.code-block .prop { color: #93c5fd; }

/* --- Info Callout --- */
.callout {
    padding: 14px 18px;
    border-radius: var(--cf-radius);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.callout-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

.callout-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.callout-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.callout-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.callout-danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* --- Auth Section --- */
.auth-box {
    background: #0f172a;
    border-radius: var(--cf-radius);
    padding: 24px;
    color: #e2e8f0;
    margin-bottom: 28px;
}

.auth-box h3 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
}

.auth-box code {
    background: rgba(255,255,255,.08);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--cf-mono);
    font-size: 13px;
}

/* --- Rate Limit Table --- */
.rate-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-bottom: 24px;
}

.rate-table th {
    text-align: left;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid var(--cf-content-border);
    font-weight: 600;
    color: #475569;
    font-size: 13px;
}

.rate-table td {
    padding: 10px 14px;
    border: 1px solid var(--cf-content-border);
}

.rate-table tr:nth-child(even) { background: #f8fafc; }

/* --- Tier Badges --- */
.tier-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.tier-starter { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.tier-pro { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.tier-enterprise { background: #faf5ff; color: #7c3aed; border: 1px solid #e9d5ff; }

/* --- Webhook Events --- */
.webhook-event {
    display: inline-block;
    font-family: var(--cf-mono);
    font-size: 12px;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 4px;
    margin: 2px 4px 2px 0;
    color: #334155;
}

/* --- Mobile Toggle --- */
.sidebar-mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px; left: 20px;
    width: 48px; height: 48px;
    background: var(--cf-accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(99,91,255,.4);
    align-items: center;
    justify-content: center;
}

/* --- Back to Top --- */
.back-to-top {
    position: fixed;
    bottom: 20px; right: 20px;
    width: 40px; height: 40px;
    background: var(--cf-accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    z-index: 200;
    box-shadow: var(--cf-shadow-lg);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .3s, transform .3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
    .apidocs-sidebar {
        transform: translateX(-100%);
        transition: transform .3s ease;
    }
    .apidocs-sidebar.open { transform: translateX(0); }
    .apidocs-main { margin-left: 0; }
    .apidocs-hero { padding: 40px 24px 36px; }
    .apidocs-hero h1 { font-size: 28px; }
    .apidocs-content { padding: 24px; }
    .sidebar-mobile-toggle { display: flex; }
    .hero-stats { flex-wrap: wrap; gap: 16px; }
}

@media (max-width: 640px) {
    .endpoint-header { flex-wrap: wrap; gap: 8px; }
    .endpoint-desc-short { display: none; }
    .hero-stats { gap: 12px; }
    .hero-stat-value { font-size: 22px; }
    .code-tabs { flex-wrap: wrap; }
    .code-tab { padding: 8px 12px; }
    .params-table { font-size: 13px; }
    .params-table th, .params-table td { padding: 6px 8px; }
}

/* --- Print --- */
@media print {
    .apidocs-sidebar, .sidebar-mobile-toggle, .back-to-top, .copy-btn { display: none !important; }
    .apidocs-main { margin-left: 0 !important; }
    .endpoint-block.open .endpoint-body, .endpoint-body { display: block !important; }
    .code-block { white-space: pre-wrap; word-break: break-all; }
}
