/* DJ da chamada (music.js): player do YouTube, bloco no palco, capinha no painel da chamada,
   linha na lista de canais e painel de busca e fila. */

/* ---------- Player: um só, posicionado sobre o lugar visível ---------- */
#dj-player {
  position: fixed; z-index: 4; pointer-events: none; overflow: hidden; border-radius: 12px; background: #000;
  transition: border-radius .2s;
}
#dj-player.off { left: -10000px !important; top: 0 !important; width: 320px !important; height: 180px !important; visibility: hidden; }
#dj-player .dj-frame, #dj-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
#dj-player[data-where="mini"] { border-radius: 6px; }
#dj-player[data-where="mini"] :is(.dj-host-label, .dj-host-paused span) { display: none; }
.dj-host-label {
  position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 16px);
  padding: 2px 8px; border-radius: 4px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 14px; font-weight: 500;
}
.dj-host-label span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dj-host-label .ico-disc { flex-shrink: 0; color: var(--brand); }
.dj-host-paused {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(0, 0, 0, .55); color: #fff; font-weight: 600; font-size: 14px;
}
.dj-listen {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: auto; z-index: 1;
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 999px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.dj-listen:hover { background: var(--brand-hover); }
#dj-player[data-where="mini"] .dj-listen { padding: 6px; font-size: 0; gap: 0; }
/* Os controles da chamada flutuam por cima do bloco do DJ, como dos outros blocos. */
#stage-controls { z-index: 5; }

/* ---------- Bloco no palco ---------- */
.tile.dj { background: #000; cursor: pointer; }
.tile.dj:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.dj-tile-art { width: 100%; height: 100%; object-fit: cover; filter: blur(2px) brightness(.6); }
/* O player fica por cima do bloco (z-index 4); os botões do bloco ficam por cima dele. */
.tile.dj > .tile-controls { z-index: 5; }
.tile.dj .dj-stage { display: none; }
#dj-player:is([data-where="focus"], [data-where="cinema"]) .dj-host-label { display: none; }

/* ---------- Palco do DJ: o bloco em destaque ----------
   Fica sempre sobre o fundo escuro da chamada, então usa as cores claras de lá em todos os temas. */
.tile.dj.focus {
  container-type: inline-size; cursor: default; background: #08080a;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent);
}
.tile.dj.focus > .tile-controls { display: none; }
.tile.dj.focus .dj-tile-art {
  position: absolute; inset: -12%; width: 124%; height: 124%; filter: blur(56px) saturate(1.5) brightness(.5); transition: opacity .4s;
}
.tile.dj.focus.paused .dj-tile-art { filter: blur(56px) saturate(.6) brightness(.35); }
.tile.dj.focus .dj-stage {
  --text: #f2f3f5; --text-strong: #fff; --text-muted: rgba(255, 255, 255, .62);
  --hover: rgba(255, 255, 255, .08); --hover-strong: rgba(255, 255, 255, .16); --bg-floating: #111214; --divider: rgba(255, 255, 255, .1);
  position: absolute; inset: 0; display: grid; gap: 12px 16px; padding: 14px 16px 16px;
  grid-template: "head head" auto "screen next" minmax(0, 1fr) "bar bar" auto / minmax(0, 1fr) 288px;
  background: radial-gradient(120% 90% at 50% 40%, transparent 30%, rgba(0, 0, 0, .55)), linear-gradient(rgba(0, 0, 0, .2), rgba(0, 0, 0, .45));
  color: var(--text); animation: dj-stage-in .28s var(--ease-out, ease-out);
}
@keyframes dj-stage-in { from { opacity: 0; } }

.dj-stage-head { grid-area: head; display: flex; align-items: center; gap: 12px; min-width: 0; }
.dj-stage-badge {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand); color: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent), 0 6px 18px color-mix(in srgb, var(--brand) 45%, transparent);
}
.tile.dj:not(.paused) .dj-stage-badge .ico { animation: dj-spin 2.4s linear infinite; }
.dj-stage-who { display: flex; flex-direction: column; min-width: 0; }
.dj-stage-who strong { color: var(--text-strong); font-size: 16px; font-weight: 700; line-height: 1.2; }
.dj-stage-who small { color: var(--text-muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dj-stage-status {
  margin-left: auto; flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px; height: 26px; padding: 0 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 30%, rgba(0, 0, 0, .35)); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .06em;
}
.tile.dj.paused .dj-stage-status { background: rgba(255, 255, 255, .1); color: var(--text-muted); }
.dj-stage-status.live { background: color-mix(in srgb, var(--red) 75%, transparent); }
.dj-stage-actions { flex-shrink: 0; display: flex; gap: 6px; }
.dj-stage .tc-btn { background: rgba(255, 255, 255, .08); transition: background .12s, transform .15s var(--spring, ease); }
.dj-stage .tc-btn:hover { background: rgba(255, 255, 255, .18); }
.dj-stage .tc-btn:active { transform: scale(.92); }

/* Barrinhas de equalizador ao lado de "TOCANDO AGORA". */
.dj-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.dj-eq i { width: 3px; height: 100%; border-radius: 2px; background: currentColor; transform-origin: bottom; animation: dj-eq 1s ease-in-out infinite; }
.dj-eq i:nth-child(2) { animation-duration: .8s; animation-delay: -.3s; }
.dj-eq i:nth-child(3) { animation-duration: 1.15s; animation-delay: -.6s; }
.dj-eq i:nth-child(4) { animation-duration: .9s; animation-delay: -.15s; }
@keyframes dj-eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }

