/* ============================================================
   CP Games — Operator API Docs
   Sophisticated theme with Light / Dark mode (CSS variables)
   ============================================================ */

:root {
    --brand: #7c3aed;
    --brand-soft: rgba(124, 58, 237, 0.1);
    --bg: #f6f7fb;
    --bg-accent: radial-gradient(1200px 500px at 85% -10%, rgba(124, 58, 237, 0.12), transparent 60%),
        radial-gradient(900px 420px at -10% 0%, rgba(34, 211, 238, 0.1), transparent 55%);
    --surface: #ffffff;
    --surface-2: #f1f3f9;
    --border: #e4e7f0;
    --text: #141824;
    --muted: #5b6376;
    --code-bg: #0f172a;
    --code-text: #e2e8f0;
    --sidebar-bg: rgba(255, 255, 255, 0.86);
    --shadow: 0 12px 40px rgba(20, 24, 36, 0.08);
    --radius: 14px;
    --method-get: #16a34a;
    --method-post: #2563eb;
    --method-put: #d97706;
    --method-delete: #dc2626;
    --success: #16a34a;
    --danger: #dc2626;
    --topbar-h: 64px;
}

[data-theme="dark"] {
    --bg: #0a0e1a;
    --bg-accent: radial-gradient(1200px 500px at 85% -10%, rgba(124, 58, 237, 0.22), transparent 60%),
        radial-gradient(900px 420px at -10% 0%, rgba(34, 211, 238, 0.12), transparent 55%);
    --surface: #11172a;
    --surface-2: #0d1322;
    --border: #232c47;
    --text: #e8ecf6;
    --muted: #9aa4bf;
    --code-bg: #070b16;
    --code-text: #e2e8f0;
    --sidebar-bg: rgba(13, 19, 34, 0.9);
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    background-image: var(--bg-accent);
    background-attachment: fixed;
    color: var(--text);
    font-size: 15px;
    line-height: 1.65;
    transition: background 0.25s ease, color 0.25s ease;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.docs-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.docs-brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 16px; }
.docs-brand img { height: 32px; width: auto; max-width: 170px; object-fit: contain; display: block; }
.docs-brand .mark {
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, var(--brand), #22d3ee);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px; font-weight: 800;
}

.version-badge {
    font-size: 12px; font-weight: 600;
    background: var(--brand-soft); color: var(--brand);
    border: 1px solid var(--border);
    padding: 2px 10px; border-radius: 999px;
    white-space: nowrap;
}

.topbar-spacer { flex: 1; }

.agent-chip {
    display: flex; align-items: center; gap: 9px;
    font-size: 13px; color: var(--muted);
    border: 1px solid var(--border);
    background: var(--surface);
    padding: 6px 8px 6px 12px; border-radius: 999px;
}
.agent-chip strong { color: var(--text); }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 8px 14px; border-radius: 10px;
    font-size: 13.5px; font-weight: 600; cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), #6d28d9); border-color: transparent; color: #fff; }
.btn-danger { background: linear-gradient(135deg, #dc2626, #991b1b); border-color: transparent; color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 8px 10px; }

.theme-toggle { line-height: 0; }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
/* Botão quadrado ajustado ao ícone — nunca largo */
button.theme-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ---------- Language select (flag + 2-letter code) ---------- */
.lang-select {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 999px;
    padding: 7px 8px 7px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    appearance: auto;
    /* Largura fixa: trocar de idioma não desloca o toggle */
    width: 102px;
    flex-shrink: 0;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
.lang-select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Toggle e chip nunca são comprimidos pelo select */
.docs-topbar .theme-toggle,
.docs-topbar .agent-chip,
.docs-topbar .version-badge {
    flex-shrink: 0;
}

/* ---------- Layout ---------- */
.docs-shell {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    max-width: 1280px;
    margin: 0 auto;
    min-height: calc(100vh - var(--topbar-h));
}

/* ---------- Sidebar ---------- */
.docs-sidebar {
    position: sticky;
    top: var(--topbar-h);
    align-self: start;
    max-height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    padding: 22px 14px 40px 22px;
    font-size: 13.5px;
}

.sidebar-group { margin-bottom: 20px; }
.sidebar-title {
    font-size: 11px; font-weight: 700; letter-spacing: 0.09em;
    text-transform: uppercase; color: var(--muted);
    margin: 0 0 8px 10px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px; border-radius: 9px;
    color: var(--muted); font-weight: 500;
}
.sidebar-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.sidebar-link .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.55; flex-shrink: 0; }

.method-mini {
    font-size: 10px; font-weight: 800; letter-spacing: 0.04em;
    padding: 1px 6px; border-radius: 6px; flex-shrink: 0;
}
.method-mini.post { background: rgba(37, 99, 235, 0.13); color: var(--method-post); }
.method-mini.get { background: rgba(22, 163, 74, 0.13); color: var(--method-get); }

/* ---------- Content ---------- */
.docs-content { padding: 30px 34px 90px; min-width: 0; }

.hero {
    border: 1px solid var(--border);
    background: linear-gradient(135deg, var(--surface), var(--surface-2));
    border-radius: 20px;
    padding: 34px 32px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: "";
    position: absolute; right: -70px; top: -70px;
    width: 250px; height: 250px; border-radius: 50%;
    background: radial-gradient(circle, var(--brand-soft), transparent 70%);
}
.hero h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--muted); max-width: 640px; }

