/* ==========================================================================
   Bati B2B — API documentation
   Display type: BR Firma (see brfirma.css). Body text: Outfit.
   Supports a light and a dark theme via [data-theme] on <html>.
   ========================================================================== */

/* ---------- Tokens ---------------------------------------------------- */
:root {
    color-scheme: light;

    --bg:          #FFFFFF;
    --bg-soft:     #F5F8FB;
    --bg-sunken:   #EDF2F7;
    --border:      #E2E9F0;
    --border-soft: #EEF3F8;

    --text:        #0B1824;
    --muted:       #55697D;
    --dim:         #7D8FA3;

    --brand:       #1A5D94;
    --brand-deep:  #0F3F67;
    --brand-wash:  #EAF2F9;
    --lime:        #A6CF52;
    --lime-deep:   #6E9530;
    --lime-wash:   #F1F8E2;

    --get:         #0A7D4F;
    --get-wash:    #E4F6EC;
    --post:        #1A5D94;
    --post-wash:   #E6EFF7;
    --err:         #B42318;
    --err-wash:    #FDECEA;

    /* the code surface stays dark in both themes */
    --code-bg:     #071320;
    --code-bar:    #0C1F33;
    --code-fg:     #C9D7E6;
    --code-line:   rgba(255, 255, 255, .09);

    --rail:        #050D16;
    --rail-fg:     #F3F7FB;
    --rail-muted:  #93A7BC;
    --rail-dim:    #64798F;
    --rail-line:   rgba(255, 255, 255, .09);
    --rail-hover:  rgba(255, 255, 255, .06);

    --display: 'BRFirma', 'Outfit', system-ui, sans-serif;
    --body:    'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono:    ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

    --rail-w:  292px;
    --top-h:   64px;
    --ease:    cubic-bezier(.22, 1, .36, 1);
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg:          #050D16;
    --bg-soft:     #0A1726;
    --bg-sunken:   #0D2033;
    --border:      rgba(255, 255, 255, .10);
    --border-soft: rgba(255, 255, 255, .06);

    --text:        #F3F7FB;
    --muted:       #9DB0C4;
    --dim:         #6B8098;

    --brand:       #74B4EA;
    --brand-deep:  #9CC9F0;
    --brand-wash:  rgba(46, 134, 214, .14);
    --lime-deep:   #BEE463;
    --lime-wash:   rgba(166, 207, 82, .14);

    --get:         #6FD3A2;
    --get-wash:    rgba(111, 211, 162, .14);
    --post:        #74B4EA;
    --post-wash:   rgba(116, 180, 234, .14);
    --err:         #F08D84;
    --err-wash:    rgba(240, 141, 132, .14);

    /* lifted above the page surface so code panels still read as raised */
    --code-bg:     #0B1B2B;
    --code-bar:    #12293E;
    --code-line:   rgba(255, 255, 255, .11);
}

/* ---------- Base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--top-h) + 20px);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-size: 15.5px;
    line-height: 1.68;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

p { margin: 0 0 14px; }
ol, ul { margin: 0 0 14px; padding-left: 20px; }
li { margin-bottom: 7px; }
li::marker { color: var(--dim); }

code, pre, kbd { font-family: var(--mono); font-size: 13px; }

:where(p, td, li, h2, h3, dd) > code {
    background: var(--bg-sunken);
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: .86em;
    color: var(--text);
    word-break: break-word;
}

::selection { background: var(--lime); color: #0B1824; }

:focus-visible {
    outline: 2px solid var(--lime);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Shell ----------------------------------------------------- */
.layout { display: flex; align-items: flex-start; }

/* ---------- Rail (sidebar) -------------------------------------------- */
.rail {
    width: var(--rail-w);
    flex: none;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--rail);
    color: var(--rail-fg);
    border-right: 1px solid var(--rail-line);
}

.rail__head {
    padding: 22px 22px 16px;
    border-bottom: 1px solid var(--rail-line);
}

.rail__brand { display: flex; align-items: center; gap: 11px; }
.rail__brand img { width: 108px; height: auto; display: block; }

