/* ============================================================
   JooseBox — Spotify-clone stylesheet
   ============================================================ */

/* Variables */
:root {
  --bg: #121212;
  --surface: #181818;
  --surface2: #282828;
  --surface3: #3e3e3e;
  --border: #282828;
  --accent: #1db954;
  --accent-hover: #1ed760;
  --discord: #5865f2;
  --text: #ffffff;
  --text-muted: #b3b3b3;
  --text-dim: #6a6a6a;
  --radius: 8px;
  --radius-sm: 4px;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --npbar-height: 90px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Circular', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { background: none; border: none; cursor: pointer; color: inherit; font: inherit; }
img { display: block; }
select { background: var(--surface2); color: var(--text); border: none; border-radius: var(--radius-sm); padding: 6px 10px; font: inherit; cursor: pointer; outline: none; }
input[type="text"], input[type="search"] {
  background: var(--surface2);
  color: var(--text);
  border: none;
  border-radius: 500px;
  padding: 8px 16px;
  font: inherit;
  outline: none;
}
input[type="text"]::placeholder { color: var(--text-dim); }
ol, ul { list-style: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================================
   APP SHELL — CSS Grid layout
   ============================================================ */
.app { height: 100%; overflow: hidden; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr var(--npbar-height);
  grid-template-areas:
    "sidebar topbar"
    "sidebar main"
    "npbar   npbar";
  height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  grid-area: sidebar;
  background: #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 0;
}

.sidebar-top {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 8px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  padding: 12px 8px 16px;
}
.logo-icon { color: var(--accent); flex-shrink: 0; }

/* Nav */
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  transition: color .15s, background .15s;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { color: var(--text); }
.nav-item.active { color: var(--text); }

/* Sidebar sections */
.sidebar-section { padding: 0 8px 12px; }
.sidebar-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 8px 0 6px;
}

.guild-select { width: 100%; font-size: 13px; }

/* Sidebar playlists */
.sidebar-playlists { display: flex; flex-direction: column; gap: 2px; }
.sidebar-playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .15s;
}
.sidebar-playlist-item:hover { color: var(--text); }
.sidebar-empty { color: var(--text-dim); font-size: 12px; padding: 4px 0; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer-actions { display: flex; align-items: center; gap: 8px; }

.spotify-connect-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 500px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
  transition: background .15s, color .15s;
  flex: 1;
}
.spotify-connect-btn:hover { background: var(--surface3); color: var(--text); }
.spotify-connect-btn.connected { background: #1d3a27; color: var(--accent); }
.spotify-connect-btn.connected svg { color: var(--accent); }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  grid-area: topbar;
  background: linear-gradient(to bottom, rgba(0,0,0,.6), transparent);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left { display: flex; gap: 8px; }

/* Source switcher */
.source-switcher {
  display: flex;
  background: rgba(0,0,0,.3);
  border-radius: 500px;
  padding: 3px;
  gap: 2px;
}

.source-pill {
  padding: 5px 16px;
  border-radius: 500px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.source-pill:hover { color: var(--text); }
.source-pill.active {
  background: var(--surface3);
  color: var(--text);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* Search bar in topbar */
.search-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border-radius: 500px;
  padding: 8px 16px;
  width: 360px;
  transition: background .15s;
}
.search-bar-wrapper:focus-within { background: var(--surface3); outline: 1px solid var(--text-muted); }
.search-bar-icon { color: var(--text-muted); flex-shrink: 0; }
.search-bar-input {
  flex: 1;
  background: none;
  border-radius: 0;
  padding: 0;
  font-size: 14px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  grid-area: main;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

/* View containers */
.view { padding: 0 0 32px; }

.view-hero {
  padding: 32px 24px 24px;
  background: linear-gradient(to bottom, #1e4d2b, var(--bg));
  margin-bottom: 8px;
}
.view-hero.yt { background: linear-gradient(to bottom, #4d1e1e, var(--bg)); }
.view-hero h1 { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.view-hero p { color: var(--text-muted); font-size: 14px; }

.view-section { padding: 16px 24px 0; }
.section-heading {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-heading a { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.section-heading a:hover { color: var(--text); text-decoration: underline; }

/* Card carousel */
.card-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-bottom: 8px;
}
.card-row::-webkit-scrollbar { display: none; }

/* Card */
.card {
  flex: 0 0 180px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  scroll-snap-align: start;
  transition: background .15s, transform .15s;
  position: relative;
}
.card:hover {
  background: var(--surface2);
  transform: translateY(-2px);
}
.card-art {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin-bottom: 12px;
  background: var(--surface3);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.card-art.rounded { border-radius: 50%; }
.card-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.card-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Play overlay button on cards */
.card-play {
  position: absolute;
  bottom: 58px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .2s, transform .2s;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  color: #000;
}
.card:hover .card-play { opacity: 1; transform: translateY(0); }
.card-play:hover { background: var(--accent-hover); transform: scale(1.05) !important; }

/* ============================================================
   TRACK LIST
   ============================================================ */
.track-list { display: flex; flex-direction: column; }

.track-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: background .1s;
}
.track-row:hover { background: var(--surface2); }
.track-row:hover .track-num { display: none; }
.track-row:hover .track-play-btn { display: flex; }

.track-num {
  font-size: 13px;
  color: var(--text-muted);
  text-align: right;
  user-select: none;
}
.track-play-btn {
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.track-play-btn:hover { color: var(--accent); }

.track-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.track-art { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface3); flex-shrink: 0; }
.track-details { min-width: 0; }
.track-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-artist { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.track-duration { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.track-list-header {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  padding: 8px 24px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* ============================================================
   ARTIST PAGE
   ============================================================ */
.artist-hero {
  padding: 80px 24px 32px;
  background: linear-gradient(to bottom, var(--surface3), var(--bg));
  display: flex;
  align-items: flex-end;
  gap: 24px;
}
.artist-hero-art { width: 200px; height: 200px; border-radius: 50%; object-fit: cover; box-shadow: 0 16px 56px rgba(0,0,0,.8); flex-shrink: 0; background: var(--surface3); }
.artist-hero-info {}
.artist-hero-type { font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: .08em; margin-bottom: 8px; }
.artist-hero-name { font-size: 48px; font-weight: 900; line-height: 1; margin-bottom: 12px; }
.artist-hero-followers { color: var(--text-muted); font-size: 13px; }

/* ============================================================
   ALBUM / PLAYLIST HERO
   ============================================================ */
.collection-hero {
  padding: 32px 24px 24px;
  background: linear-gradient(to bottom, var(--surface3), var(--bg));
  display: flex;
  gap: 24px;
  align-items: flex-end;
}
.collection-hero-art {
  width: 220px;
  height: 220px;
  border-radius: var(--radius);
  object-fit: cover;
  box-shadow: 0 16px 56px rgba(0,0,0,.8);
  flex-shrink: 0;
  background: var(--surface3);
}
.collection-hero-info {}
.collection-hero-type { font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: .08em; margin-bottom: 8px; }
.collection-hero-title { font-size: 36px; font-weight: 900; line-height: 1.1; margin-bottom: 8px; }
.collection-hero-sub { color: var(--text-muted); font-size: 13px; }

.collection-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 24px 16px;
}
.btn-play-big {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  transition: background .15s, transform .1s;
}
.btn-play-big:hover { background: var(--accent-hover); transform: scale(1.05); }

/* ============================================================
   SEARCH PAGE
   ============================================================ */
.search-hint {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}
.search-hint svg { opacity: .3; margin: 0 auto 16px; }
.search-hint h2 { font-size: 20px; color: var(--text); margin-bottom: 8px; }

/* ============================================================
   LIBRARY PAGE
   ============================================================ */
.library-tabs {
  display: flex;
  gap: 8px;
  padding: 24px 24px 16px;
}
.lib-tab {
  padding: 6px 16px;
  border-radius: 500px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.lib-tab:hover { color: var(--text); }
.lib-tab.active { background: var(--text); color: var(--bg); }

/* ============================================================
   NOW-PLAYING BAR
   ============================================================ */
.now-playing-bar {
  grid-area: npbar;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 20;
}

/* NP track info (left) */
.np-track { display: flex; align-items: center; gap: 12px; min-width: 0; }
.np-artwork-wrap { flex-shrink: 0; }
.np-artwork {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface3);
}
.np-track-info { min-width: 0; }
.np-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* Center controls */
.np-controls { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; max-width: 560px; width: 100%; }

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

.ctrl-btn {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, transform .1s;
  padding: 4px;
  border-radius: 50%;
}
.ctrl-btn:hover { color: var(--text); transform: scale(1.05); }
.ctrl-btn.active { color: var(--accent); }

.ctrl-play {
  width: 40px;
  height: 40px;
  background: var(--text);
  color: var(--bg);
  border-radius: 50%;
  transition: background .15s, transform .1s;
}
.ctrl-play:hover { background: #fff; transform: scale(1.06) !important; color: var(--bg); }

/* Progress */
.np-progress-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.np-time { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 32px; text-align: center; user-select: none; }

.np-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  transition: height .15s;
}
.np-progress-bar:hover { height: 6px; }
.np-progress-fill {
  height: 100%;
  background: var(--text-muted);
  border-radius: inherit;
  transition: background .15s;
  pointer-events: none;
}
.np-progress-bar:hover .np-progress-fill { background: var(--accent); }
.np-progress-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 12px;
  height: 12px;
  background: var(--text);
  border-radius: 50%;
  pointer-events: none;
  transition: transform .15s;
}
.np-progress-bar:hover .np-progress-thumb { transform: translate(-50%, -50%) scale(1); }

/* Right side */
.np-right {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.vol-icon { color: var(--text-muted); flex-shrink: 0; }
.vol-slider {
  -webkit-appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface3);
  outline: none;
  cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
.vol-slider:hover { accent-color: var(--accent); }
.vol-label { font-size: 11px; color: var(--text-muted); min-width: 24px; text-align: right; }

/* ============================================================
   QUEUE PANEL
   ============================================================ */
.queue-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: calc(100vh - var(--npbar-height));
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .3s ease;
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.queue-panel.open { transform: translateX(0); }

.queue-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.queue-panel-header h2 { font-size: 16px; font-weight: 700; }

.queue-now-playing { padding: 16px 20px 8px; }
.queue-up-next { flex: 1; overflow-y: auto; padding: 8px 0 0; }

.queue-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.queue-track {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: background .1s;
}
.queue-track:hover { background: var(--surface2); }
.queue-track--current { background: rgba(255,255,255,.04); margin: 0 -20px; padding-left: 20px; padding-right: 20px; }
.queue-track-art { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface3); flex-shrink: 0; }
.queue-track-info { min-width: 0; flex: 1; }
.queue-track-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-track-artist { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-track-num { font-size: 12px; color: var(--text-dim); min-width: 20px; text-align: right; }

/* ============================================================
   ICON BUTTON
   ============================================================ */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 50%;
  padding: 6px;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.08); }

/* ============================================================
   LOADING / EMPTY STATES
   ============================================================ */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--surface3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state h3 { font-size: 20px; color: var(--text); margin-bottom: 8px; }

/* Error toast */
.toast {
  position: fixed;
  bottom: calc(var(--npbar-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface3);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ============================================================
   HOMEPAGE LOGIN SCREEN (index.html reuse via #login-screen)
   ============================================================ */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 24px;
  text-align: center;
  padding: 24px;
}
.login-logo { display: flex; align-items: center; gap: 12px; font-size: 32px; font-weight: 900; }
.login-logo svg { color: var(--accent); }
.login-tagline { color: var(--text-muted); max-width: 360px; }
.btn-discord {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--discord);
  color: #fff;
  padding: 14px 28px;
  border-radius: 500px;
  font-size: 16px;
  font-weight: 700;
  transition: filter .15s;
  text-decoration: none;
}
.btn-discord:hover { filter: brightness(1.1); }

/* index.html error state */
.error-msg { color: #f04747; font-size: 13px; }

/* ============================================================
   LANDING PAGE (index.html)
   ============================================================ */
body.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: auto;
}

.landing-card {
  text-align: center;
  padding: 48px 40px;
  background: var(--surface);
  border-radius: 16px;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 16px 56px rgba(0,0,0,.6);
}

.landing-logo { font-size: 48px; line-height: 1; }

.landing-card h1 { font-size: 32px; font-weight: 900; }

.landing-sub { color: var(--text-muted); font-size: 15px; }

.btn.btn-discord, .btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--discord);
  color: #fff;
  padding: 14px 28px;
  border-radius: 500px;
  font-size: 15px;
  font-weight: 700;
  transition: filter .15s;
  text-decoration: none;
  border: none;
  cursor: pointer;
}
.btn.btn-discord:hover, .btn-discord:hover { filter: brightness(1.1); }

.error-banner {
  background: rgba(240,71,71,.15);
  border: 1px solid rgba(240,71,71,.4);
  color: #f44;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  width: 100%;
  text-align: center;
}

/* Genre cards (no artwork, colour block) */
.genre-card {
  min-height: 120px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  position: relative;
}
.genre-card-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
  padding: 0 4px 4px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
  word-break: break-word;
}
