/* 
   STABLE PREMIUM AUDIO PLAYER - V5
   Design: Symmetrical / High Precision Alignment / Above All
*/

:root {
  --ap-accent: #a85cff;
  --ap-bg: rgba(13, 13, 15, 0.94);
  --ap-border: rgba(255, 255, 255, 0.12);
  --ap-text: #ffffff;
  --ap-text-dim: rgba(255, 255, 255, 0.5);
  --ap-blur: 30px;
  --ap-radius: 24px;
}

/* Base Container */
.global-audio-player {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 620px;
  max-width: 94vw;
  height: 90px;
  background: var(--ap-bg);
  backdrop-filter: blur(var(--ap-blur));
  -webkit-backdrop-filter: blur(var(--ap-blur));
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.7), 0 0 40px rgba(168, 92, 255, 0.15);
  z-index: 2000000;
  display: flex;
  flex-direction: column;
  transition: all 0.5s cubic-bezier(0.2, 1, 0.3, 1);
}

.global-audio-player.minimized {
  transform: translateX(-50%) translateY(150px);
  opacity: 0;
}

/* Slim Progress on Top Edge */
.audio-player-progress {
  width: calc(100% - 48px);
  /* Padding from edges */
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  margin: 8px auto 0;
  border-radius: 2px;
  overflow: hidden;
}

.audio-player-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ap-accent), #ec4899);
  box-shadow: 0 0 15px var(--ap-accent);
}

/* Main Content Wrapper */
.audio-player-content {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: relative;
  z-index: 5;
}

/* Three Sections Layout */
.player-section-left {
  width: 60px;
  display: flex;
  justify-content: flex-start;
}

.player-section-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.player-section-right {
  width: 120px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

/* Track Info */
.track-info-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.audio-player-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--ap-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.audio-player-time {
  font-size: 10px;
  font-weight: 700;
  color: var(--ap-text-dim);
  font-variant-numeric: tabular-nums;
}

/* Controls */
.controls-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.control-btn {
  background: transparent;
  border: none;
  color: var(--ap-text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 12px;
  transition: all 0.2s;
  outline: none;
}

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

.play-btn-wrapper {
  width: 44px;
  height: 44px;
  background: #fff;
  color: #111;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.play-btn-wrapper:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 35px rgba(255, 255, 255, 0.2);
}

/* Volume Sticky Popup */
.volume-wrapper {
  position: relative;
  height: 44px;
  display: flex;
  align-items: center;
}

.volume-popup {
  position: absolute;
  bottom: 110%;
  /* Move up a bit */
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ap-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--ap-border);
  border-radius: 14px;
  padding: 12px 10px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.3s ease;
  transition-delay: 0.8s;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  z-index: 2000001;
}

.volume-wrapper:hover .volume-popup,
.volume-popup:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  transition-delay: 0s;
}

.volume-range {
  -webkit-appearance: slider-vertical;
  width: 20px;
  /* Wider for easier hit */
  height: 100px;
  accent-color: var(--ap-accent);
  cursor: pointer;
  pointer-events: auto;
}

/* COMPACT MINI PLAYLIST */
.audio-player-playlist-container {
  position: absolute;
  bottom: 100px;
  left: 0;
  width: 280px;
  background: var(--ap-bg);
  backdrop-filter: blur(30px);
  border: 1px solid var(--ap-border);
  border-radius: 22px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  /* FIXED: items will be vertical */
  z-index: 2000001;
}

.audio-player-playlist-container.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.audio-playlist-header {
  display: none;
  /* REMOVE HEADER TEXT */
}

.audio-playlist-items {
  max-height: 240px;
  overflow-y: auto;
  padding: 12px 0;
  width: 100%;
}

