/* ════════════════════════════════════════════════
   VARIABLEN & RESET
════════════════════════════════════════════════ */
:root {
  --bg0: #0a0a0f;
  --bg1: #111118;
  --bg2: #16161f;
  --bg3: #1e1e2a;
  --bg4: #252535;
  --border: #2a2a3d;
  --border-bright: #3d3d5c;
  --accent: #7c6fff;
  --accent2: #ff6b9d;
  --accent-dim: rgba(124,111,255,0.15);
  --text: #e0e0f0;
  --text-dim: #7070a0;
  --text-muted: #404060;
  --success: #4ade80;
  --danger: #ff5566;
  --radius: 8px;
  --sidebar-w: 240px;
  --font-ui: 'Syne', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
}

/* ════════════════════════════════════════════════
   SCREENS
════════════════════════════════════════════════ */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* ════════════════════════════════════════════════
   AUTH SCREEN
════════════════════════════════════════════════ */
#auth-screen {
  align-items: center;
  justify-content: center;
  position: relative;
}

.auth-bg {
  position: absolute; inset: 0; overflow: hidden;
  pointer-events: none;
}

.grid-lines {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(124,111,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,111,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
}
.orb1 { width: 400px; height: 400px; background: #7c6fff; top: -100px; right: -100px; animation: float1 8s ease-in-out infinite; }
.orb2 { width: 300px; height: 300px; background: #ff6b9d; bottom: -80px; left: -80px; animation: float2 10s ease-in-out infinite; }

@keyframes float1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-30px,40px); } }
@keyframes float2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(40px,-30px); } }

.auth-card {
  position: relative; z-index: 1;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(124,111,255,0.1);
  animation: cardIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px;
}
.logo-icon { font-size: 24px; color: var(--accent); }
.logo-text { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }

.auth-tabs {
  display: flex; gap: 4px;
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 28px;
}

.tab-btn {
  flex: 1; padding: 8px; border: none; background: transparent;
  color: var(--text-dim); font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  border-radius: calc(var(--radius) - 2px); cursor: pointer; transition: all 0.2s;
}
.tab-btn.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 12px rgba(124,111,255,0.4);
}

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: 1px; color: var(--text-dim);
  text-transform: uppercase; margin-bottom: 6px;
}
.field input {
  width: 100%; padding: 11px 14px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font-mono); font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,111,255,0.15);
}
.field input::placeholder { color: var(--text-muted); }

.error-msg {
  color: var(--danger); font-size: 12px;
  margin-bottom: 12px; min-height: 18px;
}

.btn-primary {
  width: 100%; padding: 12px; border: none;
  background: var(--accent); color: #fff;
  font-family: var(--font-ui); font-size: 14px; font-weight: 700;
  border-radius: var(--radius); cursor: pointer; letter-spacing: 0.5px;
  transition: all 0.2s; box-shadow: 0 4px 16px rgba(124,111,255,0.3);
}
.btn-primary:hover {
  background: #9380ff;
  box-shadow: 0 6px 24px rgba(124,111,255,0.5);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

/* ════════════════════════════════════════════════
   CHAT LAYOUT
════════════════════════════════════════════════ */
#chat-screen { display: none; }
#chat-screen.active { display: flex; }

.layout { display: flex; width: 100%; height: 100vh; overflow: hidden; }

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

.sidebar-header {
  display: flex; align-items: center; gap: 8px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header .logo-text { font-size: 16px; font-weight: 800; flex: 1; }

.sidebar-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  color: var(--text-muted);
}

.icon-btn {
  background: transparent; border: none;
  color: var(--text-dim); cursor: pointer; font-size: 16px;
  width: 26px; height: 26px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.icon-btn:hover { background: var(--bg3); color: var(--text); }

.room-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; cursor: pointer;
  color: var(--text-dim); font-size: 13px; font-weight: 600;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}
.room-item:hover { background: var(--bg2); color: var(--text); }
.room-item.active {
  background: var(--accent-dim); color: var(--accent);
  border-left-color: var(--accent);
}
.room-item .room-hash { color: var(--text-muted); font-size: 15px; }
.room-item.active .room-hash { color: var(--accent); }

.online-user {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px; font-size: 13px;
}
.online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); flex-shrink: 0;
}
.online-name { font-weight: 600; }
.online-room { font-size: 11px; color: var(--text-muted); }