.section { margin-bottom: 44px; scroll-margin-top: 84px; }
.section > h2 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
.section > .lede { color: var(--muted); margin: 0 0 18px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-head { padding: 18px 22px 0; }
.card-body { padding: 6px 22px 22px; }

.endpoint-path {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin: 6px 0 4px;
}
.method {
    font-size: 12px; font-weight: 800; letter-spacing: 0.05em;
    padding: 4px 11px; border-radius: 8px; color: #fff; flex-shrink: 0;
}
.method.post { background: var(--method-post); }
.method.get { background: var(--method-get); }
.path {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14.5px; font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 5px 12px; border-radius: 9px;
    word-break: break-all;
}
.copy-btn {
    border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
    border-radius: 8px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.copy-btn:hover { color: var(--brand); border-color: var(--brand); }

.card h3.endpoint-title { margin: 2px 0 0; font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

table.spec { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 12px 0; }
table.spec th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.spec td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.spec tr:last-child td { border-bottom: none; }
table.spec code, p code, li code {
    font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
    font-size: 12.5px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px;
}
.req { color: var(--danger); font-weight: 700; font-size: 12px; }
.opt { color: var(--muted); font-size: 12px; }

/* ---------- Code blocks + tabs ---------- */
.code-tabs { display: flex; gap: 6px; margin: 14px 0 0; }
.code-tab {
    border: 1px solid var(--border); border-bottom: none;
    background: var(--surface-2); color: var(--muted);
    font-size: 12.5px; font-weight: 700;
    padding: 7px 16px; border-radius: 10px 10px 0 0; cursor: pointer;
}
.code-tab.active { background: var(--code-bg); color: #fff; border-color: var(--code-bg); }
.code-wrap { position: relative; background: var(--code-bg); border-radius: 0 12px 12px 12px; }
.code-wrap pre {
    margin: 0; padding: 18px;
    color: var(--code-text);
    font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
    font-size: 12.8px; line-height: 1.6;
    overflow-x: auto; max-height: 420px;
}
.code-wrap .copy-btn {
    position: absolute; top: 10px; right: 10px;
    background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.16); color: #cbd5e1;
}
.code-wrap .copy-btn:hover { color: #fff; border-color: #fff; }

h4.block-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 20px 0 8px; }

.status-pill {
    display: inline-block; font-size: 12px; font-weight: 800;
    padding: 2px 10px; border-radius: 999px; margin-right: 8px;
}
.status-pill.ok { background: rgba(22, 163, 74, 0.14); color: var(--success); }
.status-pill.err { background: rgba(220, 38, 38, 0.12); color: var(--danger); }

/* ---------- Credentials ---------- */
.cred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 14px 0; }
.cred {
    border: 1px dashed var(--border); border-radius: 11px;
    padding: 12px 14px; background: var(--surface-2);
}
.cred .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.cred .v { font-family: "JetBrains Mono", monospace; font-size: 13px; word-break: break-all; margin: 4px 0 8px; }

.alert {
    border-radius: 11px; padding: 13px 16px; font-size: 13.5px;
    border: 1px solid var(--border); background: var(--surface-2);
    margin: 14px 0;
}
.alert.warn { border-color: rgba(217, 119, 6, 0.45); background: rgba(217, 119, 6, 0.08); }
.alert.info { border-color: rgba(37, 99, 235, 0.4); background: rgba(37, 99, 235, 0.07); }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh; display: grid; place-items: center;
    padding: 24px;
}
.login-card {
    width: min(430px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px; box-shadow: var(--shadow);
    padding: 38px 36px;
}
.login-card .mark {
    width: 52px; height: 52px; border-radius: 15px;
    background: linear-gradient(135deg, var(--brand), #22d3ee);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 24px; font-weight: 800; margin-bottom: 18px;
}
.login-card h1 { margin: 0 0 4px; font-size: 23px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
    width: 100%; padding: 11px 13px; font-size: 14px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); color: var(--text);
}
.field input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.form-error {
    background: rgba(220, 38, 38, 0.09); border: 1px solid rgba(220, 38, 38, 0.4);
    color: var(--danger); border-radius: 10px; padding: 10px 13px; font-size: 13.5px; margin-bottom: 15px;
}
.flash-ok {
    background: rgba(22, 163, 74, 0.09); border: 1px solid rgba(22, 163, 74, 0.4);
    color: var(--success); border-radius: 10px; padding: 10px 13px; font-size: 13.5px; margin-bottom: 15px;
}
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 14.5px; }

/* ---------- Try-it panel ---------- */
.tryit-panel {
    position: fixed; top: 0; right: 0; z-index: 70;
    width: min(620px, 94vw); height: 100vh;
    background: var(--surface); border-left: 1px solid var(--border);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.25);
    transform: translateX(105%); transition: transform 0.28s ease;
    display: flex; flex-direction: column;
}
.tryit-panel.open { transform: translateX(0); }
.tryit-head {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.tryit-head h2 { margin: 0; font-size: 16px; flex: 1; }
.tryit-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.tryit-body select, .tryit-body textarea, .tryit-body input {
    width: 100%; padding: 10px 12px; font-size: 13.5px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); color: var(--text);
    font-family: "JetBrains Mono", monospace;
}
.tryit-body select { font-family: inherit; }
.tryit-resp { margin-top: 14px; }
.tryit-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.overlay {
    position: fixed; inset: 0; z-index: 65;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ---------- Footer ---------- */
.docs-footer {
    border-top: 1px solid var(--border);
    padding: 22px 34px; color: var(--muted); font-size: 13px;
    display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
    .docs-shell { grid-template-columns: 1fr; }
    .docs-sidebar {
        position: static; max-height: none;
        display: flex; gap: 6px; overflow-x: auto;
        padding: 14px;
    }
    .sidebar-group { display: contents; }
    .sidebar-title { display: none; }
    .sidebar-link { white-space: nowrap; border: 1px solid var(--border); }
    .docs-content { padding: 20px 16px 80px; }
    .agent-chip .who { display: none; }
}
