/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:           #0a0a14;
  --bg-surface:   #111120;
  --bg-elevated:  #1a1a2e;
  --accent:       #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow:  rgba(124, 58, 237, 0.25);
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --border:       #1e1e38;
  --discord:      #5865f2;
  --danger:       #ef4444;
  --success:      #34d399;
}

/* ─── Reset / Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input  { font-family: inherit; }

.hidden { display: none !important; }

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar          { width: 4px; height: 4px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ─── Header ────────────────────────────────────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

#logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.01em;
}

.logo-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 0 10px var(--accent));
}

#user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px 4px 4px;
}

.user-pill img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.user-pill span {
  font-size: 0.875rem;
  font-weight: 500;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.78rem;
  transition: border-color 0.15s, color 0.15s;
}

.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ─── Guest bar ─────────────────────────────────────────────────────────────── */
#guest-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 9px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ─── Discord buttons ───────────────────────────────────────────────────────── */
.btn-discord-sm,
.btn-discord-full {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--discord);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.1s;
}

.btn-discord-sm:hover,
.btn-discord-full:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-discord-sm   { padding: 6px 12px; font-size: 0.78rem; }
.btn-discord-full { padding: 10px 18px; font-size: 0.875rem; width: 100%; justify-content: center; }

.btn-discord-sm img,
.btn-discord-full img { width: 16px; height: 16px; }

/* ─── Main layout ───────────────────────────────────────────────────────────── */
#main {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  overflow: hidden;
  min-height: 0;
}

/* ─── Panel shared ──────────────────────────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
}

/* ─── Queue panel ───────────────────────────────────────────────────────────── */
#queue-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

#queue-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}

#queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 48px 16px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.queue-item:hover { background: var(--bg-elevated); }

.q-pos {
  font-size: 0.7rem;
  color: var(--accent-light);
  font-weight: 700;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.q-thumb {
  width: 58px;
  height: 38px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.q-meta {
  flex: 1;
  overflow: hidden;
}

.q-title {
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.q-by {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.queue-item:hover .btn-remove { opacity: 1; }
.btn-remove:hover { color: var(--danger); }

/* Add song area */
#add-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#add-form {
  display: flex;
  gap: 6px;
}

#song-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.78rem;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

#song-input::placeholder { color: var(--text-muted); }
#song-input:focus { border-color: var(--accent); }

#add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  transition: opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

#add-btn:hover         { opacity: 0.85; }
#add-btn:disabled      { opacity: 0.45; cursor: not-allowed; }

/* ─── Stage ─────────────────────────────────────────────────────────────────── */
#stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 32px;
  background: var(--bg);
  overflow: hidden;
}

/* DJ card */
#dj-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

#dj-card:not(.empty) {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

#dj-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  object-fit: cover;
  background: var(--bg-elevated);
}

#dj-card.empty #dj-avatar {
  border-color: var(--border);
  box-shadow: none;
}

#dj-info { display: flex; flex-direction: column; gap: 1px; }

#dj-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-light);
  text-transform: uppercase;
}

#dj-card.empty #dj-label { color: var(--text-muted); }

#dj-name {
  font-size: 0.9rem;
  font-weight: 600;
}

#dj-card.empty #dj-name { color: var(--text-muted); }

/* Video player */
#player-wrap {
  position: relative;
  width: 100%;
  max-width: 820px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border);
}

#yt-player,
#yt-player iframe {
  width: 100%;
  height: 100%;
  display: block;
}

/* Muted overlay (guests) */
#muted-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 5;
}

.mo-icon { font-size: 2.8rem; }
.mo-text { color: var(--text-muted); font-size: 0.9rem; }
#muted-overlay .btn-discord-full { max-width: 220px; }

/* Now playing */
#now-playing {
  text-align: center;
  max-width: 700px;
  width: 100%;
}

#np-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-light);
  font-weight: 700;
  margin-bottom: 5px;
}

#np-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Chat panel ────────────────────────────────────────────────────────────── */
#chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

#listener-count {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

#listener-avatars {
  display: flex;
  flex-direction: row-reverse;
}

#listener-avatars img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  margin-left: -5px;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

/* Chat message */
.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.chat-msg img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
}

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

.chat-msg-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 2px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.chat-msg-name.is-me { color: var(--success); }

.chat-msg-time {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 400;
}

.chat-msg-text {
  font-size: 0.83rem;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}

/* System messages */
.chat-system {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 2px 0;
}

/* Chat footer */
#chat-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

#chat-input-row {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
}

#chat-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.83rem;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

#chat-input::placeholder { color: var(--text-muted); }
#chat-input:focus  { border-color: var(--accent); }
#chat-input:disabled { opacity: 0.4; }

#chat-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 13px;
  font-size: 1rem;
  line-height: 1;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

#chat-send:hover    { opacity: 0.85; }
#chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

#chat-guest-bar {
  padding: 0 12px 10px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

#chat-guest-bar a { color: var(--accent-light); }
#chat-guest-bar a:hover { text-decoration: underline; }

/* ─── Toasts ─────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-light);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.83rem;
  color: var(--text);
  max-width: 300px;
  animation: toast-in 0.2s ease;
  pointer-events: all;
}

.toast.error { border-left-color: var(--danger); }

@keyframes toast-in {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
