/* Lune API portal styles. MudBlazor supplies the component styles; this file adds layout details and the plain-HTML
   pieces (static error pages, code blocks, the logout form inside the profile menu). Colours use MudBlazor's palette
   variables where possible, so the dark theme works too. */

:root {
    --lune-brand: #1d4e89;
    --lune-brand-dark: #14365f;
    --lune-accent: #e0a100;
    --lune-code-bg: var(--mud-palette-background-gray, #f4f6f8);
    --lune-border: var(--mud-palette-lines-default, rgba(0, 0, 0, 0.12));
    --lune-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

html, body {
    margin: 0;
    min-height: 100%;
}

h1:focus, h1:focus-visible {
    outline: none;
}

code, pre, .lune-mono {
    font-family: var(--lune-mono);
}

/* App bar and profile menu */
.lune-logo {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.lune-menu-header {
    opacity: 0.8;
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lune-logout-form {
    margin: 0;
}

.lune-menu-button {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 6px 16px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.lune-menu-button:hover,
.lune-menu-button:focus-visible {
    background-color: var(--mud-palette-action-default-hover, rgba(0, 0, 0, 0.04));
}

/* Page heading and generic states */
.lune-page-heading h1 {
    margin: 0;
}

.lune-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.lune-state-text {
    max-width: 48rem;
}

.lune-skeleton > * + * {
    margin-top: 8px;
}

/* KPI tiles and cards */
.lune-kpi {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lune-kpi-title {
    text-transform: none;
    opacity: 0.75;
}

.lune-kpi-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.lune-kpi-hint {
    opacity: 0.7;
}

.lune-quota-card,
.lune-rate-card {
    height: 100%;
}

.lune-num {
    text-align: end !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.lune-nowrap {
    white-space: nowrap;
}

.lune-muted {
    opacity: 0.7;
}

/* Code blocks */
.lune-code-block {
    position: relative;
    border: 1px solid var(--lune-border);
    border-radius: 6px;
    background: var(--lune-code-bg);
}

.lune-code {
    margin: 0;
    padding: 12px 16px;
    padding-right: 7.5rem;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre;
}

.lune-copy-button {
    position: absolute !important;
    top: 8px;
    right: 8px;
}

/* One-time secret display (§13.4) */
.lune-secret-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.lune-secret-value {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--lune-border);
    border-radius: 4px;
    background: var(--lune-code-bg);
    color: inherit;
    font-family: var(--lune-mono);
    font-size: 0.9rem;
}

/* Tables */
.lune-table-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.lune-definition-list {
    display: grid;
    grid-template-columns: minmax(10rem, max-content) 1fr;
    gap: 6px 24px;
    margin: 0;
}

.lune-definition-list dt {
    font-weight: 500;
    opacity: 0.75;
}

.lune-definition-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* Static error pages (ErrorLayout) */
.lune-error-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    background: #f4f6f8;
    font-family: Roboto, "Segoe UI", Helvetica, Arial, sans-serif;
    color: #1f2937;
}

.lune-error-card {
    width: 100%;
    max-width: 32rem;
    padding: 32px;
    box-sizing: border-box;
    background: #ffffff;
    border-radius: 8px;
}

.lune-error-logo {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--lune-brand);
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
}

.lune-error-card h1 {
    margin: 0 0 12px;
    font-size: 1.5rem;
    font-weight: 500;
}

.lune-error-card p {
    margin: 0 0 12px;
    line-height: 1.5;
}

.lune-error-card a.lune-error-home {
    color: var(--lune-brand);
}

/* Plain links rendered as buttons (e.g. the CSV download, which must bypass the Blazor router) */
.lune-link-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 4px;
    background: var(--mud-palette-primary, var(--lune-brand));
    color: var(--mud-palette-primary-text, #ffffff) !important;
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.02857em;
    line-height: 1.75;
}

.lune-link-button:hover,
.lune-link-button:focus-visible {
    background: var(--mud-palette-primary-darken, var(--lune-brand-dark));
}

@media (max-width: 600px) {
    .lune-definition-list {
        grid-template-columns: 1fr;
    }

    .lune-code {
        padding-right: 16px;
        padding-top: 48px;
    }
}

/* Unhandled circuit failure (§13.6): blazor.web.js switches this to display: block. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    padding: 12px 48px 12px 16px;
    background: #b3261e;
    color: #ffffff;
    font-family: Roboto, "Segoe UI", Helvetica, Arial, sans-serif;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.25);
}

#blazor-error-ui a.reload {
    color: #ffffff;
    font-weight: 500;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 6px;
    right: 12px;
    border: 0;
    background: transparent;
    color: #ffffff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

/* A dialog failed (its own error boundary in MainLayout): the message floats above the page. */
.lune-dialog-error {
    position: fixed;
    left: 50%;
    top: 24px;
    transform: translateX(-50%);
    z-index: 1500;
    width: min(36rem, calc(100% - 32px));
}
