/* ============================================================
   Piggyback Music - Shared Styles
   Emo pig energy: black/white spirals, pink accents
   ============================================================ */

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

:root {
  --pink: #FF69B4;
  --pink-bright: #FF1493;
  --pink-glow: rgba(255, 105, 180, 0.3);
  --pink-dim: rgba(255, 105, 180, 0.15);
  --black: #0a0a0a;
  --black-card: #111;
  --black-hover: #1a1a1a;
  --white: #f5f5f5;
  --gray: #888;
  --gray-light: #aaa;
  --gray-dark: #333;
  --border: rgba(255, 255, 255, 0.06);
  --border-pink: rgba(255, 105, 180, 0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--black);
  color: var(--white);
  overflow-x: hidden;
  min-height: 100vh;
}

a { color: var(--pink); text-decoration: none; }
a:hover { color: var(--pink-bright); }

/* Spiral background */
.spiral-bg {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
  background:
    repeating-conic-gradient(
      from 0deg at 50% 50%,
      #0a0a0a 0deg 10deg,
      #151515 10deg 20deg
    );
  opacity: 0.4;
  animation: slowRotate 120s linear infinite;
}

@keyframes slowRotate {
  from { transform: scale(3) rotate(0deg); }
  to { transform: scale(3) rotate(360deg); }
}

.content {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ============================================================
   Navigation
   ============================================================ */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 48px;
  border-bottom: 1px solid rgba(255, 105, 180, 0.15);
  backdrop-filter: blur(20px);
  background: rgba(10, 10, 10, 0.85);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.5px;
  color: var(--white);
}

.logo span { color: var(--pink); }

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-links a {
  color: var(--gray);
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 20px;
  transition: all 0.2s;
  font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
}

.nav-links a.active {
  color: var(--pink);
  background: var(--pink-dim);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 20px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.25s;
  text-decoration: none;
}

.btn-pink {
  background: linear-gradient(135deg, var(--pink-bright), var(--pink));
  color: white;
  box-shadow: 0 4px 20px rgba(255, 20, 147, 0.3);
}

.btn-pink:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(255, 20, 147, 0.5);
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--pink);
  border: 1px solid rgba(255, 105, 180, 0.3);
}

.btn-outline:hover {
  background: rgba(255, 105, 180, 0.1);
  border-color: var(--pink);
  color: var(--pink);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--gray-light);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 0.95rem;
  border-radius: 24px;
}

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

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s;
}

.card:hover {
  border-color: var(--border-pink);
  background: rgba(255, 105, 180, 0.03);
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  transform: translateY(-2px);
}

/* ============================================================
   Tags / Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 10px;
  font-weight: 500;
}

.badge-pink {
  background: var(--pink-dim);
  color: var(--pink);
}

.badge-original {
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
}

.badge-branch {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.badge-deep {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.mood-tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--gray-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ============================================================
   Page Layout
   ============================================================ */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 48px 120px;
}

.page-header {
  margin-bottom: 48px;
}

.page-label {
  font-size: 0.75rem;
  color: var(--pink);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 12px;
  font-weight: 600;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 12px;
}

.page-subtitle {
  font-size: 1.1rem;
  color: var(--gray);
  line-height: 1.6;
  max-width: 600px;
}

.highlight {
  background: linear-gradient(135deg, var(--pink-bright), var(--pink), #ff8dc7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   Grid Layouts
   ============================================================ */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ============================================================
   Song Card
   ============================================================ */
.song-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.song-card:hover {
  border-color: var(--border-pink);
  background: rgba(255, 105, 180, 0.04);
  transform: translateY(-3px);
}

.song-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.song-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.song-card-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.3px;
  line-height: 1.3;
}

.song-card-artist {
  font-size: 0.82rem;
  color: var(--gray);
  margin-top: 2px;
}

.song-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--gray);
}

.song-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.song-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ============================================================
   Audio Player
   ============================================================ */
.player {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-pink);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin: 24px 0;
}

.player-main {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 20px;
}

