/* Argus — KI-Infrastruktur-Monitor
   Dark "mission control" Oberfläche. Tokens aus dem validierten Referenz-Farbschema. */

:root {
  color-scheme: dark;
  --surface-0: #0d0d0d;      /* Seiten-Ebene */
  --surface-1: #1a1a19;      /* Karten */
  --surface-2: #232322;      /* angehobene Karten / hover */
  --surface-3: #2c2c2a;      /* Inputs, Trennlinien-Flächen */
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --accent: #3987e5;          /* series-1 blue, dark step */
  --accent-soft: rgba(57, 135, 229, 0.14);
  --accent-2: #9085e9;        /* violet, für sekundäre Akzente */

  --good: #0ca30c;
  --good-soft: rgba(12, 163, 12, 0.14);
  --warning: #fab219;
  --warning-soft: rgba(250, 178, 25, 0.14);
  --critical: #e66767;
  --critical-soft: rgba(230, 103, 103, 0.14);

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(57,135,229,0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(144,133,233,0.08), transparent 55%),
    var(--surface-0);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- App shell ---------- */

.app-shell { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,13,13,0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand-mark {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px var(--border-strong), 0 4px 14px rgba(57,135,229,0.35);
}
.brand-mark svg { width: 15px; height: 15px; }

.brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 8px 14px;
  border-radius: var(--radius-s);
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text-primary); }
.nav a.active { background: var(--accent-soft); color: #bcd7f7; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary);
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--surface-1);
  border: 1px solid var(--border);
}
.user-avatar {
  width: 22px; height: 22px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
}

.btn-logout {
  font-size: 13px; color: var(--text-muted);
  padding: 6px 10px; border-radius: var(--radius-s);
}
.btn-logout:hover { color: var(--text-primary); background: var(--surface-2); }

.main { flex: 1; padding: 28px; max-width: 1180px; width: 100%; margin: 0 auto; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.2px; }
.page-head p { margin: 0; color: var(--text-secondary); font-size: 14px; }

/* ---------- Cards / grid ---------- */

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.card-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); font-weight: 600; margin: 0 0 14px;
  display: flex; align-items: center; justify-content: space-between;
}

/* ---------- Stat tiles ---------- */

