/**
 * Track List Module Styles
 * SoundCloud-inspired design for Theo Overlay Player
 */

/* Base Track List Container */
.theo-track-list {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #000000; /* Black background for cyberpunk theme */
  color: #00ffff; /* Cyan text color */
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  margin: 20px 0;
  max-width: 100%;
}

/* Make full layout much wider */
.theo-track-list-full {
  max-width: 1200px;
  width: 100%;
}

/* Dark theme support */
.theme-dark .theo-track-list,
body.theme-dark .theo-track-list {
  background: #1a1a1a;
  color: #e5e7eb;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* Track List Header */
.track-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.8) !important; /* Dark background */
  border-bottom: 1px solid rgba(0, 255, 255, 0.3); /* Cyan border */
  color: #00ffff; /* Cyan text */
}

.theme-dark .track-list-header,
body.theme-dark .track-list-header {
  background: #2d3748;
  border-bottom-color: #4a5568;
}

.track-list-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #00ffff; /* Cyan text */
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
}

.theme-dark .track-list-title,
body.theme-dark .track-list-title {
  color: #e5e7eb;
}

.track-list-controls {
  display: flex;
  gap: 8px;
}

.track-list-refresh {
  background: transparent;
  border: 1px solid rgba(0, 255, 255, 0.3); /* Cyan border */
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #00ffff; /* Cyan text */
}

.track-list-refresh:hover {
  background: rgba(0, 255, 255, 0.15) !important; /* Dark cyan hover */
  border-color: #00ffff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.4);
}

.theme-dark .track-list-refresh,
body.theme-dark .track-list-refresh {
  border-color: #4a5568;
  color: #e5e7eb;
}

.theme-dark .track-list-refresh:hover,
body.theme-dark .track-list-refresh:hover {
  background: #374151;
  border-color: #6b7280;
}

/* Loading, Error, and Empty States */
.track-list-loading,
.track-list-error,
.track-list-empty {
  padding: 40px 20px;
  text-align: center;
  color: rgba(0, 255, 255, 0.7); /* Cyan text */
  background: transparent !important;
}

.theme-dark .track-list-loading,
.theme-dark .track-list-error,
.theme-dark .track-list-empty,
body.theme-dark .track-list-loading,
body.theme-dark .track-list-error,
body.theme-dark .track-list-empty {
  color: #9ca3af;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 255, 255, 0.3); /* Cyan border */
  border-top: 3px solid #00ffff; /* Cyan spinner */
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}

.theme-dark .loading-spinner,
body.theme-dark .loading-spinner {
  border-color: #4a5568;
  border-top-color: #ff5500;
}

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

.error-icon,
.empty-icon {
  font-size: 32px;
  margin-bottom: 16px;
}

.track-list-retry {
  background: #ff5500;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  margin-top: 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.track-list-retry:hover {
  background: #e64900;
}

/* Track List Container */
.track-list-container {
  padding: 0;
  background: transparent !important; /* Ensure no white background */
}

/* Individual Track Item */
.track-item {
  display: flex;
  align-items: flex-start;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.2); /* Cyan border */
  transition: background-color 0.2s ease;
  cursor: pointer;
  min-height: 160px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.6) !important; /* Dark background */
  color: #00ffff; /* Cyan text */
}

