/* KanbanAI — dunkles Design im Stil der Claude-App:
   warmes Anthrazit, Koralle als Akzent, runde Ecken, ruhige Flächen. */

:root {
  --bg: #262624;          /* warmes Anthrazit (Seite) */
  --panel: #30302e;       /* Sidebar, Karten */
  --panel-2: #2c2b29;     /* Bubbles, dezente Flächen */
  --panel-deep: #1f1e1d;  /* Eingaben, tiefe Flächen */
  --line: #3c3b38;        /* Rahmen */
  --line-soft: #34332f;
  --text: #f2f0ea;        /* warmes Off-White */
  --muted: #a5a196;       /* warmes Grau */
  --accent: #d97757;      /* Claude-Koralle */
  --accent-hover: #c9673f;
  --accent-soft: rgba(217, 119, 87, 0.14);
  --danger: #e0655a;
  --ok: #74b98a;
  --warn: #d6a24e;
  --user-bubble: #36352f; /* eigene Nachricht */
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; display: flex; flex-direction: column; }

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

h1, h2, h3 { margin: 0 0 12px; line-height: 1.3; font-weight: 600; }
h2 { font-size: 20px; letter-spacing: -0.01em; }
h3 { font-size: 15px; }

/* ---------- Buttons & Formulare ---------- */

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 500;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover:not(:disabled) { background: #3a3a37; border-color: #4a4945; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary { background: transparent; }
.btn-secondary:hover:not(:disabled) { background: var(--panel); }

.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover:not(:disabled) { background: rgba(224, 101, 90, 0.12); border-color: transparent; }

.btn-small { padding: 4px 10px; font-size: 13px; }

.btn-link {
  border: none; background: none; padding: 0; font: inherit;
  color: var(--accent); text-decoration: underline; cursor: pointer;
}

input[type="text"], input[type="password"], textarea, select {
  font: inherit;
  color: var(--text);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-deep);
  width: 100%;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #6f6c64; }
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 13px; color: var(--muted); }
.field { margin-bottom: 14px; }
.field-check { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; font-size: 14px; color: var(--text); margin-top: 6px; }
.field-check input { width: auto; margin-top: 3px; }

.form-msg { min-height: 20px; font-size: 13px; margin-top: 8px; }
.form-msg.err { color: var(--danger); }
.form-msg.ok { color: var(--ok); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 11px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; font-size: 18px; letter-spacing: -0.02em; margin-right: 10px; white-space: nowrap; }
.topnav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.topnav a {
  text-decoration: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}
