/* =====================================================================
   base.css — theme tokens, reset, typography, app shell (sidebar + content)
   Two themes are defined entirely with CSS custom properties so colours are
   easy to change in one place:
     - light  -> :root (the default)
     - dark   -> [data-theme="dark"]
   The active theme is set via the data-theme attribute on <html>.
   ===================================================================== */

/* ---- Light theme (default) ---- */
:root {
    /* Surfaces */
    --bg: #faf9f7;
    --surface: #ffffff;
    --surface-2: #f4f5f7;
    --surface-3: #eceef2;
    --border: #e4e6ec;
    --border-strong: #d3d7e0;

    /* Text */
    --text: #1f2430;
    --muted: #5d6675;
    --faint: #8a93a3;

    /* Brand / accents */
    --accent: #7c5cff;
    --accent-2: #3f6fe0;
    --accent-grad: linear-gradient(135deg, #7c5cff 0%, #4a8cff 100%);
    --on-accent: #ffffff;

    /* Status */
    --success: #0f9d6b;
    --success-bg: rgba(15, 157, 107, 0.12);
    --danger: #d64545;
    --danger-bg: rgba(214, 69, 69, 0.10);
    --danger-ring: 0 0 0 3px rgba(214, 69, 69, 0.30);

    /* Sidebar */
    --sidebar-bg: #f1f0ec;
    --sidebar-border: #e4e6ec;
    --sidenav-hover-bg: rgba(0, 0, 0, 0.05);
    --sidenav-active-bg: rgba(124, 92, 255, 0.12);

    /* Misc surfaces */
    --icon-chip-bg: #ffffff;
    --icon-chip-ring: rgba(42, 49, 71, 0.16);

    /* Syntax colours for rendered request/response payloads (see the Prism token map
       in components.css). Kept per-theme so highlighting follows the light/dark toggle. */
    --code-key: #6d28d9;
    --code-string: #0f7b5f;
    --code-number: #b45309;
    --code-url: #2563eb;
    --code-punct: #8a93a3;

    /* Shape */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow: 0 8px 24px rgba(20, 30, 60, 0.10);
    --ring: 0 0 0 3px rgba(124, 92, 255, 0.30);

    --container: 1040px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
    --bg: #0b0d14;
    --surface: #141826;
    --surface-2: #1c2133;
    --surface-3: #242a40;
    --border: #2a3147;
    --border-strong: #3a425e;

    --text: #eef1f8;
    --muted: #9aa3bd;
    --faint: #6b7390;

    --accent: #7c5cff;
    --accent-2: #6ea8ff;
    --accent-grad: linear-gradient(135deg, #7c5cff 0%, #4a8cff 100%);
    --on-accent: #ffffff;

    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.12);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --danger-ring: 0 0 0 3px rgba(248, 113, 113, 0.30);

    --sidebar-bg: #0e1019;
    --sidebar-border: #1f2538;
    --sidenav-hover-bg: rgba(255, 255, 255, 0.06);
    --sidenav-active-bg: rgba(124, 92, 255, 0.18);

    --icon-chip-bg: #ffffff;
    --icon-chip-ring: rgba(31, 36, 48, 0.22);

    --code-key: #c4b5fd;
    --code-string: #6ee7b7;
    --code-number: #fbbf24;
    --code-url: #93c5fd;
    --code-punct: #6b7390;

    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

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

html,
body {
    margin: 0;
    padding: 0;
}

/* Always reserve space for the vertical scrollbar so content doesn't shift
   horizontally when the page grows tall enough to need one (e.g. expanding a row). */
html {
    scrollbar-gutter: stable;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
    /* Values the portal shows can be long and unbroken (a 200-character server name, a URL). Break them
       rather than let them widen the page; .portal-content's min-width: 0 is what makes this take effect. */
    overflow-wrap: break-word;
}

/* Subtle accent glow only in dark mode. */
[data-theme="dark"] body {
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
        radial-gradient(1000px 500px at -10% 0%, rgba(74, 140, 255, 0.12), transparent 55%),
        var(--bg);
}

a {
    color: var(--accent-2);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1 {
    font-size: 1.7rem;
    margin: 0 0 0.25rem;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

h2 {
    font-size: 1.2rem;
    margin: 0 0 0.5rem;
    overflow-wrap: anywhere;
}

h3 {
    font-size: 1rem;
    margin: 0 0 0.5rem;
    overflow-wrap: anywhere;
}

code {
    font-family: "Cascadia Code", "Consolas", ui-monospace, monospace;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.15em 0.45em;
    font-size: 0.85em;
    /* Breaks a long value only when it cannot fit a line on its own, rather than mid-word wherever the
       line happens to end. Long values that need to stay on one line sit in a .portal-copy-field. */
    overflow-wrap: break-word;
}

/* Hidden on screen but still reachable by screen readers and keyboard focus. */
.portal-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* =====================================================================
   App shell — left sidebar + scrollable content (claude.ai style)
   ===================================================================== */
.portal-shell {
    display: flex;
    min-height: 100vh;
}

.portal-sidebar {
    flex: 0 0 260px;
    width: 260px;
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}

.portal-brand:hover {
    text-decoration: none;
}

.portal-brand-mark {
    width: 48px;
    height: auto;
    flex: none;
}

.portal-sidenav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.portal-sidenav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-weight: 500;
}

.portal-sidenav a:hover {
    background: var(--sidenav-hover-bg);
    color: var(--text);
    text-decoration: none;
}

.portal-sidenav a.is-active {
    background: var(--sidenav-active-bg);
    color: var(--accent);
    font-weight: 600;
}

.portal-sidenav a i,
.portal-sidenav-btn i {
    width: 1.1rem;
    text-align: center;
}

.portal-sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--sidebar-border);
}

.portal-sidebar-footer form {
    margin: 0;
}

.portal-sidenav-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}

.portal-sidenav-btn:hover {
    background: var(--sidenav-hover-bg);
    color: var(--text);
}

a.portal-sidenav-btn:hover {
    text-decoration: none;
}

a.portal-sidenav-btn.is-active {
    background: var(--sidenav-active-bg);
    color: var(--accent);
    font-weight: 600;
}

.portal-content {
    flex: 1;
    min-width: 0;
}

.portal-main {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 2rem 2rem 3rem;
}

.portal-main-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* ---- Responsive: collapse sidebar to a top strip on small screens ---- */
@media (max-width: 820px) {
    .portal-shell {
        flex-direction: column;
    }

    .portal-sidebar {
        flex: none;
        width: auto;
        height: auto;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.25rem;
        border-right: none;
        border-bottom: 1px solid var(--sidebar-border);
    }

    .portal-brand {
        margin-bottom: 0;
    }

    .portal-sidenav {
        flex-direction: row;
    }

    .portal-sidebar-footer {
        margin: 0 0 0 auto;
        flex-direction: row;
        padding-top: 0;
        border-top: none;
    }

    .portal-main {
        padding: 1.25rem;
    }
}
