/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --text-primary: #f0f0f5;
  --text-secondary: #8a8a9a;
  --text-muted: #5a5a6a;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --gradient-1: #7c3aed;
  --gradient-2: #ec4899;
  --gradient-3: #06b6d4;
  --border: rgba(255, 255, 255, 0.06);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== BACKGROUND GRADIENT ===== */
.bg-gradient {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(124, 58, 237, 0.12) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(236, 72, 153, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 50% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  transition: transform 8s ease;
}

/* ===== APP LAYOUT ===== */
.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== PLAYER CONTAINER ===== */
.player-container {
  background: var(--bg-card);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 20px;
  box-shadow: var(--shadow);
}

/* ===== ALBUM ART ===== */
.now-playing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

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

.album-art {
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--bg-secondary), rgba(124, 58, 237, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.album-art.playing {
  transform: scale(1.02);
}

.album-art-placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

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

.vinyl-disc {
  position: absolute;
  top: 50%;
  right: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at center,
    #1a1a2e 0%, #1a1a2e 15%,
    #2d2d44 16%, #1a1a2e 18%,
    #2d2d44 19%, #1a1a2e 21%,
    #2d2d44 22%, #1a1a2e 30%,
    #2d2d44 31%, #1a1a2e 33%,
    #2d2d44 34%, #1a1a2e 42%,
    #2d2d44 43%, #1a1a2e 45%,
    #2d2d44 46%, #1a1a2e 48%
  );
  transform: translateY(-50%);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.4s ease, right 0.4s ease;
  z-index: -1;
}

.vinyl-disc::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.vinyl-disc.spinning {
  animation: spin 3s linear infinite;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

.album-art-wrapper:hover .vinyl-disc,
.vinyl-disc.visible {
  opacity: 1;
  right: -20px;
}

/* ===== TRACK INFO ===== */
.track-info {
  text-align: center;
  width: 100%;
}

.track-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ===== PROGRESS BAR ===== */
.progress-section {
  margin-top: 24px;
}

.progress-bar-container {
  cursor: pointer;
  padding: 8px 0;
  position: relative;
}

.progress-bar-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  position: relative;
  transition: height var(--transition);
}

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

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gradient-1), var(--gradient-2));
  border-radius: 2px;
  width: 0%;
  position: relative;
  transition: none;
}

.progress-bar-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition);
  pointer-events: none;
}

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

.time-display {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.control-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
}

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

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

.play-btn {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2)) !important;
  color: #fff !important;
  margin: 0 8px;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: all var(--transition);
}

.play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.5);
}

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

.repeat-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--accent-light);
  background: var(--bg-primary);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== VOLUME ===== */
.volume-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.volume-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
  flex-shrink: 0;
}

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

.volume-slider-container {
  flex: 1;
  cursor: pointer;
  padding: 8px 0;
}

.volume-slider-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  position: relative;
}

.volume-slider-fill {
  height: 100%;
  background: var(--accent-light);
  border-radius: 2px;
  width: 80%;
}

.volume-slider-thumb {
  position: absolute;
  top: 50%;
  left: 80%;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition);
  pointer-events: none;
}

.volume-slider-container:hover .volume-slider-thumb {
  transform: translate(-50%, -50%) scale(1);
}

/* ===== PLAYLIST ===== */
.playlist-section {
  background: var(--bg-card);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.playlist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.playlist-header h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.playlist-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.playlist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: 400px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.playlist::-webkit-scrollbar {
  width: 4px;
}

.playlist::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.playlist-item:hover {
  background: var(--bg-card-hover);
}

.playlist-item.active {
  background: rgba(124, 58, 237, 0.1);
}

.playlist-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--accent);
  border-radius: 2px;
}

.playlist-item-index {
  width: 24px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.playlist-item.active .playlist-item-index {
  color: var(--accent-light);
}

.playlist-item-art {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--bg-secondary), rgba(124, 58, 237, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.playlist-item-art svg {
  color: var(--text-muted);
  opacity: 0.4;
}

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

.playlist-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-item.active .playlist-item-title {
  color: var(--accent-light);
}

.playlist-item-artist {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.playlist-item-duration {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Playing animation */
.playing-indicator {
  display: none;
  gap: 2px;
  align-items: flex-end;
  height: 16px;
}

.playlist-item.active.is-playing .playing-indicator {
  display: flex;
}

.playlist-item.active.is-playing .playlist-item-index-num {
  display: none;
}

.playing-indicator span {
  display: block;
  width: 3px;
  background: var(--accent-light);
  border-radius: 1px;
  animation: bar-bounce 1.2s ease-in-out infinite;
}

.playing-indicator span:nth-child(1) { height: 40%; animation-delay: 0s; }
.playing-indicator span:nth-child(2) { height: 70%; animation-delay: 0.2s; }
.playing-indicator span:nth-child(3) { height: 50%; animation-delay: 0.4s; }

@keyframes bar-bounce {
  0%, 100% { height: 30%; }
  50% { height: 100%; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
  .app {
    padding: 16px 12px;
    gap: 16px;
  }

  .player-container {
    padding: 20px 18px 16px;
  }

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

  .track-title {
    font-size: 1.15rem;
  }

  .vinyl-disc {
    display: none;
  }

  .playlist {
    max-height: 300px;
  }
}

@media (min-width: 768px) {
  .app {
    padding: 40px 24px;
    justify-content: center;
    min-height: 100vh;
  }
}

@media (min-width: 1024px) {
  .app {
    max-width: 520px;
  }

  .album-art-wrapper {
    width: 280px;
    height: 280px;
  }
}

/* ===== SCROLLBAR GLOBAL ===== */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

/* ===== UTILITIES ===== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