.player-play {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink-bright), var(--pink));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  flex-shrink: 0;
  transition: all 0.25s;
  box-shadow: 0 4px 20px rgba(255, 20, 147, 0.4);
}

.player-play:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 30px rgba(255, 20, 147, 0.6);
}

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

.player-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-artist {
  font-size: 0.9rem;
  color: var(--gray);
  margin-top: 4px;
}

.player-progress {
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  cursor: pointer;
  margin-bottom: 8px;
}

.player-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--pink-bright), var(--pink));
  border-radius: 3px;
  transition: width 0.1s linear;
}

.player-progress-knob {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: var(--pink);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px rgba(255, 20, 147, 0.5);
  opacity: 0;
  transition: opacity 0.2s;
}

.player-progress:hover .player-progress-knob {
  opacity: 1;
}

.player-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--gray);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Waveform visualization
   ============================================================ */
.waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 48px;
  margin: 16px 0;
}

.waveform-bar {
  flex: 1;
  background: rgba(255, 105, 180, 0.2);
  border-radius: 2px;
  min-width: 2px;
  transition: background 0.15s;
}

.waveform-bar.active {
  background: var(--pink);
}

/* ============================================================
   Song Tree Visualization
   ============================================================ */
.tree-container {
  position: relative;
  width: 100%;
  overflow-x: auto;
  padding: 40px 0;
}

.tree-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
}

.tree-svg line {
  stroke: var(--pink);
  stroke-width: 2;
  opacity: 0.3;
}

.tree-nodes {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.tree-level {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 48px;
  width: 100%;
}

.tree-level:first-child {
  margin-top: 0;
}

.tree-node-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-width: 200px;
  max-width: 280px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  text-align: center;
}

.tree-node-card:hover {
  border-color: var(--pink);
  background: rgba(255, 105, 180, 0.08);
  transform: translateY(-3px);
}

.tree-node-card.root {
  border-color: rgba(255, 215, 0, 0.3);
  background: rgba(255, 215, 0, 0.05);
}

.tree-node-card.root:hover {
  border-color: #ffd700;
}

.tree-node-card.current {
  border-color: var(--pink);
  box-shadow: 0 0 20px rgba(255, 20, 147, 0.3);
}

.tree-node-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.tree-node-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.3px;
}

.tree-node-artist {
  font-size: 0.75rem;
  color: var(--gray);
  margin-top: 2px;
}

.tree-node-depth {
  font-size: 0.65rem;
  color: var(--pink);
  margin-top: 6px;
}

/* Tree connector lines using CSS */
.tree-connector {
  display: flex;
  justify-content: center;
  position: relative;
  height: 48px;
}

.tree-connector::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, var(--pink), rgba(255, 105, 180, 0.2));
}

/* Flat tree for mobile / simple view */
.tree-flat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tree-flat-node {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--pink);
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  transition: all 0.3s;
}

.tree-flat-node:hover {
  background: rgba(255, 105, 180, 0.08);
  transform: translateX(8px);
}

.tree-flat-node[data-depth="0"] { border-left-color: #ffd700; }
.tree-flat-node[data-depth="1"] { margin-left: 40px; border-left-color: var(--pink); }
.tree-flat-node[data-depth="2"] { margin-left: 80px; border-left-color: rgba(255, 105, 180, 0.5); }
.tree-flat-node[data-depth="3"] { margin-left: 120px; border-left-color: rgba(255, 105, 180, 0.3); }
.tree-flat-node[data-depth="4"] { margin-left: 160px; border-left-color: rgba(139, 92, 246, 0.5); }

.tree-flat-icon {
  font-size: 1.3rem;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.tree-flat-info { flex: 1; }

.tree-flat-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.tree-flat-artist {
  font-size: 0.78rem;
  color: var(--gray);
}

.tree-flat-badge {
  flex-shrink: 0;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--white);
}

.form-label .optional {
  color: var(--gray);
  font-weight: 400;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  transition: all 0.2s;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 20, 147, 0.15);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-select option {
  background: var(--black);
  color: var(--white);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--gray);
  margin-top: 6px;
}

