/* App-Shell: Seitenleiste, Kopfleiste, Inhalt, Ausklappmenüs. Farben ausschließlich über Tokens (tokens.css). */

html, body {
    background: var(--s-canvas);
    color: var(--s-text);
    font-family: var(--s-font);
    font-size: var(--s-text-base);
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--s-font-display);
    color: var(--s-text);
    letter-spacing: -.01em;
}

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

a {
    color: var(--s-primary);
}

:focus-visible {
    outline: 2px solid var(--s-primary);
    outline-offset: 2px;
}

.symbol {
    flex: none;
    vertical-align: -0.2em;
}

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

/* Sprunglink für Tastatur und Screenreader */
.sprunglink {
    position: absolute;
    left: 8px;
    top: -48px;
    z-index: 2000;
    padding: 8px 12px;
    border-radius: var(--s-radius-sm);
    background: var(--s-primary-fill);
    color: #fff;
    text-decoration: none;
}

.sprunglink:focus {
    top: 8px;
}

/* ---------- Shell ---------- */
.shell {
    display: flex;
    min-height: 100vh;
}

.seitenleiste {
    width: var(--s-sidebar-width);
    flex: none;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--s-surface);
    border-right: 1px solid var(--s-border);
    transition: width .15s ease;
    z-index: 1030;
}

.hauptbereich {
    flex: 1;
    /* Ohne min-width: 0 wächst der Bereich mit breiten Tabellen mit und die ganze Seite scrollt horizontal. */
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.inhalt {
    flex: 1;
    padding: var(--s-space-6) var(--s-space-8) var(--s-space-8);
    max-width: 1600px;
    width: 100%;
}

/* ---------- Seitenleiste ---------- */
.nav-kopf {
    height: var(--s-topbar-height);
    display: flex;
    align-items: center;
    padding: 0 var(--s-space-4);
    border-bottom: 1px solid var(--s-border);
    flex: none;
}

.marke {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--s-text);
    text-decoration: none;
    font-family: var(--s-font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
}

.marke-zeichen {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--s-primary-fill);
    color: #fff;
    display: grid;
    place-items: center;
    flex: none;
}

.nav-seiten {
    flex: 1;
    overflow-y: auto;
    padding: var(--s-space-2) var(--s-space-3) var(--s-space-4);
}

.nav-gruppe {
    margin: var(--s-space-4) var(--s-space-2) var(--s-space-1);
    font-size: var(--s-text-xs);
    font-weight: 600;
    color: var(--s-text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
}

.nav-eintrag {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 36px;
    padding: 0 10px;
    margin: 1px 0;
    border: 0;
    border-radius: var(--s-radius-sm);
    background: none;
    color: var(--s-text-2);
    font-size: var(--s-text-base);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.nav-eintrag:hover {
    background: var(--s-surface-hover);
    color: var(--s-text);
}

.nav-eintrag.active {
    background: var(--s-primary-subtle);
    color: var(--s-primary-text);
}

.nav-eintrag.active .symbol {
    color: var(--s-primary);
}

.nav-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.nav-zaehler {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--s-neutral-subtle);
    color: var(--s-text-2);
    font-size: var(--s-text-xs);
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.nav-zaehler.dringend {
    background: var(--s-danger-subtle);
    color: var(--s-danger);
}

.nav-fuss {
    flex: none;
    padding: var(--s-space-2) var(--s-space-3);
    border-top: 1px solid var(--s-border);
}

/* Eingeklappt: nur Symbole */
html.nav-schmal .seitenleiste {
    width: var(--s-sidebar-collapsed);
}

html.nav-schmal .nav-text,
html.nav-schmal .marke-text,
html.nav-schmal .nav-gruppe {
    display: none;
}

html.nav-schmal .nav-seiten,
html.nav-schmal .nav-fuss {
    padding-left: 10px;
    padding-right: 10px;
}

html.nav-schmal .nav-eintrag {
    justify-content: center;
    padding: 0;
    position: relative;
}

html.nav-schmal .nav-zaehler {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    padding: 0 4px;
    font-size: 10px;
}

html.nav-schmal .nav-gruppe + .nav-eintrag,
html.nav-schmal .nav-eintrag + .nav-gruppe {
    margin-top: var(--s-space-3);
}

html.nav-schmal .nav-kopf {
    justify-content: center;
    padding: 0;
}

/* ---------- Kopfleiste ---------- */
.kopfleiste {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--s-topbar-height);
    display: flex;
    align-items: center;
    gap: var(--s-space-3);
    padding: 0 var(--s-space-6) 0 var(--s-space-8);
    background: color-mix(in srgb, var(--s-canvas) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--s-border);
}

.kopf-rechts {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
}

.kopf-knopf {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: var(--s-radius-sm);
    background: none;
    color: var(--s-text-2);
    cursor: pointer;
}

.kopf-knopf:hover {
    background: var(--s-surface-hover);
    color: var(--s-text);
}

.kopf-neu {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    height: 32px;
    font-weight: 500;
}

.kopf-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: var(--s-primary-subtle);
    color: var(--s-primary-text);
    font-size: var(--s-text-xs);
    font-weight: 700;
    cursor: pointer;
    margin-left: var(--s-space-1);
}

