/* ========================================
   PLAYER - Audio Player Controls
   Bottom header, playback controls, volume
   ======================================== */

/* ========== LOOP BOTTOM STICKY HEADER ========== */
.loop-bottom-header {
  position: fixed;
  bottom: 0;
  left: 280px;
  right: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 12px clamp(20px, 5vw, 50px);
  display: none;
  align-items: center;
  z-index: 9999;
  /* 1px border + 12+12 padding + cover 64px = 89px (évite +1px vs footer) */
  height: 89px;
  min-height: 89px;
  max-height: 89px;
  box-sizing: border-box;
  pointer-events: auto;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease, border-color 0.3s ease;
}

/* ✅ S'adapter quand le sidebar est collapsed */
.side-panel.collapsed ~ .loop-bottom-header {
  left: 72px;
}

/* ✅ Force l'affichage quand un loop joue - vraiment global */
.loop-bottom-header.playing,
.loop-bottom-header[style*="display: flex"] {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* ✅ Padding global pour toutes les sections quand le header joue */
body.audio-playing .content,
body.audio-playing #loops-content,
body.audio-playing #quick-access-content,
body.audio-playing .pack-view,
body.audio-playing .playlist-view,
body.audio-playing .creator-view {
  padding-bottom: 140px !important;
}

#currentLoopInfo {
  display: none;
  flex: 1;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

#currentLoopInfo[style*="display: flex"] {
  display: flex !important;
}

#loops-content[style*="display: flex"] ~ .loop-bottom-header {
  display: flex !important;
}

/* ========== PACK COVER ========== */
.player-pack-cover {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-secondary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  flex-shrink: 0;
}

.player-pack-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-cover-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  color: var(--text-secondary);
}

