/* ── Variables ───────────────────────────────────────────── */
:root {
  --bg:           #080f18;
  --bg-card:      rgba(12, 22, 36, 0.85);
  --bg-soft:      rgba(255, 255, 255, 0.05);
  --border:       rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text:         #eef2f8;
  --text-soft:    #7a90a8;
  --brand:        #f5742a;
  --brand-soft:   #ffb168;
  --brand-dim:    rgba(245, 116, 42, 0.15);
  --mint:         #6ee7d2;
  --mint-dim:     rgba(110, 231, 210, 0.12);
  --radius-xl:    20px;
  --radius-lg:    14px;
  --radius-md:    10px;
  --radius-sm:    7px;
  --shadow:       0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-sm:    0 2px 8px rgba(0, 0, 0, 0.3);
  --font:         'Inter', 'Segoe UI', sans-serif;
  --topbar-h:     58px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }
.hidden { display: none !important; }

/* ── Base ────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 10% 0%, rgba(245, 116, 42, 0.14) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 90% 100%, rgba(110, 231, 210, 0.1) 0%, transparent 60%);
  overflow-x: hidden;
}

/* grain overlay */
.noise {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: rgba(8, 15, 24, 0.88);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

.brand-icon { font-size: 20px; line-height: 1; }

.brand-name {
  font-weight: 800; font-size: 1.05rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-soft));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-connect {
  display: flex; align-items: center; gap: 8px;
  flex: 1; max-width: 360px;
}

.topbar-status {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-soft);
  transition: background 0.3s;
}
.status-dot.connected    { background: #4ade80; box-shadow: 0 0 6px #4ade80; animation: pulse-dot 2s infinite; }
.status-dot.connecting   { background: var(--brand-soft); animation: pulse-dot 1s infinite; }
.status-dot.error        { background: #f87171; }
.status-dot.stream-ended { background: #a78bfa; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.status-text { font-size: 0.82rem; color: var(--text-soft); font-weight: 500; }

/* ── Shell ───────────────────────────────────────────────── */
.app-shell {
  position: relative; z-index: 1;
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
  display: flex; flex-direction: column; gap: 14px;
}

/* ── Control bar ─────────────────────────────────────────── */
.control-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}

.control-bar-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.stat-pills {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.stat-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.stat-pill.dj-active {
  border-color: var(--brand);
  background: var(--brand-dim);
}

/* volume pill */
.volume-pill { gap: 8px; }
.volume-slider {
  -webkit-appearance: none; appearance: none;
  width: 80px; height: 4px;
  border-radius: 2px; outline: none; cursor: pointer;
  background: linear-gradient(to right, var(--brand) 0%, var(--brand) 80%, rgba(255,255,255,0.15) 80%);
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px;
  border-radius: 50%; background: var(--brand); cursor: pointer;
}
.volume-slider::-moz-range-thumb {
  width: 12px; height: 12px; border: none;
  border-radius: 50%; background: var(--brand); cursor: pointer;
}

.stat-label {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-soft);
}

.stat-value {
  font-size: 0.82rem; font-weight: 600;
  color: var(--text);
  max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  padding: 11px 16px;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--brand);
  background: rgba(245, 116, 42, 0.08);
  color: var(--text-soft);
  font-size: 0.85rem;
  line-height: 1.5;
  min-height: 0;
}
.toast:empty { display: none; }

/* ── Main grid ───────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 380px 1fr 280px;
  grid-template-rows: auto;
  gap: 14px;
  align-items: start;
}

.col-player { display: flex; flex-direction: column; gap: 14px; }
.col-side   { display: flex; flex-direction: column; gap: 14px; }

/* ── Panel base ──────────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  padding: 18px;
  transition: border-color 0.2s;
}

.panel:hover { border-color: var(--border-hover); }

.panel-kicker {
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--brand-soft);
  margin-bottom: 4px;
}

.panel-title {
  font-size: 1.1rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}

.panel-header { margin-bottom: 0; }
.panel-header .panel-title { margin-bottom: 12px; }

/* ── Live badge ──────────────────────────────────────────── */
.live-badge {
  font-size: 0.58rem; font-weight: 800;
  letter-spacing: 0.1em;
  padding: 2px 7px;
  border-radius: 4px;
  background: #ef4444;
  color: #fff;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ── Now playing ─────────────────────────────────────────── */
.panel-now-playing { position: relative; overflow: hidden; }

.panel-now-playing::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(245,116,42,0.08), transparent 70%);
  pointer-events: none;
}

