/* Visma Gaia-tokens, slik at appen passer inn i Business NXT. Kun lys modus. */
:root {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #f2f3f5;
    --card-bg: #ffffff;
    --border: #e2e4e9;
    --border-strong: #cccfd7;
    --focus: #1f4e66;
    --text: #133445;
    --text-secondary: #6f7687;
    --text-disabled: #8f95a4;
    --primary: #1f4e66;
    --primary-hover: #2a6480;
    --error: #cc453e;
    --error-light: #fcf1ee;
    --success: #448548;
    --success-light: #eef5ee;
    --warning: #bb5822;
    --warning-light: #fcf0e7;
    --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
    font-feature-settings: 'liga' 1, 'calt' 1;
    font-size: 0.875rem;
    line-height: 1.25rem;
    margin: 0;
}

.page {
    padding: 1rem;
}

/* Skall med sidemeny, kun når appen åpnes direkte (ikke inne i Business NXT). */
.shell {
    display: flex;
    min-height: 100vh;
}

.shell > .page {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
}

.sidebar {
    width: 15rem;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.nav-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 3.5rem;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
}

.nav-toggle {
    display: none;
    padding: 0.125rem 0.625rem;
    font-size: 1rem;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.75rem 0.5rem;
}

.nav-heading {
    margin: 1rem 0.75rem 0.25rem;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.nav-link {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border-left: 3px solid transparent;
    color: var(--text);
    text-decoration: none;
}

.nav-link:hover {
    background: var(--border);
}

.nav-link.active {
    background: var(--card-bg);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

@media (max-width: 768px) {
    .shell {
        flex-direction: column;
    }

    .sidebar {
        width: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .nav-top {
        border-bottom: none;
    }

    .nav-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        border-top: 1px solid var(--border);
    }

    .nav-links.open {
        display: flex;
    }

    .shell > .page {
        padding: 1rem;
    }
}

h1 {
    font-size: 1.25rem;
    line-height: 2rem;
    font-weight: 600;
    margin: 0;
}

h2 {
    font-size: 1rem;
    line-height: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

h1:focus {
    outline: none;
}

.subtitle,
.muted,
.hint {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin: 0;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.context-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.badge {
    border-radius: 4px;
    padding: 0 0.5rem;
    font-weight: 500;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    min-width: 0;
}

.runner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
}

@media (max-width: 900px) {
    .runner {
        grid-template-columns: minmax(0, 1fr);
    }
}

.editor {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toolbar,
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
}

.toolbar label {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

input,
select,
textarea {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
}

select {
    max-width: 22rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: -1px;
}

.code {
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

textarea.code {
    resize: vertical;
    tab-size: 2;
}

textarea.query {
    min-height: 18rem;
}

textarea.variables {
    min-height: 5rem;
}

button {
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    padding: 0.375rem 1rem;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
}

button:hover:not(:disabled) {
    background: var(--surface);
}

button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

button.primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

button:disabled {
    cursor: default;
    opacity: 0.6;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

pre.output {
    margin: 0;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 4px;
    overflow: auto;
    max-height: 70vh;
}

.alert {
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
}

.alert ul {
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
}

.alert-error {
    background: var(--error-light);
    color: var(--error);
}

.intro p {
    margin: 0;
    max-width: 48rem;
}

.section-title {
    margin-top: 1.5rem;
}

.app-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
    gap: 1rem;
}

.app-item h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.app-link {
    display: block;
    color: var(--text);
    text-decoration: none;
}

.app-link:hover {
    border-color: var(--focus);
    background: var(--surface);
}

.app-url {
    display: block;
    margin-top: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--surface);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.75rem;
    overflow-wrap: anywhere;
    user-select: all;
}

.footnote {
    margin-top: 1rem;
}

.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
    margin: 1rem 0;
}

.facts dt {
    color: var(--text-secondary);
}

.facts dd {
    margin: 0;
}

#blazor-error-ui {
    background: var(--warning-light);
    color: var(--text);
    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;
}

.blazor-error-boundary {
    background: var(--error);
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Det oppstod en feil.";
}

.loading-progress {
    position: absolute;
    display: block;
    width: 6rem;
    height: 6rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    color: var(--text-secondary);
    inset: calc(20vh + 2.5rem) 0 auto 0;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Laster");
}
