/* ── DESIGN TOKENS ──────────────────────────────────────────── */
:root {
    --bg-base:       #0f172a;
    --bg-surface:    #1e293b;
    --bg-terminal:   #020617;
    --border-color:  #334155;
    --text-primary:  #f8fafc;
    --text-muted:    #94a3b8;
    --text-body:     #cbd5e1;
    --accent-sky:    #38bdf8;
    --accent-emerald:#10b981;
    --header-height: 64px;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-body);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ── HEADER ─────────────────────────────────────────────────── */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    gap: 16px;
}

.logo-area {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.logo-url { text-decoration: none; color: #ffffff; }
.logo-url:visited { color: inherit; }
.logo-accent { color: var(--accent-sky); }

.console-badge {
    font-size: 0.75rem;
    font-weight: 400;
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--accent-sky);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 10px;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

/* ── HEADER NAV ─────────────────────────────────────────────── */
.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    margin-left: 32px;
}

.header-nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    transition: color 0.15s, background-color 0.15s;
}

.header-nav-link:hover,
.header-nav-link.active {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.06);
}

.user-auth-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Hamburger-only blocks, shown by the max-width: 1279px query below. They must be
   declared before it: a later rule of equal specificity would win on phones. */
.mobile-nav-auth,
.app-header .header-playground-btn { display: none; }

