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

:root {
  --green: #1DB954;
  --green-dark: #1aa34a;
  --green-glow: rgba(29, 185, 84, 0.15);
  --bg: #0a0a0a;
  --bg-light: #141414;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222;
  --text: #ffffff;
  --text-muted: #a0a0a0;
  --text-dim: #666;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --border: #2a2a2a;
  --radius: 12px;
  --radius-lg: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px;
}

/* ==================== HEADER ==================== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-left h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-logo {
  width: 28px;
  height: 28px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-info {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--green);
  color: #000;
  box-shadow: 0 2px 12px rgba(29, 185, 84, 0.3);
}

.btn-primary:hover {
  background: var(--green-dark);
  box-shadow: 0 4px 20px rgba(29, 185, 84, 0.4);
}

.btn-small {
  padding: 6px 14px;
  font-size: 0.8rem;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-small:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: #555;
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  padding: 6px 14px;
  font-size: 0.8rem;
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-add {
  background: var(--green);
  color: #000;
  padding: 6px 18px;
  font-size: 0.85rem;
  border-radius: 20px;
}

.btn-add:hover {
  box-shadow: 0 2px 12px rgba(29, 185, 84, 0.4);
}

.btn-add.added {
  background: var(--bg-card);
  color: var(--green);
  border: 1px solid var(--green);
  pointer-events: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ==================== AUTH PAGE ==================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(29, 185, 84, 0.08) 0%, transparent 60%);
}

.auth-container {
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  text-align: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 28px;
  box-shadow: 0 8px 32px rgba(29, 185, 84, 0.3);
}

.auth-container h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 36px;
  font-size: 0.95rem;
}

.auth-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.25s ease;
}

.tab.active {
  color: var(--text);
  background: var(--bg-light);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.tab:hover:not(.active) {
  color: var(--text);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-wrapper {
  position: relative;
}

.input-wrapper .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 16px;
  pointer-events: none;
}

.auth-form input {
  width: 100%;
  padding: 13px 16px 13px 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
}

.auth-form .btn-primary {
  margin-top: 4px;
  padding: 13px;
  font-size: 0.95rem;
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.hidden {
  display: none !important;
}

/* ==================== SEARCH ==================== */
.search-section {
  margin-bottom: 32px;
}

.search-box {
  position: relative;
  margin-bottom: 12px;
}

.search-box .search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 18px;
  pointer-events: none;
  transition: color 0.2s;
}

.search-box input {
  width: 100%;
  padding: 16px 20px 16px 50px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-light);
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
  background: var(--bg-card);
}

.search-box input:focus ~ .search-icon {
  color: var(--green);
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.search-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 12px 0;
}

/* Loading spinner */
.loading {
  display: flex;
  justify-content: center;
  padding: 24px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

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

.track-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: transparent;
  border-radius: var(--radius);
  transition: background 0.15s ease;
  animation: fadeSlideIn 0.25s ease;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.track-item:hover {
  background: var(--bg-card);
}

.track-number {
  width: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  flex-shrink: 0;
}

.track-item img {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-card);
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.track-artist {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-added-by {
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 2px;
}

.track-actions {
  flex-shrink: 0;
}

/* ==================== PROGRESS BAR ==================== */
.progress-section {
  margin-bottom: 8px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.progress-bar {
  height: 4px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-fill.warning {
  background: #f39c12;
}

.progress-fill.full {
  background: var(--danger);
}

/* ==================== PLAYLIST SECTION ==================== */
.playlist-section {
  margin-top: 8px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 12px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.95rem;
}

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast-success {
  background: rgba(29, 185, 84, 0.9);
  color: #000;
}

.toast-error {
  background: rgba(231, 76, 60, 0.9);
  color: #fff;
}

.toast-info {
  background: rgba(40, 40, 40, 0.95);
  color: #fff;
  border: 1px solid var(--border);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ==================== ADMIN ==================== */
.admin-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}

.admin-card h2 {
  margin-bottom: 12px;
  font-size: 1.1rem;
  font-weight: 700;
}

.admin-card p {
  color: var(--text-muted);
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.status-badge.connected {
  background: var(--green-glow);
  color: var(--green);
}

.status-badge.disconnected {
  background: rgba(231, 76, 60, 0.1);
  color: var(--danger);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-row input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
}

#playlist-status {
  margin-top: 10px;
  font-size: 0.85rem;
}

/* ==================== DIVIDER ==================== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  .header-right {
    flex-wrap: wrap;
    justify-content: center;
  }
  .container {
    padding: 16px;
  }
  .input-row {
    flex-direction: column;
  }
  .auth-card {
    padding: 20px;
  }
  .track-item {
    gap: 10px;
    padding: 8px 10px;
  }
  .track-item img {
    width: 44px;
    height: 44px;
  }
  .track-number {
    display: none;
  }
}