/* File Upload */
.file-upload {
  border: 2px dashed rgba(255, 105, 180, 0.2);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.file-upload:hover,
.file-upload.dragover {
  border-color: var(--pink);
  background: rgba(255, 105, 180, 0.05);
}

.file-upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.file-upload-text {
  font-size: 0.95rem;
  color: var(--gray);
  margin-bottom: 4px;
}

.file-upload-text strong {
  color: var(--pink);
}

.file-upload-hint {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
}

.file-upload input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-preview {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 105, 180, 0.1);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.file-upload-preview.visible {
  display: flex;
}

.file-upload-preview-name {
  font-size: 0.85rem;
  font-weight: 500;
  flex: 1;
}

.file-upload-preview-size {
  font-size: 0.75rem;
  color: var(--gray);
}

/* Tag picker */
.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-picker-item {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--gray);
  transition: all 0.2s;
  user-select: none;
}

.tag-picker-item:hover {
  border-color: var(--border-pink);
  color: var(--white);
}

.tag-picker-item.selected {
  background: var(--pink-dim);
  border-color: var(--pink);
  color: var(--pink);
}

/* ============================================================
   Empty States
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 0.95rem;
  color: var(--gray);
  max-width: 400px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

/* ============================================================
   Loading / Spinner
   ============================================================ */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 105, 180, 0.2);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px;
  color: var(--gray);
  font-size: 0.9rem;
}

/* ============================================================
   Toast / Alerts
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  background: var(--black-card);
  border: 1px solid var(--border-pink);
  border-radius: var(--radius);
  font-size: 0.85rem;
  z-index: 1000;
  animation: slideUp 0.3s ease;
  max-width: 400px;
}

.toast-success { border-color: #22c55e; }
.toast-error { border-color: #ef4444; color: #ef4444; }

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

/* ============================================================
   Song Detail Layout
   ============================================================ */
.song-detail {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 48px;
  align-items: start;
}

.song-detail-main { min-width: 0; }

.song-detail-sidebar {
  position: sticky;
  top: 100px;
}

.sidebar-section {
  margin-bottom: 32px;
}

.sidebar-section-title {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--gray-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.75rem;
}

/* ============================================================
   Branch lineage breadcrumb
   ============================================================ */
.lineage {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 0.82rem;
}

.lineage-item {
  color: var(--gray);
  transition: color 0.2s;
}

.lineage-item:hover { color: var(--pink); }

.lineage-separator {
  color: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   Stats row
   ============================================================ */
.stats-row {
  display: flex;
  gap: 24px;
  margin: 16px 0;
}

.stat {
  text-align: center;
}

.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--pink);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

/* ============================================================
   Upload progress
   ============================================================ */
.upload-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}

.upload-overlay.visible {
  display: flex;
}

.upload-overlay-text {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
}

.upload-progress-bar {
  width: 300px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pink-bright), var(--pink));
  border-radius: 2px;
  width: 0%;
  animation: indeterminate 1.5s ease infinite;
}

@keyframes indeterminate {
  0% { width: 0%; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

/* ============================================================
   Footer (app pages)
   ============================================================ */
.app-footer {
  padding: 32px 48px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.25);
}

.app-footer a {
  color: rgba(255, 255, 255, 0.35);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .song-detail {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .song-detail-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  nav { padding: 12px 20px; }
  .nav-left { gap: 16px; }
  .nav-links { display: none; }
  .page { padding: 32px 20px 80px; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .player-main { flex-direction: column; text-align: center; }
  .player-play { width: 56px; height: 56px; }
  .file-upload { padding: 24px; }

  .tree-flat-node[data-depth="1"] { margin-left: 24px; }
  .tree-flat-node[data-depth="2"] { margin-left: 48px; }
  .tree-flat-node[data-depth="3"] { margin-left: 72px; }
  .tree-flat-node[data-depth="4"] { margin-left: 96px; }
}

@media (max-width: 480px) {
  .logo { font-size: 1.1rem; }
  .page-title { font-size: 1.8rem; }
  .btn-lg { padding: 12px 20px; font-size: 0.85rem; }
}
