/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:          #121212;
  --surface:     #1e1e1e;
  --elevated:    #282828;
  --border:      rgba(255, 255, 255, 0.1);
  --green:       #8b5cf6;
  --green-hover: #a78bfa;
  --text:        #ffffff;
  --muted:       #b3b3b3;
  --danger:      #e22134;
  --radius:      10px;
  --transition:  0.18s ease;
}

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

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

/* ── Header ────────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 18, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--green);
  text-decoration: none;
}

.logo h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  font-family: monospace;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border: none;
  border-radius: 500px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #000;
}
.btn-primary:hover {
  background: var(--green-hover);
  transform: scale(1.04);
}

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

.btn-lg {
  padding: 14px 36px;
  font-size: 1rem;
}

/* ── Main layout ───────────────────────────────────────────────────────────── */
main {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 16px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Mobile: col-right unsichtbar, QR-Karte versteckt */
.col-right {
  display: contents;
}

.qr-card { display: none; }

/* ── QR-Code ───────────────────────────────────────────────────────────────── */
#qr-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

#qr-wrap canvas {
  border-radius: 8px;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.qr-url {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: monospace;
  text-align: center;
}

/* ── Desktop-Layout ────────────────────────────────────────────────────────── */
@media (min-width: 900px) {
  body {
    overflow: hidden;
    height: 100dvh;
  }

  /*
    Grid:
      [ now-playing ] [ qr-card ]   ← oben: Song links, QR rechts
      [ col-right              ]    ← unten: volle Breite
  */
  main {
    display: grid;
    grid-template-columns: 1fr 160px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "now-playing qr-card"
      "right       right";
    gap: 20px;
    max-width: none;
    width: 100%;
    height: calc(100dvh - 64px);
    padding: 20px 24px;
    overflow: hidden;
    box-sizing: border-box;
  }

  #now-playing {
    grid-area: now-playing;
    align-self: stretch;
  }

  /* QR-Karte: gleiche Höhe wie Now-Playing, quadratisch durch feste Breite */
  .qr-card {
    grid-area: qr-card;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
  }

  /* Rechte Spalte: Auth + Search + Queue */
  .col-right {
    grid-area: right;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    min-width: 0;
  }

  /* Queue-Karte füllt verfügbaren Platz, scrollt intern */
  .queue-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }

  #queue-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }

  #queue-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  /* Search-Ergebnisse scrollen intern */
  #search-section { flex-shrink: 0; }

  #search-results {
    max-height: 240px;
    overflow-y: auto;
  }

  /* Now-Playing: Fortschrittsbalken bricht auf volle Breite um */
  .now-playing-content {
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 20px;
  }

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

  .progress-wrap {
    width: 100%;
    flex-shrink: 0;
  }

  .progress-bar {
    height: 8px;
    border-radius: 4px;
    margin-bottom: 8px;
  }

  .progress-times {
    font-size: 0.78rem;
  }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}

.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ── Now Playing ───────────────────────────────────────────────────────────── */
.now-playing-card {
  background: linear-gradient(135deg, #2d1f4e 0%, #231a3a 50%, var(--surface) 100%);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
}

.now-playing-empty {
  color: var(--muted);
  font-size: 0.875rem;
  width: 100%;
  text-align: center;
  padding: 16px 0;
}

.now-playing-content {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.now-playing-art {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--elevated);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  transition: box-shadow 0.5s ease;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 0 0 rgba(139, 92, 246, 0.5); }
  50%       { box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 0 8px rgba(139, 92, 246, 0); }
}

.now-playing-art.is-playing {
  animation: pulse-glow 2.5s ease-in-out infinite;
}

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

.now-playing-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--green);
  margin-bottom: 6px;
}

