/*
  Styles der Admin-/Verwaltungsoberflaeche (siehe Konzeptdokument,
  Abschnitt 5.2): Desktop-orientiertes Layout mit Seitenleiste, reines
  HTML5/CSS/JS ohne Framework (siehe Konzeptdokument, Abschnitt 2 und
  frontend-admin/Dockerfile).
*/
:root {
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-surface-alt: #f0f2f4;
  --color-border: #dde3e8;
  --color-text: #1c2733;
  --color-muted: #5b6b7a;
  --color-accent: #2c6e9e;
  --color-ok: #2f9e5c;
  --color-warn: #b8860b;
  --color-error: #c0392b;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ---------- Login ---------- */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-karte {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.login-karte h1 { font-size: 1.2rem; margin-top: 0; }

/* ---------- App-Shell ---------- */
header.app-header {
  background: var(--color-accent);
  color: #fff;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header.app-header h1 { margin: 0; font-size: 1.15rem; }
header.app-header .rechts { display: flex; align-items: center; gap: 1rem; font-size: 0.85rem; }
header.app-header button { background: rgba(255,255,255,0.15); border: none; color: #fff; padding: 0.4rem 0.8rem; border-radius: 6px; }

.layout { display: flex; min-height: calc(100vh - 56px); }
nav#sidebar {
  width: 220px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 1rem 0;
  flex-shrink: 0;
}
nav#sidebar button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 0.9rem;
  cursor: pointer;
}
nav#sidebar button:hover, nav#sidebar button.aktiv { background: var(--color-surface-alt); font-weight: 600; }
nav#sidebar .gruppe-titel {
  padding: 1rem 1.25rem 0.3rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

main#content { flex: 1; padding: 1.5rem 2rem; max-width: 1100px; }

/* ---------- Allgemeine Bausteine ---------- */
.karte {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

/* Footer mit Versionsanzeige (siehe backend/app/version.py) sowie
   Ressourcen-Ampel-Kacheln (Systemressourcen-Karte im Dashboard, siehe
   app/services/systemstatus.py). */
.app-footer {
  padding: 0.6rem 1.5rem;
  font-size: 0.75rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}
.app-footer .version-mismatch { color: var(--color-warn); font-weight: 600; }

.ressourcen-kacheln { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 0.75rem; }
.ressourcen-kachel {
  flex: 1 1 140px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 0.9rem 1rem;
  background: var(--color-surface-alt);
}
.ressourcen-kachel .titel { font-size: 0.8rem; color: var(--color-muted); }
.ressourcen-kachel .wert { font-size: 1.6rem; font-weight: 700; margin-top: 0.2rem; }
.ressourcen-kachel.status-ok { border-color: var(--color-ok); }
.ressourcen-kachel.status-ok .wert { color: var(--color-ok); }
.ressourcen-kachel.status-warnung { border-color: var(--color-warn); }
.ressourcen-kachel.status-warnung .wert { color: var(--color-warn); }
.ressourcen-kachel.status-kritisch { border-color: var(--color-error); }
.ressourcen-kachel.status-kritisch .wert { color: var(--color-error); }
.formular label { display: block; margin-top: 0.8rem; font-size: 0.85rem; color: var(--color-muted); }
.formular input, .formular select, .formular textarea {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text);
}
.formular textarea { min-height: 4.5rem; font-family: monospace; font-size: 0.85rem; }
.metadaten-formular {
  margin-top: 0.35rem;
  padding: 0.6rem 0.8rem 0.2rem;
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-alt);
}
.metadaten-formular label { margin-top: 0.6rem; }
.metadaten-formular .hinweis { margin-top: 0; }
.tarifpositionen-formular {
  margin-top: 0.35rem;
  padding: 0.6rem 0.8rem;
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-alt);
}
.tarifpositionen-formular .tarifzeile { margin-bottom: 0.5rem; }
.tarifpositionen-formular .tarifzeile:last-child { margin-bottom: 0; }

table.tabelle { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius); overflow: hidden; }
table.tabelle th, table.tabelle td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--color-border); text-align: left; font-size: 0.88rem; }
table.tabelle th { background: var(--color-surface-alt); color: var(--color-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }
table.tabelle tbody tr:hover { background: var(--color-surface-alt); }

button.primaer, button.sekundaer, button.gefahr {
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  margin-right: 0.5rem;
  margin-top: 0.5rem;
}
button.primaer { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
button.sekundaer { background: var(--color-surface); color: var(--color-text); }
button.gefahr { background: rgba(192,57,43,0.1); color: var(--color-error); border-color: var(--color-error); }
button.link-btn { background: none; border: none; color: var(--color-accent); cursor: pointer; font-size: 0.82rem; padding: 0.15rem 0.35rem; }
button.link-btn.gefahr-text { color: var(--color-error); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.72rem; background: var(--color-surface-alt); color: var(--color-muted); }
.badge.ok { background: rgba(47,158,92,0.12); color: var(--color-ok); }
.badge.warn { background: rgba(184,134,11,0.12); color: var(--color-warn); }

.status-ok { color: var(--color-ok); font-weight: 600; }
.status-error { color: var(--color-error); font-weight: 600; }

.filterzeile { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filterzeile > div { min-width: 160px; }
.filterzeile label { display: block; font-size: 0.8rem; color: var(--color-muted); margin-bottom: 0.25rem; }
.filterzeile input, .filterzeile select { padding: 0.5rem; border: 1px solid var(--color-border); border-radius: 6px; width: 100%; }

.hinweis { font-size: 0.8rem; color: var(--color-muted); margin-top: 0.4rem; }

/* ---------- Live-Suche in Auswahlfeldern ---------- */
/* Ersetzt vollstaendig geladene Auswahllisten durch eine Hintergrundsuche in
   der Datenbank (Freitext -> GET .../?suche=...), siehe app.js,
   Abschnitt "Live-Suche-Widget". */
.such-feld { position: relative; }
.such-ergebnisse {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}
.such-treffer { padding: 0.5rem 0.7rem; font-size: 0.88rem; cursor: pointer; }
.such-treffer:hover { background: var(--color-surface-alt); }
.such-kein-treffer { padding: 0.5rem 0.7rem; font-size: 0.82rem; color: var(--color-muted); }

#toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  max-width: 360px;
  padding: 0.85rem 1.1rem;
  border-radius: 8px;
  background: #1c2733;
  color: #fff;
  font-size: 0.88rem;
  display: none;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
#toast.error { background: var(--color-error); }
