/* =========================================================================
   OX Chat – Design-System-Tokens aus dem ERP-Prototyp (Dark).
   Layout: Icon-Leiste (Reiter) · Chat-Liste · Chat-Bereich.
   ========================================================================= */
:root {
  --bg:            #0c0e13;
  --sidebar:       #13161e;
  --surface:       #181c25;
  --surface-2:     #1f242f;
  --border:        #242a36;
  --border-strong: #313847;

  --text:          #e8eaf1;
  --muted:         #9097a6;
  --faint:         #5d6473;

  --accent:        #6c6cf5;
  --accent-2:      #8a6cff;
  --accent-soft:   rgba(108, 108, 245, .16);
  --success:       #38d39f;
  --danger:        #f46a6a;

  --radius:   18px;
  --radius-m: 14px;
  --radius-s: 10px;
  --shadow:   0 2px 6px rgba(0,0,0,.35), 0 12px 30px rgba(0,0,0,.28);

  --rail-w: 76px;
  --liste-w: 320px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; }

/* ===== Login ============================================================= */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px 32px; box-shadow: var(--shadow);
}
.login-logo, .rail-logo {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 19px; color: #fff;
}
.login-logo { margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 26px; }
.login-hint { color: var(--faint); font-size: 12px; margin: 14px 0 0; }
.btn-primary {
  width: 100%; padding: 12px; border: 0; border-radius: var(--radius-s);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 14px; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ===== App-Rahmen ======================================================== */
.app { display: flex; height: 100vh; }

/* ===== Icon-Leiste (Reiter) ============================================== */
.rail {
  width: var(--rail-w); flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 0; background: var(--bg);
}
.rail-logo { width: 42px; height: 42px; font-size: 16px; margin-bottom: 14px; }
.rail-tab {
  position: relative; width: 56px; padding: 9px 0 7px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 0; border-radius: var(--radius-m);
  color: var(--muted);
}
.rail-tab:hover { color: var(--text); background: var(--surface); }
.rail-tab.aktiv { color: #fff; background: var(--accent-soft); }
.rail-tab.aktiv svg, .rail-tab.aktiv .rail-ki-logo { color: var(--accent); }
.rail-label { font-size: 10px; letter-spacing: .02em; }
.rail-ki-logo {
  width: 22px; height: 22px; border-radius: 7px; font-size: 10.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--success), #1fa97f); color: #fff;
}
.rail-badge {
  position: absolute; top: 4px; right: 8px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 10.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.rail-spacer { flex: 1; }
.rail-aktion {
  background: none; border: 0; color: var(--faint); padding: 8px;
  border-radius: var(--radius-s);
}
.rail-aktion:hover { color: var(--danger); background: var(--surface); }
.btn-push { color: var(--accent); animation: puls 2s ease-in-out infinite; }
.btn-push:hover { color: var(--accent); background: var(--accent-soft); }
.btn-push.aktiv { color: var(--success); animation: none; }
.avatar-klein { width: 36px; height: 36px; font-size: 12px; margin-bottom: 4px; }

/* ===== Chat-Liste (Panel) ================================================ */
.liste {
  width: var(--liste-w); flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--sidebar); border: 1px solid var(--border);
  border-radius: var(--radius); margin: 10px 0 10px 2px;
  overflow: hidden;
}
.liste-kopf { padding: 16px 18px 8px; }
.liste-titel { font-weight: 800; font-size: 17px; }

.sb-search { padding: 4px 12px 12px; }
.sb-search input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; font-size: 13px;
  color: var(--text); outline: none;
}
.sb-search input:focus { border-color: var(--accent); }

.verzeichnis { padding: 0 8px 8px; border-bottom: 1px solid var(--border); }
.verz-hinweis { color: var(--faint); font-size: 11px; padding: 2px 10px 6px; text-transform: uppercase; letter-spacing: .04em; }