.topnav a:hover { background: var(--panel); color: var(--text); }
.topnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; position: relative; }
.username-btn {
  font: inherit; border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--text); padding: 6px 10px; cursor: pointer; font-weight: 500;
}
.username-btn:hover { background: var(--panel); }
.usermenu {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 6px;
  width: 270px; max-width: calc(100vw - 24px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; z-index: 30;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.usermenu.open { display: block; }

/* ---------- Verbindungsstatus ---------- */

.connbar {
  display: none; padding: 7px 18px;
  background: var(--accent-soft); border-bottom: 1px solid var(--line);
  color: var(--text); font-size: 13px;
}
.connbar.visible { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Hauptbereich ---------- */

.main { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; padding: 0; }
.main.boxed { max-width: 940px; margin: 0 auto; padding: 24px; }

/* WICHTIG: .view nur volle Breite — KEINE Flex-Vollhöhe (drückt sonst Tabellen platt).
   Der Chat nutzt stattdessen .sparring-layout für die Vollhöhe. */
.view { width: 100%; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error-text { color: var(--danger); }

.error-box {
  border: 1px solid rgba(224, 101, 90, 0.4); background: rgba(224, 101, 90, 0.1);
  color: var(--danger); padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 12px;
}
.notice-box {
  border: 1px solid var(--line); background: var(--accent-soft);
  color: var(--text); padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 12px;
}

.badge {
  display: inline-block; font-size: 11px; font-weight: 500;
  padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); margin-left: 8px; white-space: nowrap; vertical-align: middle;
}
.badge-entschieden, .badge-green { color: var(--ok); border-color: rgba(116, 185, 138, 0.4); }
.badge-archiviert { color: var(--warn); border-color: rgba(214, 162, 78, 0.4); }
.badge-konvergiert, .badge-accent { color: var(--accent); border-color: rgba(217, 119, 87, 0.4); }
.badge-geparkt, .badge-muted { color: var(--muted); }
.badge-red { color: var(--danger); border-color: rgba(224, 101, 90, 0.4); }

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

.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 360px; max-width: 100%;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.login-card h1 { font-size: 22px; margin-bottom: 22px; letter-spacing: -0.02em; }

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

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data th { background: var(--panel-deep); font-weight: 600; white-space: nowrap; color: var(--muted); }
table.data td .btn { margin: 1px 4px 1px 0; }

/* ---------- Sparring-Layout: Sidebar + Chat ---------- */

.sparring-layout { flex: 1; min-height: 0; display: flex; width: 100%; }

.sparring-sidebar {
  width: 300px; flex-shrink: 0;
  border-right: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head { padding: 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.sidebar-head .btn { width: 100%; }
.side-panel { border-bottom: 1px solid var(--line); background: var(--panel-deep); padding: 14px; }
.side-panel h3 { margin: 0 0 10px; font-size: 14px; }
.side-panel textarea, .side-panel input { margin-bottom: 8px; }
.side-empty { padding: 16px; }

.threads { flex: 1; overflow: auto; }
.thread-item { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); cursor: pointer; transition: background 0.1s ease; }
.thread-item:hover { background: var(--panel-2); }
.thread-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.thread-item .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

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

.chat-view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.thread-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.thread-title { font-weight: 600; font-size: 15px; }
.thread-actions { margin-left: auto; display: flex; gap: 6px; }
.close-panel { border-bottom: 1px solid var(--line); }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-messages { display: flex; flex-direction: column; gap: 14px; }
.chat-empty { margin: auto; color: var(--muted); }

.msg {
  padding: 11px 15px; border-radius: var(--radius); max-width: 74%;
  align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line-soft);
}
.msg-own { background: var(--user-bubble); align-self: flex-end; border-color: var(--line); }
.msg-ai { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.msg-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg-author { font-weight: 600; margin-right: 8px; color: var(--text); }
.msg-ai .msg-author { color: var(--accent); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-pending { opacity: 0.55; }
.msg-failed { outline: 1px solid var(--danger); }
.msg-fail { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* Ephemere Anzeigen (Typing / Agent) */
.chat-indicators { display: flex; flex-direction: column; gap: 10px; }
.ind-bubble {
  font-size: 13px; color: var(--muted);
  background: var(--panel-2); border-radius: var(--radius); padding: 9px 14px;
  align-self: flex-start; max-width: 74%; border: 1px solid var(--line-soft);
}
.ind-ai { color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.ind-ai .ind-label { font-weight: 600; }
.ind-draft { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); margin-top: 5px; }

.dots span { animation: dotblink 1.4s infinite; opacity: 0.25; }
.dots span:nth-child(2) { animation-delay: 0.25s; }
.dots span:nth-child(3) { animation-delay: 0.5s; }
@keyframes dotblink { 0%, 70%, 100% { opacity: 0.25; } 25% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots span { animation: none; opacity: 0.7; } }

.chat-inputrow {
  display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line);
  background: var(--bg); align-items: flex-end;
}
.chat-inputrow textarea {
  flex: 1; width: auto; min-height: 52px; max-height: 200px;
  background: var(--panel-deep); border-radius: var(--radius);
}
.chat-hint { padding: 6px 18px 12px; font-size: 12px; color: var(--muted); background: var(--bg); }
.chat-error { padding: 6px 18px 0; font-size: 13px; color: var(--danger); }

/* ---------- Admin: linkes Menü + Inhalt ---------- */

.admin-layout { display: flex; gap: 22px; align-items: flex-start; }
.admin-nav {
  width: 210px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 24px;
}
.admin-nav button {
  font: inherit; text-align: left;
  padding: 9px 13px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--muted); cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.admin-nav button:hover { background: var(--panel); color: var(--text); }
.admin-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.admin-content { flex: 1; min-width: 0; }
.admin-content > .panel:first-child { margin-top: 0; }

@media (max-width: 720px) {
  .admin-layout { flex-direction: column; }
  .admin-nav { width: 100%; flex-direction: row; flex-wrap: wrap; position: static; }
}

/* ---------- Meetings & Admin (boxed) ---------- */

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head h2 { margin: 0; }

.rec-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); margin-right: 8px; }
.rec-time { font-size: 30px; font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-status { margin: 12px 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab-btn {
  font: inherit; background: none; border: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 8px 15px; cursor: pointer; color: var(--muted);
}
.tab-btn:hover:not(:disabled) { background: var(--panel); color: var(--text); }
.tab-btn.active { background: var(--panel); color: var(--accent); font-weight: 600; }
.tab-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.doc-pre {
  white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0; padding: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  max-height: 60vh; overflow-y: auto;
}
.doc-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.doc-edit textarea { min-height: 300px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.meeting-meta { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
audio { width: 100%; max-width: 560px; display: block; margin: 10px 0; }

/* ---------- Responsiv ---------- */

@media (max-width: 720px) {
  .sparring-layout { flex-direction: column; }
  .sparring-sidebar { width: 100%; max-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .main.boxed { padding: 14px; }
  .topbar { padding: 9px 12px; gap: 8px; }
  .msg, .ind-bubble { max-width: 92%; }
  .rec-time { font-size: 24px; }
  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 7px 8px; }
}