.audio-playlist-item {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.audio-playlist-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.audio-playlist-item.active {
  background: rgba(168, 92, 255, 0.14);
}

.playlist-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ap-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Floating Restore Button */
.audio-player-restore-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 62px;
  height: 62px;
  background: linear-gradient(135deg, var(--ap-accent), #7a1dfa);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 15px 40px rgba(168, 92, 255, 0.4);
  cursor: pointer;
  transform: scale(0);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 2000002;
}

.audio-player-restore-btn.visible {
  transform: scale(1);
  opacity: 1;
}

/* Minimalist Wave Animation */
.audio-player-waves {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  opacity: 0.3;
  /* Brightened */
  pointer-events: none;
  z-index: 1;
}

.audio-player-waves span {
  width: 3px;
  height: 12%;
  background: var(--ap-accent);
  border-radius: 4px;
  transition: height 0.1s;
  box-shadow: 0 0 12px var(--ap-accent), 0 0 20px rgba(168, 92, 255, 0.4);
  /* STRONG GLOW */
}

/* ========================================================= */
/* === COMPACT / NARROW LAYOUT (CEP panels, small screens) = */
/* ========================================================= */

/* CEP override — two-row layout */
html.is-cep .global-audio-player {
  width: calc(100% - 16px);
  max-width: 100%;
  bottom: 8px;
  height: auto;
  border-radius: 18px;
  padding-bottom: 8px;
}

/* Content becomes a CSS grid: 2 rows */
html.is-cep .audio-player-content {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  padding: 4px 12px 0;
  gap: 0 8px;
}

/* ROW 1 LEFT: Playlist button */
html.is-cep .player-section-left {
  grid-row: 1;
  grid-column: 1;
  width: auto;
  display: flex;
  justify-content: flex-start;
}

html.is-cep .player-section-left .control-btn {
  padding: 4px;
}

html.is-cep .player-section-left .control-btn svg {
  width: 20px;
  height: 20px;
}

/* ROW 1 CENTER: Track title + timer */
html.is-cep .player-section-center .track-info-wrapper {
  grid-row: 1;
  grid-column: 2;
}

/* ROW 1 RIGHT: Volume, minimize, close */
html.is-cep .player-section-right {
  grid-row: 1;
  grid-column: 3;
  width: auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
}

html.is-cep .player-section-right .control-btn {
  padding: 3px;
}

html.is-cep .player-section-right .control-btn svg {
  width: 18px;
  height: 18px;
}

/* ROW 2: Play controls centered, spanning full width */
html.is-cep .player-section-center .controls-row {
  grid-row: 2;
  grid-column: 1 / -1;
}

/* Center section: break into grid items */
html.is-cep .player-section-center {
  display: contents;
}

html.is-cep .track-info-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

html.is-cep .audio-player-title {
  max-width: none;
  font-size: 12px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html.is-cep .audio-player-time {
  font-size: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.6;
}

/* Controls row: centered, full width */
html.is-cep .controls-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 4px 0 2px;
  position: relative;
  z-index: 10;
}

html.is-cep .play-btn-wrapper {
  width: 42px;
  height: 42px;
}

html.is-cep .play-btn-wrapper svg {
  width: 22px;
  height: 22px;
}

html.is-cep .control-btn.btn-md {
  padding: 6px;
}

html.is-cep .control-btn.btn-md svg {
  width: 22px;
  height: 22px;
}

/* Volume popup adjustments */
html.is-cep .volume-popup {
  right: 0;
  left: auto;
  transform: translateX(0) translateY(10px);
}

html.is-cep .volume-wrapper:hover .volume-popup,
html.is-cep .volume-popup:hover {
  transform: translateX(0) translateY(0);
}

/* Progress bar */
html.is-cep .audio-player-progress {
  width: calc(100% - 20px);
  margin: 6px auto 0;
}

/* Waves stay behind controls */
html.is-cep .audio-player-waves {
  z-index: 1;
}

/* Playlist popup */
html.is-cep .audio-player-playlist-container {
  width: calc(100% - 16px);
  left: 8px;
  bottom: calc(100% + 8px);
}

/* Restore button */
html.is-cep .audio-player-restore-btn {
  bottom: 12px;
  right: 12px;
  width: 48px;
  height: 48px;
}

/* Also handle narrow viewports via media query (browser) */
@media (max-width: 500px) {
  .global-audio-player {
    width: calc(100% - 16px);
    bottom: 8px;
    height: auto;
    border-radius: 18px;
    padding-bottom: 8px;
  }

  .audio-player-content {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    padding: 4px 12px 0;
    gap: 0 8px;
  }

  .player-section-left {
    grid-row: 1;
    grid-column: 1;
    width: auto;
  }

  .player-section-center {
    display: contents;
  }

  .player-section-center .track-info-wrapper {
    grid-row: 1;
    grid-column: 2;
  }

  .player-section-center .controls-row {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-content: center;
    gap: 16px;
    padding: 4px 0 2px;
  }

  .player-section-right {
    grid-row: 1;
    grid-column: 3;
    width: auto;
    gap: 2px;
  }

  .audio-player-title {
    max-width: none;
    font-size: 12px;
  }

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

  .audio-player-progress {
    width: calc(100% - 20px);
  }
}