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

:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --success: #00b894;
  --danger: #e74c3c;
  --warning: #fdcb6e;
  --bg: #1a1a2e;
  --text: #e0e0e0;
  --dark: #e0e0e0;
  --gray: #999;
  --light-gray: #333;
  --lighter-gray: #222;
  --white: #2a2a3e;
  --card: #252540;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* ===== Header ===== */
.site-header {
  background: #16162a;
  color: #fff;
  padding: 0.6rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.logo {
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.venue-logo {
  height: 36px;
  width: auto;
  border-radius: 4px;
}

nav { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
nav a { color: #bbb; font-size: 0.85rem; }
nav a:hover { color: #fff; text-decoration: none; }

.user-info {
  color: var(--warning);
  font-size: 0.85rem;
  font-weight: 500;
}
.user-info-link {
  color: var(--warning);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.user-info-link:hover { color: #fff; text-decoration: none; }

.nav-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255,255,255,0.3);
}
.nav-avatar-placeholder {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
  font-size: 0.9rem;
}
.alert-success { background: rgba(0,184,148,0.15); color: #00b894; border: 1px solid rgba(0,184,148,0.3); }
.alert-error { background: rgba(231,76,60,0.15); color: #e74c3c; border: 1px solid rgba(231,76,60,0.3); }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--dark);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn:hover { background: var(--lighter-gray); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== Forms ===== */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  max-width: 420px;
  margin: 0 auto;
}
.form-wide { max-width: 700px; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--gray); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--lighter-gray);
  color: var(--text);
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 1rem; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ===== Auth page ===== */
.auth-page { max-width: 420px; margin: 3rem auto; text-align: center; }
.auth-page h1 { margin-bottom: 1rem; }

.auth-venue-branding {
  margin-bottom: 1.5rem;
}
.auth-venue-logo {
  max-height: 80px;
  width: auto;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}
.auth-venue-name {
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 700;
}

/* ===== Page headers ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 1rem;
}
.page-header h1 { font-size: 1.4rem; }

.venue-badge {
  background: var(--primary);
  color: #fff;
  padding: 0.2rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.header-actions { display: flex; gap: 0.5rem; align-items: center; }
.count {
  background: var(--primary);
  color: #fff;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: 0.3rem;
}

/* ===== Filter / Search bars ===== */
.filter-bar, .search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  background: var(--card);
  padding: 0.75rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-bar select, .search-bar select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-size: 0.85rem;
}
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.search-input:focus { outline: none; border-color: var(--primary); }

.search-row {
  margin-bottom: 0.5rem;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.search-row .search-input {
  flex: 1;
  width: 100%;
  padding: 0.6rem 0.9rem;
  font-size: 1rem;
  border: 2px solid var(--light-gray);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.search-row .search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}
.search-btn {
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  white-space: nowrap;
}
.live-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}
.live-toggle input { accent-color: var(--primary); }
.live-label {
  font-size: 0.75rem;
  color: var(--gray);
  font-weight: 600;
}

/* ===== Song cards (singer view) ===== */
.song-list { display: flex; flex-direction: column; gap: 0.2rem; }

.song-card {
  background: var(--card);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.song-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.song-primary {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.song-meta { display: inline-block; font-size: 0.75rem; color: #ddd; background: rgba(108,92,231,0.2); padding: 0.15rem 0.5rem; border-radius: 4px; white-space: nowrap; font-weight: 500; }
.song-key { color: #a78bfa; background: rgba(108,92,231,0.3); font-weight: 700; }

/* Pitch control / request form */
.request-form {
  width: 100%;
  padding: 0.5rem 0 0.2rem;
  border-top: 1px solid var(--lighter-gray);
  margin-top: 0.3rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.pitch-control {
  flex: 1;
  min-width: 200px;
}
.pitch-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dark);
}
.key-shifted {
  color: var(--primary);
  font-weight: 700;
  margin-left: 0.3rem;
}
.key-shifted::before { content: '→ '; color: var(--gray); font-weight: 400; }
.pitch-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
}
.pitch-slider-wrap input[type="range"] {
  flex: 1;
  height: 4px;
  accent-color: var(--primary);
}
.pitch-bound { font-size: 0.7rem; color: var(--gray); }
.pitch-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 24px;
  text-align: center;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-duet { background: #74b9ff; color: var(--dark); }
.badge-explicit { background: var(--danger); color: #fff; }
.badge-pending { background: var(--warning); color: var(--dark); }
.badge-accepted { background: var(--success); color: #fff; }
.badge-declined { background: var(--danger); color: #fff; }

/* Favorite button */
.btn-fav {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #bbb;
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  line-height: 1;
  transition: color 0.15s;
}
.btn-fav:hover { color: #e6c200; }
.btn-fav.active { color: #f1c40f; text-shadow: 0 0 4px rgba(241, 196, 15, 0.4); }

.btn-request {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
}

/* ===== Request cards (singer) ===== */
.requests-list { display: flex; flex-direction: column; gap: 0.4rem; }
.request-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--warning);
}
.request-card.status-accepted { border-left-color: var(--success); }
.request-card.status-declined { border-left-color: var(--danger); }
.request-status { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; }
.decline-reason { font-size: 0.8rem; color: var(--danger); font-style: italic; }

/* ===== KJ Dashboard ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.panel h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }

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

.kj-request-card {
  background: var(--lighter-gray);
  border-radius: var(--radius);
  padding: 0.75rem;
  border-left: 4px solid var(--warning);
  transition: all 0.3s;
}
.kj-request-card.status-accepted { border-left-color: var(--success); opacity: 0.5; }
.kj-request-card.status-declined { border-left-color: var(--danger); opacity: 0.5; }

.requester { display: block; font-size: 0.8rem; color: var(--primary); margin-top: 0.2rem; }

/* Singer list (KJ dashboard) */
.singer-list { display: flex; flex-direction: column; gap: 0.3rem; }
.singer-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: var(--lighter-gray);
  border-radius: var(--radius);
}
.singer-info { flex: 1; min-width: 0; }
.singer-name { display: block; font-weight: 600; font-size: 0.85rem; }
.singer-stats { display: block; font-size: 0.75rem; color: var(--gray); }

.request-with-avatar {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.request-with-avatar .request-info { flex: 1; min-width: 0; }

.request-actions { display: flex; gap: 0.3rem; margin-top: 0.5rem; }

.decline-form {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.decline-form input {
  flex: 1;
  min-width: 150px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

/* ===== Admin tables ===== */
.table-responsive { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
}
.data-table th {
  background: #16162a;
  color: #fff;
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
}
.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--lighter-gray);
}
.data-table tr:hover td { background: var(--lighter-gray); }
.row-inactive { opacity: 0.5; }

.bulk-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.bulk-actions select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}
.page-info { font-size: 0.85rem; color: var(--gray); }
.page-size {
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

/* ===== QR page ===== */
.qr-page { padding: 2rem 0; }
.qr-image img { max-width: 300px; border-radius: var(--radius); box-shadow: var(--shadow); }

/* ===== Import results ===== */
.import-results { padding: 1rem; background: var(--lighter-gray); border-radius: var(--radius); }
.text-success { color: var(--success); }
.text-warning { color: #e17055; }
.text-center { text-align: center; }
.text-muted { color: var(--gray); }
.mt-1 { margin-top: 0.75rem; }
.mt-2 { margin-top: 1.5rem; }
.inline-form { display: inline-flex; align-items: center; gap: 0.3rem; }
.inline-form select {
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

/* ===== Settings sections ===== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

.logo-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.5rem 0;
}
.logo-preview img {
  max-height: 60px;
  border-radius: var(--radius);
  border: 1px solid var(--light-gray);
}

.genre-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 400px;
  overflow-y: auto;
}
.genre-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.5rem;
  background: var(--lighter-gray);
  border-radius: var(--radius);
  font-size: 0.85rem;
}
.genre-item .genre-name { flex: 1; font-weight: 500; }
.genre-item .genre-count { color: var(--gray); font-size: 0.75rem; }

.genre-delete-form {
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 0.6rem;
  margin-bottom: 0.3rem;
}

.unmanaged-genres {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--light-gray);
}

/* ===== Rotation / Up Next ===== */
.now-playing-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.75rem;
}
.now-playing-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.8;
  margin-bottom: 0.3rem;
}
.now-playing-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.now-playing-info .song-title { color: #fff; font-size: 1rem; }
.now-playing-info .requester { color: rgba(255,255,255,0.8); }

.rotation-list { display: flex; flex-direction: column; gap: 0.2rem; }

.rotation-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.rotation-item.rotation-mine {
  background: #f0edff;
  border-left: 3px solid var(--primary);
}
.rotation-pos {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray);
  min-width: 20px;
  text-align: center;
}
.rotation-info { flex: 1; min-width: 0; }
.rotation-song {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rotation-singer {
  display: block;
  font-size: 0.75rem;
  color: var(--gray);
}
.rotation-mine .rotation-singer { color: var(--primary); font-weight: 600; }

/* ===== Profile / Avatars ===== */
.avatar-section { text-align: center; }
.avatar-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--light-gray);
}
.avatar-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 2.5rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--light-gray);
  flex-shrink: 0;
}
.avatar-sm-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== Toast Notifications ===== */
#toast-container {
  position: fixed;
  top: 60px;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
  width: calc(100% - 2rem);
}

.toast {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border-left: 4px solid var(--gray);
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
  overflow: hidden;
}
.toast-show {
  opacity: 1;
  transform: translateX(0);
}
.toast-hide {
  opacity: 0;
  transform: translateX(100%);
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }

.toast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem 0.25rem;
  font-size: 0.85rem;
}
.toast-header strong { color: var(--dark); }
.toast-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--gray);
  cursor: pointer;
  line-height: 1;
  padding: 0 0.2rem;
}
.toast-body {
  padding: 0.25rem 0.75rem 0.6rem;
  font-size: 0.82rem;
  color: var(--gray);
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 1.5rem 0;
  color: var(--gray);
  font-size: 0.8rem;
  margin-top: 2rem;
}

/* ===== Print ===== */
@media print {
  .site-header, .site-footer, .btn, nav { display: none !important; }
  .qr-image img { max-width: 400px; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  nav { width: 100%; justify-content: flex-start; overflow-x: auto; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .song-row { flex-wrap: wrap; }
  .song-primary { min-width: 100%; font-size: 0.82rem; }
  .song-right { width: 100%; justify-content: flex-end; margin-top: 0.1rem; }
  .data-table { font-size: 0.78rem; }
  .data-table th, .data-table td { padding: 0.4rem 0.5rem; }
}
