/* Audio Player - Lecteur d'ambiance sonore */

/* Section Ambiance */
#ambiance-section {
  padding: 2rem;
}

.audio-player-container {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Liste des sons disponibles */
.sounds-library {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sound-category {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  cursor: pointer;
  user-select: none;
}

.category-icon {
  font-size: 1.5rem;
}

.category-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  flex: 1;
}

.category-toggle {
  color: var(--text-muted);
  transition: transform 0.2s;
}

.category-header.collapsed .category-toggle {
  transform: rotate(-90deg);
}

.sounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.sounds-grid::-webkit-scrollbar {
  width: 6px;
}

.sounds-grid::-webkit-scrollbar-track {
  background: var(--surface-light);
  border-radius: 3px;
}

.sounds-grid::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

.sound-item {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sound-item:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.sound-item.playing {
  background: var(--success);
  border-color: var(--success);
}

.sound-icon {
  font-size: 1.25rem;
}

.sound-name {
  font-size: 0.875rem;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sound-add-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.sound-add-btn:hover {
  opacity: 1;
}

/* Panneau de contrôle et playlist */
.player-panel {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  position: sticky;
  top: 100px;
  height: fit-content;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

.player-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.player-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.player-status {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Lecteur audio principal */
.audio-player-main {
  background: var(--surface-light);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.now-playing {
  text-align: center;
  margin-bottom: 1rem;
}

.now-playing-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.now-playing-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}

.audio-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.audio-control-btn {
  background: var(--primary);
  border: none;
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.audio-control-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.audio-control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.audio-control-btn.play-pause {
  width: 56px;
  height: 56px;
}

.audio-control-btn svg {
  width: 24px;
  height: 24px;
}

.audio-progress {
  margin-bottom: 0.75rem;
}

.player-controls .progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  margin-bottom: 0.25rem;
}

.player-controls .progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.1s linear;
}

.player-controls .progress-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.625rem;
  color: var(--text-muted);
}

/* Timer */
.timer-section {
  background: var(--surface-light);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.timer-header {
  margin-bottom: 0.75rem;
}

.timer-header h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.timer-display {
  text-align: center;
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
  font-variant-numeric: tabular-nums;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
  transition: all 0.3s;
}

.timer-display.running {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.5);
  animation: pulse-timer 2s ease-in-out infinite;
}

@keyframes pulse-timer {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.5);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.8);
  }
}

.timer-controls-btns {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.timer-control-btn {
  flex: 1;
  background: var(--primary);
  border: none;
  color: white;
  padding: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
}

.timer-control-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.timer-control-btn.pause {
  background: var(--warning);
}

.timer-control-btn.pause:hover {
  background: #d97706;
}

.timer-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.timer-preset-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.timer-preset-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.timer-custom {
  display: flex;
  gap: 0.5rem;
}

.timer-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  text-align: center;
}

.timer-input:focus {
  outline: none;
  border-color: var(--primary);
}

.timer-set-btn {
  background: var(--primary);
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.timer-set-btn:hover {
  background: var(--primary-dark);
}

/* Playlist */
.playlist-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.playlist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.playlist-header h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.playlist-clear {
  background: none;
  border: 1px solid var(--border);
  color: var(--danger);
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.playlist-clear:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.playlist-items {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.5rem;
  min-height: 200px;
}

.playlist-items::-webkit-scrollbar {
  width: 6px;
}

.playlist-items::-webkit-scrollbar-track {
  background: var(--surface-light);
  border-radius: 3px;
}

.playlist-items::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

.playlist-item {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.playlist-item:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.playlist-item.active {
  background: var(--success);
  border-color: var(--success);
}

.playlist-item-icon {
  font-size: 1.25rem;
}

.playlist-item-info {
  flex: 1;
  min-width: 0;
}

.playlist-item-name {
  font-size: 0.875rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-item-category {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.playlist-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.playlist-item-remove:hover {
  opacity: 1;
  color: var(--danger);
}

.playlist-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .audio-player-container {
    grid-template-columns: 1fr;
  }

  .player-panel {
    position: relative;
    top: 0;
    max-height: none;
  }

  .sounds-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 640px) {
  .sounds-grid {
    grid-template-columns: 1fr;
  }

  .timer-presets {
    grid-template-columns: repeat(2, 1fr);
  }
}