.now-playing-name {
  font-size: 1.4rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.now-playing-artist {
  font-size: 0.95rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

.progress-wrap {
  flex-shrink: 0;
  width: 200px;
}

.progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 1s linear;
}

.progress-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ── Auth prompt ───────────────────────────────────────────────────────────── */
.auth-prompt {
  text-align: center;
  padding: 48px 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.auth-prompt-icon {
  color: var(--green);
  opacity: 0.8;
}

.auth-prompt p {
  color: var(--muted);
  font-size: 1rem;
  max-width: 320px;
}

/* ── Search ────────────────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
}

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

.search-input {
  width: 100%;
  padding: 11px 44px;
  background: var(--elevated);
  border: 2px solid transparent;
  border-radius: 500px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}

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

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

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}
.search-clear:hover { color: var(--text); }

/* ── Search results ────────────────────────────────────────────────────────── */
.search-results {
  display: none;
  margin-top: 8px;
  background: var(--elevated);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.search-results.visible { display: block; }

.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}

.search-result:last-child { border-bottom: none; }
.search-result:hover { background: rgba(255, 255, 255, 0.06); }

.search-no-results {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Track thumbnail ───────────────────────────────────────────────────────── */
.track-thumb {
  width: 42px;
  height: 42px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}

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

.track-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.track-duration {
  font-size: 0.75rem;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.add-btn {
  background: var(--green);
  color: #000;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  opacity: 0;
  line-height: 1;
}

.search-result:hover .add-btn {
  opacity: 1;
  transform: scale(1.1);
}
.add-btn:hover { background: var(--green-hover); }

/* ── Queue ─────────────────────────────────────────────────────────────────── */
.queue-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.queue-header .section-title { margin-bottom: 0; }

.badge {
  background: var(--elevated);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 500px;
  border: 1px solid var(--border);
}

.queue-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 24px;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

.queue-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background var(--transition);
  position: relative;
}

.queue-item:hover { background: rgba(255, 255, 255, 0.05); }

.queue-item.top-item {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.queue-rank {
  width: 22px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.top-item .queue-rank { color: var(--green); }

.track-added-by {
  font-size: 0.72rem;
  color: var(--green);
  opacity: 0.7;
  margin-top: 1px;
}

.queue-item .track-info .track-album {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  opacity: 0.8;
}

/* ── Vote ──────────────────────────────────────────────────────────────────── */
.vote-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  min-width: 36px;
}

.vote-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 34px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.vote-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(139, 92, 246, 0.1);
}

.vote-btn.voted {
  border-color: var(--green);
  color: var(--green);
  background: rgba(139, 92, 246, 0.15);
}

.vote-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.voted + .vote-count,
.vote-btn.voted ~ .vote-count { color: var(--green); }

/* ── Remove button ─────────────────────────────────────────────────────────── */
.remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  opacity: 0;
}

.queue-item:hover .remove-btn { opacity: 1; }
.remove-btn:hover {
  background: rgba(226, 33, 52, 0.15);
  color: var(--danger);
}

/* ── Spotify Next Up ───────────────────────────────────────────────────────── */
.next-up-divider {
  list-style: none;
  padding: 14px 16px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.next-up-item {
  opacity: 0.55;
}

.next-up-item:hover {
  opacity: 0.8;
}



/* ── Admin Panel ───────────────────────────────────────────────────────────── */

.btn-icon {
  padding: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  justify-content: center;
}

.btn-danger {
  background: rgba(226, 33, 52, 0.15);
  color: var(--danger);
  border: 1px solid rgba(226, 33, 52, 0.3);
}
.btn-danger:hover {
  background: rgba(226, 33, 52, 0.25);
}

.admin-panel {
  max-width: 420px;
  width: 100%;
}

.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 4px;
}

.admin-token-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  max-height: 50vh;
  overflow-y: auto;
}

.admin-token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.admin-token-name {
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#confirm-overlay {
  z-index: 400;
}

.confirm-modal {
  gap: 20px;
  padding: 28px 24px;
  max-width: 320px;
}

.confirm-message {
  font-size: 1rem;
  text-align: center;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

.confirm-actions .btn {
  flex: 1;
}

.admin-self-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--elevated);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
}

.admin-token-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.admin-delete-btn {
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  border-color: var(--danger);
  opacity: 0.7;
}
.admin-delete-btn:hover { opacity: 1; }

/* ── NFC Modal ─────────────────────────────────────────────────────────────── */
.nfc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.nfc-modal {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.nfc-step { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.nfc-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  margin: 0 auto 4px;
}

.nfc-icon--success {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--green);
}

.nfc-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.nfc-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.nfc-sim-box {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.nfc-sim-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nfc-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition);
}

.nfc-input:focus { border-color: var(--green); }

.nfc-cancel {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 8px;
  margin-top: 4px;
  opacity: 0.8;
}

.nfc-cancel:hover { opacity: 1; }

.nfc-manual-toggle {
  font-size: 0.8rem;
  padding: 5px 14px;
  margin-top: 8px;
  opacity: 0.7;
}
.nfc-manual-toggle:hover { opacity: 1; }

.nfc-user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  cursor: pointer;
}

.nfc-user-badge:hover { border-color: var(--green); color: var(--text); }
.nfc-user-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
}

.toast {
  background: var(--elevated);
  color: var(--text);
  padding: 11px 22px;
  border-radius: 500px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--green); }

/* ── In-Queue indicator ────────────────────────────────────────────────────── */
.search-result.in-queue {
  opacity: 0.55;
  pointer-events: none;
}

.in-queue-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--green);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── QR Code ───────────────────────────────────────────────────────────────── */
.qr-card { text-align: center; }

.qr-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0 4px;
}

#qr-canvas {
  border-radius: 8px;
  display: block;
}

.qr-url {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: monospace;
  letter-spacing: 0.02em;
}

/* ── Admin Sections ────────────────────────────────────────────────────────── */
.admin-section {
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}

.admin-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── Admin Playback ────────────────────────────────────────────────────────── */
.admin-playback {
  display: flex;
  gap: 10px;
  width: 100%;
}

.admin-playback-btn {
  flex: 1;
  justify-content: center;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
#queue-list,
#search-results {
  scrollbar-width: thin;
  scrollbar-color: var(--elevated) transparent;
}

#queue-list::-webkit-scrollbar,
#search-results::-webkit-scrollbar {
  width: 6px;
}

#queue-list::-webkit-scrollbar-track,
#search-results::-webkit-scrollbar-track {
  background: transparent;
}

#queue-list::-webkit-scrollbar-thumb,
#search-results::-webkit-scrollbar-thumb {
  background: var(--elevated);
  border-radius: 3px;
}

#queue-list::-webkit-scrollbar-thumb:hover,
#search-results::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 580px) {
  header { padding: 0 16px; }
  main { padding: 16px 12px 60px; gap: 14px; }
  .card { padding: 16px; }
  .progress-wrap { display: none; }
  .queue-item .track-album { display: none; }
  .queue-rank { display: none; }
}
