/* ============================================================
   Melody Player — Premium Dark Theme
   ============================================================ */

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #121212;
  --bg-elevated: #1a1a1a;
  --bg-hover: #252525;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-tertiary: #666666;
  --accent: #ff6b6b;
  --accent-glow: rgba(255, 107, 107, 0.35);
  --accent-gradient: linear-gradient(135deg, #ff6b6b, #ee5a24);
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.06);
  --progress-bg: rgba(255, 255, 255, 0.08);
  --progress-buffer: rgba(255, 255, 255, 0.15);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-stack: -apple-system, 'SF Pro Display', 'Inter', system-ui, sans-serif;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-stack);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* ---- App Layout ---- */

.app {
  display: flex;
  height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px;
  gap: 32px;
}

/* ---- Now Playing ---- */

.now-playing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-width: 0;
}

/* Album Art */
.album-art {
  width: 300px;
  height: 300px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2c2c3e 0%, #1a1a2e 40%, #16213e 100%);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.5),
    0 8px 16px rgba(0, 0, 0, 0.3);
  transition: background 0.6s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.album-art::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 50%);
  pointer-events: none;
}

.album-art.playing {
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.6),
    0 0 80px var(--accent-glow);
}

.album-letter {
  font-size: 120px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.06);
  user-select: none;
  transition: color 0.6s ease;
  line-height: 1;
}

.album-art.playing .album-letter {
  color: rgba(255, 255, 255, 0.1);
}

/* Track Info */
.track-info {
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.track-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.3s ease;
}

.track-artist {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.3s ease;
}

.track-info.fade-out .track-title,
.track-info.fade-out .track-artist {
  opacity: 0;
}

/* ---- Progress Bar ---- */

.progress-container {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 420px;
}

.time-display {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  min-width: 36px;
  user-select: none;
}

.time-display:first-child {
  text-align: right;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--progress-bg);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  transition: height 0.15s ease;
}

.progress-bar:hover {
  height: 6px;
}

.progress-bar:hover .progress-thumb {
  opacity: 1;
  transform: scale(1);
}

.progress-buffered {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--progress-buffer);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-filled {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.progress-thumb {
  width: 12px;
  height: 12px;
  background: var(--text-primary);
  border-radius: 50%;
  position: absolute;
  right: -6px;
  top: 50%;
  transform: scale(0);
  transform-origin: center;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

.progress-bar.scrubbing .progress-thumb {
  opacity: 1;
  transform: scale(1);
}

/* ---- Controls ---- */

.controls {
  display: flex;
  align-items: center;
  gap: 24px;
}

.control-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, transform 0.15s ease;
}

.control-btn:hover {
  color: var(--accent);
  transform: scale(1.08);
}

.control-btn:active {
  transform: scale(0.95);
}

.play-btn {
  width: 56px;
  height: 56px;
  background: var(--text-primary);
  color: var(--bg-primary);
  border-radius: 50%;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.3s ease;
}

.play-btn:hover {
  color: var(--bg-primary);
  background: var(--text-primary);
  transform: scale(1.06);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.15);
}

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

/* ---- Volume ---- */

.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 200px;
}

.volume-icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.volume-icon-btn:hover {
  color: var(--text-primary);
}

.volume-slider-wrap {
  flex: 1;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--progress-bg);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

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

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

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

/* ---- Playlist Panel ---- */

.playlist-panel {
  width: 340px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.playlist-title {
  font-size: 18px;
  font-weight: 600;
  padding: 24px 24px 16px;
  letter-spacing: -0.2px;
}

.track-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.track-list::-webkit-scrollbar {
  width: 4px;
}

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

.track-list::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 2px;
}

/* Track Row */
.track-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s ease;
  user-select: none;
}

.track-row:hover {
  background: var(--bg-hover);
}

.track-row.active {
  background: rgba(255, 107, 107, 0.08);
}

.track-row-number {
  width: 24px;
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
  flex-shrink: 0;
}

.track-row.active .track-row-number {
  color: var(--accent);
}

/* Playing Indicator (animated bars) */
.playing-indicator {
  display: none;
  align-items: flex-end;
  gap: 2px;
  width: 24px;
  height: 16px;
  justify-content: center;
}

.track-row.active .playing-indicator {
  display: flex;
}

.track-row.active .track-row-number-text {
  display: none;
}

.playing-indicator .bar {
  width: 3px;
  background: var(--accent);
  border-radius: 1px;
  animation: eq-bar 0.8s ease-in-out infinite;
}

.playing-indicator .bar:nth-child(1) {
  height: 60%;
  animation-delay: 0s;
}

.playing-indicator .bar:nth-child(2) {
  height: 100%;
  animation-delay: 0.15s;
}

.playing-indicator .bar:nth-child(3) {
  height: 40%;
  animation-delay: 0.3s;
}

.playing-indicator.paused .bar {
  animation-play-state: paused;
}

@keyframes eq-bar {
  0%, 100% { height: 20%; }
  50% { height: 100%; }
}

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

.track-row-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

.track-row.active .track-row-title {
  color: var(--accent);
}

.track-row-artist {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-row-duration {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .app {
    flex-direction: column;
    padding: 24px 16px;
    gap: 24px;
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
  }

  html, body {
    overflow: auto;
  }

  .now-playing {
    justify-content: flex-start;
    padding-top: 16px;
  }

  .album-art {
    width: 240px;
    height: 240px;
  }

  .album-letter {
    font-size: 90px;
  }

  .playlist-panel {
    width: 100%;
    max-height: 320px;
  }

  .progress-container {
    max-width: 100%;
  }

  .volume-control {
    max-width: 160px;
  }
}

@media (max-width: 480px) {
  .app {
    padding: 16px 12px;
  }

  .album-art {
    width: 200px;
    height: 200px;
  }

  .album-letter {
    font-size: 72px;
  }

  .track-title {
    font-size: 18px;
  }

  .controls {
    gap: 20px;
  }

  .play-btn {
    width: 48px;
    height: 48px;
  }
}