.rail__tag {
    display: inline-block;
    margin-top: 12px;
    padding: 3px 10px;
    border-radius: 100px;
    background: var(--lime);
    color: #0B1824;
    font-family: var(--display);
    font-weight: 700;
    font-size: .64rem;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.rail__search { position: relative; margin-top: 16px; }

.rail__search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--rail-dim);
    pointer-events: none;
}

.rail__search input {
    width: 100%;
    padding: 9px 12px 9px 35px;
    border: 1px solid var(--rail-line);
    border-radius: 9px;
    background: rgba(255, 255, 255, .045);
    color: var(--rail-fg);
    font-family: var(--body);
    font-size: .88rem;
    outline: none;
    transition: border-color .25s var(--ease), background-color .25s var(--ease);
}

.rail__search input::placeholder { color: var(--rail-dim); }
.rail__search input:focus { border-color: rgba(166, 207, 82, .55); background: rgba(255, 255, 255, .07); }

.rail__nav {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 22px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .16) transparent;
}

.rail__nav::-webkit-scrollbar { width: 8px; }
.rail__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 8px; }

.rail__group {
    font-family: var(--display);
    font-weight: 700;
    font-size: .68rem;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--rail-dim);
    margin: 22px 0 7px;
    padding-inline: 10px;
}

.rail__group:first-child { margin-top: 0; }

.rail__link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: 9px;
    color: var(--rail-muted);
    font-size: .9rem;
    line-height: 1.35;
    position: relative;
    transition: background-color .2s var(--ease), color .2s var(--ease);
}

.rail__link:hover { background: var(--rail-hover); color: var(--rail-fg); text-decoration: none; }

.rail__link.is-active {
    background: rgba(166, 207, 82, .13);
    color: var(--rail-fg);
    font-weight: 500;
}

.rail__link.is-active::before {
    content: '';
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 3px 3px 0;
    background: var(--lime);
}

.rail__verb {
    flex: none;
    width: 34px;
    font-family: var(--mono);
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--rail-dim);
}

.rail__link.is-active .rail__verb,
.rail__link:hover .rail__verb { color: var(--lime); }

.rail__foot {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--rail-line);
    display: grid;
    gap: 9px;
}

.rail__empty {
    display: none;
    padding: 10px;
    color: var(--rail-dim);
    font-size: .88rem;
}

.rail.is-filtering .rail__empty.is-on { display: block; }

/* ---------- Buttons --------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 100px;
    font-family: var(--display);
    font-weight: 700;
    font-size: .88rem;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .25s var(--ease), background-color .25s var(--ease),
                border-color .25s var(--ease), color .25s var(--ease);
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn--lime { background: var(--lime); color: #0B1824; }
.btn--lime:hover { background: #BEE463; }

.btn--ghost { border-color: var(--rail-line); color: var(--rail-fg); }
.btn--ghost:hover { background: var(--rail-hover); border-color: rgba(255, 255, 255, .26); }

/* ---------- Main ------------------------------------------------------ */
.main { flex: 1; min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--top-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 clamp(18px, 3.4vw, 46px);
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.crumbs {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: .85rem;
    color: var(--dim);
    min-width: 0;
}

.crumbs b {
    font-family: var(--display);
    font-weight: 700;
    color: var(--text);
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__spacer { flex: 1; }

.icon-btn {
    width: 38px;
    height: 38px;
    flex: none;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-soft);
    color: var(--muted);
    cursor: pointer;
    transition: all .25s var(--ease);
}

.icon-btn:hover { color: var(--text); border-color: var(--dim); }
.icon-btn .i-dark { display: none; }
:root[data-theme="dark"] .icon-btn .i-dark { display: block; }
:root[data-theme="dark"] .icon-btn .i-light { display: none; }

.rail-toggle { display: none; }

.content {
    padding: clamp(28px, 4vw, 52px) clamp(18px, 3.4vw, 46px) 110px;
    max-width: 1120px;
}

/* ---------- Headings -------------------------------------------------- */
.page-title {
    font-family: var(--display);
    font-weight: 900;
    font-size: clamp(2rem, 4vw, 2.8rem);
    line-height: 1.05;
    letter-spacing: -.028em;
    margin: 0 0 10px;
}

.lead {
    font-size: 1.08rem;
    line-height: 1.65;
    color: var(--muted);
    margin: 0 0 26px;
    max-width: 62ch;
}

.section { scroll-margin-top: calc(var(--top-h) + 20px); }
.section + .section { margin-top: 64px; }

.section > h2 {
    font-family: var(--display);
    font-weight: 900;
    font-size: clamp(1.4rem, 2.4vw, 1.85rem);
    letter-spacing: -.022em;
    line-height: 1.2;
    margin: 0 0 16px;
    padding-top: 30px;
    border-top: 1px solid var(--border);
}

#introduction > h2:first-child,
.section--lead > h2 { border-top: 0; padding-top: 0; }

.kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--display);
    font-weight: 700;
    font-size: .68rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--brand);
    margin-bottom: 14px;
}

