/* ---------- Design tokens ---------- */

:root {
    color-scheme: light dark;

    /* Typography */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    /* Radii */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 8px;

    /* Surfaces */
    --color-bg: #ffffff;
    --color-surface: #f6f8fa;
    --color-surface-2: #eef2f6;

    /* Text */
    --color-fg: #1f2328;
    --color-fg-muted: #6e7781;
    --color-fg-subtle: #9aa1a8;

    /* Borders */
    --color-border: #d0d7de;
    --color-border-muted: #e6e8eb;

    /* Accent */
    --color-accent: #1b6ec2;
    --color-accent-fg: #ffffff;
    --color-accent-hover-bg: rgba(27, 110, 194, 0.08);
    --color-focus-ring: rgba(27, 110, 194, 0.25);
    --color-link: #0366d6;

    /* Status / diff (GitHub Light) */
    --color-danger: #cf222e;
    --color-danger-bg: #ffebe9;
    --color-danger-inline: #ffb8b8;
    --color-success: #1a7f37;
    --color-success-bg: #dafbe1;
    --color-success-inline: #abf2bc;
    --color-warning: #9a6700;
    --color-error-fg: #c0392b;

    /* Sidebar (adaptive surface) */
    --color-sidebar-bg: var(--color-surface);
    --color-sidebar-fg: var(--color-fg);
    --color-sidebar-fg-muted: var(--color-fg-muted);
    --color-sidebar-border: var(--color-border);
    --color-sidebar-link-hover-bg: var(--color-surface-2);
    --color-sidebar-link-active-bg: var(--color-accent-hover-bg);
    --color-sidebar-link-active-fg: var(--color-accent);

    /* Overlays */
    --color-overlay-bg: rgba(255, 255, 255, 0.65);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.12);

    /* Error banner (intentionally not surface — needs attention) */
    --color-error-banner-bg: #fff8c5;
    --color-error-banner-fg: #1f2328;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0d1117;
        --color-surface: #161b22;
        --color-surface-2: #21262d;

        --color-fg: #c9d1d9;
        --color-fg-muted: #8b949e;
        --color-fg-subtle: #6e7681;

        --color-border: #30363d;
        --color-border-muted: #21262d;

        --color-accent: #58a6ff;
        --color-accent-fg: #0d1117;
        --color-accent-hover-bg: rgba(88, 166, 255, 0.12);
        --color-focus-ring: rgba(88, 166, 255, 0.4);
        --color-link: #58a6ff;

        --color-danger: #ff7b72;
        --color-danger-bg: rgba(248, 81, 73, 0.15);
        --color-danger-inline: rgba(248, 81, 73, 0.4);
        --color-success: #3fb950;
        --color-success-bg: rgba(46, 160, 67, 0.15);
        --color-success-inline: rgba(46, 160, 67, 0.45);
        --color-warning: #d29922;
        --color-error-fg: #ff7b72;

        --color-overlay-bg: rgba(13, 17, 23, 0.7);
        --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.5);

        --color-error-banner-bg: #4d3800;
        --color-error-banner-fg: #f0d77a;
    }
}

/* ---------- Reset ---------- */

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

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

ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

/* ---------- Layout utilities (replacing Bootstrap subset still used by markup) ---------- */

.nav {
    display: flex;
    flex-wrap: wrap;
}

.flex-column {
    flex-direction: column;
}

.nav-item {
    display: block;
}

.nav-link {
    display: block;
    padding: 0.5rem 1rem;
    color: inherit;
    text-decoration: none;
}

.navbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.navbar-brand {
    margin-right: 1rem;
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
}

.navbar-toggler {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.5rem;
    line-height: 1;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
}

.collapse {
    display: none;
}

.pl-4 { padding-left: 1.5rem; }
.px-3 { padding-left: 1rem; padding-right: 1rem; }
.px-4 { padding-left: 1.5rem; padding-right: 1.5rem; }

/* ---------- Base ---------- */

html, body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-fg);
}

a, .btn-link {
    color: var(--color-link);
}

.btn-primary {
    color: var(--color-accent-fg);
    background-color: var(--color-accent);
    border-color: var(--color-accent);
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--color-success);
}

.invalid {
    outline: 1px solid var(--color-danger);
}

.validation-message {
    color: var(--color-danger);
}

#blazor-error-ui {
    background: var(--color-error-banner-bg);
    color: var(--color-error-banner-fg);
    border-top: 1px solid var(--color-border);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }
