/* Abgabesystem – gemeinsames Stylesheet */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #dde1e6;
  --border-strong: #c3c9d1;
  --text: #1f2933;
  --text-muted: #5f6b7a;
  --accent: #2f5d8a;
  --accent-hover: #24496d;
  --accent-soft: #e8eef5;

  --danger: #b42318;
  --danger-soft: #fdecea;
  --danger-border: #f3b8b2;
  --success: #17703a;
  --success-soft: #e8f5ec;
  --success-border: #a9d8b8;
  --warning: #9a5b00;
  --warning-soft: #fff4e0;
  --warning-border: #f0cf8f;

  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { line-height: 1.25; margin: 1.5rem 0 0.75rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

code, pre { font-family: var(--mono); font-size: 0.92em; }

/* ---------- Kopfleiste ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.site-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.site-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.site-nav a {
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover { color: var(--text); }

.site-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

/* ---------- Inhalt ---------- */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.page-title { margin-top: 0; }

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

.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* Login, Registrierung etc.: zentrierte Karte */
.page-narrow { max-width: 440px; padding-top: 3rem; }

.muted { color: var(--text-muted); }
.prose { max-width: 70ch; }
.form-narrow { max-width: 520px; }

/* Schlüssel/Wert-Liste */
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.25rem;
  margin: 0 0 1rem;
}
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; }

/* Korrektor-Bemerkung */
.remark {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0;
  max-height: 32rem;
  overflow-y: auto;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.actions form { margin: 0; }
.toolbar { margin-bottom: 1rem; }
.mono { font-family: var(--mono); }
.break { overflow-wrap: anywhere; max-width: 40ch; }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }

.stat {
  font-size: 1.25rem;
  font-weight: 600;
}

.stat-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.6rem 1rem;
  min-width: 8rem;
}

/* ---------- Meldungen ---------- */

.alert {
  border: 1px solid;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.alert-error   { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger); }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert-info    { background: var(--accent-soft);  border-color: #c4d3e3;               color: var(--accent-hover); }

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

label { display: block; font-weight: 500; margin-bottom: 0.25rem; }

.field { margin-bottom: 1rem; }
.field-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.field-error { font-size: 0.85rem; color: var(--danger); margin-top: 0.25rem; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="search"], input:not([type]), select, textarea {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
  max-width: 100%;
}

.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea { width: 100%; }
textarea.mono { font-family: var(--mono); font-size: 0.9rem; }

input.input-narrow { width: 6rem; }
.field input.input-narrow { width: 6rem; }

button.small, .button.small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }

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

input[type="file"] { font: inherit; max-width: 100%; }

input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }

button, .button {
  font: inherit;
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}

button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.button-secondary, button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.button-secondary:hover, button.secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

.button-block { width: 100%; text-align: center; }

button:disabled, button:disabled:hover {
  background: var(--border);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

label.checkbox { display: flex; align-items: flex-start; gap: 0.5rem; font-weight: 400; }
label.checkbox input { margin-top: 0.3rem; }

/* Formularzeile: Felder nebeneinander, auf schmalen Bildschirmen umbrechend */
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; margin-bottom: 1rem; }
.form-row .field { margin-bottom: 0; }

textarea { width: 100%; }

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

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

table { border-collapse: collapse; }

.table-wrap table { width: 100%; }

th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr:last-child td, table tr:last-child td { border-bottom: 0; }

tbody tr:hover td { background: var(--surface-2); }

th a { color: inherit; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Tabellen, die (noch) nicht in .table-wrap stehen */
table:not(.table-wrap table) { background: var(--surface); border: 1px solid var(--border); }

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

.warn { color: var(--danger); }
.ok { color: var(--success); }

.due-passed { color: var(--danger); font-weight: 600; }
.due-open { color: var(--success); font-weight: 600; }

/* Zeilenfarben */
.row-open td    { background: #fdf3f2; }
.row-done td    { background: #f1f8f3; }
.row-problem td { background: #fdf7ec; }

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge-open    { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger); }
.badge-done    { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.badge-problem { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }

/* ---------- Statistik ---------- */

.chart-box {
  position: relative;
  height: 460px;
}
.chart-actions { margin-top: 0.75rem; }
.highlight { color: var(--danger); }

/* ---------- Audit-Log ---------- */

details > summary { cursor: pointer; }
details[open] > summary { margin-bottom: 0.5rem; }
.quicklinks { columns: 2 22rem; margin: 0; padding-left: 1.25rem; }
.quicklinks li { break-inside: avoid; }
.pager { display: flex; gap: 0.75rem; }
td.details { min-width: 22rem; max-width: 70ch; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.875rem; }
td.entity-id { max-width: 24ch; overflow-wrap: anywhere; }

/* ---------- Handy ---------- */

@media (max-width: 640px) {
  body { font-size: 14px; }
  .page { padding: 1rem 0.75rem 2rem; }
  .page-narrow { padding-top: 1.5rem; }
  .card { padding: 1rem; }
  th, td { padding: 0.4rem 0.5rem; }
  .site-user span { display: none; }
  .chart-box { height: 320px; }
}
