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

:root {
  --bg: #0a0a0f;
  --surface: rgba(255,255,255,0.04);
  --surface2: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.08);
  --text: #f0f0f5;
  --muted: rgba(240,240,245,0.55);
  --accent: #c8ff00;
  --accent2: #00ffd2;
  --danger: #ff4d6d;
  --radius: 16px;
  --cover-color: #1a1a2e;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  overflow: hidden;
  position: fixed;
}

/* BG BLUR LAYER */
#bg-blur {
  position: fixed; inset: 0; z-index: 0;
  background-size: cover; background-position: center;
  filter: blur(80px) saturate(1.4) brightness(0.3);
  transition: background-image 0.8s ease;
  transform: scale(1.1);
}
#bg-overlay {
  position: fixed; inset: 0; z-index: 1;
  background: linear-gradient(135deg, rgba(10,10,15,0.75) 0%, rgba(10,10,15,0.6) 100%);
}

/* LAYOUT */
#app {
  position: relative; z-index: 2;
  display: flex; width: 100vw; height: 100vh;
}

/* SIDEBAR */
#sidebar {
  width: 260px; min-width: 260px;
  height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(10,10,15,0.6);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

#sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}

.logo {
  font-family: 'Space Mono', monospace;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--accent);
}

#playlist-count {
  font-size: 11px; color: var(--muted);
  font-family: 'Space Mono', monospace;
}

#playlist-container {
  flex: 1; overflow-y: auto;
  padding: 12px 0;
}

#playlist-container::-webkit-scrollbar { width: 3px; }
#playlist-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.playlist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; cursor: pointer;
  transition: background 0.2s;
  position: relative;
}
.playlist-item:hover { background: var(--surface); }
.playlist-item.active { background: var(--surface2); }
.playlist-item.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent); border-radius: 0 2px 2px 0;
}

.playlist-thumb {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--surface2); flex-shrink: 0;
  object-fit: cover; overflow: hidden;
}
.playlist-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.playlist-thumb-placeholder {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--surface2); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.playlist-info { flex: 1; min-width: 0; }
.playlist-title {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.playlist-artist {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.playlist-duration {
  font-size: 10px; color: var(--muted);
  font-family: 'Space Mono', monospace;
}

.playing-wave {
  display: none; align-items: flex-end; gap: 2px; height: 16px;
}
.active .playing-wave { display: flex; }
.active .playlist-duration { display: none; }
.wave-bar {
  width: 3px; background: var(--accent); border-radius: 2px;
  animation: wave-bounce 0.6s ease-in-out infinite alternate;
}
.wave-bar:nth-child(1) { height: 6px; animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 12px; animation-delay: 0.15s; }
.wave-bar:nth-child(3) { height: 8px; animation-delay: 0.3s; }
.wave-bar:nth-child(4) { height: 14px; animation-delay: 0.1s; }
@keyframes wave-bounce { from { transform: scaleY(0.4); } to { transform: scaleY(1); } }
.paused .wave-bar { animation-play-state: paused; }

/* MAIN PLAYER */
#main {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px; position: relative;
  overflow-y: auto;
}

#player-card {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 400px;
}

/* COVER SPINNING */
#cover-wrap {
  position: relative; margin-bottom: 28px;
}
#cover-ring {
  width: 220px; height: 220px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.06);
  position: absolute; inset: -10px;
  animation: spin-slow 20s linear infinite;
  animation-play-state: paused;
}
#cover-ring.spinning { animation-play-state: running; }

#cover-disc {
  width: 200px; height: 200px; border-radius: 50%;
  overflow: hidden; position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 2px rgba(255,255,255,0.05);
  animation: spin-slow 20s linear infinite;
  animation-play-state: paused;
  background: var(--cover-color);
}
#cover-disc.spinning { animation-play-state: running; }

#cover-img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
#cover-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
}