.player-cover-placeholder::before {
  content: "";
  width: 32px;
  height: 32px;
  background: currentColor;
  mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5L21 3V16"/><path d="M6 21C7.65685 21 9 19.6569 9 18C9 16.3431 7.65685 15 6 15C4.34315 15 3 16.3431 3 18C3 19.6569 4.34315 21 6 21Z"/><path d="M18 19C19.6569 19 21 17.6569 21 16C21 14.3431 19.6569 13 18 13C16.3431 13 15 14.3431 15 16C15 17.6569 16.3431 19 18 19Z"/></svg>');
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

/* ========== PLAYER INFO ========== */
.player-info-section {
  min-width: 0;
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.player-loop-name {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Satoshi', 'Plus Jakarta Sans', sans-serif;
  transition: color 0.3s ease;
}

[data-theme="dark"] .player-loop-name {
  color: #ffffff;
}

.player-loop-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #666;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.3s ease;
}

[data-theme="dark"] .player-loop-meta {
  color: #999;
}

.meta-separator {
  color: #ccc;
  transition: color 0.3s ease;
}

[data-theme="dark"] .meta-separator {
  color: #555;
}

/* ========== WAVEFORM ========== */
.player-waveform-container {
  flex: 0 0 400px;
  height: 48px;
  width: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

.player-waveform-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.player-waveform-wrapper [id^="waveform-"] {
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ========== SPACER ========== */
.player-spacer {
  flex: 1;
  min-width: 20px;
}

/* ========== CONTROLS ========== */
.player-controls-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}

.player-ctrl-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.player-ctrl-btn svg {
  width: 18px;
  height: 18px;
}

.player-ctrl-btn:hover {
  color: #1a1a1a;
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .player-ctrl-btn {
  color: #999;
}

[data-theme="dark"] .player-ctrl-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Même traitement que .player-ctrl-btn : discret, pas de pastille pleine */
.player-play-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.player-play-btn:hover {
  color: #1a1a1a;
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .player-play-btn {
  color: #999;
}

[data-theme="dark"] .player-play-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Mêmes glyphes arrondis que loop/pack cards (viewBox 384×512 / 320×512) */
.player-play-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.player-play-btn svg.play-icon {
  width: 19px;
  height: 19px;
  margin-left: 3px;
}

.player-play-btn:active {
  opacity: 0.8;
}

/* ========== SEPARATOR ========== */
.player-separator {
  width: 1px;
  height: 24px;
  background: rgba(0, 0, 0, 0.1);
  margin: 0 4px;
  flex-shrink: 0;
  transition: background 0.3s ease;
}

[data-theme="dark"] .player-separator {
  background: rgba(255, 255, 255, 0.15);
}

/* ========== ACTIONS ========== */
.player-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.player-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

[data-theme="dark"] .player-action-btn {
  border-color: rgba(255, 255, 255, 0.15);
  color: #999;
}

.player-action-btn svg {
  width: 16px;
  height: 16px;
}

.player-action-btn .download-icon,
.player-action-btn .checkmark-icon {
  fill: none;
  stroke: currentColor;
}

.player-action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.15);
  color: #1a1a1a;
}

[data-theme="dark"] .player-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.player-action-btn.liked {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.player-action-btn.liked svg {
  fill: #ef4444;
}

.player-action-btn.liked:hover,
[data-theme="dark"] .player-action-btn.liked:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

/* ========== VOLUME ========== */
.player-volume-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.player-volume-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.player-volume-btn svg {
  width: 18px;
  height: 18px;
}

.player-volume-btn:hover {
  color: #1a1a1a;
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .player-volume-btn {
  color: #999;
}

[data-theme="dark"] .player-volume-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.player-volume-slider-container {
  width: 80px;
  height: 32px;
  display: flex;
  align-items: center;
}

.player-volume-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

[data-theme="dark"] .player-volume-slider {
  background: rgba(255, 255, 255, 0.15);
}

.player-volume-slider:hover {
  background: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .player-volume-slider:hover {
  background: rgba(255, 255, 255, 0.2);
}

.player-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #1a1a1a;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .player-volume-slider::-webkit-slider-thumb {
  background: #ffffff;
}

.player-volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.player-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #1a1a1a;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .player-volume-slider::-moz-range-thumb {
  background: #ffffff;
}

.player-volume-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Cacher les anciens éléments */
#masterVolumeValue {
  display: none;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
  .player-info-section {
    width: 140px;
  }
  
  .player-waveform-container {
    flex: 0 0 350px;
    width: 350px;
  }
  
  .player-volume-slider-container {
    width: 70px;
  }
}

@media (max-width: 900px) {
  .player-pack-cover {
    width: 56px;
    height: 56px;
  }
  
  .player-info-section {
    width: 120px;
  }
  
  .player-loop-name {
    font-size: 13px;
  }
  
  .player-loop-meta {
    font-size: 10px;
  }
  
  .player-waveform-container {
    flex: 0 0 280px;
    width: 280px;
    height: 40px;
  }
  
  .player-volume-slider-container {
    width: 60px;
  }
}

@media (max-width: 950px) {
  .player-volume-slider-container {
    width: 50px;
  }
}

@media (max-width: 850px) {
  .player-volume-slider-container {
    display: none;
  }
  
  .player-separator:last-of-type {
    display: none;
  }
}

@media (max-width: 700px) {
  .loop-bottom-header {
    padding: 8px 14px;
    height: 58px;
    min-height: 58px;
    max-height: 58px;
  }

  #currentLoopInfo {
    flex-wrap: nowrap;
    gap: 8px;
  }

  /* Cacher waveform + spacers + volume + prev/next + séparateurs */
  .player-waveform-container,
  .player-spacer,
  .player-volume-group,
  .player-controls-group .player-ctrl-btn,
  .player-separator {
    display: none;
  }

  .player-controls-group {
    gap: 0;
    flex-shrink: 0;
  }

  /* Actions (like + download) collés à droite */
  .player-actions-group {
    margin-left: auto;
    flex-shrink: 0;
  }
  
  .player-pack-cover {
    width: 48px;
    height: 48px;
  }
  
  .player-info-section {
    width: 110px;
  }
  
  .player-ctrl-btn {
    width: 28px;
    height: 28px;
  }
  
  .player-ctrl-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .player-play-btn {
    width: 28px;
    height: 28px;
  }
  
  .player-play-btn svg {
    width: 16px;
    height: 16px;
  }

  .player-play-btn svg.play-icon {
    width: 17px;
    height: 17px;
    margin-left: 2px;
  }
  
  .player-action-btn {
    width: 28px;
    height: 28px;
  }
  
  .player-action-btn svg {
    width: 14px;
    height: 14px;
  }
  
  .player-separator {
    height: 20px;
  }
  
  .player-volume-btn {
    width: 28px;
    height: 28px;
  }
  
  .player-volume-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* ========== MASTER VOLUME ========== */
.master-volume-container {
  background: #FFFFFF;
  border: 1px solid #D9D9D9;
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 400px;
  transition: border-color 0.2s ease, background-color 0.3s ease;
}

/* Dark mode pour master volume container */
[data-theme="dark"] .master-volume-container {
  background: var(--bg-secondary);
  border-color: var(--border-color-dark);
}

.master-volume-container:hover {
  border-color: #000;
}

.master-volume-label {
  font-weight: 600;
  font-size: 14px;
  color: #000;
  min-width: 100px;
  transition: color 0.3s ease;
}

/* Dark mode pour master volume label */
[data-theme="dark"] .master-volume-label {
  color: var(--text-primary);
}

.master-volume-container .PB-range-slider-div {
  flex: 1;
}


/* ========== VOLUME SLIDER ========== */
.PB-range-slider {
  appearance: none;
  width: 100%;
  max-width: 200px;
  height: 4px;
  border-radius: 5px;
  background: #D5DBE1;
  outline: none;
  opacity: 0.7;
  transition: opacity .2s;
}

.PB-range-slider::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background-color: #000000;
  cursor: pointer;
  transition: 0.3s ease-in-out;
}

.PB-range-slider::-webkit-slider-thumb:hover {
  box-shadow: 0px 0px 0px 8px rgba(0, 0, 0, 0.16);
  transition: 0.3s ease-in-out;
}

.PB-range-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background-color: #000000;
  cursor: pointer;
  border: none;
}

