/* ========== CSS Variables ========== */
:root {
  --bg: #0a0a0f;
  --bg2: #111117;
  --bg3: #18181f;
  --bg4: #1e1e28;
  --border: rgba(255,255,255,0.07);
  --text: #e8e8f0;
  --text-sub: #888899;
  --accent: #00e5ff;
  --accent-dim: rgba(0,229,255,0.12);
  --accent-glow: rgba(0,229,255,0.25);
  --red: #ff4d6d;
  --player-h: 88px;
  --sidebar-w: 220px;
  --radius: 10px;
  --transition: 0.18s ease;
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }

/* ========== Screens ========== */
.screen { display: none; position: fixed; inset: 0; }
.screen.active { display: flex; }

/* ========== Login Screen ========== */
#login-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 40% 40%, rgba(0,229,255,0.06) 0%, transparent 70%),
              radial-gradient(ellipse at 70% 80%, rgba(100,0,255,0.04) 0%, transparent 60%),
              var(--bg);
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.login-logo span {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
}

.login-box h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}
.login-sub {
  color: var(--text-sub);
  margin-bottom: 28px;
  font-size: 13.5px;
}

.config-section { margin-bottom: 20px; }
.config-section label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sub);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.config-section input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.config-section input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.hint {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 6px;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius);
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.error-msg {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(255,77,109,0.12);
  border: 1px solid rgba(255,77,109,0.3);
  border-radius: 8px;
  color: var(--red);
  font-size: 13px;
}

/* ========== App Layout ========== */
#app-screen {
  display: none;
  flex-direction: row;
  height: 100vh;
}
#app-screen.active { display: flex; }

/* ========== Sidebar ========== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  height: calc(100vh - var(--player-h));
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar-logo span {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-sub);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }

.queue-badge {
  margin-left: auto;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-bottom {
  padding: 16px 12px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg3);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}
#user-name {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-sub);
  transition: background var(--transition), color var(--transition);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-ghost.small { font-size: 12px; padding: 5px 10px; }

/* ========== Main Content ========== */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--player-h));
}

.tab-panel { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.tab-panel.active { display: flex; }

/* Search Header */
.search-header {
  padding: 24px 28px 16px;
  flex-shrink: 0;
}
.search-header h2 { font-size: 18px; font-weight: 600; margin-bottom: 14px; }

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-sub);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 30px;
  color: var(--text);
  padding: 11px 44px;
  font-size: 14.5px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.search-input::placeholder { color: var(--text-sub); }
.search-spinner {
  position: absolute;
  right: 16px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Queue Header */
.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 16px;
  flex-shrink: 0;
}
.queue-header h2 { font-size: 18px; font-weight: 600; }

/* Results List */
.results-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg4) transparent;
}
.results-list::-webkit-scrollbar { width: 6px; }
.results-list::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 10px; }

/* Track Item */
.track-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.track-item:hover { background: var(--bg3); }
.track-item.playing { background: var(--accent-dim); }
.track-item.playing .t-title { color: var(--accent); }

.t-index {
  width: 26px;
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  flex-shrink: 0;
}
.track-item.playing .t-index { display: none; }
.play-indicator {
  display: none;
  width: 26px;
  flex-shrink: 0;
  justify-content: center;
}
.track-item.playing .play-indicator { display: flex; align-items: center; }
.play-indicator svg { animation: pulse 1.2s ease-in-out infinite; color: var(--accent); }
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.t-cover {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg4);
}
.t-cover-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--bg4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.t-info { flex: 1; min-width: 0; }
.t-title {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-artist {
  display: block;
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.t-duration {
  font-size: 12px;
  color: var(--text-sub);
  flex-shrink: 0;
}

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

.action-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  transition: background var(--transition), color var(--transition);
}
.action-btn:hover { background: var(--bg4); color: var(--text); }
.action-btn.remove:hover { color: var(--red); }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  color: var(--text-sub);
  font-size: 14px;
  padding: 40px;
}

/* ========== Player Bar ========== */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--player-h);
  background: rgba(14,14,20,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.track-cover-wrapper { flex-shrink: 0; }
.track-cover {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
}
.cover-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.track-info { min-width: 0; }
.track-title {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.track-artist {
  display: block;
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.ctrl-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  transition: color var(--transition), background var(--transition), transform var(--transition);
}
.ctrl-btn:hover { color: var(--text); background: var(--bg3); }
.ctrl-btn:active { transform: scale(0.92); }
.play-btn {
  width: 46px;
  height: 46px;
  background: var(--accent);
  color: #000;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.play-btn:hover { background: var(--accent); opacity: 0.9; color: #000; }

.player-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}
.time-label {
  font-size: 11px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: center;
}
.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg4);
  border-radius: 10px;
  cursor: pointer;
  max-width: 180px;
  position: relative;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 10px;
  transition: width 0.5s linear;
  pointer-events: none;
}

/* ========== Utilities ========== */
.hidden { display: none !important; }
