/* =============================================================
   Traklife Spotify Player — native UI styles (light theme)
   ============================================================= */

/* ── Container ─────────────────────────────────────────────── */
.tl-spotify-player {
  position: relative;
  font-family: inherit;
  color: #111;
  padding-bottom: 90px; /* reserve room for fixed player bar */
}

/* ── Connect banner ─────────────────────────────────────────── */
.tl-connect-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(29, 185, 84, 0.08);
  border: 1px solid rgba(29, 185, 84, 0.35);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tl-connect-text {
  font-size: .875rem;
  color: rgba(0, 0, 0, .65);
  flex: 1;
  min-width: 140px;
}

.tl-connect-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1db954;
  color: #000;
  font-weight: 700;
  font-size: .8125rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 9px 22px;
  border: none;
  border-radius: 500px;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.tl-connect-btn svg  { flex-shrink: 0; }
.tl-connect-btn:hover  { background: #17a349; transform: scale(1.03); }
.tl-connect-btn:active { transform: scale(.97); }

/* ── Status bar (shown when connected) ─────────────────────── */
.tl-player-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(29, 185, 84, 0.08);
  border-radius: 6px;
  padding: 8px 14px;
  margin-bottom: 20px;
  font-size: .8125rem;
}

.tl-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1db954;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(29, 185, 84, .6);
  animation: tl-pulse 2s ease-in-out infinite;
}

@keyframes tl-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .45; }
}

.tl-status-text {
  flex: 1;
  color: rgba(0, 0, 0, .7);
}