.PB-range-slider-div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
}

.PB-range-slidervalue {
  font-weight: 600;
  min-width: 40px;
  text-align: center;
  font-size: 14px;
}

/* ========== PACK PREVIEW PROGRESS BAR ========== */
.pack-preview-progress-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.pack-preview-time {
  font-size: 13px;
  color: #666;
  font-weight: 500;
}

[data-theme="dark"] .pack-preview-time {
  color: #999;
}

.pack-preview-progress-bar {
  width: 100%;
  padding: 12px 0;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
}

.pack-preview-progress-bar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  pointer-events: none;
}

[data-theme="dark"] .pack-preview-progress-bar::before {
  background: rgba(255, 255, 255, 0.1);
}

.pack-preview-progress-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: #AAAAAA;
  border-radius: 2px;
  transition: width 0.1s linear;
  width: 0%;
  pointer-events: none;
}

/* ========== BOTTOM DOWNLOAD BUTTON STATES ========== */
.player-action-btn .spinner {
  display: none;
  width: 16px;
  height: 16px;
  will-change: transform, opacity;
}

.player-action-btn .spinner svg {
  animation: rotate 1s linear infinite;
  width: 100%;
  height: 100%;
  display: block;
  will-change: transform;
}

.player-action-btn .spinner circle {
  stroke: #666;
  stroke-width: 4;
  fill: none;
  stroke-dasharray: 80, 200;
  stroke-dashoffset: 0;
  animation: dash 1.5s ease-in-out infinite;
  stroke-linecap: round;
  will-change: stroke-dasharray, stroke-dashoffset;
}

[data-theme="dark"] .player-action-btn .spinner circle {
  stroke: #999;
}

.player-action-btn.downloading {
  opacity: 1 !important;
  cursor: wait !important;
  pointer-events: none !important;
  background: rgba(0, 0, 0, 0.05) !important;
}

[data-theme="dark"] .player-action-btn.downloading {
  background: rgba(255, 255, 255, 0.08) !important;
}

.player-action-btn.downloading .download-icon {
  display: none !important;
}

.player-action-btn.downloading .checkmark-icon {
  display: none !important;
}

.player-action-btn.downloading .spinner {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.player-action-btn.downloaded {
  background: transparent !important;
  cursor: default !important;
  pointer-events: none !important;
}

.player-action-btn.downloaded .download-icon {
  display: none !important;
}

.player-action-btn.downloaded .checkmark-icon {
  display: block !important;
  stroke: #333 !important;
}

[data-theme="dark"] .player-action-btn.downloaded .checkmark-icon {
  stroke: #ccc !important;
}

.player-action-btn.cloud-download {
  background: transparent !important;
  cursor: pointer !important;
}

.player-action-btn.cloud-download:hover {
  background: rgba(0, 0, 0, 0.05) !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
}

[data-theme="dark"] .player-action-btn.cloud-download:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
}

@keyframes rotate {
  100% { transform: rotate(360deg); }
}

@keyframes dash {
  0% {
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 90, 200;
    stroke-dashoffset: -35px;
  }
  100% {
    stroke-dashoffset: -125px;
  }
}