/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-darkest:  #0d0d0f;
  --bg-deep:     #111114;
  --bg-base:     #16161a;
  --bg-raised:   #1e1e24;
  --bg-surface:  #242430;
  --bg-hover:    #2a2a38;
  --border:      #2c2c3a;
  --accent:      #7c6fff;
  --accent-dim:  #5a4fe0;
  --accent-glow: rgba(124, 111, 255, 0.18);
  --green:       #4ade80;
  --red:         #f87171;
  --yellow:      #fbbf24;
  --text-1:      #e8e8f0;
  --text-2:      #a0a0b8;
  --text-3:      #606078;
  --radius:      10px;
  --sidebar-w:   240px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

html, body {
  height: 100%;
  background: var(--bg-darkest);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

/* ===== OVERLAY / MODAL ===== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.overlay.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(124,111,255,0.08);
  animation: modal-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-in {
  from { transform: scale(0.88) translateY(12px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-logo {
  display: flex; justify-content: center;
  margin-bottom: 16px;
}

.modal h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-1);
  margin-bottom: 6px;
}

.modal-sub {
  color: var(--text-2);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.input-wrap {
  position: relative;
  margin-bottom: 8px;
}

.input-wrap input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 48px 12px 16px;
  color: var(--text-1);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-count {
  position: absolute;
  right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.error-msg {
  color: var(--red);
  font-size: 0.82rem;
  min-height: 18px;
  margin-bottom: 12px;
  text-align: left;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  margin-bottom: 20px;
}
.btn-primary:hover {
  background: var(--accent-dim);
  box-shadow: 0 4px 20px rgba(124,111,255,0.35);
}
.btn-primary:active { transform: scale(0.98); }

.setup-link {
  color: var(--text-3);
  font-size: 0.82rem;
  text-decoration: none;
  transition: color 0.2s;
}
.setup-link:hover { color: var(--accent); }

/* ===== APP LAYOUT ===== */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

.hidden { display: none !important; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.server-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: default;
}

.server-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.server-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-1);
}
.server-sub {
  font-size: 0.72rem;
  color: var(--text-3);
}

.channels-section {
  padding: 16px 8px 4px;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 8px;
  margin-bottom: 4px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.88rem;
  position: relative;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}
.channel-item:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
.channel-item.active {
  background: var(--bg-surface);
  color: var(--text-1);
}
.channel-item.vc-active {
  color: var(--green);
}

.ch-prefix {
  color: var(--text-3);
  font-size: 1rem;
  font-weight: 500;
  flex-shrink: 0;
}
.vc-icon { color: var(--text-3); }
.channel-item.vc-active .vc-icon { color: var(--green); }

.vc-participants {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.vc-participant {
  font-size: 0.72rem;
  color: var(--green);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer {
  margin-top: auto;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-darkest);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
}

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

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

.user-controls {
  display: flex;
  gap: 4px;
}

.ctrl-btn {
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.ctrl-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.ctrl-btn.active { color: var(--red); }

/* ===== CHAT AREA ===== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
  flex-shrink: 0;
}

.ch-hash {
  color: var(--text-3);
  font-size: 1.2rem;
  font-weight: 500;
}
.chat-title {
  font-weight: 600;
  color: var(--text-1);
}
.chat-desc {
  color: var(--text-3);
  font-size: 0.82rem;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

/* ===== MESSAGES ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
}

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

.message {
  display: flex;
  gap: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.1s;
}
.message:hover { background: var(--bg-raised); }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-content { flex: 1; min-width: 0; }

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.msg-nick {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-1);
}
.msg-nick.self { color: var(--accent); }

.msg-time {
  font-size: 0.72rem;
  color: var(--text-3);
}

.msg-text {
  color: var(--text-1);
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.system-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 0.82rem;
  padding: 8px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

/* ===== INPUT BAR ===== */
.input-bar {
  padding: 12px 20px 16px;
  flex-shrink: 0;
}

.input-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 10px 10px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-inner:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-1);
  font-family: var(--font);
  font-size: 0.9rem;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}
#chat-input::placeholder { color: var(--text-3); }

.send-btn {
  width: 34px; height: 34px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.send-btn:hover { background: var(--accent-dim); }
.send-btn:active { transform: scale(0.93); }

/* ===== VOICE PANEL ===== */
.voice-panel {
  position: fixed;
  bottom: 70px;
  left: 8px;
  width: calc(var(--sidebar-w) - 16px);
  background: var(--bg-raised);
  border: 1px solid var(--green);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(74,222,128,0.1);
  z-index: 100;
  animation: slide-up 0.25s ease;
}

@keyframes slide-up {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.vp-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--green);
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.vp-users {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  min-height: 20px;
}

.vp-user {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-1);
}

.vp-user-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.vp-talking {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  margin-left: auto;
  flex-shrink: 0;
  transition: background 0.1s;
}
.vp-talking.on { background: var(--green); box-shadow: 0 0 6px var(--green); }

.btn-disconnect {
  width: 100%;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 7px;
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  padding: 7px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-disconnect:hover {
  background: rgba(248, 113, 113, 0.22);
  border-color: var(--red);
}

/* ===== AVATAR COLORS ===== */
.av-0 { background: #7c6fff; }
.av-1 { background: #34d399; }
.av-2 { background: #f87171; }
.av-3 { background: #fbbf24; }
.av-4 { background: #60a5fa; }
.av-5 { background: #f472b6; }
.av-6 { background: #a78bfa; }
.av-7 { background: #2dd4bf; }

/* ===== ADMIN STYLES ===== */
.admin-panel-btn {
  margin-left: auto;
  padding: 4px 12px;
  background: rgba(124,111,255,0.12);
  border: 1px solid rgba(124,111,255,0.3);
  color: #7c6fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.15s;
}
.admin-panel-btn:hover { background: rgba(124,111,255,0.22); }

.admin-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  font-size: 0.85rem;
  padding: 0 4px;
  transition: opacity 0.15s;
  color: var(--red);
}
.message:hover .admin-del-btn { opacity: 1; }

/* Password input in login modal */
#pass-input {
  width: 100%;
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--text-1);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
#pass-input:focus { border-color: var(--accent); }

/* ===== ADMIN TABS ===== */
.admin-tab {
  padding: 6px 14px;
  background: #1e1e24;
  border: 1px solid #2c2c3a;
  color: #a0a0b8;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.admin-tab.active {
  background: rgba(124,111,255,0.15);
  border-color: rgba(124,111,255,0.4);
  color: #7c6fff;
}
.admin-tab-content.hidden { display: none; }

/* ===== AVATAR IMAGES ===== */
.msg-avatar, .user-avatar, .vp-user-avatar {
  position: relative;
  overflow: hidden;
}
.av-img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.user-avatar { cursor: pointer; transition: opacity 0.2s; }
.user-avatar:hover { opacity: 0.8; }
.user-avatar:hover::after {
  content: '📷';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
}
