/* ═══════════════════════════════════════════════════════════
   STREAMIFY — Spotify-style Dark Theme
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --green:       #1DB954;
  --green-dark:  #17a349;
  --bg-base:     #121212;
  --bg-elevated: #1e1e1e;
  --bg-highlight:#282828;
  --bg-press:    #333333;
  --text-primary:#FFFFFF;
  --text-secondary:#B3B3B3;
  --text-subdued: #6A6A6A;
  --border:      #333333;
  --sidebar-w:   240px;
  --player-h:    90px;
  --radius:      8px;
  --transition:  0.15s ease;
}

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input { font: inherit; }
img { display: block; }
svg { flex-shrink: 0; }

/* ── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-press); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subdued); }

/* ── APP LAYOUT ────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr auto;
  grid-template-rows: 1fr;
  height: calc(100vh - var(--player-h));
  overflow: hidden;
}

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
  background: #000;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 16px;
  color: var(--green);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0 8px;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-highlight); }
.nav-item.active { color: var(--text-primary); }
.nav-item svg { opacity: 0.7; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.sidebar-playlists {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8px 8px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px 8px;
  color: var(--text-subdued);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.playlist-list { display: flex; flex-direction: column; gap: 1px; }

.playlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  transition: color var(--transition), background var(--transition);
}
.playlist-item:hover { color: var(--text-primary); background: var(--bg-highlight); }
.playlist-item.active { color: var(--text-primary); }

.playlist-icon {
  width: 32px; height: 32px;
  border-radius: 4px;
  background: var(--bg-highlight);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.playlist-icon.liked { background: linear-gradient(135deg, #450af5, #c4efd9); color: #fff; }

/* ── MAIN CONTENT ──────────────────────────────────────────── */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── TOPBAR ────────────────────────────────────────────────── */
.topbar {
  padding: 16px 24px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 480px;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-secondary);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 10px 40px 10px 44px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
#search-input::placeholder { color: var(--text-subdued); }
#search-input:focus {
  border-color: var(--text-secondary);
  background: var(--bg-highlight);
}

.btn-clear {
  position: absolute;
  right: 12px;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 4px;
  border-radius: 50%;
  transition: color var(--transition);
}
.btn-clear:hover { color: var(--text-primary); }

/* ── VIEW CONTAINER ────────────────────────────────────────── */
.view-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}
.view.active { display: block; }

/* ── HOME VIEW ─────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 60px 24px 40px;
}
.hero h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #fff 0%, var(--green) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 28px;
}

.featured-section { margin-top: 32px; }
.featured-section h2 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }

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

.track-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: background var(--transition);
}
.track-card:hover { background: var(--bg-highlight); }
.track-card img {
  width: 100%; aspect-ratio: 1;
  border-radius: 4px;
  object-fit: cover;
  margin-bottom: 12px;
}
.track-card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-card-artist { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

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

.track-row {
  display: grid;
  grid-template-columns: 40px 48px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.track-row:hover { background: var(--bg-elevated); }
.track-row.playing { background: var(--bg-elevated); }
.track-row.playing .track-row-title { color: var(--green); }

.track-row-num {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  width: 24px;
}
.track-row.playing .track-row-num { color: var(--green); }

.track-row-thumb {
  width: 48px; height: 48px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-highlight);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subdued);
  flex-shrink: 0;
}
.track-row-thumb img { width: 100%; height: 100%; border-radius: 4px; object-fit: cover; }

.track-row-info { min-width: 0; }
.track-row-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-row-artist { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

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

.track-row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.track-row:hover .track-row-actions { opacity: 1; }

/* ── SEARCH STATUS ─────────────────────────────────────────── */
.search-status {
  padding: 8px 0 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ── LIBRARY ───────────────────────────────────────────────── */
.library-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}
.library-header h2 { font-size: 24px; font-weight: 700; }
.track-count { color: var(--text-secondary); font-size: 13px; }

