/**
 * Song Filter Bar Module Styles
 * Neon-accented search bar with realtime filtering
 */

/* Base Song Filter Bar Container */
.theo-song-filter-bar {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: transparent;
  border-radius: 12px;
  box-shadow: none;
  overflow: visible;
  margin: 20px 0;
  max-width: 100%;
  position: relative;
}

/* When searching, show background and shadow */
.theo-song-filter-bar.has-results {
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Dark theme support */
.theme-dark .theo-song-filter-bar,
body.theme-dark .theo-song-filter-bar {
  background: #1a1a1a;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Search Bar Container */
.song-filter-search-container {
  position: relative;
  padding: 0;
  background: transparent;
  border-bottom: none;
}

/* When searching, add padding and background */
.theo-song-filter-bar.has-results .song-filter-search-container {
  padding: 20px;
  background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
  border-bottom: 1px solid #e9ecef;
}

.theme-dark .theo-song-filter-bar.has-results .song-filter-search-container,
body.theme-dark .theo-song-filter-bar.has-results .song-filter-search-container {
  background: linear-gradient(180deg, #2d3748 0%, #1a1a1a 100%);
  border-bottom-color: #4a5568;
}

/* Search Input Wrapper */
.song-filter-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 100%;
  width: 100%;
}

/* Search Input */
.song-filter-input {
  width: 100%;
  padding: 14px 45px 14px 60px !important; /* top right bottom left - 60px left for icon (20px icon + 40px gap), 45px right for clear */
  font-size: 18px;
  font-weight: 500;
  border: 2px solid #e9ecef;
  border-radius: 50px; /* Fully rounded when not searching */
  background: #fff;
  color: #333;
  transition: all 0.3s ease;
  outline: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  box-sizing: border-box !important; /* Ensure padding is included in width calculation */
  text-indent: 0 !important; /* Ensure no text indentation */
  margin: 0; /* Remove any margins */
}

/* When searching, make it less rounded */
.theo-song-filter-bar.has-results .song-filter-input {
  border-radius: 8px;
}

.theme-dark .song-filter-input,
body.theme-dark .song-filter-input {
  background: #2d3748;
  border-color: #4a5568;
  color: #e5e7eb;
}

.song-filter-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.theme-dark .song-filter-input::placeholder,
body.theme-dark .song-filter-input::placeholder {
  color: #6b7280;
}

/* Neon accent on focus - using CSS variables for dynamic colors */
.song-filter-input:focus {
  border-color: var(--theo-accent-color, #f97316);
  box-shadow: 
    0 0 0 3px rgba(249, 115, 22, 0.1),
    0 0 20px rgba(249, 115, 22, 0.3),
    0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.theme-dark .song-filter-input:focus,
body.theme-dark .song-filter-input:focus {
  border-color: var(--theo-accent-color, #f97316);
  box-shadow: 
    0 0 0 3px rgba(249, 115, 22, 0.2),
    0 0 30px rgba(249, 115, 22, 0.4),
    0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Search Icon */
.song-filter-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  min-width: 20px;
  max-width: 20px;
  pointer-events: none;
  color: #9ca3af;
  transition: color 0.3s ease;
  z-index: 1; /* Behind text but visible */
  flex-shrink: 0; /* Prevent icon from shrinking */
  display: block; /* Ensure it's a block element */
  overflow: visible; /* Ensure icon doesn't clip */
}

.song-filter-input:focus ~ .song-filter-search-icon {
  color: var(--theo-accent-color, #f97316);
}

.theme-dark .song-filter-search-icon,
body.theme-dark .song-filter-search-icon {
  color: #6b7280;
}

.theme-dark .song-filter-input:focus ~ .song-filter-search-icon,
body.theme-dark .song-filter-input:focus ~ .song-filter-search-icon {
  color: var(--theo-accent-color, #f97316);
  filter: drop-shadow(0 0 4px rgba(249, 115, 22, 0.6));
}

/* Clear Button */
.song-filter-clear {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 18px;
  line-height: 1;
}

.song-filter-clear.visible {
  display: flex;
}

.song-filter-clear:hover {
  background: rgba(249, 115, 22, 0.1);
  color: var(--theo-accent-color, #f97316);
  transform: translateY(-50%) scale(1.1);
}

.theme-dark .song-filter-clear,
body.theme-dark .song-filter-clear {
  color: #6b7280;
}

.theme-dark .song-filter-clear:hover,
body.theme-dark .song-filter-clear:hover {
  background: rgba(249, 115, 22, 0.2);
  color: var(--theo-accent-color, #f97316);
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.3);
}

/* Loading Indicator */
.song-filter-loading {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(249, 115, 22, 0.2);
  border-top-color: var(--theo-accent-color, #f97316);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.song-filter-loading.active {
  display: block;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* Results Container */
.song-filter-results {
  min-height: 200px;
  background: #fff;
  display: none; /* Hidden by default */
}

.theo-song-filter-bar.has-results .song-filter-results {
  display: block; /* Show when searching */
}

.theme-dark .song-filter-results,
body.theme-dark .song-filter-results {
  background: #1a1a1a;
}

/* Ensure track list inside results gets dark mode */
.theme-dark .song-filter-results .theo-track-list,
body.theme-dark .song-filter-results .theo-track-list {
  background: #1a1a1a;
  color: #e5e7eb;
}

.theme-dark .song-filter-results .theo-track-list .track-list-container,
body.theme-dark .song-filter-results .theo-track-list .track-list-container {
  background: #1a1a1a;
}

/* Empty State */
.song-filter-empty {
  padding: 60px 20px;
  text-align: center;
  color: #9ca3af;
  display: none;
  background: #fff;
}

.theo-song-filter-bar.has-results .song-filter-empty.visible {
  display: block;
}

.theme-dark .song-filter-empty,
body.theme-dark .song-filter-empty {
  background: #1a1a1a;
}

.theme-dark .song-filter-empty,
body.theme-dark .song-filter-empty {
  color: #6b7280;
}

.song-filter-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.song-filter-empty-text {
  font-size: 16px;
  font-weight: 500;
}

/* Error State */
.song-filter-error {
  padding: 40px 20px;
  text-align: center;
  color: #ef4444;
  display: none;
  background: #fff;
}

.theo-song-filter-bar.has-results .song-filter-error.visible {
  display: block;
}

.theme-dark .song-filter-error,
body.theme-dark .song-filter-error {
  background: #1a1a1a;
}

.theme-dark .song-filter-error,
body.theme-dark .song-filter-error {
  color: #f87171;
}

.song-filter-error-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.song-filter-error-text {
  font-size: 14px;
  margin-bottom: 12px;
}

.song-filter-retry {
  background: var(--theo-accent-color, #f97316);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.song-filter-retry:hover {
  background: #ea580c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

/* Track List Integration */
.song-filter-results .theo-track-list {
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  border: none;
  background: #fff;
}

.theme-dark .song-filter-results .theo-track-list,
body.theme-dark .song-filter-results .theo-track-list {
  background: #1a1a1a;
}

.song-filter-results .track-list-container {
  padding: 0;
  background: #fff;
}

.theme-dark .song-filter-results .track-list-container,
body.theme-dark .song-filter-results .track-list-container {
  background: #1a1a1a;
}

/* Responsive Design */
@media (max-width: 768px) {
  .song-filter-input {
    font-size: 16px;
    padding: 12px 40px 12px 55px; /* 55px left for icon on mobile too */
  }
  
  .song-filter-search-icon {
    left: 18px;
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
  }
  
  .song-filter-clear {
    right: 18px;
    width: 28px;
    height: 28px;
  }
  
  .theo-song-filter-bar.has-results .song-filter-search-container {
    padding: 16px;
  }
}

/* Animation for results appearing */
.song-filter-results .track-list-container {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

