/* ==========================================================================
   APIS – Design-Tokens
   Einzige Quelle fuer Farben, Abstaende, Radien und Schatten.
   Komponenten verwenden ausschliesslich diese Variablen.
   ========================================================================== */
:root {
    /* Markenfarbe (Navigation, Karten-Kopf, primaere Aktionen) */
    --brand-50:  #eef1f8;
    --brand-100: #dde4f1;
    --brand-200: #bcc7de;
    --brand-300: #97a6c8;
    --brand-400: #7285ae;
    --brand-500: #5b6e9c;
    --brand-600: #4d5f8a;
    --brand-700: #3f4e72;
    --brand-900: #2a3450;

    /* Text */
    --ink-900: #1b2231;
    --ink-700: #39435a;
    --ink-500: #68738c;
    --ink-400: #8b94a8;
    --on-brand: #ffffff;

    /* Flaechen */
    --page:          #f2f4f9;
    --surface:       #ffffff;
    --surface-muted: #f6f8fc;
    --line:          #e3e8f1;
    --line-strong:   #cdd5e5;

    /* Status */
    --danger:     #c62828;
    --danger-bg:  #fdecea;
    --success:    #2e7d32;
    --success-bg: #eaf4ea;
    --warning:    #b26a00;
    --warning-bg: #fff6e5;
    --info:       #2b6cb0;
    --info-bg:    #e9f1fa;

    /* Form */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --shadow-1: 0 1px 2px rgba(27, 34, 49, .06), 0 1px 3px rgba(27, 34, 49, .07);
    --shadow-2: 0 4px 14px rgba(27, 34, 49, .09), 0 1px 3px rgba(27, 34, 49, .05);
    --shadow-3: 0 16px 40px rgba(27, 34, 49, .16);

    /* Raster */
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;

    --topbar-h: 60px;
    --content-max: 1200px;
    --content-pad: 1.5rem;

    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --transition: 140ms ease;
}

@media (max-width: 720px) {
    :root {
        --content-pad: 1rem;
        --topbar-h: 56px;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--ink-900);
    background-color: var(--page);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
    margin: 0 0 .5rem;
    line-height: 1.25;
    font-weight: 600;
    color: var(--ink-900);
    letter-spacing: -.01em;
}

h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--brand-600);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--brand-700); text-decoration: underline; }

h1:focus, h2:focus { outline: none; }

:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: var(--space-5) 0;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .9em;
    color: var(--brand-700);
    background: var(--brand-50);
    padding: .1em .35em;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Layout-Helfer
   ========================================================================== */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding-inline: var(--content-pad);
}

.container--wide { max-width: 1440px; }
.container--narrow { max-width: 760px; }

/* Vertikaler Rhythmus zwischen Bloecken */
.stack > * + * { margin-top: var(--space-5); }
.stack-sm > * + * { margin-top: var(--space-3); }
.stack-lg > * + * { margin-top: var(--space-7); }

/* Responsive Raster – bricht ohne Media-Query auf eine Spalte um */
.grid {
    display: grid;
    gap: var(--space-5);
}
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Raster-Kinder duerfen nicht durch ihren Inhalt wachsen
   (sonst schiebt z.B. eine breite Tabelle die ganze Seite auseinander). */
.grid > * { min-width: 0; }

/* Inhalt + Randspalte; unter 960px einspaltig */
.grid--main-aside { grid-template-columns: minmax(0, 1fr); }

@media (min-width: 960px) {
    .grid--main-aside { grid-template-columns: minmax(0, 1.9fr) minmax(280px, 1fr); }
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
}
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }

.spacer { flex: 1 1 auto; }

/* ==========================================================================
   Typografie-Hilfen
   ========================================================================== */
.text-muted { color: var(--ink-500); }
.text-small { font-size: .875rem; }
.text-eyebrow {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-400);
}
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }

.section-heading {
    text-align: center;
    max-width: 640px;
    margin-inline: auto;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .55rem 1.1rem;
    min-height: 40px;
    font: inherit;
    font-size: .875rem;
    font-weight: 600;
    letter-spacing: .02em;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition),
                color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.btn--primary {
    background: var(--brand-500);
    color: var(--on-brand);
    box-shadow: var(--shadow-1);
}
.btn--primary:hover { background: var(--brand-600); color: var(--on-brand); }

.btn--outline {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink-700);
}
.btn--outline:hover { border-color: var(--brand-400); color: var(--brand-700); background: var(--brand-50); }

.btn--ghost { background: transparent; color: var(--brand-600); }
.btn--ghost:hover { background: var(--brand-50); color: var(--brand-700); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #a91f1f; color: #fff; }

.btn--sm { min-height: 32px; padding: .3rem .7rem; font-size: .8rem; }
.btn--lg { min-height: 48px; padding: .75rem 1.6rem; font-size: 1rem; }
.btn--block { width: 100%; }
.btn--icon { padding: .45rem; min-height: 36px; aspect-ratio: 1; }

/* Button-Gruppe: umbricht auf kleinen Schirmen sauber */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}
.btn-group--stack { flex-direction: column; align-items: stretch; }

/* ==========================================================================
   Formularelemente
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: .35rem; }

.field-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--ink-700);
}

.input, .select, .textarea {
    width: 100%;
    padding: .55rem .75rem;
    min-height: 40px;
    font: inherit;
    font-size: .925rem;
    color: var(--ink-900);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px var(--brand-50);
}
.textarea { min-height: 96px; resize: vertical; }

.valid.modified:not([type=checkbox]) { border-color: var(--success); }
.invalid { border-color: var(--danger); }
.validation-message { color: var(--danger); font-size: .8rem; }

/* ==========================================================================
   Tabelle
   ========================================================================== */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .925rem;
}
.table th, .table td {
    padding: .7rem .85rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.table th {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-500);
    background: var(--surface-muted);
    white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--brand-50); }
