/* ABC-on Chat - Styling */
/* Folgt System-Praeferenz via prefers-color-scheme, manuell ueberschreibbar via [data-theme] */

:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-bubble-self: #2563eb;
  --bg-bubble-other: #e5e7eb;
  --text: #111827;
  --text-bubble-self: #ffffff;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --accent: #2563eb;
  --error: #dc2626;
  --success: #16a34a;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 12px;
  --gap: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-elevated: #1e293b;
    --bg-bubble-self: #3b82f6;
    --bg-bubble-other: #334155;
    --text: #f1f5f9;
    --text-bubble-self: #ffffff;
    --text-muted: #94a3b8;
    --border: #334155;
    --accent: #60a5fa;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
  }
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-bubble-self: #2563eb;
  --bg-bubble-other: #e5e7eb;
  --text: #111827;
  --text-bubble-self: #ffffff;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --accent: #2563eb;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --bg-bubble-self: #3b82f6;
  --bg-bubble-other: #334155;
  --text: #f1f5f9;
  --text-bubble-self: #ffffff;
  --text-muted: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.screen {
  display: none;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
}

.screen.active { display: flex; }

.hidden { display: none !important; }

/* ─── Login ───────────────────────────────────────── */
#login-screen.active {
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--bg-elevated);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  margin: 1rem;
}

.login-box h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-box label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-box input {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

.login-box input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-box button[type="submit"] {
  width: 100%;
  padding: 0.7rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}

.login-box button[type="submit"]:hover { opacity: 0.9; }

.error {
  color: var(--error);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

/* ─── Chat ────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 0.6rem; }

.status-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.status-badge.online { background: var(--success); color: white; }
.status-badge.offline { background: var(--text-muted); color: white; }

.header-right { display: flex; gap: 0.5rem; }

.header-right button {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
}

.header-right button:hover { background: var(--bg); }

/* ─── Messages ────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.bubble {
  max-width: 75%;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
}

.bubble.self {
  align-self: flex-end;
  background: var(--bg-bubble-self);
  color: var(--text-bubble-self);
  border-bottom-right-radius: 4px;
}

.bubble.other {
  align-self: flex-start;
  background: var(--bg-bubble-other);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.bubble .meta {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.3rem;
}

.bubble.file {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bubble .file-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.bubble .file-size {
  font-size: 0.75rem;
  opacity: 0.8;
}

.bubble .file-action {
  background: rgba(255,255,255,0.2);
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  color: inherit;
  font-size: 0.8rem;
}

.bubble.other .file-action {
  background: rgba(0,0,0,0.1);
}

.bubble img.preview {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 0.3rem;
}

/* ─── Typing-Indikator ───────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.5rem 1rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: pulse 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 60%, 100% { transform: scale(0.7); opacity: 0.4; }
  30% { transform: scale(1); opacity: 1; }
}

/* ─── Composer ────────────────────────────────────── */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.composer button {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
}

.composer button:hover { background: var(--bg); }

#send-btn {
  background: var(--accent);
  color: white;
}

#send-btn:hover { background: var(--accent); opacity: 0.9; }

#message-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0.6rem 0.9rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  resize: none;
  max-height: 120px;
  outline: none;
}

#message-input:focus { border-color: var(--accent); }

/* ─── Connection-Status (Toast) ──────────────────── */
.connection-status {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.connection-status.show { opacity: 1; }
.connection-status.error { background: var(--error); color: white; }
.connection-status.success { background: var(--success); color: white; }

/* ─── Incoming Toast (Notification fuer neue Nachrichten) ── */
.incoming-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-150%);
  background: var(--accent);
  color: white;
  padding: 0.8rem 1.2rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform 0.3s ease-out;
  z-index: 9999;
  max-width: 90%;
  text-align: center;
}

.incoming-toast.show {
  transform: translateX(-50%) translateY(0);
}