.user-auth-actions > span {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── LAYOUT GRIDS ───────────────────────────────────────────── */
/* Playground: sidebar + content + right panel */
.layout-wrapper {
    margin-top: var(--header-height);
    display: grid;
    grid-template-columns: 320px 1fr 1fr;
    min-height: calc(100vh - var(--header-height));
}

/* Landing / docs: sidebar + content */
.layout-wrapper-aside-1-col {
    margin-top: var(--header-height);
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: calc(100vh - var(--header-height));
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar-nav {
    background-color: var(--bg-base);
    border-right: 1px solid var(--border-color);
    padding: 20px 14px 32px;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.sidebar-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 0 4px 12px;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Dataset filter — v1 (2025 Q3) vs v2 (2026 Q2), as one segmented
   control. Both are listed together, so this keeps the sidebar readable. */
.nav-version-filter {
    display: flex;
    padding: 3px;
    margin-bottom: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.nav-version-option {
    flex: 1;
    padding: 5px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-version-option:hover { color: var(--text-primary); }

.nav-version-option.is-selected {
    color: var(--bg-base);
    background: var(--accent-sky);
}

.nav-version-option:focus-visible {
    outline: 2px solid var(--accent-sky);
    outline-offset: 1px;
}

.nav-search {
    position: relative;
    margin-bottom: 14px;
}

.nav-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    width: 14px;
    height: 14px;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.nav-search-input {
    width: 100%;
    padding: 8px 10px 8px 32px;
    font-size: 0.8rem;
    color: var(--text-primary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.nav-search-input::placeholder { color: var(--text-muted); }

.nav-search-input:focus {
    outline: none;
    border-color: var(--accent-sky);
}

.nav-search-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 8px;
}

/* ── Endpoint groups (collapsible) ── */
.nav-group { margin-bottom: 2px; }
.nav-group ul { list-style: none; padding: 2px 0 8px; }

.nav-group-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 6px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.nav-group-head::-webkit-details-marker { display: none; }
.nav-group-head:hover { background-color: rgba(255, 255, 255, 0.04); }
.nav-group-head:focus-visible { outline: 2px solid var(--accent-sky); outline-offset: -2px; }

.nav-group-chevron {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.nav-group[open] > .nav-group-head .nav-group-chevron { transform: rotate(90deg); }

.nav-group-label { flex: 1; min-width: 0; }

.nav-group-count {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ── Endpoint rows ── */
.nav-item {
    position: relative;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
    margin-left: 10px;
    padding: 6px 8px;
    color: var(--text-body);
    text-decoration: none;
    font-size: 0.8rem;
    border-radius: 6px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--text-primary);
    background-color: rgba(56, 189, 248, 0.14);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 7px;
    bottom: 7px;
    width: 3px;
    border-radius: 2px;
    background: var(--accent-sky);
}

.nav-item:focus-visible { outline: 2px solid var(--accent-sky); outline-offset: -2px; }

.nav-method {
    margin-top: 1px;
    padding: 1px 0;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.62rem;
    font-weight: 700;
    text-align: center;
}

.nav-method-get  { background: rgba(56, 189, 248, 0.15); color: var(--accent-sky); }
.nav-method-post { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

.nav-item-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Long names wrap to two lines at most; the title attribute has the rest. */
.nav-item-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}

.nav-item-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.66rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.nav-item-tags {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    margin-top: 1px;
}

.nav-dataset,
.nav-deprecated {
    padding: 0 5px;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.5;
}

.nav-dataset-v1 { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.nav-dataset-v2 { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.nav-deprecated { background: rgba(239, 68, 68, 0.12); color: #f87171; }

@media (prefers-reduced-motion: reduce) {
    .nav-group-chevron, .nav-item, .nav-version-option { transition: none; }
}

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 4px;
    margin-right: 8px;
    font-family: monospace;
}

.badge-get  { background: rgba(56, 189, 248, 0.15); color: var(--accent-sky); }
.badge-post { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

.badge-dataset { font-size: 0.6rem; letter-spacing: 0.04em; }
.badge-dataset-v1 { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.badge-dataset-v2 { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

.badge-deprecated {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    font-size: 0.6rem;
}

/* ── MAIN CONTENT ───────────────────────────────────────────── */
.main-content {
    background-color: var(--bg-base);
    padding: 40px;
    overflow-y: auto;
    min-width: 0;
}

h1 { font-size: 2rem; color: var(--text-primary); margin-bottom: 12px; }
h2 { font-size: 1.4rem; color: var(--text-primary); margin-top: 32px; margin-bottom: 16px; }
h3 { color: var(--text-primary); }

.lead-text { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 24px; }

.hero-section { margin-bottom: 32px; }

/* ── INFO CARD ──────────────────────────────────────────────── */
.info-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 24px;
}

/* ── PARAMETERS TABLE ───────────────────────────────────────── */
.parameters-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    margin-bottom: 24px;
}

.parameters-table th,
.parameters-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.parameters-table th {
    background-color: rgba(30, 41, 59, 0.5);
    color: var(--text-primary);
    font-weight: 600;
}

/* ── CODE ───────────────────────────────────────────────────── */
code {
    font-family: 'Fira Code', Consolas, Monaco, monospace;
    /*background-color: var(--bg-surface);*/
    color: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.code-terminal {
    background-color: #010409;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
}

.code-terminal pre {
    margin: 0;
    padding: 4px;
    overflow-x: auto;
    font-family: 'Fira Code', Consolas, Monaco, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #e2e8f0;
    white-space: pre-wrap;
}

.code-terminal .json-key     { color: #ff7b72; font-weight: bold; }
.code-terminal .json-string  { color: #a5d6ff; }
.code-terminal .json-number  { color: #d2a8ff; }
.code-terminal .json-boolean { color: #ffadb1; }
.code-terminal .json-null    { color: #79c0ff; }
.code-terminal .json-comment { color: #8b949e; font-style: italic; }

/* ── TERMINAL METHOD BAR ────────────────────────────────────── */
.terminal-method-bar {
    background-color: var(--bg-terminal);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    margin-bottom: 15px;
    color: var(--accent-sky);
    overflow-x: auto;
    white-space: nowrap;
}

/* ── ENDPOINT SECTIONS ──────────────────────────────────────── */
.endpoints-specification { margin-top: 24px; }
.endpoints-specification h3 { font-size: 1rem; margin-bottom: 8px; }
.next-endpoint { margin-top: 40px; }

.section-divider { border: 0; border-top: 1px solid var(--border-color); margin: 40px 0; }

.required { color: #ef4444; }
.optional  { color: var(--text-muted); }

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    border: none;
    white-space: nowrap;
}

.btn-primary { background-color: #0284c7; color: #fff; }
.btn-primary:hover { background-color: #0369a1; }

.btn-secondary { color: var(--text-body); background-color: transparent; }
.btn-secondary:hover { color: var(--text-primary); }

.btn-execute {
    display: block;
    width: 100%;
    background-color: var(--accent-emerald);
    color: #fff;
    font-weight: 600;
    text-align: center;
    padding: 12px;
    margin-top: 24px;
}
.btn-execute:hover { background-color: #059669; }

/* ── MOBILE NAV BUTTON ──────────────────────────────────────── */
.mobile-nav-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-nav-btn span {
    display: block;
    height: 2px;
    background: var(--text-muted);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.mobile-nav-btn--open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-nav-btn--open span:nth-child(2) { opacity: 0; }
.mobile-nav-btn--open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */

/* Tablet: the request panel moves under the docs instead of a third column */
@media (max-width: 1200px) {
    .layout-wrapper {
        grid-template-columns: 260px 1fr;
    }
    .layout-wrapper > .playground-console {
        grid-column: 2;
        position: static;
        height: auto;
        border-left: none;
        border-top: 1px solid var(--border-color);
        scroll-margin-top: calc(var(--header-height) + 64px);
    }
}

/* Endpoint drawer bar: narrow screens only */
.pg-mobile-bar,
.pg-drawer-backdrop { display: none; }

/* Narrow: one column; the endpoint sidebar slides in as a drawer */
@media (max-width: 900px) {
    .layout-wrapper,
    .layout-wrapper-aside-1-col {
        grid-template-columns: 1fr;
    }
    .layout-wrapper > .playground-console { grid-column: 1; }
    /* A scrolling main would trap the sticky endpoint bar inside it. */
    .layout-wrapper > .main-content,
    .layout-wrapper-aside-1-col > .main-content { overflow: visible; }

    .layout-wrapper .sidebar-nav,
    .layout-wrapper-aside-1-col .sidebar-nav {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        height: auto;
        width: min(88vw, 360px);
        z-index: 1001;
        border-right: 1px solid var(--border-color);
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.45);
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform 0.22s ease, visibility 0s linear 0.22s;
    }
    .sidebar-nav.sidebar-nav--open {
        transform: none;
        visibility: visible;
        transition: transform 0.22s ease;
    }

    .pg-drawer-backdrop {
        display: block;
        position: fixed;
        inset: var(--header-height) 0 0 0;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.55);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
    }
    .has-drawer-open .pg-drawer-backdrop { opacity: 1; pointer-events: auto; }

    .pg-mobile-bar {
        display: flex;
        gap: 8px;
        position: sticky;
        top: var(--header-height);
        z-index: 10;
        margin: -40px -40px 24px;
        padding: 10px 40px;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border-color);
    }
    .pg-mobile-bar .btn { display: inline-flex; align-items: center; gap: 8px; }
    .pg-mobile-bar-browse { flex: 1; justify-content: center; border: 1px solid var(--border-color); }
    .pg-mobile-bar svg { width: 16px; height: 16px; }
}

@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
    .layout-wrapper .sidebar-nav,
    .layout-wrapper-aside-1-col .sidebar-nav,
    .pg-drawer-backdrop { transition: none; }
}

/* Narrow desktops: the full header (nine links + sign-in buttons) only fits
   from ~1540px, so tighten the links before switching to the hamburger. */
@media (max-width: 1599px) {
    .header-nav { margin-left: 16px; gap: 0; }
    .header-nav-link { padding: 6px 8px; font-size: 0.84rem; }
}

/* Tablets and phones: hamburger nav. The breakpoint is where the header stops
   fitting on one row, not a phone width; below it the auth buttons and the
   last links were pushed off-screen with no way to reach them. */
@media (max-width: 1279px) {
    .mobile-nav-btn { display: flex; }

    .user-auth-actions { display: none; }

    .app-header .header-playground-btn {
        display: inline-flex;
        margin-left: auto;
        margin-right: 10px;
    }
    .mobile-nav-btn { margin-left: 0; }

    .header-nav {
        margin-left: 0px;
        display: none;
        flex-direction: column;
        gap: 4px;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        max-height: calc(100vh - var(--header-height));
        overflow-y: auto;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
        z-index: 999;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .header-nav.mobile-nav-open { display: flex; }

    .header-nav-link {
        padding: 10px 12px;
        font-size: 1rem;
    }

    .mobile-nav-auth {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding-top: 12px;
        margin-top: 8px;
        border-top: 1px solid var(--border-color);
    }

    .mobile-nav-auth .btn {
        width: 100%;
        text-align: center;
        padding: 10px 16px;
    }
    /* Stacked full-width, an outline-less secondary button reads as plain text. */
    .mobile-nav-auth .btn-secondary { border: 1px solid var(--border-color); }
}

/* Phones */
@media (max-width: 640px) {
    .app-header { padding: 0 16px; }

    .btn { padding: 6px 12px; font-size: 0.8rem; }

    .main-content { padding: 20px 16px; }
    .pg-mobile-bar { margin: -20px -16px 20px; padding: 10px 16px; }

    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.2rem; }
    .lead-text { font-size: 1rem; }

    .parameters-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .parameters-table { min-width: 480px; }
}


/* ── SITE FOOTER ────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-base);
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 32px;
    font-size: 0.875rem;
}

@media (max-width: 600px) {
    .site-footer-inner { padding: 24px 16px; }
}

.site-footer-copy { color: var(--text-muted); }

.site-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.site-footer-links a {
    color: var(--text-body);
    text-decoration: none;
}

.site-footer-links a:hover { color: var(--accent-sky); }
