/* ===========================================
   JUKEBOX - Modern Earthy UI Styles
   =========================================== */

/* Base Font Styling */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

.font-display {
  font-family: 'Outfit', 'Inter', system-ui, sans-serif;
}

/* CSS Custom Properties for Colors */
:root {
  --earth-cream: #FDF8F3;
  --earth-sand: #F5EFE6;
  --earth-terracotta: #E07A5F;
  --earth-golden: #F2CC8F;
  --earth-sage: #81B29A;
  --earth-clay: #D4A574;
  --earth-coral: #F4A261;
  --earth-midnight: #1A1A2E;
  --earth-slate: #252A3D;
  --earth-dusk: #2D3250;
  --earth-ink: #2D3436;
  --earth-mist: #F8F9FA;
  --earth-stone: #6B7280;
  --spotify: #1DB954;
}

/* Global Transitions */
* {
  transition-property: background-color, border-color, color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 200ms;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Custom Selection Color */
::selection {
  background-color: rgba(224, 122, 95, 0.3);
  color: var(--earth-ink);
}

.dark ::selection {
  background-color: rgba(244, 162, 97, 0.4);
  color: var(--earth-mist);
}

/* Loading indicator spinner */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Audio waveform loader animation */
@keyframes audio-wave {
  0%, 100% {
    height: 8px;
    opacity: 0.6;
  }
  50% {
    height: 24px;
    opacity: 1;
  }
}

.audio-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
}

.audio-loader span {
  display: block;
  width: 4px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--earth-terracotta), var(--earth-coral));
  animation: audio-wave 1s ease-in-out infinite;
}

.audio-loader span:nth-child(1) { animation-delay: 0s; }
.audio-loader span:nth-child(2) { animation-delay: 0.1s; }
.audio-loader span:nth-child(3) { animation-delay: 0.2s; }
.audio-loader span:nth-child(4) { animation-delay: 0.3s; }
.audio-loader span:nth-child(5) { animation-delay: 0.4s; }

.dark .audio-loader span {
  background: linear-gradient(180deg, var(--earth-coral), var(--earth-golden));
}

#loading-indicator {
  font-size: 1.1rem;
  color: var(--earth-terracotta);
}

.dark #loading-indicator {
  color: var(--earth-coral);
}

/* Dual Range Slider Styling */
#min-year-slider,
#max-year-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 9999px;
  outline: none;
  opacity: 0.85;
  transition: opacity 0.2s;
  pointer-events: auto;
}

#min-year-slider:hover,
#max-year-slider:hover {
  opacity: 1;
}

#min-year-slider::-webkit-slider-thumb,
#max-year-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--spotify), var(--earth-sage));
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 4px 12px rgba(29, 185, 84, 0.35);
  transition: all 0.2s;
  pointer-events: auto;
}

#min-year-slider::-webkit-slider-thumb:hover,
#max-year-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 6px 16px rgba(29, 185, 84, 0.45);
}

#min-year-slider::-moz-range-thumb,
#max-year-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--spotify), var(--earth-sage));
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 4px 12px rgba(29, 185, 84, 0.35);
  transition: all 0.2s;
  pointer-events: auto;
}

#min-year-slider::-moz-range-thumb:hover,
#max-year-slider::-moz-range-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 6px 16px rgba(29, 185, 84, 0.45);
}

/* Dark mode adjustments for dual range sliders */
.dark #min-year-slider::-webkit-slider-thumb,
.dark #max-year-slider::-webkit-slider-thumb {
  border-color: var(--earth-dusk);
}

.dark #min-year-slider::-moz-range-thumb,
.dark #max-year-slider::-moz-range-thumb {
  border-color: var(--earth-dusk);
}

/* Slider track and range styling */
#slider-track {
  pointer-events: none;
}

#slider-range {
  pointer-events: none;
  transition: all 0.2s ease;
}

/* Table Row Styling */
#data-table tr {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

#data-table tr::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--earth-terracotta), var(--earth-coral));
  transition: width 0.3s ease;
}

#data-table tr:hover::after {
  width: 100%;
}

#data-table td {
  color: var(--earth-ink);
  vertical-align: middle;
}

.dark #data-table td {
  color: var(--earth-mist);
}

/* Serial number badge animation */
#data-table tr:hover td:first-child > div {
  background: linear-gradient(135deg, var(--earth-terracotta), var(--earth-coral));
  color: white;
  box-shadow: 0 4px 12px rgba(224, 122, 95, 0.3);
}

