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

/* ─── CSS Custom Properties ─────────────────────────────────────── */
:root {
  --bg: #0a0a0a;
  --card: #181818;
  --card-hover: #282828;
  --accent: #1db954;
  --accent-hover: #1ed760;
  --accent-dim: rgba(29, 185, 84, 0.15);
  --text: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #6b6b6b;
  --border: #333333;
  --border-light: #444444;
  --danger: #e53935;
  --danger-hover: #ef5350;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input, select {
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.2s;
}

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

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

select option {
  background: #2a2a2a;
}

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ─── Utility Classes ────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 50px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  white-space: nowrap;
  min-height: 40px;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: white;
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--card-hover);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.8rem;
  min-height: 32px;
}

.btn-icon {
  padding: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  min-height: auto;
}

/* ─── Progress Bar ───────────────────────────────────────────────── */
.progress-container {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.75rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s linear;
  width: 0%;
}

.progress-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* ─── Album Art ──────────────────────────────────────────────────── */
.album-art {
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--card-hover);
  flex-shrink: 0;
}

.album-art-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-hover);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.5rem;
  flex-shrink: 0;
}

/* ─── Toast Notifications ────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 50px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease forwards;
  max-width: 90vw;
  text-align: center;
}

.toast.success {
  border-color: var(--accent);
  color: var(--accent);
}

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

.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

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

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

/* ─── Loading Spinner ────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ─── ════════════════════════════════════════════════════════════ ─ */
/* ─── ADMIN LAYOUT ───────────────────────────────────────────────── */
/* ─── ════════════════════════════════════════════════════════════ ─ */

.admin-layout {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* Header */
.admin-header {
  background: rgba(10, 10, 10, 0.95);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.admin-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

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

.admin-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.admin-user a {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.admin-user a:hover {
  color: var(--danger);
}

/* Main content */
.admin-content {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem;
  gap: 1.5rem;
}

.admin-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Create Room Form */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* QR Section */
.qr-section {
  text-align: center;
}

.qr-image {
  width: 200px;
  height: 200px;
  border-radius: var(--radius-sm);
  border: 4px solid white;
  margin: 0 auto 1rem;
  display: block;
}

.qr-url {
  font-size: 0.8rem;
  color: var(--text-secondary);
  word-break: break-all;
  margin-bottom: 1rem;
  font-family: monospace;
}

.qr-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Now Playing Card - Admin */
.now-playing-card {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.now-playing-art {
  width: 72px;
  height: 72px;
}

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

.now-playing-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}

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

.now-playing-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Queue List */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: background 0.15s;
}

.queue-item:hover {
  background: var(--card-hover);
  border-color: var(--border-light);
}

.queue-position {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

.queue-art {
  width: 40px;
  height: 40px;
  border-radius: 4px;
}

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

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

.queue-artist {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-added-by {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.queue-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.queue-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

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

.queue-btn.danger:hover {
  background: rgba(229, 57, 53, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

.queue-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Status indicator */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
  margin-right: 0.5rem;
}

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

/* ─── ════════════════════════════════════════════════════════════ ─ */
/* ─── ROOM LAYOUT ────────────────────────────────────────────────── */
/* ─── ════════════════════════════════════════════════════════════ ─ */

.room-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 600px;
  margin: 0 auto;
}

/* Room Header */
.room-header {
  background: rgba(10, 10, 10, 0.95);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.room-header-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.room-header-logo {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* Now Playing Hero */
.hero-now-playing {
  padding: 1.25rem;
  background: linear-gradient(180deg, var(--card) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
}

.hero-art-container {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.hero-art {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

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

.hero-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.hero-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.hero-artist {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mini Queue */
.mini-queue {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.mini-queue-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.mini-queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mini-queue-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mini-queue-num {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 16px;
  text-align: right;
}

.mini-queue-art {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  flex-shrink: 0;
}

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

.mini-queue-name {
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-queue-artist {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-queue-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Search */
.search-section {
  padding: 1rem 1.25rem 0.75rem;
  position: sticky;
  top: 57px;
  background: rgba(10, 10, 10, 0.95);
  z-index: 90;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.search-input-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input {
  padding-left: 2.25rem;
  padding-right: 2.5rem;
}

.search-clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem;
  display: none;
}

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

/* Track List */
.track-list-section {
  padding: 0.75rem 1.25rem 5rem;
}

.track-list-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.75rem;
  padding-top: 0.5rem;
}

.track-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  border: 1px solid transparent;
}

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

.track-art {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  flex-shrink: 0;
}

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

.track-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}

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

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

.track-add-btn {
  flex-shrink: 0;
  min-width: 90px;
  font-size: 0.78rem;
  padding: 0.4rem 0.875rem;
  min-height: 36px;
}

.track-add-btn.queued {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  cursor: default;
  opacity: 0.8;
}

.track-add-btn.cooldown {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: not-allowed;
  font-size: 0.7rem;
  min-width: 110px;
}

.load-more-btn {
  width: 100%;
  margin-top: 1rem;
  border-radius: var(--radius-sm);
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .admin-content {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .admin-header {
    padding: 0 1rem;
  }

  .room-header {
    padding: 0.75rem 1rem;
  }

  .hero-art {
    width: 64px;
    height: 64px;
  }

  .hero-title {
    font-size: 1.05rem;
  }

  .track-item {
    padding: 0.5rem;
  }

  .track-art {
    width: 42px;
    height: 42px;
  }
}