.raum-liste { flex: 1; overflow-y: auto; padding: 4px 8px 10px; }
.raum, .verz-eintrag {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px; border: 0; border-radius: var(--radius-m);
  background: none; color: var(--text); text-align: left;
}
.raum:hover, .verz-eintrag:hover { background: var(--surface); }
.raum.aktiv { background: var(--accent-soft); }
.raum-text { flex: 1; min-width: 0; }
.raum-name { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.raum-vorschau { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.raum-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.raum-zeit { color: var(--faint); font-size: 11px; }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.liste-leer {
  color: var(--faint); font-size: 12.5px; text-align: center;
  padding: 18px 20px; line-height: 1.6;
}

/* Avatare: Initialen auf Verlauf */
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.avatar.bot { background: linear-gradient(135deg, var(--success), #1fa97f); }
.avatar-msg { width: 30px; height: 30px; font-size: 10.5px; align-self: flex-end; }

/* ===== Chat-Bereich ====================================================== */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 10px 10px 10px 8px; }
#chat-aktiv { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.chat-leer {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--faint); text-align: center; gap: 12px;
  height: 100%;
}
.leer-icon svg { width: 44px; height: 44px; opacity: .45; }

.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; background: var(--sidebar);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.btn-zurueck { display: none; border: 0; }
.chat-name { font-weight: 700; font-size: 15px; }
.chat-sub { color: var(--muted); font-size: 12px; }

/* Nachrichten */
.nachrichten {
  flex: 1; overflow-y: auto; padding: 18px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.tag-trenner {
  align-self: center; margin: 14px 0 8px; padding: 3px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; color: var(--faint); font-size: 11px;
}
.msg-zeile { display: flex; gap: 8px; max-width: 68%; align-self: flex-start; }
.msg-zeile.eigene { align-self: flex-end; }
.msg {
  padding: 9px 13px; border-radius: 16px; border-bottom-left-radius: 6px;
  background: var(--surface); border: 1px solid var(--border);
  word-wrap: break-word; white-space: pre-wrap; min-width: 0;
}
.msg-zeile.eigene .msg {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 0; color: #fff;
  border-radius: 16px; border-bottom-right-radius: 6px;
}
.msg .absender { font-size: 11.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg-zeit { font-size: 10.5px; color: var(--faint); margin-top: 3px; text-align: right; }
.msg-zeile.eigene .msg-zeit { color: rgba(255,255,255,.75); }

/* Bild-Nachricht */
.msg-bild {
  display: block; max-width: 320px; max-height: 260px; width: auto;
  border-radius: 12px; cursor: pointer; margin: 2px 0;
}

/* Datei-Nachricht */
.msg-datei {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.06); border-radius: 12px;
  padding: 8px 12px; margin: 2px 0; cursor: pointer; border: 0;
  color: inherit; text-align: left; max-width: 300px;
}
.msg-datei:hover { background: rgba(255,255,255,.12); }
.msg-datei svg { flex-shrink: 0; }
.msg-datei-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-datei-groesse { font-size: 11px; opacity: .7; }

/* Sprachnachricht */
.msg-audio { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.audio-play {
  width: 34px; height: 34px; border-radius: 50%; border: 0; flex-shrink: 0;
  background: rgba(255,255,255,.14); color: inherit;
  display: flex; align-items: center; justify-content: center;
}
.msg-zeile:not(.eigene) .audio-play { background: var(--accent-soft); color: var(--accent); }
.audio-play svg { width: 18px; height: 18px; }
.audio-welle { flex: 1; display: flex; align-items: center; gap: 2px; height: 26px; }
.audio-welle i {
  flex: 1; background: currentColor; opacity: .35; border-radius: 2px;
  min-width: 2px;
}
.audio-welle i.aktiv { opacity: 1; }
.audio-dauer { font-size: 11px; opacity: .8; flex-shrink: 0; }

/* Composer */
.composer, .aufnahme {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px; margin-top: 10px;
  background: var(--sidebar); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-m); padding: 10px 14px;
  font: inherit; color: var(--text); outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.comp-btn {
  width: 40px; height: 40px; border: 0; border-radius: 12px; flex-shrink: 0;
  background: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.comp-btn:hover { color: var(--accent); background: var(--surface); }
.btn-send {
  width: 42px; height: 42px; border: 0; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.btn-send:hover { filter: brightness(1.08); }
.btn-send svg { width: 19px; height: 19px; margin-left: 2px; }

/* Aufnahme-Leiste */
.aufnahme { align-items: center; }
.aufnahme .punkt {
  width: 12px; height: 12px; border-radius: 50%; background: var(--danger);
  animation: puls 1.2s ease-in-out infinite;
}
@keyframes puls { 50% { opacity: .35; } }
#aufnahme-zeit { font-weight: 700; font-variant-numeric: tabular-nums; }
.aufnahme-hinweis { color: var(--muted); font-size: 13px; flex: 1; }

/* ===== Mobil (Vorstufe zur techapp-Einbettung) =========================== */
@media (max-width: 760px) {
  .rail { width: 56px; }
  .rail-label { display: none; }
  .rail-tab { width: 44px; padding: 10px 0; }
  .liste { width: calc(100% - 8px); margin: 8px 8px 8px 0; }
  .btn-zurueck { display: flex; }
  .chat { display: none; padding: 8px 8px 8px 0; }
  .app.mobil-chat .liste { display: none; }
  .app.mobil-chat .chat { display: flex; }
  .msg-zeile { max-width: 86%; }
  .msg-bild { max-width: 230px; }
}
