:root {
  --bg-primary: #030303;
  --bg-secondary: #212121;
  --bg-hover: #3d3d3d;
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --accent-color: #ff0000;
  --border-color: rgba(255, 255, 255, 0.1);
  --font-family: 'Roboto', sans-serif;
  --transition-speed: 0.2s;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-secondary);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--bg-hover);
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding-bottom: 90px; /* Space for the bottom player */
}

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background-color: rgba(3, 3, 3, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-input {
  background-color: var(--bg-secondary);
  border: 1px solid transparent;
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 20px;
  width: 300px;
  font-size: 0.9rem;
  transition: border-color var(--transition-speed), background-color var(--transition-speed);
}

.search-input:focus {
  outline: none;
  border-color: var(--text-secondary);
  background-color: var(--bg-hover);
}

.sort-select {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: none;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}

/* Toggle Switch */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
}

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-hover);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--accent-color);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Layout */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  padding: 32px;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  background-color: var(--bg-primary);
}

.stats-card {
  margin-bottom: 40px;
}

.sidebar h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.artist-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.artist-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  border-radius: 4px;
  transition: background-color var(--transition-speed);
}

.artist-list li:hover {
  background-color: var(--bg-hover);
}

.artist-name {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
}

.artist-count {
  color: var(--text-secondary);
  font-size: 0.8rem;
  background-color: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Main Content */
.content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  position: relative;
}

.songs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

.song-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 8px;
  padding: 12px;
  background-color: transparent;
  transition: background-color var(--transition-speed);
}

.song-card:hover {
  background-color: var(--bg-secondary);
}

.thumbnail-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--bg-hover);
}

.thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.song-card:hover .thumbnail {
  transform: scale(1.05);
}

.play-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity var(--transition-speed);
}

.song-card:hover .play-overlay {
  opacity: 1;
}

.play-icon {
  width: 48px;
  height: 48px;
  fill: white;
}

.song-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.song-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.song-title:hover {
  text-decoration: underline;
}

.song-artist {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.song-artist:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.song-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.loading, .no-results {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 1.2rem;
}

.hidden {
  display: none !important;
}

/* Bottom Player */
.bottom-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 90px;
  background-color: #121212;
  border-top: 1px solid var(--border-color);
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.player-thumbnail {
  width: 64px;
  height: 64px;
  border-radius: 4px;
  object-fit: cover;
}

.player-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-title {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-artist {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
}

.play-pause-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-speed);
}

.play-pause-btn:hover:not(:disabled) {
  background-color: var(--bg-hover);
}

.play-pause-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }
  .search-input {
    width: 100%;
  }
  .controls {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }
  .sort-select {
    width: 100%;
  }
  .main-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
  }
  .content {
    padding: 16px;
  }
  .bottom-player {
    padding: 0 12px;
    height: 70px;
  }
  .player-info {
    width: auto;
  }
  .app-container {
    padding-bottom: 70px;
  }
  .player-thumbnail {
    width: 48px;
    height: 48px;
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 20px;
    display: none; /* Alternatively, make it a toggleable menu */
  }

  .topbar {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    align-items: stretch;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .search-input {
    width: 100%;
  }

  .content {
    padding: 16px;
  }

  .songs-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
  }
}
