/* ===========================================
   MUSIC PLAYER - MODERN DESIGN
   
   A full-featured music player with:
   - Now Playing card with album art
   - Progress bar with seeking
   - Shuffle, repeat, volume controls
   - Picture-in-Picture mini player
   - Queue overlay
   - Responsive design
   =========================================== */

/* CSS Variables for theming - AMOLED Black */
:root {
  --player-bg: #000000;
  --player-accent: #7b2ff7;
  --player-accent-glow: rgba(123, 47, 247, 0.4);
  --player-text: #ffffff;
  --player-text-muted: rgba(255, 255, 255, 0.5);
  --player-border: rgba(255, 255, 255, 0.06);
}

/* ===========================================
   MAIN PLAYER CONTAINER
   =========================================== */
.music-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--player-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--player-border);
  z-index: 9999;
  padding: 12px 24px;
  transition: transform 0.3s ease;
}

.music-player.hidden {
  transform: translateY(100%);
}

/* ===========================================
   NOW PLAYING SECTION
   =========================================== */
.now-playing {
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Album Art */
.now-playing-art {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #000000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  position: relative;
  background-size: cover;
  background-position: center;
}

.now-playing-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.art-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--player-text-muted);
}

/* Song Info */
.now-playing-info {
  min-width: 180px;
  max-width: 250px;
  flex-shrink: 0;
}

.song-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--player-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.song-artist {
  font-size: 13px;
  color: var(--player-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===========================================
   PROGRESS BAR SECTION
   =========================================== */
.progress-section {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

.time-current,
.time-duration {
  font-size: 12px;
  color: var(--player-text-muted);
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}

.time-current {
  text-align: right;
}

.progress-bar-container {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  transition: height 0.15s ease;
}

.progress-bar-container:hover {
  height: 8px;
}

.progress-bar-container:hover .progress-bar-thumb {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.progress-bar-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 3px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--player-accent), #9d4edd);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
  position: relative;
}

.progress-bar-thumb {
  position: absolute;
  left: 0%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 12px;
  height: 12px;
  background: var(--player-text);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease, left 0.1s linear;
  pointer-events: none;
}

/* ===========================================
   PLAYER CONTROLS
   =========================================== */
.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.control-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--player-text-muted);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.control-btn svg {
  width: 22px;
  height: 22px;
}

.control-btn:hover {
  color: var(--player-text);
  background: rgba(255, 255, 255, 0.1);
}

.control-btn.active {
  color: var(--player-accent);
}

/* Play/Pause Button - Larger */
.control-btn.play-btn {
  width: 48px;
  height: 48px;
  background: var(--player-accent);
  color: var(--player-text);
}

.control-btn.play-btn:hover {
  background: #8b3ff8;
  transform: scale(1.05);
  box-shadow: 0 0 20px var(--player-accent-glow);
}

.control-btn.play-btn svg {
  width: 26px;
  height: 26px;
}

/* Play/Pause Icon Toggle */
.control-btn .pause-icon,
.pip-btn .pause-icon {
  display: none;
}

.control-btn.playing .play-icon,
.pip-btn.playing .play-icon {
  display: none;
}

.control-btn.playing .pause-icon,
.pip-btn.playing .pause-icon {
  display: block;
}

/* Volume Control */
.volume-control {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.volume-slider-container {
  width: 0;
  overflow: hidden;
  transition: width 0.2s ease;
}

.volume-control:hover .volume-slider-container {
  width: 100px;
}

.volume-slider-track {
  position: relative;
  width: 100px;
  height: 20px;
  display: flex;
  align-items: center;
}

.volume-slider-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: var(--accent-color, #1db954);
  border-radius: 2px;
  pointer-events: none;
  width: 50%;
}

.volume-slider-ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  padding: 0 6px;
}

.volume-slider-ticks .tick {
  width: 2px;
  height: 8px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
}

.volume-slider-ticks .tick[data-value="0"],
.volume-slider-ticks .tick[data-value="100"] {
  height: 10px;
  background: rgba(255, 255, 255, 0.5);
}

.volume-slider {
  width: 100px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--player-text);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--player-text);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Volume Icons */
#volumeBtn .volume-low,
#volumeBtn .volume-mute {
  display: none;
}

#volumeBtn.low .volume-high,
#volumeBtn.low .volume-mute {
  display: none;
}

#volumeBtn.low .volume-low {
  display: block;
}

#volumeBtn.muted .volume-high,
#volumeBtn.muted .volume-low {
  display: none;
}