.dark #data-table tr:hover td:first-child > div {
  background: linear-gradient(135deg, var(--earth-coral), var(--earth-terracotta));
  box-shadow: 0 4px 12px rgba(244, 162, 97, 0.3);
}

/* Album art in table */
#data-table img {
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#data-table img:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Genre badge hover effect */
#data-table td span[class*="rounded-full"]:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Table header styling */
table thead th {
  position: relative;
  letter-spacing: 0.025em;
}

table thead th::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--earth-terracotta);
  transition: width 0.3s ease;
}

table thead th:hover::after {
  width: 60%;
}

/* Spotify logged-in button styling */
#logged-in-msg {
  position: relative;
  transition: all 0.3s ease;
  border-radius: 0.75rem;
}

#logged-in-msg .checkmark {
  color: var(--spotify);
  font-weight: bold;
  transition: all 0.3s ease;
}

.dark #logged-in-msg .checkmark {
  color: var(--spotify);
}

#logged-in-msg:hover {
  background-color: var(--earth-terracotta) !important;
  color: white !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(224, 122, 95, 0.35);
}

#logged-in-msg:hover .checkmark {
  color: white !important;
}

/* Tags Modal Styling */
#tags-modal-overlay {
  backdrop-filter: blur(8px);
  transition: opacity 0.3s ease;
}

#tags-modal {
  animation: modalSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(-30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Tags button styling */
.tags-button {
  transition: all 0.2s ease;
  border-radius: 0.5rem;
  padding: 0.375rem 0.5rem;
}

.tags-button:hover {
  transform: scale(1.15);
  background-color: rgba(224, 122, 95, 0.15);
}

.dark .tags-button:hover {
  background-color: rgba(244, 162, 97, 0.2);
}

/* Autocomplete suggestions styling */
#autocompleteSuggestions span {
  transition: all 0.2s ease;
  background: linear-gradient(135deg, var(--earth-golden), var(--earth-coral));
  color: var(--earth-ink);
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

#autocompleteSuggestions span:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 4px 12px rgba(242, 204, 143, 0.4);
}

/* Tag chips styling */
#tagsList span,
#existingTagsList span:not(:first-child) {
  transition: all 0.2s ease;
  animation: tagSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background: linear-gradient(135deg, var(--earth-sage), #6ba386);
  color: white;
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}

.dark #tagsList span,
.dark #existingTagsList span:not(:first-child) {
  background: linear-gradient(135deg, var(--earth-terracotta), var(--earth-coral));
}

@keyframes tagSlideIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateX(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

#tagsList span:hover,
#existingTagsList span:not(:first-child):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(129, 178, 154, 0.4);
}

.dark #tagsList span:hover,
.dark #existingTagsList span:not(:first-child):hover {
  box-shadow: 0 4px 12px rgba(224, 122, 95, 0.4);
}

/* Modal close button */
#close-tags-modal {
  transition: all 0.2s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
}

/* Streamgraph Styling */
#streamgraph-container {
  transition: all 0.3s ease;
}

#streamgraph {
  position: relative;
  overflow: visible;
}

.streamgraph-path {
  cursor: pointer;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.streamgraph-path:hover {
  opacity: 0.85;
  filter: brightness(1.1);
}

.streamgraph-tooltip {
  position: absolute;
  z-index: 1000;
  display: none;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.98);
  border: 2px solid var(--earth-terracotta);
  border-radius: 1rem;
  padding: 12px 18px;
  color: var(--earth-ink);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(224, 122, 95, 0.25);
  text-align: left;
  backdrop-filter: blur(12px);
  white-space: nowrap;
}

.dark .streamgraph-tooltip {
  background: rgba(45, 50, 80, 0.98);
  border-color: var(--earth-coral);
  color: var(--earth-mist);
  box-shadow: 0 8px 24px rgba(244, 162, 97, 0.3);
}

.streamgraph-legend-item {
  display: inline-flex;
  align-items: center;
  margin: 6px;
  padding: 8px 14px;
  border-radius: 9999px;
  background: white;
  border: 2px solid var(--earth-sand);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 600;
  color: var(--earth-ink);
}

.dark .streamgraph-legend-item {
  background: var(--earth-slate);
  border-color: var(--earth-dusk);
  color: var(--earth-mist);
}

.streamgraph-legend-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  border-color: var(--earth-terracotta);
}

.dark .streamgraph-legend-item:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  border-color: var(--earth-coral);
}

.streamgraph-legend-item.hidden {
  opacity: 0.35;
  text-decoration: line-through;
  visibility: visible !important;
  pointer-events: all;
}

