/* ============================================
   CSS Custom Properties
   ============================================ */
:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --text: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --hover: #f3f4f6;
  --active-bg: #eff6ff;
  --active-border: #3b82f6;
  --accent: #3b82f6;
  --player-bg: #111827;
  --player-text: #f9fafb;
  --player-secondary: #9ca3af;
  --player-progress-bg: #374151;
  --player-progress-fill: #3b82f6;
  --header-height: 64px;
  --player-height: 90px;
  --max-width: 960px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* ============================================
   Header
   ============================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--accent);
}

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

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  font-size: 16px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.search-clear:hover {
  color: var(--text);
  background: var(--hover);
}

/* ============================================
   Main Content
   ============================================ */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px 120px;
}

/* Track list header */
.track-list-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  margin-top: 8px;
}

/* Column widths */
.col-num {
  width: 40px;
  flex-shrink: 0;
  text-align: center;
}

.col-title {
  flex: 2;
  min-width: 0;
}

.col-artist {
  flex: 1;
  min-width: 0;
}

.col-album {
  flex: 1;
  min-width: 0;
}

.col-duration {
  width: 60px;
  flex-shrink: 0;
  text-align: right;
}

/* Track rows */
.track-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.track-row:hover {
  background: var(--hover);
}

.track-row.active {
  background: var(--active-bg);
}

.track-num {
  width: 40px;
  flex-shrink: 0;
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.track-row.active .track-num {
  color: var(--accent);
}

.track-playing-icon {
  color: var(--accent);
  font-size: 16px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.track-title {
  flex: 2;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
}

.track-row.active .track-title {
  color: var(--accent);
}

.track-artist {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
}

.track-album {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
}

.track-duration {
  width: 60px;
  flex-shrink: 0;
  text-align: right;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================
   State Messages (loading / empty / error)
   ============================================ */
.state-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 15px;
  gap: 16px;
}

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

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

.btn {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  background: var(--accent);
  color: white;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.85;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 24px 0;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}

.page-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.page-btn.active {
  background: var(--accent);
  color: white;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-btn:disabled:hover {
  background: none;
}

/* ============================================
   Player Bar
   ============================================ */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--player-bg);
  color: var(--player-text);
  height: var(--player-height);
  display: flex;
  flex-direction: column;
}

/* Progress slider */
.player-progress {
  width: 100%;
  height: 20px;
  display: flex;
  align-items: center;
  padding: 0;
  position: relative;
  flex-shrink: 0;
  margin-top: -6px;
}

.player-progress input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--player-progress-bg);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

.player-progress input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--player-progress-fill);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s;
}

.player-progress input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

.player-progress input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--player-progress-fill);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.player-progress input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--player-progress-bg);
  border-radius: 2px;
  border: none;
}

/* Player body */
.player-body {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

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

.player-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-artist {
  font-size: 12px;
  color: var(--player-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ctrl-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--player-text);
  transition: background 0.1s, transform 0.1s;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ctrl-btn:active {
  transform: scale(0.92);
}

.ctrl-play {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: white;
}

.ctrl-play:hover {
  background: #2563eb;
}

.player-time {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--player-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: right;
}

.time-sep {
  margin: 0 2px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 640px) {
  .col-album,
  .track-album {
    display: none;
  }

  .col-duration,
  .track-duration {
    display: none;
  }

  .header-inner {
    gap: 12px;
  }

  .logo {
    font-size: 18px;
  }

  .player-body {
    gap: 12px;
  }

  .player-time {
    display: none;
  }
}

@media (max-width: 420px) {
  .col-artist,
  .track-artist {
    display: none;
  }

  .track-title {
    flex: 1;
  }
}
