/* Postback Portal – eigenes CSS, keine externen Abhängigkeiten.
   Hell und dunkel über prefers-color-scheme. */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #d9dde3;
    --text: #1d2430;
    --muted: #68717f;
    --accent: #2f6fe4;
    --accent-text: #ffffff;
    --ok: #1a7f46;
    --ok-bg: #e4f5ea;
    --bad: #c0392b;
    --bad-bg: #fcebe9;
    --info-bg: #e8f0fd;
    --off-bg: #eceef1;
    --radius: 6px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c;
        --surface: #1c2029;
        --border: #2d333e;
        --text: #e6e9ee;
        --muted: #939dab;
        --accent: #4d8bf5;
        --ok: #4ec27e;
        --ok-bg: #16301f;
        --bad: #ef7768;
        --bad-bg: #331a17;
        --info-bg: #182435;
        --off-bg: #242933;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .5rem; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
a { color: var(--accent); }

/* ---------- Layout ---------- */

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

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

.brand { font-weight: 600; padding: 0 1rem 1rem; font-size: 1.05rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.user { display: flex; align-items: center; gap: .5rem; }
.user-name { font-weight: 500; }

.content { padding: 1.5rem; flex: 1; }

.centered {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .5rem;
}

/* ---------- Navigation ---------- */

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

.nav-group {
    padding: 1rem 1rem .25rem;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}

.nav-item {
    padding: .45rem 1rem;
    color: var(--text);
    text-decoration: none;
    border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--off-bg); }

.nav-item.active {
    border-left-color: var(--accent);
    background: var(--info-bg);
    font-weight: 500;
}

/* ---------- Elemente ---------- */

.btn {
    display: inline-block;
    padding: .4rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { background: var(--off-bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-small { padding: .2rem .5rem; font-size: .85rem; }
.btn-block { width: 100%; margin-top: 1rem; }
.btn:disabled { opacity: .6; cursor: default; }

input, select, textarea, .input {
    padding: .4rem .55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    width: 100%;
}

textarea { resize: vertical; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin: 1rem 0;
}

.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar label { color: var(--muted); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.card.narrow, .login-card { max-width: 420px; }

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
}

.login-card label { display: block; margin-top: .75rem; font-size: .9rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.bad-text { color: var(--bad); }

.truncate {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Formulare ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1rem;
}

.field { display: flex; flex-direction: column; gap: .3rem; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: .9rem; font-weight: 500; }
.field .check { font-weight: 400; display: flex; align-items: center; gap: .5rem; }
.field .check input { width: auto; }
.hint { font-size: .8rem; color: var(--muted); }

.form-actions { display: flex; gap: .5rem; margin-top: 1rem; }

.validation-message { color: var(--bad); font-size: .85rem; }

/* ---------- Tabellen ---------- */

.grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.grid th, .grid td {
    padding: .5rem .65rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.grid th {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    background: var(--off-bg);
}

.grid tbody tr:hover { background: var(--off-bg); }
.grid .row-inactive { opacity: .55; }
.grid .actions { white-space: nowrap; display: flex; gap: .3rem; }

.detail { background: var(--off-bg); }
.detail-list { display: grid; grid-template-columns: 170px 1fr; gap: .35rem 1rem; margin: 0; }
.detail-list dt { color: var(--muted); font-size: .85rem; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.detail-list pre {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 260px;
    overflow: auto;
    font-size: .85rem;
}

/* ---------- Status ---------- */

.badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .8rem;
    background: var(--off-bg);
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--accent); }
.badge-off { background: var(--off-bg); color: var(--muted); }

.chip {
    font-size: .75rem;
    padding: .05rem .45rem;
    border-radius: 999px;
    background: var(--off-bg);
    color: var(--muted);
}

.alert {
    padding: .6rem .8rem;
    border-radius: var(--radius);
    margin: .75rem 0;
}

.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-info { background: var(--info-bg); color: var(--accent); }

/* ---------- Kacheln ---------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .75rem;
    margin: 1rem 0;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.tile-value { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile.ok .tile-value { color: var(--ok); }
.tile.bad .tile-value { color: var(--bad); }

/* ---------- Blazor ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: .7rem 1.25rem;
    background: var(--bad-bg);
    color: var(--bad);
    border-top: 1px solid var(--bad);
    z-index: 1000;
}

@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-group { width: 100%; padding-bottom: 0; }
    .content { padding: 1rem; }
    .truncate { max-width: 180px; }
}