.streamgraph-legend-item.focused {
  background: rgba(29, 185, 84, 0.15);
  border-color: var(--spotify);
  box-shadow: 0 0 0 4px rgba(29, 185, 84, 0.15);
  transform: scale(1.05);
}

.dark .streamgraph-legend-item.focused {
  background: rgba(29, 185, 84, 0.25);
  border-color: var(--spotify);
  box-shadow: 0 0 0 4px rgba(29, 185, 84, 0.2);
}

.streamgraph-legend-color {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  margin-right: 8px;
  display: inline-block;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Streamgraph loading animation */
#streamgraph.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--earth-stone);
  font-size: 16px;
}

#streamgraph.loading::before {
  content: "🎵";
  margin-right: 10px;
  animation: bounce 1s ease-in-out infinite;
}

/* Streamgraph axis styling */
#streamgraph .axis text {
  fill: var(--earth-ink);
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
}

.dark #streamgraph .axis text {
  fill: var(--earth-mist);
}

#streamgraph .axis path,
#streamgraph .axis line {
  stroke: var(--earth-stone);
  stroke-width: 1;
}

.dark #streamgraph .axis path,
.dark #streamgraph .axis line {
  stroke: rgba(248, 249, 250, 0.3);
}

/* Filter chips styling */
#filter-display span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--earth-golden), var(--earth-coral));
  color: var(--earth-ink);
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(242, 204, 143, 0.3);
  transition: all 0.2s ease;
}

.dark #filter-display span {
  background: linear-gradient(135deg, var(--earth-terracotta), var(--earth-coral));
  color: white;
  box-shadow: 0 2px 8px rgba(224, 122, 95, 0.3);
}

#filter-display span:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(242, 204, 143, 0.4);
}

.dark #filter-display span:hover {
  box-shadow: 0 4px 12px rgba(224, 122, 95, 0.4);
}

#filter-display button {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

#filter-display button:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

/* World Map Container */
#world-map {
  background: linear-gradient(180deg, var(--earth-sand) 0%, var(--earth-cream) 100%);
  border: 2px solid var(--earth-sand);
}

.dark #world-map {
  background: linear-gradient(180deg, var(--earth-slate) 0%, var(--earth-midnight) 100%);
  border-color: var(--earth-slate);
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--earth-sand);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--earth-terracotta), var(--earth-coral));
  border-radius: 5px;
  border: 2px solid var(--earth-sand);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--earth-coral), var(--earth-terracotta));
}

.dark ::-webkit-scrollbar-track {
  background: var(--earth-slate);
}

.dark ::-webkit-scrollbar-thumb {
  border-color: var(--earth-slate);
}

/* Focus states for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--earth-terracotta);
  outline-offset: 2px;
}

.dark button:focus-visible,
.dark input:focus-visible,
.dark select:focus-visible,
.dark textarea:focus-visible {
  outline-color: var(--earth-coral);
}

/* Spotify button special styling - preserved green */
#login-link,
#create-playlist-button {
  background: var(--spotify) !important;
}

/* Font Awesome Icon Animations */
.fa-spin {
  animation: fa-spin 1s linear infinite;
}

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

/* Icon hover effects */
button i,
a i {
  transition: transform 0.2s ease, color 0.2s ease;
}

button:hover i:not(.fa-spinner),
a:hover i:not(.fa-spinner) {
  transform: scale(1.1);
}

/* Rotating disc animation for loading */
.fa-compact-disc {
  animation: disc-spin 2s linear infinite;
}

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

/* Pulse animation for icons */
.icon-pulse {
  animation: icon-pulse 2s ease-in-out infinite;
}

@keyframes icon-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

/* Action buttons in table */
.action-btn {
  padding: 0.375rem 0.625rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background-color: rgba(224, 122, 95, 0.15);
  transform: scale(1.1);
}

.dark .action-btn:hover {
  background-color: rgba(244, 162, 97, 0.2);
}

/* Play button special hover */
.play-btn:hover {
  color: var(--spotify);
}

/* Text gradient utility */
.text-gradient {
  background: linear-gradient(135deg, var(--earth-terracotta), var(--earth-coral));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Glassmorphism effect for cards */
.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.dark .glass {
  background: rgba(45, 50, 80, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Subtle pattern background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23E07A5F' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  z-index: -1;
}

.dark body::before {
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23F4A261' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Upgrade toast animation */
.animate-fade-in {
  animation: toastFadeIn 0.3s ease-out;
}

@keyframes toastFadeIn {
  0% {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
