/*
  ClassicAMP - Classical Music PWA Player
  Based on AmplitudeJS Dynamic Playlist Player
  Original: https://serversideup.net/open-source/amplitudejs/examples/dynamic-playlist-player
  License: MIT (https://github.com/serversideup/amplitudejs/blob/master/LICENSE)

  ============================================
  THEME CONFIGURATION - Edit colors here
  ============================================
*/

:root {
  /* === PRIMARY COLORS (from icon gradient) === */
  --color-primary: #9C1D6F;           /* Main accent color - dark (normal state) */
  --color-primary-light: #A93C83;     /* Lighter +14% (hover state) */
  --color-primary-dark: #7B1558;      /* Even darker variant */

  /* === BACKGROUND COLORS === */
  --color-bg: #FFFFFF;                /* Main background */
  --color-bg-secondary: #F5F5F6;      /* Secondary background (playlist controls) */
  --color-bg-player: #FFFFFF;         /* Player container background */

  /* === TEXT COLORS === */
  --color-text: #414344;              /* Primary text */
  --color-text-secondary: #AAAFB3;    /* Secondary text (time, artist) */

  /* === UI COLORS === */
  --color-border: #E5E5E5;            /* Borders */
  --color-shadow: rgba(0, 0, 0, 0.12); /* Shadows */
  --color-hover: rgba(169, 60, 131, 0.15);   /* Hover state (primary light +14%) */
  --color-active: rgba(156, 29, 111, 0.25);  /* Active song highlight (primary) */

  /* === PROGRESS BAR === */
  --color-progress-bg: #E1E1E1;       /* Progress bar background */
  --color-progress-buffered: #D7DEE3; /* Buffered progress */

  /* === BODY GRADIENT (from icon) === */
  --gradient-start: #4B196F;          /* Top - dark purple */
  --gradient-end: #9C1D6F;            /* Bottom - magenta */

  /* === SIZING === */
  --player-max-width: 400px;
  --border-radius: 12px;
  --border-radius-sm: 6px;
}

/*
  ============================================
  DARK THEME - Uncomment to enable
  ============================================
*/
/*
:root {
  --color-primary: #8B5CF6;
  --color-primary-light: #A78BFA;
  --color-primary-dark: #7C3AED;

  --color-bg: #1a1a2e;
  --color-bg-secondary: #16213e;
  --color-bg-player: #1a1a2e;

  --color-text: #EEEEEE;
  --color-text-secondary: #888888;

  --color-border: rgba(255, 255, 255, 0.1);
  --color-shadow: rgba(0, 0, 0, 0.3);
  --color-hover: rgba(139, 92, 246, 0.2);
  --color-active: rgba(139, 92, 246, 0.35);

  --color-progress-bg: #333333;
  --color-progress-buffered: #444444;

  --gradient-start: #1a1a2e;
  --gradient-end: #16213e;
}
*/

/* ============================================
   BASE STYLES
   ============================================ */

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

body {
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* ============================================
   PLAYER CONTAINER
   ============================================ */

#player-container {
  width: 100%;
  max-width: var(--player-max-width);
  background-color: var(--color-bg-player);
  box-shadow: 0 12px 40px var(--color-shadow);
  border-radius: var(--border-radius);
  position: relative;
  overflow: hidden;
}

/* ============================================
   PLAYER TOP BAR
   ============================================ */

.player-top {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-border);
}

.player-top .center {
  flex: 1;
  text-align: center;
}

.player-top .now-playing {
  color: var(--color-text);
  font-weight: 600;
  font-size: 15px;
}

.player-top .search-toggle,
.player-top .show-playlist {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.player-top .search-toggle:hover,
.player-top .show-playlist:hover {
  background-color: var(--color-hover);
}

.player-top .show-playlist {
  margin-left: auto;
}

.player-top svg {
  width: 22px;
  height: 22px;
  fill: var(--color-text-secondary);
}

/* ============================================
   SEARCH BAR
   ============================================ */

.search-bar {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background-color: var(--color-bg-secondary);
  gap: 12px;
}

.search-bar.hidden {
  display: none;
}

.search-bar input {
  flex: 1;
  border: none;
  background: var(--color-bg);
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  color: var(--color-text);
  outline: none;
}

.search-bar input::placeholder {
  color: var(--color-text-secondary);
}

.search-bar input:focus {
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.search-close {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.search-close:hover {
  background-color: var(--color-hover);
}

.search-close svg {
  width: 20px;
  height: 20px;
  fill: var(--color-text-secondary);
}

/* ============================================
   PLAYER CENTER - ALBUM ART & META
   ============================================ */

#player-center {
  padding: 24px 20px;
}

/* Cover Slideshow Container */
#cover-slideshow {
  width: 280px;
  height: 280px;
  margin: 0 auto 32px;
  border-radius: var(--border-radius);
  box-shadow: 0 12px 40px var(--color-shadow);
  overflow: hidden;
  position: relative;
}

/* Slide layers for crossfade */
#cover-slideshow .slide-current,
#cover-slideshow .slide-next {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#cover-slideshow .slide-next {
  opacity: 0;
  z-index: 2;
}