.mandant-wahl {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    padding-left: var(--s-space-3);
    margin-left: var(--s-space-1);
    border-left: 1px solid var(--s-border);
}

.mandant-auswahl {
    width: 190px;
}

.mandant-art {
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--s-neutral-subtle);
    color: var(--s-text-2);
    font-size: var(--s-text-xs);
    font-weight: 500;
    white-space: nowrap;
}

.darstellung-symbol {
    display: none;
}

html[data-darstellung=hell] .darstellung-symbol[data-wert=hell],
html[data-darstellung=dunkel] .darstellung-symbol[data-wert=dunkel],
html[data-darstellung=system] .darstellung-symbol[data-wert=system],
html:not([data-darstellung]) .darstellung-symbol[data-wert=system] {
    display: inline-flex;
}

html[data-darstellung=hell] [data-darstellung-wahl=hell],
html[data-darstellung=dunkel] [data-darstellung-wahl=dunkel],
html[data-darstellung=system] [data-darstellung-wahl=system] {
    color: var(--s-primary-text);
    background: var(--s-primary-subtle);
}

/* ---------- Ausklappmenüs (<details class="menue">) ---------- */
.menue {
    position: relative;
}

.menue > summary {
    list-style: none;
}

.menue > summary::-webkit-details-marker {
    display: none;
}

.menue-liste {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    padding: 6px;
    background: var(--s-elevated);
    border: 1px solid var(--s-border);
    border-radius: var(--s-radius);
    box-shadow: var(--s-shadow-pop);
    z-index: 1050;
}

.menue-rechts .menue-liste {
    left: auto;
    right: 0;
}

.menue-eintrag {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    border: 0;
    border-radius: var(--s-radius-sm);
    background: none;
    color: var(--s-text);
    font-size: var(--s-text-base);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menue-eintrag .symbol {
    color: var(--s-text-muted);
}

.menue-eintrag:hover,
.menue-eintrag:focus-visible {
    background: var(--s-surface-hover);
    color: var(--s-text);
}

.menue-titel {
    padding: 6px 10px 4px;
    font-size: var(--s-text-xs);
    font-weight: 600;
    color: var(--s-text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.menue-kopf {
    padding: 8px 10px;
}

.menue-trenner {
    height: 1px;
    margin: 6px 0;
    background: var(--s-border);
}

/* ---------- Schmale Bildschirme: Navigation als Schublade ---------- */
.nur-schmal,
.shell-abdeckung {
    display: none;
}

@media (max-width: 900px) {
    .seitenleiste,
    html.nav-schmal .seitenleiste {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--s-sidebar-width);
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--s-shadow-pop);
    }

    html.nav-schmal .nav-text,
    html.nav-schmal .marke-text,
    html.nav-schmal .nav-gruppe {
        display: revert;
    }

    html.nav-schmal .nav-eintrag {
        justify-content: flex-start;
        padding: 0 10px;
    }

    html.nav-offen .seitenleiste {
        transform: none;
    }

    html.nav-offen .shell-abdeckung {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .35);
        z-index: 1025;
    }

    .nur-schmal {
        display: inline-grid;
    }

    .nav-einklappen {
        display: none;
    }

    .kopfleiste {
        padding: 0 var(--s-space-4);
    }

    .inhalt {
        padding: var(--s-space-4);
    }
}

@media (max-width: 640px) {
    .nur-breit {
        display: none !important;
    }

    .mandant-auswahl {
        width: 140px;
    }

    .mandant-wahl {
        border-left: 0;
        padding-left: 0;
    }

    .mandant-wahl > .symbol {
        display: none;
    }
}

/* ---------- Blazor-Fehlerleiste ---------- */
#blazor-error-ui {
    background: var(--s-warning-subtle);
    color: var(--s-text);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1100;
}

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