.kicker::before {
    content: '';
    width: 22px;
    height: 2px;
    background: linear-gradient(90deg, var(--brand), transparent);
}

.sub-heading {
    font-family: var(--display);
    font-weight: 700;
    font-size: .7rem;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--dim);
    margin: 24px 0 9px;
}

/* ---------- Base URL card --------------------------------------------- */
.url-card {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-soft);
    margin: 20px 0;
}

.url-card__label {
    font-family: var(--display);
    font-weight: 700;
    font-size: .66rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--dim);
}

.url-card code {
    font-size: .92rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-all;
    flex: 1;
    min-width: 0;
}

/* ---------- Note ------------------------------------------------------ */
.note {
    position: relative;
    display: flex;
    gap: 13px;
    padding: 15px 18px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    border-radius: 0 12px 12px 0;
    background: var(--brand-wash);
    margin: 20px 0;
    font-size: .95rem;
}

.note svg { flex: none; margin-top: 3px; color: var(--brand); }
.note p:last-child { margin-bottom: 0; }

.note--warn { border-left-color: var(--lime-deep); background: var(--lime-wash); }
.note--warn svg { color: var(--lime-deep); }

/* ---------- Steps ----------------------------------------------------- */
.steps { list-style: none; margin: 0 0 20px; padding: 0; counter-reset: step; }

.steps li {
    position: relative;
    counter-increment: step;
    padding: 0 0 20px 46px;
    margin: 0;
}

.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-family: var(--display);
    font-weight: 700;
    font-size: .8rem;
}

.steps li::after {
    content: '';
    position: absolute;
    left: 13.5px;
    top: 32px;
    bottom: 4px;
    width: 1px;
    background: var(--border);
}

.steps li:last-child { padding-bottom: 0; }
.steps li:last-child::after { display: none; }

:root[data-theme="dark"] .steps li::before { color: #050D16; background: var(--brand); }

/* ---------- Tables ---------------------------------------------------- */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 4px;
}

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }

th {
    text-align: left;
    font-family: var(--display);
    font-weight: 700;
    font-size: .66rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--dim);
    padding: 11px 16px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
    color: var(--muted);
}

td:first-child { color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg-soft); }

.params td:first-child { white-space: nowrap; }

.param__meta {
    display: block;
    margin-top: 4px;
    font-size: .74rem;
    letter-spacing: .01em;
}

.param__sep { color: var(--border); margin: 0 5px; }

.param__meta .is-required {
    font-family: var(--display);
    font-weight: 700;
    font-size: .68rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--err);
}

.param__meta .is-optional { color: var(--dim); }

.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 100px;
    font-family: var(--display);
    font-weight: 700;
    font-size: .64rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
}

.pill--req { background: var(--err-wash); color: var(--err); }
.pill--opt { background: var(--bg-sunken); color: var(--dim); }

.type {
    font-family: var(--mono);
    font-size: .78rem;
    color: var(--dim);
    white-space: nowrap;
}

/* ---------- Endpoint -------------------------------------------------- */
.endpoint {
    border: 1px solid var(--border);
    border-radius: 18px;
    margin: 22px 0;
    background: var(--bg);
    overflow: hidden;
    scroll-margin-top: calc(var(--top-h) + 20px);
}

.endpoint__head {
    padding: 18px 22px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
}

.endpoint__head h3 {
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -.01em;
    margin: 0 0 11px;
}