.sidebar-footer {
  margin-top: auto; padding: 14px 16px;
  border-top: 1px solid var(--border);
}
#me-badge {
  display: flex; align-items: center; gap: 10px;
}
.me-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.me-name { font-weight: 700; font-size: 13px; }
.me-label { font-size: 10px; color: var(--text-muted); }

/* ─── CHAT AREA ─── */
.chat-area {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg0);
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg1);
  display: flex; align-items: center;
}
#chat-room-name {
  font-size: 16px; font-weight: 800; letter-spacing: -0.3px;
}
.room-desc {
  display: block; font-size: 12px;
  color: var(--text-dim); margin-top: 1px;
}

/* ─── MESSAGES ─── */
.messages {
  flex: 1; overflow-y: auto;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 2px;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

.msg {
  display: flex; gap: 12px;
  padding: 6px 10px; border-radius: var(--radius);
  transition: background 0.1s;
  animation: msgIn 0.2s ease both;
}
.msg:hover { background: var(--bg2); }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 800;
  color: #fff; margin-top: 1px;
}
.msg-body { flex: 1; min-width: 0; }
.msg-meta {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px;
}
.msg-author { font-size: 13px; font-weight: 700; }
.msg-time {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-muted);
}
.msg-text { font-size: 14px; line-height: 1.5; word-break: break-word; color: var(--text); }

.msg-grouped { padding-top: 2px; }
.msg-grouped .msg-avatar { visibility: hidden; }
.msg-grouped .msg-meta { display: none; }

.system-msg {
  text-align: center; font-size: 12px;
  color: var(--text-muted); padding: 8px 0;
  font-family: var(--font-mono);
}

/* ─── INPUT AREA ─── */
.input-area {
  display: flex; gap: 10px; align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg1);
}
.input-area input {
  flex: 1; padding: 12px 16px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-family: var(--font-ui); font-size: 14px;
  outline: none; transition: all 0.2s;
}
.input-area input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,111,255,0.12);
}
.input-area input:disabled { opacity: 0.4; cursor: not-allowed; }
.input-area input::placeholder { color: var(--text-muted); }

.btn-send {
  width: 44px; height: 44px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 16px;
  cursor: pointer; transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(124,111,255,0.3);
  display: flex; align-items: center; justify-content: center;
}
.btn-send:hover { background: #9380ff; transform: scale(1.05); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ════════════════════════════════════════════════
   MODAL
════════════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }

.modal-card {
  background: var(--bg2); border: 1px solid var(--border-bright);
  border-radius: 14px; padding: 32px; width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: cardIn 0.3s ease both;
}
.modal-card h3 { font-size: 18px; font-weight: 800; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn-primary { flex: 1; }

.btn-ghost {
  flex: 1; padding: 12px; border: 1px solid var(--border-bright);
  background: transparent; color: var(--text-dim);
  font-family: var(--font-ui); font-size: 14px; font-weight: 600;
  border-radius: var(--radius); cursor: pointer; transition: all 0.2s;
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

/* ════════════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════════════ */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted); gap: 12px;
}
.empty-state .big-icon { font-size: 48px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════ */
@media (max-width: 600px) {
  :root { --sidebar-w: 200px; }
  .msg-text { font-size: 13px; }
}

/* ── ROLLEN ──────────────────────────────────────────────── */
.role-header {
  padding: 12px 16px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
}

.me-role-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 2px 8px; border-radius: 20px;
  margin-top: 2px;
}