/* A tela: 16:9, o maior possível no espaço do meio. O player do YouTube é posicionado por cima dela. */
.dj-screen-wrap { grid-area: screen; min-width: 0; min-height: 0; container-type: size; display: grid; place-items: center; }
.dj-screen {
  width: min(100cqw, 100cqh * 16 / 9); aspect-ratio: 16 / 9; border-radius: 12px; background: #000; cursor: pointer;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .06);
}

.dj-stage-next {
  grid-area: next; min-height: 0; display: flex; flex-direction: column; padding: 6px; border-radius: 12px;
  background: rgba(0, 0, 0, .38); border: 1px solid rgba(255, 255, 255, .08); backdrop-filter: blur(14px);
}
.dj-next-list { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; }
.dj-next-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; transition: background .12s; }
.dj-next-list li:hover { background: var(--hover); }
.dj-next-list img { flex-shrink: 0; width: 56px; height: 32px; border-radius: 6px; object-fit: cover; background: #000; }
.dj-next-list .dj-track-text strong { font-size: 12.5px; }
.dj-next-list .dj-track-text small { font-size: 11px; }
.dj-next-empty {
  flex: 1; margin: 0; padding: 12px 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; color: var(--text-muted); font-size: 12.5px; line-height: 1.4;
}
.dj-next-empty .ico { color: var(--brand); }
.dj-next-more {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; margin-top: 4px; border: 0; border-radius: 8px;
  background: var(--hover); color: var(--text-strong); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s;
}
.dj-next-more:hover { background: var(--brand); }

.dj-stage-bar {
  grid-area: bar; min-width: 0; padding: 10px 14px 12px; border-radius: 14px;
  background: rgba(0, 0, 0, .42); border: 1px solid rgba(255, 255, 255, .08); backdrop-filter: blur(16px);
}
.dj-stage-bar .dj-progress { padding: 0 0 8px; }
.dj-stage-bar.paused .dj-bar i { background: var(--text-muted); }
.dj-stage-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dj-stage-art { flex-shrink: 0; width: 64px; height: 36px; border-radius: 6px; object-fit: cover; background: #000; }
.dj-stage-track { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dj-stage-track strong { color: var(--text-strong); font-size: 15px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dj-stage-track small { color: var(--text-muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dj-stage-row .dj-controls { flex-shrink: 0; padding: 0; }
.dj-stage-row .dj-volume { margin-left: 10px; }

@container (max-width: 860px) {
  .tile.dj.focus .dj-stage { grid-template: "head" auto "screen" minmax(0, 1fr) "bar" auto / minmax(0, 1fr); }
  .dj-stage-next { display: none; }
}
@container (max-width: 600px) {
  .tile.dj.focus .dj-stage { gap: 8px; padding: 10px; }
  .dj-stage-badge { width: 32px; height: 32px; border-radius: 10px; }
  .dj-stage-who small, .dj-stage-art, .dj-stage-row .dj-volume { display: none; }
  .dj-stage-status { height: 24px; padding: 0 9px; }
  .dj-stage-bar { padding: 8px 10px 10px; }
  .dj-stage-row .dj-ctl { width: 32px; height: 32px; }
  .dj-stage-row .dj-ctl.primary { width: 36px; height: 36px; }
}
@container (max-width: 420px) {
  .dj-stage-status { display: none; }
  .dj-stage-actions { margin-left: auto; }
}

/* Modo cinema: o palco do DJ cobre a janela (e o navegador entra em tela cheia). */
#stage .tile.dj.cinema, #stage:has(.tile.focus) .tile.dj.cinema {
  position: fixed; inset: 0; z-index: 26; width: auto; height: auto; min-height: 0; aspect-ratio: auto; border-radius: 0; box-shadow: none;
}
.tile.dj.cinema .dj-stage { padding: 20px 28px 24px; gap: 16px 20px; grid-template-columns: minmax(0, 1fr) 320px; }
@container (max-width: 860px) { .tile.dj.cinema .dj-stage { grid-template-columns: minmax(0, 1fr); padding: 12px; } }

/* ---------- Botão na barra da chamada ---------- */
.sc-btn#sc-music.active { background: var(--brand); color: #fff; }
.sc-btn#sc-music.active .ico-disc { animation: dj-spin 2.4s linear infinite; }
.sc-btn#sc-music:hover:not(:disabled) .ico-disc { animation: dj-spin .9s linear infinite; }
@keyframes dj-spin { to { transform: rotate(360deg); } }

/* ---------- Capinha no painel da chamada ---------- */
#dj-mini {
  display: flex; align-items: center; gap: 8px; padding: 8px 6px 8px 8px; border-bottom: 1px solid var(--divider);
  background: color-mix(in srgb, var(--brand) 9%, transparent);
}
#dj-mini.hidden { display: none; }
.dj-mini-art {
  flex-shrink: 0; width: 64px; height: 36px; padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: #000; cursor: pointer;
}
.dj-mini-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dj-mini-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dj-mini-text strong { font-size: 13px; color: var(--text-strong); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dj-mini-text small { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dj-mini .icon-btn { flex-shrink: 0; width: 28px; height: 28px; }

/* ---------- Linha "DJ" na lista da sala de voz ---------- */
.voice-user.dj-user { color: var(--interactive); }
.dj-avatar {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff;
}
.dj-avatar.spinning .ico { animation: dj-spin 2.4s linear infinite; }
.dj-user .name { display: flex; align-items: baseline; gap: 6px; min-width: 0; overflow: hidden; }
.dj-user .name b { color: var(--text); font-weight: 600; flex-shrink: 0; }
.dj-user-title { font-size: 12px; color: var(--text-muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dj-user .flags { margin-left: auto; color: var(--text-muted); display: grid; }

/* ---------- Autocompletar dos comandos ---------- */
.ac-hint { color: var(--text-muted); font-size: 13px; padding: 1px 6px; border-radius: 4px; background: var(--hover); }

/* ---------- Painel: busca, tocando agora e fila ---------- */
#dj-panel {
  /* Altura fixa: buscar ou a fila mudar não faz o painel pular de lugar. */
  position: fixed; z-index: 30; width: min(400px, calc(100vw - 16px)); height: min(560px, calc(100dvh - 16px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-floating); border: 1px solid var(--divider); border-radius: 12px; box-shadow: 0 16px 48px rgba(0, 0, 0, .5);
  animation: menu-in .16s var(--ease-out, ease-out);
}
.dj-panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 10px 14px; }
.dj-panel-head > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dj-panel-head strong { color: var(--text-strong); font-size: 15px; }
.dj-panel-head small { color: var(--text-muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dj-badge { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: #fff; flex-shrink: 0; }

.dj-search {
  display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; padding: 0 12px; height: 40px; border-radius: 8px;
  background: var(--bg-input); color: var(--text-muted); box-shadow: inset 0 0 0 1px transparent; transition: box-shadow .15s;
}
.dj-search:focus-within { box-shadow: inset 0 0 0 2px var(--brand); }
.dj-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 14px; }
.dj-input::placeholder { color: var(--text-muted); }
.dj-input:focus, .dj-input:focus-visible { outline: none; box-shadow: none; }
.dj-input::-webkit-search-cancel-button { filter: grayscale(1) brightness(1.6); }

.dj-results:empty { display: none; }
.dj-results { padding: 0 6px; border-bottom: 1px solid var(--divider); max-height: 46%; overflow-y: auto; flex-shrink: 0; }
.dj-body { flex: 1; overflow-y: auto; padding: 4px 6px 8px; min-height: 0; }
.dj-body:has(.dj-empty) { display: grid; align-content: center; }
.dj-section-title {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--text-muted);
}
.dj-clear { border: 0; background: transparent; color: var(--link); font: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0; cursor: pointer; padding: 0; }
.dj-clear:hover { text-decoration: underline; }
.dj-status { margin: 4px 8px 10px; color: var(--text-muted); font-size: 13px; }

.dj-list { list-style: none; margin: 0 0 6px; padding: 0; }
.dj-track { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; transition: background .12s; }
.dj-track:hover { background: var(--hover); }
.dj-index { width: 16px; text-align: center; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.dj-thumb { width: 64px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--bg-input); flex-shrink: 0; }
.dj-track-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dj-track-text strong {
  color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dj-track-text small { color: var(--text-muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dj-time { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.dj-remove { flex-shrink: 0; width: 28px; height: 28px; opacity: 0; }
.dj-track:hover .dj-remove, .dj-remove:focus-visible { opacity: 1; }
.dj-add {
  flex-shrink: 0; width: 32px; height: 32px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--hover-strong); color: var(--text-strong); transition: background .12s, transform .15s var(--spring, ease);
}
.dj-add:hover:not(:disabled) { background: var(--brand); color: #fff; transform: scale(1.08); }
.dj-add.done { background: var(--green); color: #fff; cursor: default; }
.dj-add:disabled:not(.done) { opacity: .4; cursor: not-allowed; }

.dj-now { padding-bottom: 6px; }
.dj-now-row { display: flex; gap: 12px; align-items: center; padding: 4px 8px 0; }
.dj-now-art { width: 96px; height: 54px; border-radius: 8px; object-fit: cover; background: var(--bg-input); flex-shrink: 0; }
.dj-now .dj-track-text strong { font-size: 14px; color: var(--text-strong); }
.dj-progress { display: flex; align-items: center; gap: 8px; padding: 10px 8px 4px; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dj-bar { flex: 1; height: 4px; border-radius: 999px; background: color-mix(in srgb, var(--text) 16%, transparent); overflow: hidden; }
.dj-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--brand); transition: width .5s linear; }
.dj-now.paused .dj-bar i { background: var(--text-muted); }
.dj-progress.is-live .dj-bar i { background: var(--red); }
.dj-progress.is-live .dj-total { color: var(--red); font-weight: 700; }
.dj-controls { display: flex; align-items: center; gap: 6px; padding: 4px 8px 0; }
.dj-ctl {
  width: 36px; height: 36px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--hover); color: var(--text-strong); transition: background .12s, transform .15s var(--spring, ease);
}
.dj-ctl:hover:not(:disabled) { background: var(--hover-strong); }
.dj-ctl:active:not(:disabled) { transform: scale(.92); }
.dj-ctl.primary { width: 40px; height: 40px; background: var(--text-strong); color: var(--bg-floating); }
.dj-ctl.primary:hover:not(:disabled) { background: #fff; transform: scale(1.05); }
.dj-ctl:disabled { opacity: .4; cursor: not-allowed; }
.dj-volume { margin-left: auto; display: flex; align-items: center; gap: 4px; min-width: 0; }
.dj-volume input { width: 96px; }
.dj-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 22px 24px 18px;
  color: var(--text-muted); font-size: 13px;
}
.dj-empty .ico { color: var(--brand); margin-bottom: 4px; }
.dj-empty strong { color: var(--text-strong); font-size: 15px; }
.dj-last { display: flex; align-items: flex-start; gap: 6px; margin: 4px 8px 0; padding-top: 8px; border-top: 1px solid var(--divider); color: var(--text-muted); font-size: 12px; }
.dj-last .ico { flex-shrink: 0; margin-top: 1px; }

@media (max-width: 640px) {
  .dj-remove { opacity: 1; }
  .dj-volume input { width: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .dj-avatar.spinning .ico, .sc-btn#sc-music .ico-disc, .dj-stage-badge .ico, .dj-eq i, .tile.dj.focus .dj-stage { animation: none !important; }
}
:root[data-reduce-motion="true"] :is(.dj-avatar.spinning .ico, .sc-btn#sc-music .ico-disc, .dj-stage-badge .ico, .dj-eq i, .tile.dj.focus .dj-stage) { animation: none !important; }