.blazor-error-boundary {
    background: var(--s-danger-subtle);
    border: 1px solid var(--s-danger);
    border-radius: var(--s-radius);
    padding: 1rem;
    color: var(--s-danger);
}

.blazor-error-boundary::after {
    content: "Es ist ein Fehler aufgetreten.";
}

/* ---------- Suche in der Kopfleiste und Befehlspalette ---------- */
.kopf-suche {
    display: flex;
    align-items: center;
    gap: var(--s-space-2);
    white-space: nowrap;
    overflow: hidden;
    width: min(360px, 40vw);
    height: 34px;
    padding: 0 var(--s-space-2) 0 var(--s-space-3);
    border: 1px solid var(--s-border);
    border-radius: var(--s-radius);
    background: var(--s-surface);
    color: var(--s-text-muted);
    font-size: var(--s-text-sm);
    cursor: pointer;
}

@media (max-width: 1280px) {
    .kopf-suche kbd {
        display: none;
    }
}

.kopf-suche:hover {
    border-color: var(--s-border-strong);
    color: var(--s-text-2);
}

@media (max-width: 640px) {
    .kopf-suche {
        width: 36px;
        padding: 0;
        justify-content: center;
        border: 0;
        background: none;
    }
}

.palette-abdeckung {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 20, .45);
    z-index: 1990;
}

.palette {
    position: fixed;
    top: 12vh;
    left: 50%;
    transform: translateX(-50%);
    width: min(640px, calc(100vw - 32px));
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    background: var(--s-elevated);
    border: 1px solid var(--s-border);
    border-radius: var(--s-radius-lg);
    box-shadow: var(--s-shadow-pop);
    z-index: 1995;
    overflow: hidden;
}

.palette-eingabe {
    display: flex;
    align-items: center;
    gap: var(--s-space-3);
    padding: var(--s-space-3) var(--s-space-4);
    border-bottom: 1px solid var(--s-border);
}

.palette-eingabe input {
    flex: 1;
    border: 0;
    outline: none;
    background: none;
    color: var(--s-text);
    font-size: var(--s-text-md);
}

.palette-eingabe input::-webkit-search-cancel-button {
    display: none;
}

.palette-liste {
    overflow-y: auto;
    padding: var(--s-space-2);
}

.palette-gruppe {
    padding: var(--s-space-2) var(--s-space-2) var(--s-space-1);
    font-size: var(--s-text-xs);
    font-weight: 600;
    color: var(--s-text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.palette-eintrag {
    display: flex;
    align-items: center;
    gap: var(--s-space-3);
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--s-radius-sm);
    background: none;
    color: var(--s-text);
    text-align: left;
    cursor: pointer;
}

.palette-eintrag .symbol {
    color: var(--s-text-muted);
}

.palette-eintrag.aktiv {
    background: var(--s-primary-subtle);
    color: var(--s-primary-text);
}

.palette-eintrag.aktiv .symbol {
    color: var(--s-primary);
}

.palette-titel {
    font-weight: 500;
    white-space: nowrap;
}

.palette-unter {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--s-text-muted);
    font-size: var(--s-text-sm);
}

.palette-leer {
    padding: var(--s-space-6);
    text-align: center;
    color: var(--s-text-muted);
}

.palette-fuss {
    padding: var(--s-space-2) var(--s-space-4);
    border-top: 1px solid var(--s-border);
    color: var(--s-text-muted);
    font-size: var(--s-text-xs);
}

/* ---------- Anmeldung ---------- */
.anmeldung {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-space-6);
    padding: var(--s-space-6) var(--s-space-4);
    background:
        radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--s-primary) 12%, transparent), transparent 60%),
        var(--s-canvas);
}

.anmeldung-kopf {
    width: min(440px, 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.anmeldung-karte {
    width: min(440px, 100%);
    padding: var(--s-space-8);
    background: var(--s-surface);
    border: 1px solid var(--s-border);
    border-radius: var(--s-radius-lg);
    box-shadow: var(--s-shadow-pop);
}

.anmeldung-fuss {
    color: var(--s-text-muted);
    font-size: var(--s-text-sm);
    margin: 0;
}

.konto-navigation .nav-link {
    color: var(--s-text-2);
    border-radius: var(--s-radius-sm);
}

.konto-navigation .nav-link.active {
    background: var(--s-primary-subtle);
    color: var(--s-primary-text);
}
