/**
 * Estilos do player de áudio.
 *
 * Reestilização "estúdio vermelho" (posições + cores, pedido do
 * cliente): capa centralizada com o visualizador de áudio ATRÁS dela,
 * controles centralizados abaixo, histórico virou card próprio com
 * grade horizontal. Nenhum seletor data-* mudou de nome — só layout e
 * paleta.
 */

/* [data-player] deixou de ter estilo de "card" (isso migrou para
   .player-card e .history-card, seus dois filhos diretos) — aqui só
   cuida do espaçamento vertical entre os dois cards. */
.player {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Card do player especificamente mais "justo" verticalmente que o
   .card base (index.php) — só topo/base, esquerda/direita continuam
   iguais ao card do histórico. Pedido explícito: menos distância entre
   a capa e a borda de cima/baixo do retângulo. */
.player-card {
    padding-top: 18px;
    padding-bottom: 18px;
}

@media (min-width: 460px) {
    .player-card { padding-top: 20px; padding-bottom: 20px; }
}

/* ==========================================================================
   PALCO DO PLAYER: capa centralizada + visualizador atrás dela
   ========================================================================== */

.player-stage {
    position: relative;
    width: 100%;
    height: 128px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

@media (min-width: 460px) {
    .player-stage { height: 162px; margin-bottom: 16px; }
}

@media (min-width: 700px) {
    .player-stage { height: 204px; margin-bottom: 20px; }
}

/* Visualizador: cobre a largura toda do palco, centralizado verticalmente
   e ATRÁS da capa (z-index abaixo). Fundo transparente de propósito —
   quem aparece por trás é o próprio card, não uma caixa própria. */
.player-visualizer {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 70%;
    z-index: 1;
    background: transparent;
    pointer-events: none;
}

.player-visualizer canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Estado de erro: visualizador discreto, sem chamar mais atenção do que
   a mensagem de erro do player já chama. */
.player-visualizer[data-visualizer-estado="error"] {
    opacity: 0.5;
}

/* Fallback de último recurso — só aparece se o JS concluir que nem
   Canvas 2D está disponível neste navegador. */
.player-visualizer-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.player-visualizer-fallback[hidden] {
    display: none;
}

.player-visualizer-fallback-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.35;
    animation: player-visualizer-pulso 1.2s ease-in-out infinite;
}

.player-visualizer-fallback-dot:nth-child(2) { animation-delay: 0.15s; }
.player-visualizer-fallback-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes player-visualizer-pulso {
    0%, 100% { transform: scale(1); opacity: 0.35; }
    50% { transform: scale(1.6); opacity: 0.9; }
}

/* Capa do artista: por CIMA do visualizador (z-index maior), quadrada,
   com borda + glow vermelho no lugar do card neutro anterior. */
.player-cover {
    position: relative;
    z-index: 2;
    width: 102px;
    height: 102px;
    flex-shrink: 0;
    border-radius: 14px;
    overflow: hidden;
    background: #0b0405;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border: 2px solid rgba(255, 31, 58, 0.65);
    box-shadow:
        0 0 26px rgba(255, 31, 58, 0.55),
        0 0 70px rgba(255, 31, 58, 0.22);
}

@media (min-width: 460px) {
    .player-cover { width: 128px; height: 128px; border-radius: 16px; }
}

@media (min-width: 700px) {
    .player-cover { width: 162px; height: 162px; border-radius: 18px; }
}

.player-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-cover-placeholder {
    width: 32%;
    height: 32%;
    opacity: 0.4;
}

/* ==========================================================================
   INFO + CONTROLES: tudo centralizado abaixo do palco
   ========================================================================== */

.player-info {
    text-align: center;
}

.player-info .titulo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-info .artista {
    font-size: 15px;
    color: var(--muted);
    margin-top: 4px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 460px) {
    .player-info .titulo { font-size: 23px; }
    .player-info .artista { font-size: 16px; }
}

/* Indicador discreto de última consulta ao polling — segue escondido
   por pedido do cliente; o polling continua rodando normalmente. */
.player-updated,
.player-updated[hidden] {
    display: none;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
}

.player-btn {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 24px rgba(255, 31, 58, 0.55);
    transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.15s ease;
}

.player-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 32px rgba(255, 31, 58, 0.7);
}

.player-btn:active {
    transform: scale(0.96);
}

.player-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.player-btn svg {
    width: 24px;
    height: 24px;
}

.player-btn.is-loading svg {
    animation: player-spin 0.9s linear infinite;
}

@keyframes player-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.player-volume {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.player-volume svg {
    width: 18px;
    height: 18px;
    color: var(--muted);
    flex-shrink: 0;
}

.player-volume input[type="range"] {
    flex: 1;
    height: 4px;
    border-radius: 999px;
    appearance: none;
    background: var(--border);
    outline: none;
    cursor: pointer;
}

.player-volume input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(255, 31, 58, 0.65);
    cursor: pointer;
}

.player-volume input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(255, 31, 58, 0.65);
    cursor: pointer;
}

.player-status {
    margin-top: 12px;
    font-size: 13px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.player-status.is-error {
    color: var(--error);
}

.player-status.is-playing {
    color: var(--ok);
}

.player-retry {
    background: none;
    border: 1px solid var(--error);
    color: var(--error);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 11px;
    cursor: pointer;
    margin-left: 4px;
}

.player-retry:hover {
    background: rgba(255, 92, 106, 0.1);
}

.player-retry[hidden] {
    display: none;
}

/* ==========================================================================
   HISTÓRICO — card próprio, grade horizontal
   ========================================================================== */

.player-history-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 18px;
}

.player-history-title svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
    flex-shrink: 0;
}

.player-history-empty {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}

.player-history-empty[hidden] {
    display: none;
}

/* Grade horizontal das últimas 5 músicas: 2 colunas no mobile (sem
   scroll horizontal), sobe pra 3 em tablet e 5 em desktop — mesma
   música tocando aparece na mesma "coluna" pra todo mundo. */
.player-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (min-width: 460px) {
    .player-history-list { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 700px) {
    .player-history-list { grid-template-columns: repeat(5, 1fr); }

    /**
     * PC mostra só 5 músicas (celular mostra as 6 buscadas — ver
     * HISTORY_LIMIT em history.js e 'historico.limite' em config.php).
     * Corte puramente visual: o 6º item continua no DOM (histórico
     * real tem 6), só fica display:none nesta faixa de largura. Isso
     * evita uma 2ª linha com um único item órfão no grid de 5 colunas.
     */
    .player-history-list > *:nth-child(n+6) {
        display: none;
    }
}

.history-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.history-item-cover {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    background: #0b0405;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border: 1px solid var(--border);
}

.history-item-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-item-placeholder {
    width: 32%;
    height: 32%;
    opacity: 0.4;
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    min-width: 0;
}

.history-item-titulo {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.history-item-artista {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Barrinha decorativa vermelha embaixo de cada item — só estética,
   reforça a identidade visual "estúdio vermelho" (imagem de
   referência). Não representa estado nenhum (curtida, tocando, etc.). */
.history-item-bar {
    display: block;
    width: 26px;
    height: 3px;
    border-radius: 999px;
    background: var(--accent);
    margin-top: 2px;
}

@media (max-width: 420px) {
    .player-stage { height: 120px; }
}
