/* ═══════════════════════════════════════════════════════════════
   FamilyChat – Globale Styles
   Dunkles, modernes Theme
═══════════════════════════════════════════════════════════════ */

/* ── CSS-Variablen ─────────────────────────────────────────── */
:root {
  --bg-main:       #1a1b1e;
  --bg-sidebar:    #111214;
  --bg-card:       #242528;
  --bg-input:      #2c2d30;
  --bg-hover:      #2e2f33;
  --bg-active:     #363840;
  --bg-user-msg:   #1e3a2f;
  --bg-ai-msg:     #242528;
  --bg-btn:        #e8640a;
  --bg-btn-hover:  #d05a08;

  --text-primary:  #e8e6e1;
  --text-secondary:#9b9a97;
  --text-muted:    #6b6a68;
  --text-btn:      #ffffff;

  --border:        #36373b;
  --border-light:  #45464a;

  --accent:        #e8640a;
  --accent-light:  #f0883e;
  --danger:        #e53e3e;
  --success:       #38a169;

  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;

  --sidebar-w:     280px;
  --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:     'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-main);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  line-height: 1.6;
}
/* Seiten die scrollen müssen (Profil, Admin etc.) */
body.page-scroll { overflow-y: auto; }
a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* ── Login-Seite ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  overflow: auto;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-logo .logo-icon {
  width: 52px;
  height: 52px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
  font-size: 1.6rem;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: var(--bg-btn-hover); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { opacity: 0.85; }

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.alert-error   { background: rgba(229,62,62,.15); color: #fc8181; border: 1px solid rgba(229,62,62,.3); }
.alert-success { background: rgba(56,161,105,.15); color: #68d391; border: 1px solid rgba(56,161,105,.3); }

/* ── App-Layout ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-logo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.app-logo span { color: var(--accent); }

.new-chat-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s;
}
.new-chat-btn:hover { background: var(--bg-btn-hover); }

.sidebar-search {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  outline: none;
}
.sidebar-search input:focus { border-color: var(--accent); }

.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.conversations-list::-webkit-scrollbar { width: 4px; }
.conversations-list::-webkit-scrollbar-track { background: transparent; }
.conversations-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.conv-item {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  transition: background 0.12s;
  position: relative;
  group: true;
}

.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-active); }

.conv-icon {
  font-size: 0.9rem;
  margin-top: 1px;
  flex-shrink: 0;
  opacity: 0.6;
}

.conv-info { flex: 1; min-width: 0; }

.conv-title {
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.conv-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.conv-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
  flex-shrink: 0;
}
.conv-item:hover .conv-delete { opacity: 1; }
.conv-delete:hover { color: var(--danger); }

.conv-group-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 0.75rem 0.3rem;
  font-weight: 600;
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name  { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 0.72rem; color: var(--text-muted); }

.sidebar-footer-actions {
  width: 100%;
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.footer-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.footer-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
  text-decoration: none;
}
.footer-btn-logout:hover { color: #fc8181; border-color: #fc8181; }

/* ── Token-Verbrauch-Widget (Sidebar-Footer) ────────────────── */
.sidebar-token {
  width: 100%;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
}
.sidebar-token-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.sidebar-token-label  { font-size: 0.7rem; color: var(--text-muted); }
.sidebar-token-numbers {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sidebar-token-track {
  height: 3px;
  background: var(--bg-secondary);
  border-radius: 999px;
  overflow: hidden;
}
.sidebar-token-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ── Haupt-Chat-Bereich ─────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-main);
  flex-shrink: 0;
}

.chat-title-input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  flex: 1;
  min-width: 0;
}
.chat-title-input::placeholder { color: var(--text-muted); }

/* Modell-Anzeige im Header (read-only) */
.model-display {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  flex-shrink: 1;
}

/* ── Modell-Auswahl-Popup ─────────────────────────────────── */
.model-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.model-picker-popup {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  width: 420px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.model-picker-header { margin-bottom: 0.3rem; }
.model-picker-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}
.model-picker-subtitle {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.model-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
}
.model-card:hover   { border-color: var(--accent); background: rgba(232,100,10,.07); }
.model-card.selected { border-color: var(--accent); background: rgba(232,100,10,.12); }
.model-card-icon { font-size: 1.4rem; line-height: 1; flex-shrink: 0; }
.model-card-info { flex: 1; min-width: 0; }
.model-card-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}
.model-card-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.model-card-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(232,100,10,.18);
  color: var(--accent);
  flex-shrink: 0;
}
.model-picker-cancel {
  margin-top: 0.2rem;
  padding: 0.45rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.83rem;
  cursor: pointer;
  text-align: center;
  transition: color 0.15s;
}
.model-picker-cancel:hover { color: var(--text-secondary); }