.current-track { position: relative; }

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 28px 16px;
  color: var(--text-soft);
  text-align: center;
}

.empty-icon { font-size: 2rem; opacity: 0.4; }

.track-card {
  display: flex; gap: 14px; align-items: center;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(245,116,42,0.1), rgba(110,231,210,0.05));
  border: 1px solid rgba(245,116,42,0.2);
}

.track-thumb {
  width: 72px; height: 72px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: rgba(255,255,255,0.06);
  flex-shrink: 0;
}

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

.track-title {
  font-size: 0.95rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}

.track-meta-row {
  display: flex; flex-direction: column; gap: 2px;
}

.track-meta-row span, .track-meta-row a {
  font-size: 0.78rem; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.track-meta-row a { color: var(--brand-soft); text-decoration: none; }
.track-meta-row a:hover { text-decoration: underline; }

.track-time {
  font-size: 0.8rem; font-weight: 600;
  color: var(--mint);
  white-space: nowrap;
}

/* bars animation when playing */
.eq-bars {
  display: flex; align-items: flex-end; gap: 2px;
  height: 16px; margin-top: 8px;
}

.eq-bars span {
  width: 3px; border-radius: 2px;
  background: var(--brand);
  animation: eq 0.8s ease-in-out infinite;
}
.eq-bars span:nth-child(2) { animation-delay: 0.15s; }
.eq-bars span:nth-child(3) { animation-delay: 0.30s; }
.eq-bars span:nth-child(4) { animation-delay: 0.10s; }

@keyframes eq {
  0%, 100% { height: 4px; }
  50%       { height: 14px; }
}

/* ── YouTube embed ───────────────────────────────────────── */
.youtube-embed-host {
  margin-top: 14px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  width: 100%; padding-bottom: 56.25%; height: 0;
  background: #000;
  border: 1px solid var(--border);
}

.youtube-embed-host.yt-hidden { display: none; }

.youtube-embed-host iframe,
.youtube-embed-host #youtube-player {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  display: block; border: 0;
}

.hidden-player {
  position: fixed; width: 1px; height: 1px;
  left: -9999px; top: 0; opacity: 0; pointer-events: none;
}

/* ── Add song form ───────────────────────────────────────── */
.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row .field { flex: 1; }