@keyframes spin-slow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* SONG INFO */
#song-title {
  font-size: 20px; font-weight: 700;
  text-align: center; letter-spacing: -0.02em;
  margin-bottom: 6px;
}
#song-artist {
  font-size: 13px; color: var(--muted);
  text-align: center; margin-bottom: 28px;
  font-weight: 400;
}

/* PROGRESS */
#progress-wrap {
  width: 100%; margin-bottom: 22px;
}
#progress-bar-bg {
  width: 100%; height: 4px; background: var(--surface2);
  border-radius: 2px; cursor: pointer; position: relative;
}
#progress-bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 2px; width: 0%;
  transition: width 0.1s linear;
  position: relative;
}
#progress-bar-fill::after {
  content: ''; position: absolute; right: -5px; top: -4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
}
#time-labels {
  display: flex; justify-content: space-between;
  margin-top: 8px; font-size: 10px; color: var(--muted);
  font-family: 'Space Mono', monospace;
}

/* CONTROLS */
#controls {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-bottom: 24px;
}

.ctrl-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); transition: color 0.2s, transform 0.15s;
  display: flex; align-items: center; justify-content: center;
  padding: 8px; border-radius: 50%;
}
.ctrl-btn:hover { color: var(--text); transform: scale(1.08); }
.ctrl-btn.active-mode { color: var(--accent); }

#btn-play-pause {
  width: 56px; height: 56px;
  background: var(--accent); color: #0a0a0f;
  border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px rgba(200,255,0,0.3);
  transition: transform 0.15s, box-shadow 0.2s;
}
#btn-play-pause:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(200,255,0,0.5);
}

/* VOLUME */
#volume-wrap {
  display: flex; align-items: center; gap: 10px; width: 100%;
}
#volume-wrap svg { color: var(--muted); flex-shrink: 0; }
#volume-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) 70%, var(--surface2) 70%);
  outline: none; cursor: pointer;
}
#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
}

/* VISUALIZER */
#visualizer-wrap {
  position: absolute; bottom: 60px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 3px; height: 48px;
  opacity: 0.5;
}
.vis-bar {
  width: 4px; background: var(--accent2);
  border-radius: 2px 2px 0 0;
  min-height: 3px;
  transition: height 0.05s ease;
}

/* ADD MUSIC BTN */
#btn-add-music {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 16px;
  border-radius: 30px; cursor: pointer;
  font-family: 'Outfit', sans-serif; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  backdrop-filter: blur(12px);
  transition: background 0.2s, border-color 0.2s;
}
#btn-add-music:hover {
  background: var(--accent); color: #0a0a0f;
  border-color: var(--accent);
}

/* MODAL */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #12121a; border: 1px solid var(--border);
  border-radius: 24px; padding: 28px;
  width: 100%; max-width: 400px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: modal-in 0.25s ease;
  margin: 20px;
}
@keyframes modal-in { from { opacity: 0; transform: scale(0.96) translateY(10px); } to { opacity: 1; transform: none; } }

.modal-title {
  font-size: 18px; font-weight: 700;
  margin-bottom: 6px;
}
.modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }
.form-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: block; font-weight: 500; letter-spacing: 0.03em; }
.form-input {
  width: 100%; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text);
  font-family: 'Outfit', sans-serif; font-size: 14px;
  outline: none; transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }
.form-input[type="file"] { cursor: pointer; padding: 10px 12px; }

.btn-primary {
  width: 100%; padding: 12px;
  background: var(--accent); color: #0a0a0f;
  border: none; border-radius: 12px;
  font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s, transform 0.15s;
  margin-top: 8px;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  width: 100%; padding: 10px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 12px;
  font-family: 'Outfit', sans-serif; font-size: 13px;
  cursor: pointer; margin-top: 10px;
  transition: color 0.2s, border-color 0.2s;
}
.btn-secondary:hover { color: var(--text); border-color: var(--text); }

