/* ============================================================
   REPRODUCTOR – SPOTIFY CLONE (SIN SHUFFLE/LOOP)
   ============================================================ */

:root {
  --player-bg: #121212;
  --player-card: #181818;
  --player-text: #ffffff;
  --player-muted: #b3b3b3;
  --player-accent: #1DB954;
  --player-border: rgba(255,255,255,0.06);
  --player-radius: 14px;
  --player-shadow: 0 8px 32px rgba(0,0,0,0.6);
  --player-transition: 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* ----- CONTENEDOR PRINCIPAL (sin scroll) ----- */
#view-player {
  display: none !important;
}
#view-player.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 56px;    /* altura del header */
  left: 0;
  right: 0;
  bottom: 60px; /* altura del footer */
  background: var(--player-bg);
  padding: 0 !important;
  overflow: hidden;
  z-index: 10;
}

.player-container {
  width: 100%;
  max-width: 720px;
  height: 100%;
  max-height: 620px;
  padding: 24px 20px 24px;
  background: var(--player-card);
  border-radius: var(--player-radius);
  box-shadow: var(--player-shadow);
  border: 1px solid var(--player-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

/* ---- FILA SUPERIOR: portada + info + acciones ---- */
.player-top {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

.player-cover {
  width: 100px;
  height: 100px;
  border-radius: 10px;
  background: #282828;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  transition: transform 0.3s, box-shadow 0.3s;
}
.player-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.player-cover i {
  font-size: 36px;
  color: #535353;
}

.player-cover.playing {
  animation: cover-pulse 2s ease-in-out infinite;
}
@keyframes cover-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(29,185,84,0.3); }
  50% { transform: scale(1.02); box-shadow: 0 0 20px 6px rgba(29,185,84,0.15); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(29,185,84,0.3); }
}

.player-cover .playing-icon {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--player-accent);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s;
}
.player-cover.playing .playing-icon {
  opacity: 1;
  animation: spin-note 3s linear infinite;
}
@keyframes spin-note {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.player-info {
  flex: 1;
  min-width: 0;
}
.player-info h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--player-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-info p {
  font-size: 15px;
  color: var(--player-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.player-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.player-actions button {
  background: transparent;
  border: none;
  color: var(--player-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s, transform 0.15s;
}
.player-actions button:hover {
  color: var(--player-text);
  background: rgba(255,255,255,0.05);
  transform: scale(1.05);
}
.player-actions button:active {
  transform: scale(0.92);
}
.player-actions .list-btn .arrow {
  font-size: 14px;
  margin-left: 2px;
  transition: transform 0.3s;
}
.player-actions .list-btn .arrow.open {
  transform: rotate(180deg);
}

/* ----- BARRA DE PROGRESO ----- */
.player-progress-wrapper {
  flex-shrink: 0;
  padding: 0 0 4px;
}
.player-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: height 0.15s;
}
.player-progress-bar:hover {
  height: 8px;
}
.player-progress-fill {
  height: 100%;
  background: var(--player-accent);
  border-radius: 6px;
  width: 0%;
  transition: width 0.05s linear;
  position: relative;
}
.player-progress-fill::after {
  content: '';
  position: absolute;
  right: -6px;
  top: -5px;
  width: 16px;
  height: 16px;
  background: var(--player-accent);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: 0 0 12px rgba(29,185,84,0.3);
}
.player-progress-bar:hover .player-progress-fill::after {
  opacity: 1;
}
.player-time-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--player-muted);
  margin-top: 6px;
}

/* ----- CONTROLES + VOLUMEN (fila única) ----- */
.player-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 24px;
}
.player-controls button {
  background: transparent;
  border: none;
  color: var(--player-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: color 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-controls button:hover {
  color: var(--player-accent);
  transform: scale(1.06);
}
.player-controls button:active {
  transform: scale(0.92);
}
.player-controls .btn-play {
  font-size: 38px;
  color: var(--player-accent);
  background: rgba(29,185,84,0.12);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(29,185,84,0.12);
  transition: box-shadow 0.3s, transform 0.15s;
}
.player-controls .btn-play:hover {
  transform: scale(1.04);
  box-shadow: 0 0 36px rgba(29,185,84,0.2);
}
.player-controls .btn-play.playing {
  animation: pulse-glow 2s infinite;
}
@keyframes pulse-glow {
  0% { box-shadow: 0 0 24px rgba(29,185,84,0.12); }
  50% { box-shadow: 0 0 48px rgba(29,185,84,0.25); }
  100% { box-shadow: 0 0 24px rgba(29,185,84,0.12); }
}
.player-controls .btn-sm {
  font-size: 24px;
}

.player-volume {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 140px;
}
.player-volume input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  outline: none;
  transition: height 0.1s;
}
.player-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--player-accent);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(29,185,84,0.2);
}
.player-volume input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--player-accent);
  cursor: pointer;
  border: none;
}
.player-volume i {
  color: var(--player-muted);
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* ----- LISTA DE CANCIONES (scroll solo si necesario) ----- */
.player-playlist-panel {
  flex: 1;
  min-height: 0;
  margin-top: 4px;
}
.player-playlist-dropdown {
  max-height: 0;
  overflow-y: auto;
  transition: max-height 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.25s ease;
  opacity: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.player-playlist-dropdown.open {
  max-height: 160px;
  opacity: 1;
}
.player-playlist-dropdown::-webkit-scrollbar {
  width: 4px;
}
.player-playlist-dropdown::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}
.player-playlist-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.player-playlist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--player-muted);
  font-size: 15px;
}
.player-playlist-item:hover {
  background: rgba(255,255,255,0.04);
}
.player-playlist-item.active {
  background: rgba(29,185,84,0.08);
  color: var(--player-text);
}
.player-playlist-item .song-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.player-playlist-item .song-left .play-indicator {
  width: 20px;
  text-align: center;
  font-size: 16px;
  color: var(--player-accent);
}
.player-playlist-item .song-info {
  min-width: 0;
}
.player-playlist-item .song-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
}
.player-playlist-item .song-artist {
  font-size: 13px;
  color: var(--player-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-playlist-item .song-duration {
  font-size: 13px;
  color: var(--player-muted);
  flex-shrink: 0;
  margin-left: 14px;
}

/* ----- TOAST ----- */
.player-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 12px 24px;
  border-radius: 40px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.player-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ----- RESPONSIVE ----- */
@media (max-width: 640px) {
  #view-player.active {
    top: 50px;
    bottom: 54px;
  }
  .player-container {
    max-height: 520px;
    padding: 16px 12px 18px;
    gap: 10px;
  }
  .player-cover {
    width: 80px;
    height: 80px;
  }
  .player-cover i {
    font-size: 28px;
  }
  .player-info h3 {
    font-size: 17px;
  }
  .player-info p {
    font-size: 13px;
  }
  .player-actions button {
    font-size: 20px;
    padding: 6px;
  }
  .player-controls .btn-play {
    font-size: 30px;
    width: 52px;
    height: 52px;
  }
  .player-controls .btn-sm {
    font-size: 20px;
  }
  .player-controls {
    gap: 16px;
  }
  .player-volume {
    flex: 0 1 80px;
  }
  .player-volume input[type="range"] {
    width: 50px;
  }
  .player-volume i {
    font-size: 14px;
    width: 18px;
  }
  .player-playlist-dropdown.open {
    max-height: 120px;
  }
  .player-playlist-item {
    padding: 8px 10px;
    font-size: 14px;
  }
  .player-playlist-item .song-title {
    font-size: 14px;
  }
  .player-playlist-item .song-artist {
    font-size: 12px;
  }
  .player-playlist-item .song-duration {
    font-size: 12px;
  }
}
@media (max-width: 400px) {
  #view-player.active {
    top: 46px;
    bottom: 50px;
  }
  .player-container {
    max-height: 440px;
    padding: 12px 8px 14px;
  }
  .player-cover {
    width: 64px;
    height: 64px;
  }
  .player-info h3 {
    font-size: 15px;
  }
  .player-controls .btn-play {
    font-size: 26px;
    width: 44px;
    height: 44px;
  }
  .player-controls .btn-sm {
    font-size: 18px;
  }
  .player-actions button {
    font-size: 18px;
  }
  .player-playlist-item {
    padding: 6px 8px;
    font-size: 13px;
  }
  .player-playlist-item .song-title {
    font-size: 13px;
  }
  .player-playlist-item .song-artist {
    font-size: 11px;
  }
  .player-playlist-item .song-duration {
    font-size: 11px;
  }
}


/* ----- INDICADOR DE CARGA ----- */
.player-loading {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: var(--player-muted);
  font-size: 14px;
  padding: 6px 0;
}
.player-loading i {
  font-size: 18px;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}