/* General Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: white;
  overflow-x: hidden;
}

.container {
  width: 100%;
  min-height: 100vh;
  padding: 20px;
}

/* Songs Container */
.songs-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.songs-container h1 {
  text-align: center;
  margin-bottom: 40px;
  font-size: 2.5rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.playlist-section {
  margin-bottom: 50px;
}

.playlist-section h2 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.songs-grid {
  display: grid;
  gap: 15px;
}

.song-button {
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  color: white;
  transition: all 0.3s;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.song-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.song-button-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.song-icon {
  opacity: 0.7;
}

.song-info {
  flex: 1;
}

.song-title {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.song-loop-info {
  font-size: 0.9rem;
  opacity: 0.7;
}

.song-arrow {
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 1.5rem;
}

.song-button:hover .song-arrow {
  opacity: 1;
}

/* WAV Media Player Styles */
.wav-player-container {
  position: fixed;
  bottom: 0;
  z-index: 1000;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.3);
  color: white;
  animation: slideUp 0.3s ease-out;
}

/* Mobile/Small screens: 100% width at bottom, height 21.1vh */
@media (max-width: 877px) {
  .wav-player-container {
    width: 100%;
    left: 0;
    padding: 15px 20px;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
  }
}

/* Tablet and Desktop: 10% smaller, bottom right */
/* Desktop: Compact Layout to fit 21.1vh */
@media (min-width: 878px) {
  .wav-player-container {
    right: 0;
    left: auto;
    width: 45vw;         /* Wider to fit side-by-side content */
    max-width: 600px;
    min-height: 180px;   /* Safety minimum so text doesn't crush */
    padding: 15px 25px;
    border-radius: 20px 0 0 0; /* Rounded top-left corner only */
    margin: 0;
    
    /* Use CSS Grid to organize content efficiently */
    display: grid;
    grid-template-columns: 1fr 1.2fr; /* Left col (Info), Right col (Controls) */
    grid-template-rows: auto auto 1fr;
    column-gap: 20px;
    align-content: center;
    overflow: hidden; /* Prevent scrollbars */
  }

  /* 1. Song Name (Top Left) */
  .song-name {
    grid-column: 1;
    grid-row: 1;
    text-align: left;
    font-size: 1.2rem;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 2. Scrolling Description (Middle Left) */
  .song-description {
    grid-column: 1;
    grid-row: 2;
    margin-bottom: 5px;
    text-align: left;
  }

  /* 3. Timestamp (Bottom Left) */
  .timestamp {
    grid-column: 1;
    grid-row: 3;
    text-align: left;
    margin-bottom: 0;
    align-self: end; /* Push to bottom of cell */
  }

  /* 4. Seeker Bar (Top Right) */
  .seeker-container {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    margin-bottom: 0;
    align-self: center;
  }

  /* 5. Playback Controls (Middle Right) */
  .playback-controls {
    grid-column: 2;
    grid-row: 2;
    margin-bottom: 5px;
    gap: 10px;
  }
  
  /* Make buttons slightly smaller to fit */
  .control-button {
    width: 35px; height: 35px;
  }
  .control-button.play-pause {
    width: 45px; height: 45px;
  }

  /* 6. Bottom Controls (Loop/Vol) (Bottom Right) */
  .bottom-controls {
    grid-column: 2;
    grid-row: 3;
    gap: 10px;
    align-self: end;
  }

  /* Adjust Volume Slider width for compact space */
  .volume-control {
    justify-content: flex-end;
  }
  .volume-slider {
    max-width: 80px;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.player-row {
  margin-bottom: 20px;
}

/* Row 1: Song Name */
.song-name {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* Row 2: Song Description (Scrolling) */
.song-description {
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  height: 30px;
  margin-bottom: 15px;
}

.scrolling-text {
  display: inline-block;
  padding-left: 100%;
  animation: scroll-left 15s linear infinite;
  font-size: 14px;
  opacity: 0.9;
}

@keyframes scroll-left {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Row 3: Timestamp */
.timestamp {
  text-align: center;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  opacity: 0.9;
  margin-bottom: 15px;
}

/* Row 4: Seeker Bar */
.seeker-container {
  /* 1. Limit width to 80% and center it */
  width: 80%;
  margin: 0 auto 25px auto;
  
  /* 2. Create a stable box for the slider */
  height: 20px; 
  display: flex;
  align-items: center;
  position: relative;
}

.seeker-wrapper {
  /* 3. The visual track acts as the anchor */
  position: relative;
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  /* No overflow hidden, so the thumb can stick out slightly if needed */
}

/* The Invisible Slider Logic (Input) */
.seeker-bar {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%); /* Perfectly center vertically */
  width: 100%; /* Matches wrapper exactly */
  height: 20px; /* Touch area larger than visual track */
  margin: 0;
  padding: 0;
  
  -webkit-appearance: none;
  appearance: none;
  background: transparent; /* Invisible track */
  z-index: 10; /* Must be on top to be clickable */
  cursor: pointer;
}

/* Slider Thumb Styling */
.seeker-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
  margin-top: 0; 
}

.seeker-bar::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Visual Layers (Underneath the input) */
.seeker-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: white;
  border-radius: 10px;
  pointer-events: none;
  z-index: 2;
}

.seeker-loop {
  position: absolute;
  top: 0;
  /* left/width are set by JS */
  height: 100%;
  border-radius: 10px;
  pointer-events: none;
  z-index: 1;
}

.seeker-loop.active {
  background: rgba(0, 255, 0, 0.5);
}
.seeker-loop.inactive {
  display: none;
}

/* Row 5: Playback Controls */
.playback-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 25px;
}

.control-button {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: all 0.3s;
  backdrop-filter: blur(10px);
}

.control-button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.control-button:active {
  transform: scale(0.95);
}

.control-button.play-pause {
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.3);
}

.control-button.play-pause:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Row 6: Bottom Controls */
.bottom-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.left-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.loop-button {
  padding: 8px 16px;
  border: 2px solid;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s;
  background: transparent;
}

.loop-button:not(.active) {
  border-color: #ff4444;
  color: #ff4444;
  background: rgba(255, 68, 68, 0.1);
}

.loop-button.active {
  border-color: #44ff44;
  color: #44ff44;
  background: rgba(68, 255, 68, 0.1);
}

.loop-button:hover {
  transform: scale(1.05);
}

.repeat-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.repeat-checkbox input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  position: relative;
}

.checkbox-custom:not(.active) {
  border-color: #ff4444;
  background: rgba(255, 68, 68, 0.1);
}

.checkbox-custom.active {
  border-color: #44ff44;
  background: rgba(68, 255, 68, 0.1);
}

.checkbox-custom.active::after {
  content: '✓';
  color: #44ff44;
  font-size: 14px;
  font-weight: bold;
  position: absolute;
}

.repeat-label {
  font-size: 14px;
  font-weight: 500;
}

.theme-button {
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s;
  backdrop-filter: blur(10px);
}

.theme-button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.theme-button:active {
  transform: scale(0.95);
}

.volume-control {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  max-width: 120px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.volume-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
}

/* Dark theme support */
body.dark {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark .song-button {
  background: rgba(255, 255, 255, 0.05);
}

body.dark .song-button:hover {
  background: rgba(255, 255, 255, 0.15);
}

body.dark .playlist-section h2 {
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

body.dark .wav-player-container {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.6);
}

/* Responsive adjustments for smaller mobile */
@media (max-width: 480px) {
  .song-name {
    font-size: 20px;
  }

  .playback-controls {
    gap: 10px;
  }

  .control-button {
    width: 40px;
    height: 40px;
  }

  .control-button.play-pause {
    width: 52px;
    height: 52px;
  }

  .bottom-controls {
    flex-wrap: wrap;
  }

  .theme-button {
    order: 3;
    width: 100%;
    margin-top: 10px;
  }
}