/* =============================================
   Sound Multi-Track Player — Mobile-First CSS
   ============================================= */

.sound-player {
  position: relative;
  max-width: 600px;
  margin: 1rem auto;
  background: #1a1a2e;
  border-radius: 12px;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #e0e0e0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* ---- Header ---- */

.sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}

.sp-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-cache-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: #888;
  flex-shrink: 0;
}

.sp-cache-status.sp-cached {
  color: #2ecc71;
}

.sp-icon-cloud {
  flex-shrink: 0;
}

/* ---- Waveform Area ---- */

.sp-waveform-area {
  position: relative;
  width: 100%;
  height: 120px;
  margin: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  touch-action: none;
}

.sp-waveform-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.sp-playhead {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: #fff;
  pointer-events: none;
  transition: left 0.05s linear;
  z-index: 2;
}

.sp-playhead::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -5px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #fff;
}

/* ---- Seek Bar ---- */

.sp-seek-bar {
  padding: 4px 16px 0;
}

.sp-seek-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #333;
  outline: none;
  cursor: pointer;
}

.sp-seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}

.sp-seek-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
}

.sp-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #888;
  padding: 2px 0 0;
}

/* ---- Playback Controls ---- */

.sp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px;
}

.sp-btn {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.sp-btn:hover,
.sp-btn:focus {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sp-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.sp-play-btn {
  background: rgba(255, 255, 255, 0.1);
  width: 56px;
  height: 56px;
  color: #fff;
}

.sp-play-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sp-cache-btn {
  margin-left: auto;
}

/* ---- Track List ---- */

.sp-tracks {
  padding: 2px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sp-track {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s, opacity 0.15s;
}

.sp-track:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sp-track.sp-track-muted {
  opacity: 0.4;
}

.sp-track.sp-track-soloed {
  background: rgba(255, 255, 255, 0.1);
  border-left: 3px solid #f39c12;
}

.sp-track-color {
  width: 3px;
  height: 20px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sp-track-name {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sp-track-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Pan slider (per track) */
.sp-pan-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 48px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, #4a90d9, #444 45%, #444 55%, #e74c3c);
  outline: none;
  cursor: pointer;
}

.sp-pan-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
}

.sp-pan-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
}

.sp-pan-label {
  font-size: 0.6rem;
  color: #888;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Volume slider (per track) */
.sp-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 50px;
  height: 3px;
  border-radius: 2px;
  background: #444;
  outline: none;
  cursor: pointer;
}

.sp-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ccc;
  cursor: pointer;
}

.sp-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ccc;
  cursor: pointer;
  border: none;
}

/* Mute & Solo shared button style */
.sp-mute-btn,
.sp-solo-btn {
  background: none;
  border: 1px solid #555;
  color: #888;
  cursor: pointer;
  padding: 3px 0;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-width: 26px;
  min-height: 26px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mute button states */
.sp-mute-btn:hover {
  border-color: #e74c3c;
  color: #e74c3c;
}

.sp-mute-btn.active {
  background: #e74c3c;
  border-color: #e74c3c;
  color: #fff;
}

/* Solo button states */
.sp-solo-btn:hover {
  border-color: #f39c12;
  color: #f39c12;
}

.sp-solo-btn.active {
  background: #f39c12;
  border-color: #f39c12;
  color: #1a1a2e;
}

/* ---- Loading Overlay ---- */

.sp-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 46, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  gap: 12px;
}

.sp-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #4a90d9;
  border-radius: 50%;
  animation: sp-spin 0.8s linear infinite;
}

@keyframes sp-spin {
  to { transform: rotate(360deg); }
}

.sp-loading-text {
  margin: 0;
  font-size: 0.8rem;
  color: #aaa;
}

/* ---- Responsive ---- */

/* Small phones */
@media (max-width: 420px) {
  .sp-track {
    flex-wrap: wrap;
  }

  .sp-track-name {
    flex-basis: calc(100% - 16px);
    font-size: 0.68rem;
  }

  .sp-track-controls {
    flex-basis: 100%;
    justify-content: flex-end;
    gap: 3px;
  }

  .sp-pan-slider {
    width: 36px;
  }

  .sp-volume-slider {
    width: 36px;
  }

  .sp-controls {
    gap: 10px;
  }

  .sp-waveform-area {
    height: 80px;
  }
}

/* Tablets and up */
@media (min-width: 601px) {
  .sound-player {
    max-width: 700px;
  }

  .sp-waveform-area {
    height: 160px;
  }

  .sp-volume-slider {
    width: 70px;
  }

  .sp-pan-slider {
    width: 56px;
  }

  .sp-track {
    padding: 10px 12px;
  }
}