/* ── Löschen-Bestätigung ─────────────────────────────────── */
.confirm-popup {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.75rem 1.5rem;
  width: 340px;
  max-width: 92vw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.confirm-icon  { font-size: 2rem; margin-bottom: 0.15rem; }
.confirm-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.confirm-text  { font-size: 0.83rem; color: var(--text-muted); max-width: 280px; line-height: 1.5; margin: 0; }
.confirm-actions { display: flex; gap: 0.75rem; margin-top: 0.75rem; justify-content: center; }

/* ── Nachrichten-Feed ───────────────────────────────────────── */
.messages-feed {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem;
}

.messages-feed::-webkit-scrollbar { width: 6px; }
.messages-feed::-webkit-scrollbar-track { background: transparent; }
.messages-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Nachrichtenbreite (fix69) ───────────────────────────────
   Die Lesebreite hängt an der einzelnen Nachricht, nicht am Container:
   Fließtext bleibt bei 780px (lesbar), eine Nachricht MIT Tabelle darf bis
   zur Container-Obergrenze wachsen. Was selbst dann nicht passt, scrollt
   horizontal in der Bubble. */
.messages-container {
  max-width: 1240px;          /* Obergrenze für breite Inhalte */
  margin: 0 auto;
}

.message-wrapper {
  max-width: 780px;           /* Lesebreite für normalen Text */
  width: 100%;
  margin: 0 auto 1.25rem;
  display: flex;
  flex-direction: column;
}

/* Nachricht mit Tabelle: Platz nehmen, so viel da ist */
.message-wrapper:has(table) {
  max-width: 1240px;
}
.message-wrapper:has(table) .message-bubble {
  max-width: 100%;            /* statt 80% – die Tabelle soll den Raum nutzen */
}

.message-wrapper.user { align-items: flex-end; }
.message-wrapper.assistant { align-items: flex-start; }

.message-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
}
.msg-avatar.user { background: var(--accent); color: #fff; }
.msg-avatar.assistant { background: #6b3fa0; color: #fff; }

.message-bubble {
  max-width: 80%;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.65;
  word-break: break-word;
  position: relative;
}

.message-bubble.user {
  background: var(--bg-user-msg);
  border: 1px solid rgba(255,255,255,.06);
  border-bottom-right-radius: var(--radius-sm);
}

.message-bubble.assistant {
  background: var(--bg-ai-msg);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

/* Markdown-Inhalte */
.message-bubble p { margin-bottom: 0.6em; }
.message-bubble p:last-child { margin-bottom: 0; }

.message-bubble pre {
  position: relative;
  background: #0d0e10;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
}

/* Hinweis, wenn der Stream nach Teilantwort abbricht (fix70) */
.stream-aborted {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid #fbd38d;
  background: rgba(251, 211, 141, 0.08);
  color: #fbd38d;
  font-size: 0.8rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Tabellen in Antworten: parseMarkdown() packt jede in .table-wrapper (fix69).
   Passt sie nicht in die (ggf. verbreiterte) Bubble, scrollt sie horizontal –
   statt die Spalten zu quetschen oder aus der Bubble zu laufen. */
.message-bubble .table-wrapper {
  overflow-x: auto;
  margin: 0.75rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.message-bubble .table-wrapper table {
  width: auto;                /* so breit wie der Inhalt … */
  min-width: 100%;            /* … aber mindestens die Bubble füllen */
  margin: 0;
}
.message-bubble .table-wrapper td,
.message-bubble .table-wrapper th {
  min-width: 5rem;            /* Spalten nicht auf null quetschen – lieber scrollen */
}

.copy-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-family: var(--font-sans);
  line-height: 1.4;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s, border-color .15s;
}
.message-bubble pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,.13); }
.copy-btn.copied {
  background: rgba(50,200,100,.12);
  border-color: #32c864;
  color: #32c864;
  opacity: 1;
}

/* Kopier-Button für die gesamte Nachricht (im Message-Header) */
.msg-copy-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  line-height: 1.4;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s, border-color .15s;
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
.message-wrapper:hover .msg-copy-btn { opacity: 1; }
.msg-copy-btn:hover {
  background: rgba(255,255,255,.07);
  border-color: var(--border);
  color: var(--text-secondary);
}
.msg-copy-btn.copied {
  color: #32c864;
  border-color: #32c864;
  background: rgba(50,200,100,.12);
  opacity: 1;
}

.message-bubble code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.message-bubble :not(pre) > code {
  background: rgba(255,255,255,.08);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.message-bubble ul, .message-bubble ol {
  margin: 0.5rem 0 0.5rem 1.5rem;
}

.message-bubble li { margin-bottom: 0.2em; }

.message-bubble h1, .message-bubble h2, .message-bubble h3 {
  margin: 0.8rem 0 0.4rem;
  font-weight: 600;
}
.message-bubble h1 { font-size: 1.2em; }
.message-bubble h2 { font-size: 1.05em; }
.message-bubble h3 { font-size: 0.95em; }

.message-bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 0.75rem;
  color: var(--text-secondary);
  margin: 0.5rem 0;
}

.message-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  padding: 0 0.25rem;
}

/* Typing-Indikator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
}
.typing-dot {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* Leerer Zustand */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 2rem;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-secondary);
  max-width: 400px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 1.5rem;
  max-width: 560px;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--text-primary); }