#volumeBtn.muted .volume-mute {
  display: block;
}

/* ===========================================
   PICTURE-IN-PICTURE MINI PLAYER
   =========================================== */
.pip-player {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 320px;
  background: var(--player-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--player-border);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: grab;
}

.pip-player.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.pip-player.dragging {
  cursor: grabbing;
  transition: none;
}

.pip-art {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: #000000;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

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

.pip-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--player-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pip-artist {
  font-size: 12px;
  color: var(--player-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pip-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.pip-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--player-text-muted);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.pip-btn svg {
  width: 18px;
  height: 18px;
}

.pip-btn:hover {
  color: var(--player-text);
  background: rgba(255, 255, 255, 0.1);
}

.pip-btn.pip-play {
  width: 36px;
  height: 36px;
  background: var(--player-accent);
  color: var(--player-text);
}

.pip-btn.pip-play:hover {
  background: #8b3ff8;
}

.pip-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--player-text-muted);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.pip-expand svg {
  width: 14px;
  height: 14px;
}

.pip-expand:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--player-text);
}

.pip-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

.pip-progress-fill {
  height: 100%;
  background: var(--player-accent);
  width: 0%;
  transition: width 0.1s linear;
}

/* ===========================================
   QUEUE OVERLAY
   =========================================== */
.queue-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.queue-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.queue-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 90px;
  width: 380px;
  max-width: 100%;
  background: var(--player-bg);
  border-left: 1px solid var(--player-border);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.queue-overlay.visible .queue-panel {
  transform: translateX(0);
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--player-border);
}

.queue-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--player-text);
  margin: 0;
}

.queue-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--player-text-muted);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.queue-close svg {
  width: 20px;
  height: 20px;
}

.queue-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--player-text);
}

.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Queue Item */
.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.queue-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.queue-item.playing {
  background: rgba(123, 47, 247, 0.15);
}

.queue-item-art {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  background-color: #000000;
  position: relative;
  flex-shrink: 0;
}

.queue-item.playing .queue-item-art::after {
  content: '▶';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(123, 47, 247, 0.7);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
}

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

.queue-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--player-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item.playing .queue-item-title {
  color: var(--player-accent);
}

.queue-item-artist {
  font-size: 12px;
  color: var(--player-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item-duration {
  font-size: 12px;
  color: var(--player-text-muted);
  flex-shrink: 0;
}

/* ===========================================
   RESPONSIVE STYLES
   =========================================== */

/* Tablet */
@media (max-width: 900px) {
  .music-player {
    padding: 10px 16px;
  }

  .now-playing {
    gap: 16px;
  }

  .now-playing-info {
    min-width: 140px;
    max-width: 180px;
  }

  .progress-section {
    min-width: 150px;
  }

  .volume-control:hover .volume-slider-container {
    width: 60px;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .music-player {
    padding: 8px 12px;
  }

  .now-playing {
    gap: 10px;
    flex-wrap: wrap;
  }

  .now-playing-art {
    width: 48px;
    height: 48px;
  }

  .now-playing-info {
    min-width: 100px;
    max-width: 140px;
  }

  .song-title {
    font-size: 13px;
  }

  .song-artist {
    font-size: 11px;
  }

  .progress-section {
    order: 3;
    width: 100%;
    min-width: 100%;
    margin-top: 8px;
  }

  .player-controls {
    gap: 4px;
  }

  .control-btn {
    width: 36px;
    height: 36px;
  }

  .control-btn svg {
    width: 18px;
    height: 18px;
  }

  .control-btn.play-btn {
    width: 42px;
    height: 42px;
  }

  .volume-slider-container {
    display: none !important;
  }

  /* PiP Player */
  .pip-player {
    width: 280px;
    right: 12px;
    bottom: 90px;
  }

  /* Queue Panel */
  .queue-panel {
    width: 100%;
  }
}

/* Extra Small */
@media (max-width: 380px) {
  .now-playing-info {
    display: none;
  }

  .player-controls {
    flex: 1;
    justify-content: center;
  }

  #shuffleBtn,
  #repeatBtn,
  #queueBtn {
    display: none;
  }
}

/* ===========================================
   SCROLLBAR STYLING
   =========================================== */
.queue-list::-webkit-scrollbar {
  width: 6px;
}

.queue-list::-webkit-scrollbar-track {
  background: transparent;
}

.queue-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.queue-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===========================================
   ANIMATIONS
   =========================================== */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading .now-playing-art {
  animation: pulse 1.5s ease-in-out infinite;
}