.stat-tile { display: flex; flex-direction: column; gap: 10px; }
.stat-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); font-weight: 600;
}
.stat-value {
  font-size: 32px; font-weight: 700; letter-spacing: -0.5px;
  font-variant-numeric: proportional-nums;
  display: flex; align-items: baseline; gap: 8px;
}
.stat-value .unit { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.stat-sub { font-size: 13px; color: var(--text-secondary); }

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

.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 9px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.status-pill.good { background: var(--good-soft); color: #6fe06f; }
.status-pill.critical { background: var(--critical-soft); color: #ff9d9d; }
/* Schlafend: absichtlich aus, nicht kaputt. Bewusst gedaempft — wer den
   Bildschirm ueberfliegt, soll hier nichts Dringendes sehen. */
.status-pill.idle { background: var(--surface-3); color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: currentColor; }
.status-dot.pulse { animation: pulse 2s ease-in-out infinite; box-shadow: 0 0 0 rgba(12,163,12,0.5); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  70% { box-shadow: 0 0 0 6px transparent; opacity: 0.85; }
  100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

/* ---------- Sparkline / bar chart (hand-rolled SVG, no deps) ---------- */

.spark { display: block; width: 100%; height: 46px; }
.spark path.area { fill: var(--accent-soft); stroke: none; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.bars-wrap { position: relative; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.bars .bar {
  flex: 1; background: var(--accent); border-radius: 3px 3px 0 0;
  min-height: 2px; position: relative; cursor: pointer;
  transition: background 0.15s;
}
.bars .bar:hover { background: #5aa0ee; }
.bars .bar .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  padding: 6px 9px; border-radius: var(--radius-s); font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.1s; z-index: 5;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.bars .bar:hover .tip { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; color: var(--text-muted); }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px;
  padding: 0 12px 10px; border-bottom: 1px solid var(--border);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }
td.strong { color: var(--text-primary); font-weight: 500; }
.table-scroll { overflow-x: auto; }
.req-row { cursor: pointer; }
.req-row:hover td { background: var(--surface-2); }
.detail-row td { padding: 0 12px 16px; border-bottom: 1px solid var(--border); }
.log-detail { display: flex; flex-direction: column; gap: 12px; padding: 4px 4px 0; }
.log-detail-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 12px 14px; }
.log-detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.log-detail-text { font-size: 13.5px; line-height: 1.55; color: var(--text-primary); white-space: pre-wrap; word-wrap: break-word; max-height: 300px; overflow-y: auto; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--good-soft); color: #6fe06f; }
.badge.error { background: var(--critical-soft); color: #ff9d9d; }
.badge.web { background: var(--accent-soft); color: #9cc5f2; }
.badge.api { background: rgba(144,133,233,0.16); color: #c3bbf3; }

/* ---------- Buttons / forms ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-s);
  font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  transition: transform 0.05s, background 0.15s, border-color 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #2f6fc4); color: white; box-shadow: 0 4px 14px rgba(57,135,229,0.30); }
.btn-primary:hover { background: linear-gradient(135deg, #4d95ec, var(--accent)); }
.btn-ghost { background: var(--surface-2); color: var(--text-primary); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--critical-soft); color: #ff9d9d; }
.btn-danger:hover { background: rgba(230,103,103,0.24); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input[type=text], input[type=password], textarea, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-s); padding: 11px 13px; color: var(--text-primary);
  font-size: 14px; font-family: inherit; outline: none; transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
label { font-size: 13px; color: var(--text-secondary); font-weight: 500; display: block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card { width: 100%; max-width: 380px; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-logo .brand-mark { width: 48px; height: 48px; border-radius: 14px; }
.login-logo .brand-mark svg { width: 26px; height: 26px; }
.login-logo h1 { margin: 0; font-size: 20px; }
.login-logo p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.error-msg {
  background: var(--critical-soft); color: #ff9d9d; padding: 10px 13px;
  border-radius: var(--radius-s); font-size: 13px; margin-bottom: 16px;
}

/* ---------- Chat ---------- */

.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 160px); min-height: 420px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 6px 4px 20px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 12px; max-width: 780px; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.msg.assistant .msg-avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; }
.msg.user .msg-avatar { background: var(--surface-3); color: var(--text-secondary); }
.msg-bubble {
  padding: 12px 15px; border-radius: var(--radius-m); font-size: 14.5px; line-height: 1.55;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.assistant .msg-bubble { background: var(--surface-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg.user .msg-bubble { background: var(--accent); color: white; border-top-right-radius: 4px; }
.msg-bubble .cursor { display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: text-bottom; animation: blink 1s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

.chat-input-row { display: flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.chat-input-row textarea { resize: none; height: 52px; padding-top: 14px; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: var(--text-muted); text-align: center; }
.chat-empty h3 { color: var(--text-secondary); font-weight: 600; margin: 0; }

/* ---------- Docs ---------- */

.code-block {
  background: #0a0a0a; border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 16px 18px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.6; overflow-x: auto; color: #d7f0d7; position: relative;
}
.code-block .kw { color: #82c8ff; }
.code-block .str { color: #f2c98a; }
.copy-btn {
  position: absolute; top: 10px; right: 10px; font-size: 11px;
  padding: 5px 9px; border-radius: 6px; background: var(--surface-2);
  border: 1px solid var(--border-strong); color: var(--text-secondary); cursor: pointer;
}
.copy-btn:hover { color: var(--text-primary); }
.endpoint-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.method { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 5px; background: var(--good-soft); color: #6fe06f; }
.doc-section { margin-bottom: 36px; }
.doc-section h2 { font-size: 16px; margin: 0 0 4px; }
.doc-section > p { color: var(--text-secondary); font-size: 14px; margin: 0 0 14px; }

.key-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.key-row:last-child { border-bottom: none; }
.key-meta { font-size: 12.5px; color: var(--text-muted); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ---------- Steuerungs-Matrix (routing.php) ---------- */

.matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.matrix th, .matrix td { border: 1px solid var(--border); padding: 10px; vertical-align: top; text-align: left; }
.matrix thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }

/* Die Zweck-Spalte bleibt beim seitlichen Scrollen stehen — ohne sie weiß man
   nach zwei Spalten nicht mehr, welche Zeile man gerade bearbeitet. */
.matrix .matrix-head {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface-2); min-width: 180px;
}

/* Die Grundregel ist optisch abgesetzt: sie gilt überall dort, wo eine App
   nichts Eigenes gesetzt hat. */
.matrix .matrix-base { background: var(--accent-soft); }

.matrix-cell { min-width: 210px; }
.matrix-cell select,
.matrix-cell input[type="text"] { width: 100%; margin-bottom: 6px; }
.matrix-cell .zelle-fest {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted); margin-bottom: 6px;
}
.matrix-cell .zelle-wirkung { font-size: 11px; line-height: 1.45; }

/* Zeilen der App-Verwaltung: Felder links, Knöpfe rechts. */
.key-row {
  display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.key-row:last-of-type { border-bottom: none; }

/* ---------- Grafikspeicher (index.php) ---------- */

.gpu-karte {
  border: 1px solid var(--border); border-radius: var(--radius-m);
  background: var(--surface-2); padding: 14px 16px; margin-bottom: 12px;
}
.gpu-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.gpu-kopf .geraet { font-weight: 600; color: var(--text-primary); }

/* Ein Balken, der die ganze Karte darstellt: belegt links, frei rechts. */
.gpu-balken {
  display: flex; height: 18px; border-radius: 999px; overflow: hidden;
  background: var(--surface-3); margin: 10px 0 8px;
}
.gpu-balken > div { height: 100%; }
.gpu-balken .llm   { background: var(--accent); }
.gpu-balken .other { background: var(--accent-2); }
.gpu-balken .free  { background: transparent; }

.gpu-zeilen { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.gpu-zeilen b { color: var(--text-primary); font-weight: 600; }

/* Wo ein geladenes Modell liegt — der Unterschied zwischen 17 GB auf der Karte
   und 17 GB im Arbeitsspeicher ist der zwischen schnell und zäh. */
.platz-pille { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.platz-pille.gpu { background: var(--good-soft); color: #6fe06f; }
.platz-pille.cpu { background: var(--warning-soft); color: #ffd37a; }
.platz-pille.leer { background: var(--surface-3); color: var(--text-muted); }

.gpu-verlauf { width: 100%; height: 150px; display: block; }
.gpu-verlauf .flaeche-llm   { fill: var(--accent); opacity: 0.75; }
.gpu-verlauf .flaeche-other { fill: var(--accent-2); opacity: 0.6; }
.gpu-verlauf .raster { stroke: var(--border); stroke-width: 1; }
.gpu-verlauf .beschriftung { fill: var(--text-muted); font-size: 11px; }

.gpu-legende { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.gpu-legende .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.gpu-legende .swatch.llm { background: var(--accent); }
.gpu-legende .swatch.other { background: var(--accent-2); }
.gpu-legende .swatch.free { background: var(--surface-3); }

.gpu-zeitleiste {
  display: flex; height: 150px; border-radius: var(--radius-s); overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2);
}
.gpu-zeitleiste .abschnitt {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; overflow: hidden; white-space: nowrap;
  border-right: 1px solid var(--surface-0);
}
.gpu-zeitleiste .abschnitt.geladen { background: var(--accent-soft); color: #9cc5f2; }
.gpu-zeitleiste .abschnitt.leer { background: transparent; color: var(--text-muted); }
.gpu-zeitleiste .abschnitt span { transform: rotate(-90deg); transform-origin: center; }

@media (max-width: 720px) {
  .gpu-zeitleiste { height: 110px; }
  .gpu-verlauf { height: 120px; }
}

/* Zeitraum-Umschalter über der Verlaufsgrafik */
.zeitraum { display: inline-flex; gap: 2px; background: var(--surface-3); border-radius: 999px; padding: 2px; }
.zeitraum button {
  border: none; background: transparent; color: var(--text-muted);
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.zeitraum button:hover { color: var(--text-primary); }
.zeitraum button.aktiv { background: var(--accent); color: #fff; }

/* Waagerechte Beschriftung, wo der Abschnitt breit genug ist */
.gpu-zeitleiste .abschnitt.breit span { transform: none; }
.gpu-verlauf-hinweis {
  height: 150px; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 0 24px;
  border: 1px dashed var(--border); border-radius: var(--radius-s);
}