.search-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--mint-dim);
  border: 1px solid rgba(110,231,210,0.2);
  margin-bottom: 8px;
}
.search-preview.hidden { display: none; }
.search-preview-thumb {
  width: 52px; height: 36px; border-radius: var(--radius-sm);
  object-fit: cover; flex-shrink: 0; background: var(--bg-soft);
}
.search-preview-info { flex: 1; min-width: 0; }
.search-preview-title {
  font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-preview-meta { font-size: 0.75rem; color: var(--text-soft); }

.manual-form { display: flex; flex-direction: column; gap: 8px; }

.form-row {
  display: flex; gap: 8px;
}

.form-row .field { flex: 1; }

/* ── Fields & Buttons ────────────────────────────────────── */
.field {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.field:focus {
  border-color: rgba(245,116,42,0.5);
  background: rgba(255,255,255,0.08);
}

.field::placeholder { color: rgba(200,220,240,0.35); }

.field-sm {
  padding: 7px 11px;
  font-size: 0.85rem;
  min-width: 0; flex: 1;
}

.button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border: none; border-radius: var(--radius-md);
  font-size: 0.88rem; font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
}

.button:hover  { transform: translateY(-1px); opacity: 0.92; }
.button:active { transform: translateY(0); }

.button-primary {
  background: linear-gradient(135deg, var(--brand) 0%, #ff9350 100%);
  color: #0c1520;
  box-shadow: 0 2px 10px rgba(245,116,42,0.3);
}

.button-accent {
  background: linear-gradient(135deg, var(--mint) 0%, #a3f0db 100%);
  color: #071e18;
  box-shadow: 0 2px 10px rgba(110,231,210,0.2);
}

.button-ghost {
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border: 1px solid var(--border);
}

.button-ghost:hover { background: rgba(255,255,255,0.11); }

.button-sm { padding: 6px 12px; font-size: 0.82rem; }

/* ── Columna central (Chat + Regalos) ────────────────────── */
.col-center {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-chat,
.panel-gifts { display: flex; flex-direction: column; }

/* ── Regalos ─────────────────────────────────────────────── */
.gifts-list {
  flex: 1;
  gap: 4px !important;
}

.gifts-badge { background: rgba(74,222,128,0.18); color: #4ade80; border-color: rgba(74,222,128,0.35); }

.gift-item {
  display: flex !important;
  align-items: baseline;
  gap: 6px;
  padding: 7px 10px !important;
  border-radius: var(--radius-sm) !important;
  flex-wrap: wrap;
}

.gift-icon { flex-shrink: 0; font-size: 1rem; }

.gift-body { display: flex; gap: 5px; align-items: baseline; flex-wrap: wrap; flex: 1; }

.gift-user {
  font-size: 0.8rem; font-weight: 700;
  color: #4ade80;
  white-space: nowrap; flex-shrink: 0;
}

.gift-text {
  font-size: 0.82rem; color: var(--text);
  line-height: 1.4; word-break: break-word;
}

/* ── Chat (original) ─────────────────────────────────────── */

.chat-list {
  flex: 1;
  gap: 4px !important;
}

.chat-list li {
  display: flex; align-items: baseline; gap: 6px;
  padding: 7px 10px !important;
  border-radius: var(--radius-sm) !important;
  flex-wrap: wrap;
}

.chat-user {
  font-size: 0.8rem; font-weight: 700;
  color: var(--brand-soft);
  white-space: nowrap; flex-shrink: 0;
}

.chat-text {
  font-size: 0.82rem; color: var(--text);
  line-height: 1.4; word-break: break-word;
}

/* ── Queue ───────────────────────────────────────────────── */
.queue-list { max-height: 260px; overflow-y: auto; gap: 6px !important; }

.queue-list li {
  padding: 10px 12px !important;
}

.queue-list li strong {
  display: block; font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.queue-list li span {
  display: block; font-size: 0.75rem; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Lists shared ────────────────────────────────────────── */
.list {
  display: grid; gap: 8px;
  list-style: none; padding: 0; margin: 0;
}

.list li {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}

.list-events {
  max-height: 280px; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(245,116,42,0.3) transparent;
  padding-right: 2px;
}

.list-events::-webkit-scrollbar { width: 3px; }
.list-events::-webkit-scrollbar-track { background: transparent; }
.list-events::-webkit-scrollbar-thumb {
  background: rgba(245,116,42,0.3);
  border-radius: 2px;
}

.list-events li { display: grid; gap: 3px; }

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

.queue-empty, .events-empty {
  font-size: 0.82rem; color: var(--text-soft);
  text-align: center; padding: 16px 0;
}

/* ── Queue item with delete button ──────────────────────────── */
.queue-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
}
.queue-item-info { flex: 1; min-width: 0; }
.queue-num {
  font-size: 0.7rem; color: var(--text-soft);
  flex-shrink: 0; width: 16px; text-align: right;
}
.queue-delete {
  flex-shrink: 0;
  background: none; border: none; padding: 2px 4px;
  color: var(--text-soft); font-size: 0.85rem; line-height: 1;
  border-radius: var(--radius-sm); cursor: pointer;
  opacity: 0.5; transition: opacity 0.15s, color 0.15s;
}
.queue-delete:hover { opacity: 1; color: #f87171; }
.queue-list li.dragging { opacity: 0.4; border-style: dashed; }

/* ── History list ────────────────────────────────────────────── */
.history-list {
  max-height: 220px; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(245,116,42,0.3) transparent;
}
.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(245,116,42,0.3); border-radius: 2px; }
.history-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  opacity: 0.8;
}
.history-list li:hover { opacity: 1; }
.history-thumb {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  object-fit: cover; flex-shrink: 0; background: var(--bg-soft);
}
.history-info { flex: 1; min-width: 0; }
.history-title {
  font-size: 0.82rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-meta { font-size: 0.72rem; color: var(--text-soft); }
.history-reason {
  font-size: 0.68rem; padding: 2px 5px;
  border-radius: 99px; flex-shrink: 0;
  background: var(--bg-soft);
}
.history-reason.skipped { color: #fbbf24; }
.history-reason.finished { color: var(--mint); }

/* ── Moderation panel ────────────────────────────────────────── */
.mod-settings { margin-bottom: 10px; }
.mod-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.8rem; color: var(--text-soft); gap: 10px;
}
.mod-input { width: 64px !important; text-align: center; }
.mod-block-row {
  display: flex; gap: 8px; margin-bottom: 10px;
}
.mod-block-row .field { flex: 1; }
.blocked-list { max-height: 150px; overflow-y: auto; }
.blocked-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; font-size: 0.82rem;
}
.unblock-btn {
  background: none; border: none; padding: 2px 6px;
  color: var(--text-soft); font-size: 0.75rem;
  border-radius: var(--radius-sm); cursor: pointer;
  opacity: 0.6; transition: opacity 0.15s, color 0.15s;
}
.unblock-btn:hover { opacity: 1; color: var(--mint); }

/* ── Skip votes bar ─────────────────────────────────────────── */
.skip-votes-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; margin-top: 8px;
  border-radius: var(--radius-sm);
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.25);
  font-size: 0.78rem; color: #fbbf24;
}
.skip-votes-bar .svb-track {
  flex: 1; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}
.skip-votes-bar .svb-fill {
  height: 100%; border-radius: 2px;
  background: #fbbf24;
  transition: width 0.3s;
}

/* ── Top requesters ──────────────────────────────────────────── */
.top-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px;
}
.top-user { font-size: 0.83rem; font-weight: 600; color: var(--brand-soft); }
.top-count {
  font-size: 0.75rem; padding: 2px 8px;
  border-radius: 99px; background: var(--brand-dim);
  color: var(--brand-soft);
}

/* Entradas al live */
.joins-list { max-height: 200px; overflow-y: auto; }
.joins-list li { display: flex; align-items: center; justify-content: space-between; padding: 5px 10px; }
.join-name { font-size: 0.83rem; font-weight: 600; color: var(--text); }
.join-name::before { content: "→ "; color: #4ade80; font-weight: 700; }
.join-time { font-size: 0.72rem; color: var(--text-muted); }

/* ── DJ Mode active state ────────────────────────────────────── */
#dj-mode-toggle.active {
  background: var(--brand-dim);
  border-color: var(--brand);
  color: var(--brand-soft);
}

/* ── TTS Regalos active state ─────────────────────────────────── */
#tts-gifts-toggle.active {
  background: rgba(74, 222, 128, 0.15);
  border-color: #4ade80;
  color: #4ade80;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr 1fr;
  }
  .col-center { grid-column: 1 / -1; flex-direction: row; }
  .col-center .panel { flex: 1; }
  .col-side { grid-column: 1 / -1; flex-direction: row; }
  .col-side .panel { flex: 1; }
}

@media (max-width: 720px) {
  .main-grid { grid-template-columns: 1fr; }
  .col-center { flex-direction: column; }
  .col-side  { flex-direction: column; }

  .topbar { gap: 10px; padding: 0 14px; }
  .topbar-connect { max-width: none; flex: 1; }
  .topbar-status .status-text { display: none; }

  .control-bar { flex-direction: column; align-items: flex-start; }
  .stat-pills  { width: 100%; }

  .app-shell { width: calc(100% - 20px); padding: 12px 0 32px; }
}

@media (max-width: 480px) {
  .control-bar-actions .button-sm span { display: none; }
}