.table td.table-actions { text-align: right; white-space: nowrap; }

/* ==========================================================================
   Hinweisbox
   ========================================================================== */
.notice {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .7rem .85rem;
    font-size: .875rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}

.notice--info {
    color: var(--brand-700);
    background: var(--brand-50);
    border-color: var(--brand-200);
}

.notice--error {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: var(--danger);
}

.notice--success {
    color: var(--success);
    background: var(--success-bg);
    border-color: var(--success);
}

/* ==========================================================================
   Badge / Chip
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .6rem;
    font-size: .75rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    background: var(--brand-50);
    color: var(--brand-700);
    white-space: nowrap;
}
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--neutral { background: var(--surface-muted); color: var(--ink-500); }

/* Auf farbigem Grund, z.B. im Kartenkopf */
.badge--on-brand { background: rgba(255, 255, 255, .2); color: #fff; }

/* ==========================================================================
   Icon
   ========================================================================== */
.icon {
    width: 20px;
    height: 20px;
    flex: none;
    display: inline-block;
    vertical-align: -.2em;
}
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }
.icon--xl { width: 32px; height: 32px; }

/* ==========================================================================
   Blazor-Standard: Ladeanzeige und Fehlerleiste
   ========================================================================== */
.loading-progress {
    position: absolute;
    display: block;
    width: 7rem;
    height: 7rem;
    inset: 30vh 0 auto 0;
    margin-inline: auto;
}
.loading-progress circle {
    fill: none;
    stroke: var(--brand-100);
    stroke-width: .5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--brand-500);
    stroke-linecap: round;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
    transition: stroke-dasharray .1s ease-in-out;
}
.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    color: var(--ink-500);
    inset: calc(30vh + 8rem) 0 auto 0;
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Laden"); }

#blazor-error-ui {
    color-scheme: light only;
    position: fixed;
    inset: auto 0 0 0;
    display: none;
    z-index: 2000;
    padding: .8rem 1.25rem;
    background: var(--warning-bg);
    border-top: 3px solid var(--warning);
    box-shadow: 0 -2px 8px rgba(27, 34, 49, .12);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; }

.blazor-error-boundary {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    color: var(--danger);
}
.blazor-error-boundary::after { content: "Es ist ein unerwarteter Fehler aufgetreten."; }

/* ==========================================================================
   Sichtbarkeit / Druck
   ========================================================================== */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.hide-mobile { display: initial; }
.hide-desktop { display: none; }

@media (max-width: 720px) {
    .hide-mobile { display: none !important; }
    .hide-desktop { display: initial; }
}

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* ==========================================================================
   Navigationseintraege der Kopfleiste
   Global, weil die Eintraege von den Layouts zusammengesetzt werden
   und so in jedem Layout identisch aussehen.
   ========================================================================== */
.topnav-link {
    display: flex;
    align-items: center;
    gap: .45rem;
    min-width: 0;
    padding: .45rem .6rem;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
    color: rgba(255, 255, 255, .86);
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

/* Bei wenig Platz kürzen statt überlappen; das Dropdown darf dabei
   nicht abgeschnitten werden, deshalb kein overflow auf dem Container. */
.topnav-link > span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.topnav-link:hover {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    text-decoration: none;
}

.topnav-link.active {
    background: rgba(255, 255, 255, .2);
    color: #fff;
}

/* Hervorgehobene Aktion in der Leiste (z.B. Anmelden) */
.topnav-link--accent {
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .5);
}

.topnav-link--accent:hover {
    background: #fff;
    color: var(--brand-700);
}

/* Benutzeranzeige rechts in der Leiste */
.topnav-user {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .35rem .6rem .35rem .4rem;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: rgba(255, 255, 255, .95);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, .12);
    white-space: nowrap;
}

.topnav-avatar {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    font-size: .7rem;
    font-weight: 700;
}

.topnav-user-name {
    display: none;
}

@media (min-width: 1400px) {
    .topnav-user-name {
        display: inline;
        max-width: 22ch;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Im ausgeklappten Menue kleiner Schirme ist wieder Platz fuer den Namen */
@media (max-width: 720px) {
    .topnav-user-name {
        display: inline;
    }
}

.topnav-sep {
    width: 1px;
    height: 24px;
    margin-inline: .35rem;
    background: rgba(255, 255, 255, .28);
}

@media (max-width: 720px) {
    .topnav-link,
    .topnav-user {
        width: 100%;
        justify-content: flex-start;
        border-radius: var(--radius-sm);
    }

    .topnav-sep {
        display: none;
    }
}

/* ==========================================================================
   Reiter innerhalb einer Seite
   Global, weil die Eintraege als NavLink-Komponenten gerendert werden
   und vom scoped CSS der Komponente nicht erfasst werden.
   ========================================================================== */
.page-tabs {
    display: flex;
    gap: .15rem;
    margin-bottom: 1.25rem;
    overflow-x: auto;
    scrollbar-width: thin;
    border-bottom: 1px solid var(--line);
}

.page-tab {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .7rem .95rem;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink-500);
    border-bottom: 2px solid transparent;
    text-decoration: none;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.page-tab:hover {
    color: var(--brand-600);
    background: var(--brand-50);
    text-decoration: none;
}

.page-tab.active {
    color: var(--brand-600);
    border-bottom-color: var(--brand-500);
}
