@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* Ensure the hidden attribute always wins over CSS display values */
[hidden] { display: none !important; }

:root {
  --bg-primary: #0c0c1e;
  --bg-secondary: #12122e;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --purple: #8b5cf6;
  --purple-light: #a78bfa;
  --purple-dark: #6d28d9;
  --cyan: #06b6d4;
  --cyan-light: #67e8f9;
  --pink: #ec4899;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #475569;
  --border: rgba(139, 92, 246, 0.2);
  --border-bright: rgba(139, 92, 246, 0.5);
  --gradient: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  --gradient-text: linear-gradient(135deg, #a78bfa, #67e8f9);
  --shadow: 0 4px 24px rgba(139, 92, 246, 0.15);
  --shadow-hover: 0 8px 40px rgba(139, 92, 246, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 68px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { display: block; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--purple-dark); border-radius: 3px; }

/* ═══════════════════ HEADER ═══════════════════ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(12, 12, 30, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

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

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg { width: 22px; height: 22px; fill: white; }

.logo-text {
  font-size: 1.4rem;
  font-weight: 900;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

/* Search */
.search-wrap {
  flex: 1;
  max-width: 600px;
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrap:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.search-bar {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 0 18px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.search-bar::placeholder { color: var(--text-faint); }

.search-btn {
  background: var(--gradient);
  border: none;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.search-btn:hover { opacity: 0.85; }
.search-btn svg { width: 18px; height: 18px; stroke: white; fill: none; }

/* Upload button */
.upload-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gradient);
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: 100px;
  border: none;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.4);
  text-decoration: none;
}

.upload-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5);
}

.upload-btn svg { width: 16px; height: 16px; stroke: white; fill: none; }

/* ═══════════════════ HERO ═══════════════════ */
.hero {
  text-align: center;
  padding: 60px 20px 40px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  line-height: 1.1;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ═══════════════════ TRACKS SECTION ═══════════════════ */
.tracks-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.tracks-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.tracks-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.track-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 100px;
}

/* Grid */
.tracks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

/* Card */
.track-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.track-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-bright);
  background: var(--bg-card-hover);
}

.card-thumbnail {
  position: relative;
  padding-top: 56.25%;
  background: linear-gradient(135deg, #1e1040 0%, #0e2a40 100%);
  overflow: hidden;
}

.card-thumbnail img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.card-thumb-placeholder svg {
  width: 40px;
  height: 40px;
  opacity: 0.4;
}

.play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.track-card:hover .play-overlay { opacity: 1; }

.play-overlay svg {
  width: 52px;
  height: 52px;
  fill: white;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}

.card-info {
  padding: 14px 16px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-artist {
  font-size: 0.82rem;
  color: var(--purple-light);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-date {
  font-size: 0.75rem;
  color: var(--text-faint);
}

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

.empty-state svg {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.empty-state small {
  font-size: 0.85rem;
  color: var(--text-faint);
}

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


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

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

/* ═══════════════════ PLAYER PAGE ═══════════════════ */
.player-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 28px;
  align-items: start;
}

@media (max-width: 900px) {
  .player-layout { grid-template-columns: 1fr; }
}

/* Video container */
.video-main {}

.video-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.video-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.video-info {
  margin-top: 20px;
}

.video-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}

.video-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.video-artist {
  font-size: 1rem;
  font-weight: 700;
  color: var(--purple-light);
}

.video-date {
  font-size: 0.85rem;
  color: var(--text-faint);
}

.video-actions {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 100px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  transition: all 0.2s;
  cursor: pointer;
}

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

.btn svg { width: 14px; height: 14px; }
.btn svg[stroke] { stroke: currentColor; fill: none; }
.btn svg[fill] { fill: currentColor; }

.btn-danger { color: #f87171; border-color: rgba(248, 113, 113, 0.2); }
.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.5);
  color: #f87171;
}

/* Sidebar */
.player-sidebar {}

.sidebar-search-wrap {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}

.sidebar-search-wrap:focus-within { border-color: var(--purple); }

.sidebar-search {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 10px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.sidebar-search::placeholder { color: var(--text-faint); }

.sidebar-search-btn {
  background: transparent;
  border: none;
  padding: 0 14px;
  display: flex;
  align-items: center;
  color: var(--text-muted);
}

.sidebar-search-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.78rem;
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding-right: 4px;
}

.sidebar-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
}

.sidebar-item:hover {
  background: var(--bg-card);
  border-color: var(--border);
}

.sidebar-item.active {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--border-bright);
}

.sidebar-thumb {
  width: 100px;
  height: 56px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1e1040, #0e2a40);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.sidebar-thumb img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-thumb-placeholder svg { width: 20px; height: 20px; opacity: 0.35; }

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

.sidebar-track-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.sidebar-track-artist {
  font-size: 0.76rem;
  color: var(--purple-light);
}

/* ═══════════════════ UPLOAD PAGE ═══════════════════ */
.upload-page {
  max-width: 640px;
  margin: 40px auto;
  padding: 0 20px 60px;
}

.upload-page h1 {
  font-size: 1.8rem;
  font-weight: 900;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

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

.upload-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

/* Form */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.form-input::placeholder { color: var(--text-faint); }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--purple);
  background: rgba(139, 92, 246, 0.05);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-zone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  opacity: 0.4;
}

.drop-zone-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.drop-zone-hint {
  font-size: 0.8rem;
  color: var(--text-faint);
}

.file-selected {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

.file-selected.show { display: flex; }
.file-selected svg { width: 18px; height: 18px; color: var(--purple-light); }
.file-name { font-size: 0.85rem; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Thumbnail preview */
.thumb-preview {
  display: none;
  margin-top: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.thumb-preview.show { display: block; }
.thumb-preview img { width: 100%; max-height: 200px; object-fit: cover; }
.thumb-preview canvas { width: 100%; max-height: 200px; display: block; }

/* Thumbnail frame scrubber */
.thumb-scrubber {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-faint);
}
.thumb-scrubber.show { display: flex; }
.thumb-scrubber input[type=range] {
  flex: 1;
  accent-color: var(--purple);
  cursor: pointer;
  height: 4px;
}

/* Progress */
.upload-progress {
  display: none;
  margin-top: 20px;
}

.upload-progress.show { display: block; }

.progress-bar-wrap {
  background: rgba(255,255,255,0.05);
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  background: var(--gradient);
  border-radius: 100px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* Submit button */
.submit-btn {
  width: 100%;
  padding: 14px;
  background: var(--gradient);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  margin-top: 8px;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.submit-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Alert messages */
.alert {
  display: none;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 16px;
}

.alert.show { display: block; }
.alert-success { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3); color: #34d399; }
.alert-error { background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.3); color: #f87171; }

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ═══════════════════ FOOTER ═══════════════════ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.8rem;
}

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

.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: min(400px, calc(100vw - 40px));
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 8px;
}

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

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--gradient);
  color: white;
  border: none;
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--gradient);
  color: white;
  opacity: 0.85;
}

/* ═══════════════════ BACK LINK ═══════════════════ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 0;
  transition: color 0.15s;
  text-decoration: none;
}

.back-link:hover { color: var(--text); }
.back-link svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }

/* ═══════════════════ NOT FOUND ═══════════════════ */
.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100px 20px;
  text-align: center;
}

.not-found h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.not-found p { color: var(--text-muted); margin-bottom: 24px; }

/* ═══════════════════ RESPONSIVE ═══════════════════ */
@media (max-width: 600px) {
  .logo-text { display: none; }
  .upload-btn span { display: none; }
  .upload-btn { padding: 10px 12px; }
  .tracks-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .upload-card { padding: 20px; }
}