#cover-slideshow .slide-current {
  opacity: 1;
  z-index: 1;
}

/* Crossfade animation - new slide fades in on top */
#cover-slideshow .slide-fade-in {
  opacity: 1;
  transition: opacity 1.25s ease-in-out;
}

/* Composer change fade animation */
#cover-slideshow.composer-fade-out {
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

#cover-slideshow.composer-fade-in {
  opacity: 1;
  transition: opacity 0.3s ease-in;
}

#player-center .main-album-art,
#cover-slideshow img,
#cover-slideshow video {
  display: block;
  width: 280px;
  height: 280px;
  border-radius: var(--border-radius);
  object-fit: cover;
}

#player-center .song-meta-data {
  text-align: center;
  margin-bottom: 24px;
}

#player-center .song-meta-data .song-name {
  display: block;
  color: var(--color-text);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

#player-center .song-meta-data .song-artist {
  display: block;
  color: var(--color-text-secondary);
  font-size: 14px;
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.time-progress {
  margin-bottom: 8px;
}

#progress-container {
  position: relative;
  height: 20px;
  cursor: pointer;
  margin: 0 4px;
}

#progress-container input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  position: absolute;
  z-index: 70;
  top: 0;
  height: 20px;
  cursor: pointer;
  background: transparent;
  margin: 0;
}

#progress-container input[type="range"]:focus {
  outline: none;
}

#progress-container input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: transparent;
  border-radius: 4px;
}

#progress-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-bg);
  box-shadow: 0 2px 6px var(--color-shadow);
  margin-top: -5px;
  cursor: pointer;
}

#progress-container input[type="range"]::-moz-range-track {
  width: 100%;
  height: 4px;
  background: transparent;
  border-radius: 4px;
}

#progress-container input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-bg);
  box-shadow: 0 2px 6px var(--color-shadow);
  cursor: pointer;
}

#progress-container progress {
  position: absolute;
  left: 0;
  top: 8px;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
}

#progress-container #song-played-progress {
  z-index: 60;
}

#progress-container #song-buffered-progress {
  z-index: 10;
  background-color: var(--color-progress-bg);
}

#progress-container progress::-webkit-progress-bar {
  background: transparent;
  border-radius: 4px;
}

#progress-container #song-played-progress::-webkit-progress-value {
  background-color: var(--color-primary);
  border-radius: 4px;
}

#progress-container #song-buffered-progress::-webkit-progress-value {
  background-color: var(--color-progress-buffered);
  border-radius: 4px;
}

#progress-container progress::-moz-progress-bar {
  border-radius: 4px;
}

#progress-container #song-played-progress::-moz-progress-bar {
  background-color: var(--color-primary);
}

#progress-container #song-buffered-progress::-moz-progress-bar {
  background-color: var(--color-progress-buffered);
}

.time-container {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 4px;
}

.time-container .current-time,
.time-container .duration {
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 500;
}

/* ============================================
   PLAYER CONTROLS
   ============================================ */

#player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px 32px;
  gap: 16px;
}

#player-controls > div {
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

#player-controls > div:hover {
  transform: scale(1.1);
}

#player-controls > div:active {
  transform: scale(0.95);
}

/* Shuffle */
#shuffle {
  width: 24px;
  height: 24px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.5;
}

#shuffle.amplitude-shuffle-off {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23414344'%3E%3Cpath d='M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z'/%3E%3C/svg%3E");
}

#shuffle.amplitude-shuffle-on {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239C1D6F'%3E%3Cpath d='M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z'/%3E%3C/svg%3E");
  opacity: 1;
}

/* Previous */
#previous, #playlist-previous {
  width: 48px;
  height: 48px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23414344'%3E%3Cpath d='M6 6h2v12H6zm3.5 6l8.5 6V6z'/%3E%3C/svg%3E");
}

/* Play/Pause */
#play-pause, #playlist-play-pause {
  width: 72px;
  height: 72px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