.error-msg {
  color: var(--danger); font-size: 12px; margin-top: 10px;
  text-align: center; display: none;
}
.error-msg.show { display: block; }

.dashboard-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.dashboard-title { font-size: 18px; font-weight: 700; }
.logout-btn {
  background: none; border: 1px solid var(--border);
  color: var(--muted); padding: 6px 14px; border-radius: 20px;
  font-size: 12px; cursor: pointer; font-family: 'Outfit', sans-serif;
  transition: color 0.2s, border-color 0.2s;
}
.logout-btn:hover { color: var(--danger); border-color: var(--danger); }

.upload-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; background: var(--surface);
  border-radius: 12px; margin-top: 10px;
  font-size: 12px; color: var(--muted);
}
.upload-preview img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }

.status-msg {
  text-align: center; font-size: 12px; margin-top: 12px;
  color: var(--accent); display: none;
}
.status-msg.show { display: block; }

/* EMPTY STATE */
#empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; color: var(--muted);
  gap: 12px; text-align: center; padding: 40px 20px;
}
#empty-state svg { opacity: 0.3; }
#empty-state p { font-size: 13px; }
#empty-state small { font-size: 11px; opacity: 0.6; }

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

.loading-state {
  display: flex; align-items: center; justify-content: center;
  height: 160px; color: var(--muted); gap: 10px; font-size: 13px;
}

/* TOAST */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1e1e2a; border: 1px solid var(--border);
  color: var(--text); padding: 10px 20px; border-radius: 30px;
  font-size: 12px; z-index: 300; opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* DELETE btn in playlist */
.delete-song-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 4px; border-radius: 4px; opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  display: flex; flex-shrink: 0;
}
.playlist-item:hover .delete-song-btn { opacity: 1; }
.delete-song-btn:hover { color: var(--danger); }

/* RESPONSIVE MOBILE */
@media (max-width: 768px) {
  #sidebar {
    width: 70px;
    min-width: 70px;
  }
  #sidebar-header {
    padding: 16px 8px;
    justify-content: center;
  }
  .logo { font-size: 8px; letter-spacing: 0.1em; writing-mode: vertical-rl; text-orientation: mixed; }
  #playlist-count { display: none; }
  .playlist-item { padding: 12px 8px; justify-content: center; }
  .playlist-thumb, .playlist-thumb-placeholder { width: 44px; height: 44px; margin: 0 auto; }
  .playlist-info, .playlist-duration, .playing-wave { display: none; }
  .delete-song-btn { opacity: 0.7; }
  
  #main { padding: 16px; }
  #cover-ring { width: 180px; height: 180px; }
  #cover-disc { width: 160px; height: 160px; }
  #song-title { font-size: 17px; }
  #song-artist { font-size: 12px; margin-bottom: 20px; }
  .ctrl-btn svg { width: 18px; height: 18px; }
  #btn-play-pause { width: 48px; height: 48px; }
  #controls { gap: 12px; }
  #visualizer-wrap { bottom: 40px; }
  #btn-add-music { top: 12px; right: 12px; padding: 6px 12px; font-size: 11px; }
  .modal { padding: 20px; margin: 16px; }
}

@media (max-width: 480px) {
  #sidebar { width: 60px; min-width: 60px; }
  .playlist-thumb, .playlist-thumb-placeholder { width: 36px; height: 36px; }
}
/* SEARCH BOX */
#search-box {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 12px 4px; padding: 6px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; color: var(--muted);
  transition: border-color 0.2s;
}
#search-box:focus-within {
  border-color: var(--accent);
}
#search-input {
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 12px; width: 100%;
  font-family: 'Outfit', sans-serif;
}
#search-input::placeholder { color: var(--muted); }

/* ROLE BADGE */
.role-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; text-transform: uppercase;
  background: var(--surface2); color: var(--accent); margin-top: 2px;
}
.role-badge.user { color: var(--accent2); }
