/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #555577, #444466);
  border-radius: 6px;
  border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--accent-primary), #aa1550);
}

::-webkit-scrollbar-corner {
  background: var(--bg-primary);
}

/* Firefox scrollbar */
* {
  scrollbar-width: auto;
  scrollbar-color: #555577 var(--bg-primary);
}

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252540;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --accent-primary: #e91e63;
  --accent-secondary: #00bcd4;
  --border-color: #333355;
  --success: #4caf50;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Sticky top section */
.top-section {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  padding-bottom: 10px;
}

/* Header */
.header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0 12px;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo-img {
  height: 140px;
  width: auto;
}

.country-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.country-tab {
  padding: 8px 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.country-tab:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.country-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Filters */
.filters {
  display: flex;
  gap: 20px;
  padding: 20px 0;
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 250px;
}

.search-box input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.search-box input::placeholder {
  color: var(--text-secondary);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.filter-group select {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.stats {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-left: auto;
}

/* Player */
.player {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
  margin-bottom: 20px;
}

.player-art {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.player-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.player-art img[src]:not([src=""]) {
  display: block;
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.player-controls {
  flex-shrink: 0;
}

.btn-play-pause,
.btn-play {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: var(--accent-primary);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.2s;
}

.btn-play:hover {
  background: #c2185b;
  transform: scale(1.05);
}

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

.player-progress {
  flex: 2;
  min-width: 150px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  background: var(--accent-primary);
  width: 0%;
  transition: width 0.1s linear;
}

.progress-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Table */
.table-container {
  overflow-x: auto;
  overflow-y: auto;
  border-radius: 12px;
  background: var(--bg-secondary);
  flex: 1;
  min-height: 0; /* Important for flex scrolling */
}

.song-table {
  width: 100%;
  border-collapse: collapse;
}

.song-table th,
.song-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.song-table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.song-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.song-table th.sortable:hover {
  color: var(--text-primary);
}

.song-table th.sorted-asc::after {
  content: ' ▲';
  font-size: 0.7em;
}

.song-table th.sorted-desc::after {
  content: ' ▼';
  font-size: 0.7em;
}

.song-table tbody tr {
  transition: background 0.15s;
}

.song-table tbody tr:hover {
  background: var(--bg-tertiary);
}

.song-table tbody tr.playing {
  background: rgba(233, 30, 99, 0.1);
}

.song-table tbody tr.no-preview {
  opacity: 0.5;
}

/* Column widths */
.col-art {
  width: 60px;
}

.col-artist {
  min-width: 150px;
}

.col-title {
  min-width: 200px;
}

.col-lang {
  width: 60px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.col-year {
  width: 80px;
}

.col-peak {
  width: 70px;
}

.col-weeks {
  width: 80px;
}

.col-play {
  width: 60px;
}

/* Song artwork */
.song-art {
  width: 45px;
  height: 45px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.song-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Play button in table */
.btn-play-small {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-play-small:hover {
  background: var(--accent-primary);
  color: white;
}

.btn-play-small.playing {
  background: var(--accent-primary);
  color: white;
}

.btn-play-small:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Peak position styling */
.peak-1 {
  color: #ffd700;
  font-weight: bold;
}

.peak-top10 {
  color: var(--accent-secondary);
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-secondary);
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px;
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 16px;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 100%;
  }

  .filter-group {
    justify-content: space-between;
  }

  .stats {
    margin-left: 0;
    text-align: center;
  }

  .player {
    flex-wrap: wrap;
  }

  .player-progress {
    width: 100%;
    order: 5;
  }

  .col-weeks {
    display: none;
  }
}

@media (max-width: 480px) {
  .col-peak,
  .col-year,
  .col-lang {
    display: none;
  }

  .song-table th,
  .song-table td {
    padding: 10px 8px;
  }
}

/* Edit Mode Styles */
.edit-mode-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.btn-edit {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-edit:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.btn-edit.active {
  background: var(--accent-primary);
  color: #000;
  border-color: var(--accent-primary);
}

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

.edit-status {
  color: var(--accent-primary);
  font-size: 13px;
  font-weight: 500;
}

.lang-select {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  width: 80px;
}

.lang-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.lang-select.changed {
  border-color: var(--accent-secondary);
  background: rgba(255, 177, 66, 0.1);
}

tr.has-change {
  background: rgba(255, 177, 66, 0.05);
}

tr.has-change:hover {
  background: rgba(255, 177, 66, 0.1);
}

/* Mostly Vibes branding */
.mostlyvibes-brand {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px 10px;
  background: var(--bg-secondary);
  border-bottom-left-radius: 12px;
  border-left: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  transition: opacity 0.2s;
}

.mostlyvibes-brand:hover {
  opacity: 1;
}

.mostlyvibes-tagline {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}

.mostlyvibes-brand a {
  display: block;
  line-height: 0;
}

.mostlyvibes-brand img {
  height: 50px;
  width: auto;
}

@media (max-width: 768px) {
  .mostlyvibes-brand {
    padding: 8px 10px 6px;
  }

  .mostlyvibes-brand img {
    height: 35px;
  }

  .mostlyvibes-tagline {
    font-size: 0.6rem;
  }
}