#play-pause.amplitude-paused,
#playlist-play-pause.amplitude-paused {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='12' fill='%239C1D6F'/%3E%3Cpath d='M9.5 7.5v9l7-4.5z' fill='white'/%3E%3C/svg%3E");
}

#play-pause.amplitude-playing,
#playlist-play-pause.amplitude-playing {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='12' fill='%239C1D6F'/%3E%3Cpath d='M9 7h2v10H9zm4 0h2v10h-2z' fill='white'/%3E%3C/svg%3E");
}

/* Play/Pause hover - lighter +14% */
#play-pause:hover.amplitude-paused,
#playlist-play-pause:hover.amplitude-paused {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='12' fill='%23A93C83'/%3E%3Cpath d='M9.5 7.5v9l7-4.5z' fill='white'/%3E%3C/svg%3E");
}

#play-pause:hover.amplitude-playing,
#playlist-play-pause:hover.amplitude-playing {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='12' fill='%23A93C83'/%3E%3Cpath d='M9 7h2v10H9zm4 0h2v10h-2z' fill='white'/%3E%3C/svg%3E");
}

/* Next */
#next, #playlist-next {
  width: 48px;
  height: 48px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23414344'%3E%3Cpath d='M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z'/%3E%3C/svg%3E");
}

/* Repeat */
#repeat {
  width: 24px;
  height: 24px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.5;
}

#repeat.amplitude-repeat-off {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23414344'%3E%3Cpath d='M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z'/%3E%3C/svg%3E");
}

#repeat.amplitude-repeat-on {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239C1D6F'%3E%3Cpath d='M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z'/%3E%3C/svg%3E");
  opacity: 1;
}

/* Playlist control sizes */
#playlist-previous, #playlist-next {
  width: 32px;
  height: 32px;
}

#playlist-play-pause {
  width: 40px;
  height: 40px;
}

/* ============================================
   PLAYLIST CONTAINER
   ============================================ */

#playlist-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-bg);
  z-index: 100;
  display: none;
  flex-direction: column;
  border-radius: var(--border-radius);
}

#playlist-container.show {
  display: flex;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.playlist-top {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-border);
}

.playlist-top > div {
  flex: 1;
}

.playlist-top > div:nth-child(2) {
  text-align: center;
}

.playlist-top .queue {
  color: var(--color-text);
  font-weight: 600;
  font-size: 15px;
}

.close-playlist {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  margin-left: auto;
  transition: background-color 0.2s;
}

.close-playlist:hover {
  background-color: var(--color-hover);
}

.close-playlist svg {
  width: 22px;
  height: 22px;
  fill: var(--color-text-secondary);
}

.playlist-up-next {
  padding: 16px 20px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.playlist {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 100px;
}

/* ============================================
   PLAYLIST SONG ITEMS
   ============================================ */

.playlist-song {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  cursor: pointer;
  transition: background-color 0.15s;
  border-bottom: 1px solid var(--color-border);
}

.playlist-song:hover {
  background-color: var(--color-hover);
}

.playlist-song.amplitude-active-song-container {
  background-color: var(--color-active);
}

.playlist-song img {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.playlist-song-meta {
  margin-left: 14px;
  min-width: 0;
  flex: 1;
}

.playlist-song-meta .playlist-song-name {
  display: block;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-song-meta .playlist-artist-album {
  display: block;
  color: var(--color-text-secondary);
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* No results */
.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-secondary);
  font-size: 14px;
}

/* ============================================
   PLAYLIST BOTTOM CONTROLS
   ============================================ */

.playlist-controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--color-bg-secondary);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.playlist-controls-bar .playlist-album-art {
  width: 56px;
  height: 56px;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 4px 12px var(--color-shadow);
  object-fit: cover;
}

.playlist-controls-bar .playlist-controls {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.playlist-controls-bar .playlist-meta-data {
  flex: 1;
  min-width: 0;
}

.playlist-controls-bar .playlist-meta-data .song-name {
  display: block;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-controls-bar .playlist-meta-data .song-artist {
  display: block;
  color: var(--color-text-secondary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-control-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

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

@media (max-width: 420px) {
  body {
    padding: 0;
    align-items: flex-start;
  }

  #player-container {
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
  }

  #cover-slideshow {
    width: 240px;
    height: 240px;
  }

  #player-center .main-album-art,
  #cover-slideshow img,
  #cover-slideshow video {
    width: 240px;
    height: 240px;
  }
}

@media (min-width: 768px) {
  #player-container {
    max-width: 420px;
  }
}