.tl-disconnect-btn {
  background: none;
  border: 1px solid rgba(0, 0, 0, .22);
  color: rgba(0, 0, 0, .45);
  font-size: .75rem;
  padding: 4px 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tl-disconnect-btn:hover {
  color: #111;
  border-color: rgba(0, 0, 0, .5);
}

/* ── Track list ─────────────────────────────────────────────── */
.tl-track-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tl-no-tracks {
  padding: 32px 0;
  text-align: center;
  color: rgba(0, 0, 0, .4);
  font-size: .9rem;
}

.tl-track-item {
  display: grid;
  grid-template-columns: 28px 56px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background .12s ease;
  cursor: default;
}
.tl-track-item:hover      { background: rgba(0, 0, 0, .05); }
.tl-track-item.is-playing { background: rgba(29, 185, 84, .08); }

/* Track number */
.tl-track-num {
  text-align: right;
  font-size: .875rem;
  color: rgba(0, 0, 0, .35);
  font-variant-numeric: tabular-nums;
}
.tl-track-item.is-playing .tl-track-num { color: #1db954; }

/* Album art + play button overlay */
.tl-track-art {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(0, 0, 0, .07);
}
.tl-track-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tl-track-play-btn {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s ease;
  color: #fff;
  padding: 0;
}
.tl-track-item:hover .tl-track-play-btn,
.tl-track-item.is-playing .tl-track-play-btn {
  opacity: 1;
}
.tl-track-play-btn svg { width: 22px; height: 22px; }

/* Track info */
.tl-track-info { min-width: 0; }

.tl-track-name {
  font-size: .9375rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #111;
  line-height: 1.3;
}
.tl-track-item.is-playing .tl-track-name { color: #17a349; }

.tl-track-meta {
  display: flex;
  gap: 6px;
  margin-top: 3px;
  font-size: .8125rem;
  color: rgba(0, 0, 0, .5);
  white-space: nowrap;
  overflow: hidden;
}
.tl-track-artist { flex-shrink: 0; }
.tl-track-album {
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-track-album::before { content: '·'; margin-right: 6px; opacity: .4; }

/* Duration */
.tl-track-duration {
  font-size: .8125rem;
  color: rgba(0, 0, 0, .45);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Preview / Full badge */
.tl-track-preview-badge {
  font-size: .6875rem;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.tl-track-preview-badge.has-preview {
  background: rgba(0, 0, 0, .07);
  color: rgba(0, 0, 0, .45);
}
.tl-track-preview-badge.no-preview {
  background: rgba(29, 185, 84, .12);
  color: #17a349;
}

/* ── Persistent player bar ──────────────────────────────────── */
.tl-player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  /* shown via JS (display: flex) */
  align-items: center;
  gap: 14px;
  background: #f7f7f7;
  border-top: 1px solid rgba(0, 0, 0, .10);
  padding: 10px 24px;
  border-radius: 0;
  z-index: 9999;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, .08);
  box-sizing: border-box;
}

/* Album art thumbnail */
.tl-bar-art {
  width: 46px;
  height: 46px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(0, 0, 0, .07);
}
.tl-bar-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Track info */
.tl-bar-info { flex: 1; min-width: 0; }

.tl-bar-track-name {
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #111;
  line-height: 1.3;
}
.tl-bar-track-artist {
  font-size: .75rem;
  color: rgba(0, 0, 0, .5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Controls */
.tl-bar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.tl-bar-controls button {
  background: none;
  border: none;
  color: rgba(0, 0, 0, .55);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 5px;
  transition: color .15s, background .15s;
}
.tl-bar-controls button:hover { color: #111; background: rgba(0, 0, 0, .08); }
.tl-bar-controls svg { width: 20px; height: 20px; }

/* Central play/pause — dark circle on light bar */
.tl-bar-play-pause {
  background: #111 !important;
  color: #fff !important;
  width: 34px;
  height: 34px;
  padding: 0 !important;
}
.tl-bar-play-pause:hover { background: #333 !important; }
.tl-bar-play-pause svg { width: 21px; height: 21px; }

/* Progress row */
.tl-bar-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 2;
  min-width: 0;
}
.tl-bar-time-current,
.tl-bar-time-total {
  font-size: .7rem;
  color: rgba(0, 0, 0, .4);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.tl-bar-progress-track {
  flex: 1;
  height: 4px;
  background: rgba(0, 0, 0, .12);
  border-radius: 2px;
  overflow: hidden;
}
.tl-bar-progress-fill {
  height: 100%;
  background: #1db954;
  border-radius: 2px;
  transition: width .5s linear;
  will-change: width;
}

/* Mode label (Preview / Full Track) */
.tl-bar-mode {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #17a349;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Toast notification ─────────────────────────────────────── */
.tl-toast {
  position: fixed;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(20, 20, 20, .92);
  color: #fff;
  font-size: .875rem;
  line-height: 1.45;
  padding: 11px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  max-width: min(90vw, 380px);
  text-align: center;
  z-index: 9999;
}
.tl-toast.tl-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Section titles ─────────────────────────────────────────── */
.tl-section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: #111;
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, .08);
}

/* ── Album grid ─────────────────────────────────────────────── */
.tl-album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.tl-album-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  padding: 8px;
  transition: background .12s ease;
}
.tl-album-card:hover  { background: rgba(0, 0, 0, .05); }
.tl-album-card.is-active { background: rgba(29, 185, 84, .07); }

.tl-album-art {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, .07);
  flex-shrink: 0;
}
.tl-album-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tl-album-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: opacity .15s ease;
}
.tl-album-card:hover .tl-album-overlay { opacity: 1; }
.tl-album-card.is-active .tl-album-overlay {
  opacity: 1;
  background: rgba(29, 185, 84, .55);
}
/* Flip chevron when expanded */
.tl-album-card.is-active .tl-album-overlay svg {
  transform: rotate(180deg);
}

.tl-album-info { min-width: 0; }

.tl-album-name {
  font-size: .875rem;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.tl-album-card.is-active .tl-album-name { color: #17a349; }

.tl-album-meta {
  font-size: .75rem;
  color: rgba(0, 0, 0, .45);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Expanded album panel ───────────────────────────────────── */
.tl-album-expanded {
  margin-top: 12px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 8px;
  overflow: hidden;
}

.tl-album-expanded-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(29, 185, 84, .05);
  border-bottom: 1px solid rgba(0, 0, 0, .07);
}

.tl-album-expanded-art {
  width: 56px;
  height: 56px;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(0, 0, 0, .07);
}
.tl-album-expanded-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tl-album-expanded-info { min-width: 0; }

.tl-album-expanded-name {
  font-size: .9375rem;
  font-weight: 700;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-album-expanded-meta {
  font-size: .8125rem;
  color: rgba(0, 0, 0, .5);
  margin-top: 3px;
}

/* Track list inside expanded album uses same .tl-track-list styles */
.tl-album-expanded .tl-track-list {
  padding: 6px 0;
}

/* ── Save-to-playlist button ────────────────────────────────── */
.tl-save-to-playlist-btn {
  background: none;
  border: none;
  color: rgba(0, 0, 0, .38);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.tl-save-to-playlist-btn:hover {
  color: #1db954;
  background: rgba(29, 185, 84, .08);
}
.tl-save-to-playlist-btn svg { display: block; }

/* Track grid now has a 6th column for the save button */
.tl-track-item {
  grid-template-columns: 28px 56px 1fr auto auto 28px;
}

/* ── Playlist dropdown ──────────────────────────────────────── */
.tl-playlist-dropdown {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .14);
  min-width: 220px;
  max-width: 300px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
}

.tl-playlist-header {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, .45);
  padding: 8px 14px 6px;
  border-bottom: 1px solid rgba(0, 0, 0, .07);
  margin-bottom: 4px;
}

.tl-playlist-loading,
.tl-playlist-empty {
  font-size: .8125rem;
  color: rgba(0, 0, 0, .45);
  padding: 12px 14px;
  text-align: center;
}

.tl-playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  padding: 7px 14px;
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}
.tl-playlist-item:hover { background: rgba(0, 0, 0, .05); }

.tl-playlist-img {
  width: 36px;
  height: 36px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(0, 0, 0, .07);
}
.tl-playlist-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: rgba(0, 0, 0, .3);
}

.tl-playlist-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tl-playlist-name {
  font-size: .875rem;
  font-weight: 500;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.tl-playlist-count {
  font-size: .75rem;
  color: rgba(0, 0, 0, .45);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* display:none items are fully removed from grid auto-placement,
     so only define columns for the 4 visible children:
     art | info | duration | save-btn */
  .tl-track-item {
    grid-template-columns: 46px 1fr auto 28px;
    padding: 6px 8px;
    gap: 10px;
  }
  .tl-track-num,
  .tl-track-preview-badge { display: none; }

  /* Hide album subtitle on mobile to keep rows compact */
  .tl-track-album { display: none; }

  .tl-track-art { width: 46px; height: 46px; }

  .tl-player-bar { gap: 10px; padding: 8px 12px; }
  .tl-bar-progress { display: none; }
  .tl-bar-mode { display: none; }
}

@media (max-width: 480px) {
  .tl-connect-banner { flex-direction: column; align-items: flex-start; }
  .tl-connect-btn { align-self: flex-start; }

  .tl-album-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
  }

  .tl-album-expanded-header { padding: 10px 12px; }
}
