/* AOG Persistent Audio Player - Enhanced */
#aog-player-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  background: oklch(from var(--color-surface) l c h / 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 
    0 0 0 1px oklch(from var(--color-accent) l c h / 0.1),
    0 25px 50px -12px oklch(0% 0 0 / 0.5),
    0 0 0 0 oklch(from var(--color-accent) l c h / 0.1);
  width: 320px;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s var(--ease-out), box-shadow 0.3s ease;
  transform-origin: bottom right;
  font-family: var(--font-body, system-ui, sans-serif);
}

#aog-player-container:hover {
  box-shadow: 
    0 0 0 1px oklch(from var(--color-accent) l c h / 0.2),
    0 25px 50px -12px oklch(0% 0 0 / 0.4),
    0 8px 0 0 oklch(from var(--color-accent) l c h / 0.05);
}

#aog-player-container.collapsed {
  transform: translateY(calc(100% - 56px));
}

#aog-player-container.paused .ap-play-icon {
  opacity: 0.7;
}

/* Mobile responsive */
@media (max-width: 420px) {
  #aog-player-container {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  
  #aog-player-container.collapsed {
    transform: translateY(calc(100% - 48px));
  }
}

/* ═══════════════════════════════════════════════════════════════
   HEADER (Collapsed State)
   ═══════════════════════════════════════════════════════ */

.ap-header {
  display: flex;
  flex-direction: column;
  background: oklch(from var(--color-surface) l c h / 0.6);
  cursor: pointer;
  user-select: none;
}

.ap-header-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  height: 48px;
}

.ap-mini-cover {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  box-shadow: 0 2px 8px oklch(0% 0 0 / 0.2);
}

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

.ap-mini-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.ap-mini-artist {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ap-chevron {
  color: var(--color-text-muted);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  width: 18px;
  height: 18px;
}

#aog-player-container.collapsed .ap-chevron {
  transform: rotate(180deg);
}

.ap-mini-progress {
  height: 3px;
  background: var(--color-border);
  width: 100%;
}

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

/* ═══════════════════════════════════════════════════════
   BODY (Expanded State)
   ═══════════════════════════════════════════════════════ */

.ap-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-height: 70vh;
  overflow-y: auto;
}

#aog-player-container.collapsed .ap-body {
  display: none;
}

/* ═══════════════════════════════════════════════════════
   ARTWORK & VISUALIZER
   ═══════════════════════════════════════════════════════ */

.ap-artwork {
  position: relative;
  display: flex;
  justify-content: center;
}

.ap-cover-large {
  width: 100%;
  aspect-ratio: 1;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px oklch(0% 0 0 / 0.3);
}

.ap-visualizer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
  opacity: 0.8;
}

#viz-canvas {
  width: 100%;
  height: 100%;
}

/* ═══════════════════════════════════════════════════════
   NOW PLAYING INFO
   ═══════════════════════════════════════════════════════ */

.ap-now-playing {
  text-align: center;
  padding: 0 var(--space-2);
}

.ap-track-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.ap-track-artist {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════ */

.ap-progress-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ap-progress-bar {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.ap-progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: visible;
}

.ap-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), oklch(from var(--color-accent) l c h / 0.7));
  width: 0%;
  border-radius: 2px;
  transition: width 0.05s linear;
}

.ap-progress-handle {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 12px;
  height: 12px;
  background: var(--color-text);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 2px 8px oklch(0% 0 0 / 0.3);
}

.ap-progress-bar:hover .ap-progress-handle {
  opacity: 1;
}

.ap-progress-bar:hover .ap-progress-fill {
  background: var(--color-accent);
}

.ap-tooltip {
  position: absolute;
  bottom: 100%;
  left: 0%;
  transform: translateX(-50%);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-family: var(--font-mono);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.ap-progress-bar:hover .ap-tooltip {
  opacity: 1;
}

.ap-time-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-muted);
}

.ap-time-separator {
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTROLS
   ═══════════════════════════════════════════════════════════════ */

.ap-controls-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}

.ap-btn {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  border-radius: 50%;
  transition: all 0.2s var(--ease-out);
}

.ap-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
  transform: scale(1.1);
}

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

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

.ap-btn.active:hover {
  background: oklch(from var(--color-accent) l c h / 0.15);
}

/* Play button - prominent */
.ap-play {
  width: 56px;
  height: 56px;
  background: var(--color-text);
  color: var(--color-bg);
  box-shadow: 
    0 4px 12px oklch(from var(--color-text) l c h / 0.3),
    0 0 0 0 var(--color-text);
}

.ap-play:hover {
  background: var(--color-accent);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 
    0 6px 20px oklch(from var(--color-accent) l c h / 0.4),
    0 0 0 4px oklch(from var(--color-accent) l c h / 0.2);
}

.ap-play .lucide {
  fill: currentColor;
}

/* ═══════════════════════════════════════════════════════
   SECONDARY CONTROLS
   ═══════════════════════════════════════════════════════ */

.ap-controls-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
}

.ap-volume-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ap-volume-slider {
  width: 60px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  cursor: pointer;
  overflow: hidden;
}

.ap-volume-fill {
  height: 100%;
  background: var(--color-accent);
  width: 70%;
  transition: width 0.1s;
}

.ap-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.ap-queue-toggle,
.ap-time-toggle {
  position: relative;
}

.ap-time-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-muted);
}

/* ═══════════════════════════════════════════════════════
   QUEUE PANEL
   ═══════════════════════════════════════════════════════ */

.ap-queue-panel {
  display: none;
  flex-direction: column;
  max-height: 200px;
  border-top: 1px solid var(--color-divider);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
}

.ap-queue-panel.open {
  display: flex;
}

.ap-queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.ap-queue-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow-y: auto;
}

.ap-queue-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.ap-queue-item:hover {
  background: var(--color-surface-offset);
}

.ap-queue-item.active {
  background: oklch(from var(--color-accent) l c h / 0.1);
}

.ap-queue-item.active .ap-queue-title {
  color: var(--color-accent);
}

.ap-queue-cover {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

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

.ap-queue-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-queue-artist {
  font-size: 10px;
  color: var(--color-text-muted);
}

.ap-queue-remove {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: 50%;
  transition: all 0.2s;
}

.ap-queue-item:hover .ap-queue-remove {
  opacity: 1;
}

.ap-queue-remove:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

/* ═══════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════ */

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 oklch(from var(--color-accent) l c h / 0.4); }
  50% { box-shadow: 0 0 0 8px oklch(from var(--color-accent) l c h / 0); }
}

.ap-play {
  animation: none;
}

.ap-play:active {
  animation: pulse-glow 0.3s ease-out;
}

/* Waveform animation for playing state */
@keyframes waveform-bars {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

#aog-player-container:not(.paused):not(.collapsed) .ap-controls-main .ap-play {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

/* Mobile touch optimizations */
@media (hover: none) {
  .ap-btn:hover {
    transform: none;
    background: transparent;
  }
  
  .ap-btn:active {
    background: var(--color-surface-offset);
    transform: scale(0.95);
  }
  
  .ap-play:active {
    transform: scale(0.95);
    background: var(--color-accent);
  }
  
  .ap-progress-handle {
    opacity: 1;
    width: 16px;
    height: 16px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ap-btn,
  .ap-progress-fill,
  .ap-chevron,
  #aog-player-container,
  .ap-play {
    transition: none;
    animation: none;
  }
}