/* ── Eingabe-Bereich ─────────────────────────────────────────── */
.chat-input-area {
  padding: 0.75rem 1rem 1rem;
  background: var(--bg-main);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrapper {
  max-width: 780px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  transition: border-color 0.15s;
}
.input-wrapper:focus-within { border-color: var(--accent); }

/* Preview-Streifen über der Eingabezeile */
.image-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0.6rem 0.75rem 0;
}

.image-preview-thumb {
  position: relative;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
}
.image-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}
.remove-thumb {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.remove-thumb:hover { opacity: 0.85; }

/* Eingabezeile: 📎 + textarea + Senden */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem 0.55rem;
}

/* Options-Zeile unter dem Textarea (Anhängen, Web-Suche etc.) */
.input-options {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.75rem 0.55rem;
}

/* Web-Suche-Chip */
.search-option-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.2rem 0.65rem;
  line-height: 1.5;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.search-option-btn:hover    { color: var(--text-secondary); border-color: var(--border-light); }
.search-option-btn.active   { color: var(--accent); border-color: var(--accent); background: rgba(232,100,10,.12); }
.search-option-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Aktives Modell – Label rechts in der Options-Zeile */
.active-model-label {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Context-Window-Indikator */
.context-warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem 0.55rem;
}

.context-bar-track {
  flex: 1;
  height: 3px;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
}

.context-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--success);
  transition: width 0.5s ease, background 0.5s ease;
}

.context-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.5s ease;
}

/* Such-Indikator in der KI-Bubble */
.searching-indicator {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-spin {
  display: inline-block;
  animation: searchPulse 1.2s ease-in-out infinite;
}

@keyframes searchPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.9); }
}

/* Bild in Nachrichten-Bubble */
.message-image {
  display: block;
  max-width: 300px;
  max-height: 300px;
  border-radius: var(--radius-md);
  margin-top: 8px;
  cursor: zoom-in;
  border: 1px solid rgba(255,255,255,.08);
}

/* ── Datei-Anhänge (fix54) ──────────────────────────────────── */

/* Chip über der Eingabe, solange die Datei noch nicht abgeschickt ist */
.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
}
.file-chip-icon { font-size: 1rem; flex-shrink: 0; }
.file-chip-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-chip-meta  { color: var(--text-muted); font-size: 0.75rem; flex-shrink: 0; }
.file-chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}
.file-chip-remove:hover { color: #fc8181; background: rgba(252,129,129,.12); }

/* Download-Link in der abgeschickten Nachricht */
.message-file {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  font-size: 0.82rem;
  max-width: 320px;
  transition: background 0.12s, border-color 0.12s;
}
.message-file:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.2);
  text-decoration: none;
}
.message-file-icon { font-size: 1rem; flex-shrink: 0; }
.message-file-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message-file-size { color: var(--text-muted); font-size: 0.75rem; flex-shrink: 0; }

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 200px;
  min-height: 24px;
  overflow-y: auto;
}
#chat-input::placeholder { color: var(--text-muted); }

#chat-input::-webkit-scrollbar { width: 4px; }
#chat-input::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.send-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
  transition: background 0.15s, opacity 0.15s;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--bg-btn-hover); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.input-hint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* ── Admin-Panel ────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.admin-main::-webkit-scrollbar { width: 6px; }
.admin-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.page-header {
  margin-bottom: 1.75rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p  { color: var(--text-secondary); margin-top: 0.25rem; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
}
.stat-number { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label  { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.2rem; }

.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 0.6rem 0.9rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text-primary);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

.badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-admin   { background: rgba(232,100,10,.2);  color: var(--accent-light); }
.badge-user    { background: rgba(155,154,151,.15); color: var(--text-secondary); }
.badge-active  { background: rgba(56,161,105,.2);   color: #68d391; }
.badge-inactive{ background: rgba(229,62,62,.2);    color: #fc8181; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* ── Utilities ──────────────────────────────────────────────── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.hidden { display: none !important; }

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0; bottom: 0;
    z-index: 100;
    transition: left 0.25s ease;
  }
  .sidebar.open { left: 0; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
  }
  .sidebar-overlay.show { display: block; }

  .mobile-menu-btn {
    display: flex;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 4px;
  }

  .message-bubble { max-width: 95%; }
  .form-row { grid-template-columns: 1fr; }
  .admin-main { padding: 1rem; }
}

@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
  .sidebar-overlay { display: none !important; }
}

/* ── Animationen ────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-wrapper { animation: fadeIn 0.2s ease; }

/* Scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