/* ── QUEUE PANEL ───────────────────────────────────────────── */
.queue-panel {
  width: 0;
  overflow: hidden;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
}
.queue-panel.open { width: 280px; }

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

.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.queue-item:hover { background: var(--bg-highlight); }
.queue-item.active { background: var(--bg-highlight); }
.queue-item.active .queue-item-title { color: var(--green); }

.queue-item-thumb {
  width: 40px; height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-press);
  flex-shrink: 0;
}
.queue-item-info { min-width: 0; flex: 1; }
.queue-item-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item-artist { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── PLAYER BAR ────────────────────────────────────────────── */
.player-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--player-h);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
}

/* Track Info */
.player-track-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.player-thumb {
  width: 56px; height: 56px;
  border-radius: 4px;
  background: var(--bg-press);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subdued);
  flex-shrink: 0;
  overflow: hidden;
}
.player-thumb img { width: 100%; height: 100%; object-fit: cover; }

.player-meta { min-width: 0; flex: 1; }
.player-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.like-btn { color: var(--text-secondary); font-size: 18px; padding: 6px; }
.like-btn:hover { color: var(--text-primary); }
.like-btn.liked { color: var(--green); }

/* Controls */
.player-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.control-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}
.btn-icon:hover { color: var(--text-primary); }
.btn-icon.active { color: var(--green); }

.ctrl-btn { width: 36px; height: 36px; }

.btn-play {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--text-primary);
  color: #000;
  transition: transform var(--transition), background var(--transition);
}
.btn-play:hover { transform: scale(1.06); background: #fff; }
.btn-play:active { transform: scale(0.96); }

/* Progress */
.progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 480px;
}

.time-label { font-size: 11px; color: var(--text-secondary); white-space: nowrap; min-width: 32px; }
#time-current { text-align: right; }

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-press);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  transition: height var(--transition);
}
.progress-bar:hover { height: 6px; }

.progress-fill {
  height: 100%;
  background: var(--text-secondary);
  border-radius: 2px;
  width: 0%;
  transition: background var(--transition);
  pointer-events: none;
}
.progress-bar:hover .progress-fill { background: var(--green); }

.progress-thumb {
  position: absolute;
  top: 50%; right: 0;
  transform: translate(50%, -50%);
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.progress-bar:hover .progress-thumb { opacity: 1; }

/* Extras */
.player-extras {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.volume-container { display: flex; align-items: center; width: 100px; }

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-press);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
}
.volume-slider:hover { background: var(--green); }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 32px;
  background: var(--green);
  color: #000;
  font-size: 14px;
  font-weight: 700;
  border-radius: 24px;
  transition: background var(--transition), transform var(--transition);
}
.btn-primary:hover { background: var(--green-dark); transform: scale(1.02); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 24px;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  border-radius: 24px;
  border: 1px solid var(--border);
  transition: border-color var(--transition), background var(--transition);
}
.btn-secondary:hover { border-color: var(--text-primary); background: var(--bg-highlight); }

/* ── MODALS ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-elevated);
  border-radius: 12px;
  width: 360px;
  max-width: 90vw;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

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

.modal-body { padding: 16px 20px; }

.modal-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
.modal-input:focus { border-color: var(--green); }

.modal-list { max-height: 240px; overflow-y: auto; padding: 8px; }

.modal-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.modal-list-item:hover { background: var(--bg-highlight); }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px 20px;
}

/* ── TOAST ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--player-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-press);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-subdued);
  padding: 32px 16px;
  font-size: 13px;
}

/* ── LOADING SPINNER ───────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--bg-press);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row {
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 32px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  #app { grid-template-columns: 1fr; }
  .player-bar { grid-template-columns: 1fr 1fr; }
  .player-extras { display: none; }
  .track-row { grid-template-columns: 40px 1fr auto; }
  .track-row-num, .track-row-duration { display: none; }
}