.endpoint__line {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.verb {
    font-family: var(--mono);
    font-weight: 700;
    font-size: .7rem;
    letter-spacing: .06em;
    padding: 4px 10px;
    border-radius: 7px;
}

.verb--get  { color: var(--get);  background: var(--get-wash); }
.verb--post { color: var(--post); background: var(--post-wash); }

.route {
    font-family: var(--mono);
    font-size: .88rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-all;
}

.route .route__var { color: var(--brand); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--muted);
}

.chip svg { color: var(--dim); }
.chip--auth { border-color: color-mix(in srgb, var(--brand) 40%, transparent); color: var(--brand); }
.chip--auth svg { color: var(--brand); }

.endpoint__body { padding: 22px; }
.endpoint__body > p:first-child { margin-top: 0; }
.endpoint__body .sub-heading:first-of-type { margin-top: 0; }

.pane {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 26px;
    margin-top: 24px;
}

.pane > * { min-width: 0; }

/* ---------- Code ------------------------------------------------------ */
.code {
    border: 1px solid var(--code-line);
    border-radius: 13px;
    background: var(--code-bg);
    overflow: hidden;
}

.code__bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 9px 15px;
    background: var(--code-bar);
    border-bottom: 1px solid var(--code-line);
}

.code__lang {
    font-family: var(--mono);
    font-size: .68rem;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #62788F;
}

.copy {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border: 1px solid var(--code-line);
    border-radius: 7px;
    background: rgba(255, 255, 255, .05);
    color: #A8BACE;
    font-family: var(--body);
    font-size: .74rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s var(--ease);
}

.copy:hover { background: rgba(255, 255, 255, .11); color: #fff; }
.copy.is-done { color: var(--lime); border-color: rgba(166, 207, 82, .45); }

.code pre {
    margin: 0;
    padding: 16px 18px;
    color: var(--code-fg);
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.code pre::-webkit-scrollbar { height: 8px; }
.code pre::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 8px; }

.t-key  { color: #9CC9F0; }
.t-str  { color: #BEE463; }
.t-num  { color: #F0B36B; }
.t-bool { color: #E295D6; }
.t-null { color: #7D8FA3; }
.t-punc { color: #6B8098; }
.t-flag { color: #74B4EA; }

/* ---------- Response tabs --------------------------------------------- */
.tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--bg);
    color: var(--muted);
    font-family: var(--body);
    font-size: .8rem;
    cursor: pointer;
    transition: all .22s var(--ease);
}

.tab:hover { border-color: var(--dim); color: var(--text); }

.tab[aria-selected="true"] {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
    font-weight: 500;
}

.tab__code {
    font-family: var(--mono);
    font-size: .72rem;
    font-weight: 700;
}

.tab__code--ok  { color: var(--get); }
.tab__code--err { color: var(--err); }
.tab[aria-selected="true"] .tab__code--ok  { color: var(--lime); }
.tab[aria-selected="true"] .tab__code--err { color: #F3A79F; }

.panel[hidden] { display: none; }

/* ---------- Reference grid -------------------------------------------- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 26px;
}

/* ---------- Scrim (mobile rail) --------------------------------------- */
.scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(5, 13, 22, .55);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: all .3s var(--ease);
}

body.rail-open .scrim { opacity: 1; visibility: visible; }

/* ---------- Responsive ------------------------------------------------ */
@media (max-width: 1080px) {
    .pane, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .rail {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        width: min(310px, 86vw);
        transform: translateX(-100%);
        transition: transform .32s var(--ease);
        box-shadow: 0 0 60px rgba(0, 0, 0, .5);
    }

    body.rail-open .rail { transform: none; }

    .rail-toggle { display: grid; }

    .content { padding-bottom: 80px; }
}

@media (max-width: 560px) {
    body { font-size: 15px; }
    .topbar { gap: 10px; padding-inline: 16px; }
    .content { padding-inline: 16px; }
    .endpoint__body { padding: 18px 15px; }
    .endpoint__head { padding: 16px 15px; }
    .url-card { gap: 8px; }
    .code pre { font-size: 12px; padding: 14px; }
    th, td { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        transition-duration: .001ms !important;
        animation-duration: .001ms !important;
    }
}

/* ---------- Print ----------------------------------------------------- */
@media print {
    .rail, .topbar, .copy, .scrim { display: none !important; }
    .content { max-width: none; padding: 0; }
    .panel[hidden] { display: block !important; }
    .endpoint { break-inside: avoid; }
}
