/* =========================
   VARIABLES
========================= */
:root {
  /* Colors */
  --bg-main: #0f0f0f;
  --bg-card: #181818;
  --bg-input: #121212;
  --bg-border: #2a2a2a;
  
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #777777;
  --text-rank: #666666;
  
  --brand-green: #1db954;
  --brand-green-alpha: rgba(29, 185, 84, 0.25);
  --shadow-standard: 0 8px 24px rgba(0, 0, 0, 0.4);
  
  /* Spacing & Radius */
  --radius-lg: 14px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --transition-fast: 0.2s ease;
}

/* =========================
   BASE
========================= */
body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  margin: 0;
}

h1, h3, h5 {
  font-weight: 700;
}

/* =========================
   CARDS / CONTAINERS
========================= */
.card,
.album-card,
canvas {
  background: var(--bg-card) !important;
  box-shadow: var(--shadow-standard) !important;
  border: none !important;
  border-radius: var(--radius-md);
}

/* =========================
   SUMMARY CARDS
========================= */
.card-title {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.card-text {
  color: var(--text-primary);
}

.text-gray {
  color: var(--text-secondary) !important;
}

.text-green {
  color: var(--brand-green) !important;
}

.mdi {
  font-size: 1.1em;
  vertical-align: middle;
  opacity: 0.9;
}

.btn-sync:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* =========================
   FILTER BAR
========================= */
.filters-bar {
  display: flex;
  justify-content: space-between; 
  gap: 16px;
  align-items: center;
  background: var(--bg-card);
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

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

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.filter-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filter-select {
  appearance: none;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--bg-border);
  border-radius: 10px;
  padding: 10px 36px 10px 12px;
  font-size: 0.9rem;
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}

.filter-select:hover {
  border-color: var(--brand-green);
}

.filter-select:focus {
  outline: none;
  border-color: var(--brand-green);
  box-shadow: 0 0 0 2px var(--brand-green-alpha);
}

/* =========================
   RANGE FILTERS
========================= */
.range-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.range-pill {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.range-pill:hover {
  border-color: var(--brand-green);
  color: var(--text-primary);
}

.range-pill.active {
  background: var(--brand-green);
  color: #000000;
  border-color: var(--brand-green);
  font-weight: 600;
}

/* =========================
   GRÁFICOS
========================= */
canvas {
  padding: 16px;
}

/* =========================
   ÁLBUNS — SCROLL HORIZONTAL
========================= */
.albums-scroll {
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px;
  white-space: nowrap;
  scroll-snap-type: x mandatory;
}

.albums-scroll::-webkit-scrollbar {
  height: 8px;
}

.albums-scroll::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

.albums-scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* =========================
   CARD DE ÁLBUM
========================= */
.album-card {
  flex: 0 0 auto;          
  width: 160px;
  display: flex;
  flex-direction: column;
  padding: 10px;
  text-align: center;
  scroll-snap-align: start;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.album-card:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6) !important;
}

.album-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.album-card strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text-primary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.album-card span {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.album-card small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* =========================
   TOP TRACKS LIST (TABELA)
========================= */
.top-songs-list {
  max-height: 320px;
  overflow-y: auto;
  font-size: 0.9rem;
  color: #eaeaea;
}

.top-songs-header,
.top-song-row {
  display: grid;
  grid-template-columns: 32px 1fr 70px 80px;
  gap: 8px;
  align-items: center;
}

.top-songs-header {
  font-weight: 600;
  opacity: 0.7;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  margin-bottom: 6px;
}

.top-song-row {
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.top-song-row:last-child {
  border-bottom: none;
}

.song-title {
  font-weight: 500;
}

.song-artist {
  font-size: 0.8rem;
  opacity: 0.6;
}

.song-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.song-cover {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.song-position {
  color: var(--text-rank) !important;
}

.track-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #1f1f1f; 
  transition: background-color var(--transition-fast);
}

.track-item:hover {
  background-color: var(--bg-input);
}

.track-info {
  display: flex;
  align-items: center;
  flex-grow: 1;
  color: var(--text-primary);
}

.track-image {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 12px;
}

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

.track-title {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-artist {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.track-album, .track-plays {
  flex-basis: 150px; 
  text-align: right;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-left: 16px;
  flex-shrink: 0;
}

.track-plays {
  flex-basis: 120px; 
  font-weight: 600;
  color: var(--text-primary);
}

/* =========================
   TOP ARTISTS LIST
========================= */
.top-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 6px;
  color: #eaeaea !important;
}

strong {
  color: #eaeaea !important;
}

.top-row {
  display: grid;
  grid-template-columns: 24px 40px 1fr auto;
  align-items: center;
  gap: 10px;
}

.top-row .rank {
  color: var(--text-rank);
  font-size: 0.9rem;
}

.cover.artist {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.top-row .meta strong {
  display: block;
  font-size: 0.9rem;
}

.top-row .meta small {
  color: #888;
  font-size: 0.75rem;
}

/* =========================
   NAVBAR
========================= */
.navbar {
  border-bottom: 1px solid #222;
  background-color: var(--bg-main) !important;
  display: flex;
  justify-content: space-between;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 12px;
  font-size: 1rem;
  cursor: pointer;
  transition: color var(--transition-fast), border-bottom var(--transition-fast);
  text-decoration: none;
}

.nav-btn:hover {
  color: var(--text-primary);
}

.nav-btn.active {
  color: var(--brand-green);
  border-bottom: 3px solid var(--brand-green);
  font-weight: 600;
}

/* =========================
   SCROBBLES RECENTES
========================= */
.scrobble-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
}

.scrobble-cover {
  width: 56px;
  height: 56px;
  background: #ddd;
  flex-shrink: 0;
}

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

.scrobble-info {
  flex: 1;
}

.scrobble-track {
  font-weight: 600;
}

.scrobble-artist {
  font-size: 0.9rem;
  opacity: 0.8;
}

.scrobble-time {
  font-size: 0.8rem;
  opacity: 0.6;
}

#load-more-scrobbles {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--text-primary);
  font-weight: 500;
  letter-spacing: 0.3px;
  padding: 14px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

#load-more-scrobbles:active {
  transform: scale(0.98);
}

#load-more-scrobbles:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#load-more-scrobbles:hover {
  background: linear-gradient(
    90deg,
    rgba(29, 185, 84, 0.06),
    rgba(29, 185, 84, 0.12)
  );
}

#global-loading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* =========================
   RESPONSIVE FILTER BAR
========================= */
@media (max-width: 768px) {

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .range-filters {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .range-filters::-webkit-scrollbar {
    display: none;
  }

  .range-pill {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.8rem;
    padding: 8px 14px;
  }

  .manual-filters {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .filter-group {
    min-width: unset;
    width: 100%;
  }

  .filter-select {
    width: 100%;
  }
}