.track-item:hover {
  background: rgba(0, 255, 255, 0.15) !important; /* Dark cyan hover */
  border-bottom-color: rgba(0, 255, 255, 0.4);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

.track-item:last-child {
  border-bottom: none;
}

.theme-dark .track-item,
body.theme-dark .track-item {
  border-bottom-color: rgba(0, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.6) !important;
  color: #00ffff;
}

.theme-dark .track-item:hover,
body.theme-dark .track-item:hover {
  background: rgba(0, 255, 255, 0.15) !important;
}

/* Track Controls */
.track-controls {
  margin-right: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
}

.track-play-btn {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  border: none;
  background: rgba(255, 85, 0, 0.8);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 10;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

.track-play-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: -1;
}

.track-play-btn:hover {
  background-color: rgba(230, 73, 0, 0.9);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

.track-play-btn.playing {
  background-color: rgba(51, 51, 51, 0.8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.track-play-btn.loading {
  background-color: rgba(153, 153, 153, 0.8);
  cursor: wait;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Ensure icons are properly sized and visible */
.track-play-btn .play-icon,
.track-play-btn .pause-icon,
.track-play-btn .loading-icon {
  font-size: 48px;
  line-height: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Make sure emoji icons scale properly */
.track-play-btn .play-icon img,
.track-play-btn .pause-icon img,
.track-play-btn .loading-icon {
  width: 60px !important;
  height: 60px !important;
  object-fit: contain;
  min-width: 60px !important;
  min-height: 60px !important;
  max-width: 60px !important;
  max-height: 60px !important;
}

/* Default states - let JavaScript control these */
.track-play-btn .play-icon {
  display: flex;
}

.track-play-btn .pause-icon,
.track-play-btn .loading-icon {
  display: none;
}

.loading-icon {
  animation: spin 1s linear infinite;
}

/* Track Content */
.track-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  min-width: 0; /* Allow flex items to shrink */
  height: 140px;
  background: transparent !important;
  color: #00ffff; /* Cyan text */
}

.track-info {
  flex-shrink: 0;
  margin-bottom: 2px;
  text-align: left;
  width: 100%;
  margin-top: -20px;
}

.track-title {
  font-weight: 600;
  font-size: 16px;
  color: #00ffff; /* Cyan text */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  text-align: left !important;
  display: block;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
}

.theme-dark .track-title,
body.theme-dark .track-title {
  color: #00ffff;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
}

/* Hide artist in all layouts since it's always the same */
.track-artist {
  display: none;
}

/* Waveform Container */
.track-waveform-container {
  position: relative;
  height: 110px;
  background: rgba(0, 255, 255, 0.05); /* Dark cyan background */
  border: 1px solid rgba(0, 255, 255, 0.2); /* Cyan border */
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
  margin-bottom: 5px;
  flex: 1;
  min-height: 105px;
  margin-top: -20px;
  padding-top: 0px;
}

.theme-dark .track-waveform-container,
body.theme-dark .track-waveform-container {
  background: rgba(0, 255, 255, 0.05);
  border: 1px solid rgba(0, 255, 255, 0.2);
}

.track-waveform {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.track-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #ff5500;
  opacity: 0.6;
  transition: width 0.1s ease;
  pointer-events: none;
}

.track-seek-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}

.track-seek-overlay:hover {
  background: rgba(0, 255, 255, 0.1); /* Cyan hover */
}

/* Hover indicator line */
.track-hover-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: #00ffff; /* Cyan indicator */
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  transition: opacity 0.2s ease;
}

.theme-dark .track-hover-indicator,
body.theme-dark .track-hover-indicator {
  background: #00ffff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
}

.track-waveform-container:hover .track-hover-indicator {
  opacity: 1;
}

/* Heart button positioned over waveform */
.track-waveform-container .track-favorite {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  border: none;
  background: rgba(0, 255, 255, 0.3); /* Cyan background */
  color: #00ffff; /* Cyan color */
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  z-index: 3;
  opacity: 0;
  transform: scale(0.8);
}

.track-item:hover .track-waveform-container .track-favorite {
  opacity: 1;
  transform: scale(1);
}

.track-waveform-container .track-favorite:hover {
  background: rgba(0, 255, 255, 0.5); /* Brighter cyan hover */
  color: #00ffff;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.8);
  transform: scale(1.1);
}

.track-waveform-container .track-favorite.favorited {
  background: #ff5500;
  color: white;
  opacity: 1;
  transform: scale(1);
}

.theme-dark .track-waveform-container .track-favorite,
body.theme-dark .track-waveform-container .track-favorite {
  background: rgba(0, 255, 255, 0.3);
  color: #00ffff;
}

.theme-dark .track-waveform-container .track-favorite:hover,
body.theme-dark .track-waveform-container .track-favorite:hover {
  background: rgba(0, 255, 255, 0.5);
  color: #00ffff;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.8);
}

/* Track Duration */
.track-duration {
  flex-shrink: 0;
  font-size: 12px;
  color: rgba(0, 255, 255, 0.7); /* Cyan text */
  min-width: 40px;
  text-align: right;
  margin-top: -10 px;
}

.theme-dark .track-duration,
body.theme-dark .track-duration {
  color: rgba(0, 255, 255, 0.7);
}

/* Track Actions (Full Layout) - Hide old actions since we moved favorite to waveform */
.track-actions {
  display: none;
}

/* Layout Variations */
.theo-track-list-compact .track-item {
  padding: 8px 16px;
}

.theo-track-list-compact .track-content {
  gap: 12px;
}

.theo-track-list-compact .track-info {
  min-width: 100px;
  max-width: 150px;
}

.theo-track-list-compact .track-waveform-container {
  min-width: 150px;
}

.theo-track-list-full .track-item {
  padding: 16px 24px;
}

.theo-track-list-full .track-content {
  gap: 20px;
}

.theo-track-list-full .track-info {
  min-width: 150px;
  max-width: 250px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .theo-track-list {
    border-radius: 0;
    margin: 10px 0;
  }
  
  .track-list-header {
    padding: 12px 16px;
  }
  
  .track-item {
    padding: 12px 16px;
    min-height: 120px;
  }
  
  .track-play-btn {
    width: 80px;
    height: 100px;
  }
  
  .track-play-btn .play-icon img,
  .track-play-btn .pause-icon img,
  .track-play-btn .loading-icon {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    min-height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
  }
  
  .track-content {
    gap: 10px;
  }
  
  .track-info {
    min-width: 80px;
    max-width: 120px;
  }
  
  .track-waveform-container {
    min-width: 120px;
    height: 40px;
  }
  
  .track-actions {
    display: none; /* Hide actions on mobile */
  }
  
  .track-title {
    font-size: 13px;
  }
  
  .track-artist,
  .track-duration {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .track-content {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .track-info {
    min-width: auto;
    max-width: none;
  }
  
  .track-waveform-container {
    min-width: auto;
    order: 2;
  }
  
  .track-duration {
    order: 3;
    text-align: left;
    margin-top: 4px;
  }
}

/* Animation Classes */
.track-item.loading .track-waveform-container {
  opacity: 0.5;
}

.track-item.playing {
  border-bottom-color: rgba(255, 0, 255, 0.4);
  box-shadow: 0 0 30px rgba(255, 0, 255, 0.3);
  background: rgba(255, 0, 255, 0.1) !important;
}

.track-item.playing .track-progress {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.8; }
}

/* Accessibility */
.track-play-btn:focus,
.track-favorite:focus,
.track-share:focus,
.track-list-refresh:focus,
.track-list-retry:focus {
  outline: 2px solid #ff5500;
  outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .track-item {
    border-bottom-width: 2px;
  }
  
  .track-play-btn {
    border: 2px solid #fff;
  }
  
  .track-progress {
    opacity: 1;
  }
}
