/* Dreamshell DJ v2 — Campfire Theme (Evolved) */

:root {
  --bg: #080808;
  --bg2: #0f0d0b;
  --card: #181310;
  --card2: #1e1810;
  --card-border: #2d2018;
  --ember: #e8842e;
  --ember-bright: #ff9d45;
  --ember-glow: #ffb060;
  --ember-dim: #a05020;
  --ash: #7a6a5a;
  --smoke: #a09080;
  --text: #ede0d0;
  --text-dim: #7a6a5a;
  --text-muted: #4a3a2a;
  --fire: #ff4500;
  --gold: #f0c060;
  --radius: 14px;
  --radius-sm: 8px;
  --tab-h: 60px;
  --header-h: 72px;
  --now-h: 140px;
}

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

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Campfire Canvas ─── */
#campfire-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ─── Name Prompt ─── */
#name-prompt {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.prompt-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 36px 28px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 0 40px rgba(232,132,46,0.15);
}

.prompt-card .fire-logo {
  font-size: 2.8em;
  margin-bottom: 12px;
  display: block;
}

.prompt-card h2 {
  color: var(--ember);
  margin-bottom: 4px;
  font-size: 1.5em;
  letter-spacing: 0.5px;
}

.prompt-card .subtitle {
  color: var(--text-dim);
  font-size: 0.85em;
  margin-bottom: 24px;
  line-height: 1.5;
}

.prompt-card .input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.prompt-card input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1em;
  outline: none;
  min-width: 0;
}

.prompt-card input:focus { border-color: var(--ember); }

.prompt-card .emoji-pick {
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2em;
  white-space: nowrap;
  flex-shrink: 0;
}

.prompt-card button.join-btn {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--ember), var(--ember-bright));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity 0.15s;
}

.prompt-card button.join-btn:active { opacity: 0.85; }

/* Emoji picker popover */
.emoji-popover {
  position: fixed;
  background: var(--card2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 240px;
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.emoji-popover span {
  font-size: 1.4em;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.1s;
}
.emoji-popover span:hover { background: rgba(232,132,46,0.2); }
.emoji-popover.hidden { display: none; }

/* ─── Layout Shell ─── */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.hidden { display: none !important; }

/* ─── Header ─── */
.header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--card-border);
  background: rgba(8,8,8,0.8);
  backdrop-filter: blur(8px);
}

.header-left h1 {
  font-size: 1.2em;
  color: var(--ember);
  letter-spacing: 0.5px;
  font-weight: 700;
}

.header-left .fire-count {
  font-size: 0.75em;
  color: var(--text-dim);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 0.8em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
}
.connection-dot.connected { background: #4a4; }
.connection-dot.connecting { background: var(--ember); animation: pulse 1s infinite; }

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

/* ─── Now Playing Bar ─── */
.now-playing-bar {
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border-bottom: 1px solid var(--card-border);
  padding: 10px 16px;
}

.np-idle-msg {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85em;
  padding: 6px 0;
}

.np-content {
  display: flex;
  gap: 12px;
  align-items: center;
}

.np-thumb {
  width: 56px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--card-border);
}

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

.np-title {
  font-weight: 600;
  font-size: 0.9em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.np-meta {
  font-size: 0.75em;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.np-votes {
  font-size: 0.75em;
  color: var(--ember-dim);
  margin-top: 2px;
}

.np-advance-btn {
  background: none;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 0.8em;
  padding: 5px 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.np-advance-btn:hover { border-color: var(--ember); color: var(--ember); }

/* ─── Content Area ─── */
.content-area {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 12px 12px;
  display: none;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.tab-panel.active { display: flex; flex-direction: column; }

/* ─── Bottom Tabs ─── */
.bottom-tabs {
  height: var(--tab-h);
  display: flex;
  border-top: 1px solid var(--card-border);
  background: rgba(8,8,8,0.95);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: color 0.15s;
  padding: 8px 4px;
  position: relative;
}

.tab-btn .tab-icon { font-size: 1.3em; line-height: 1; }
.tab-btn .tab-label { font-size: 0.65em; letter-spacing: 0.3px; font-weight: 500; }

.tab-btn.active {
  color: var(--ember);
}

.tab-btn .tab-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 14px);
  background: var(--fire);
  color: #fff;
  border-radius: 10px;
  font-size: 0.6em;
  font-weight: 700;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

/* ─── Pool / Queue Cards ─── */
.song-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  transition: border-color 0.15s;
}

.song-card:active { border-color: var(--ember-dim); }

.song-thumb {
  width: 56px;
  height: 42px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}

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

.song-title {
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.song-artist {
  font-size: 0.75em;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.song-by {
  font-size: 0.7em;
  color: var(--ember-dim);
  margin-top: 2px;
}

/* Upvote button */
.upvote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: none;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 6px 10px;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  min-width: 44px;
  font-size: 0.8em;
}

.upvote-btn .vote-icon { font-size: 1.1em; }
.upvote-btn .vote-count { font-weight: 700; font-size: 0.85em; line-height: 1; }

.upvote-btn.voted {
  background: rgba(232,132,46,0.15);
  border-color: var(--ember);
  color: var(--ember);
}

.upvote-btn.bump {
  animation: voteGlow 0.4s ease-out;
}

@keyframes voteGlow {
  0% { transform: scale(1); }
  40% { transform: scale(1.2); box-shadow: 0 0 12px var(--ember); }
  100% { transform: scale(1); }
}

/* Queue number */
.queue-num {
  color: var(--ember-dim);
  font-weight: 700;
  font-size: 0.9em;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* Graduated badge */
.grad-badge {
  font-size: 0.65em;
  background: rgba(232,132,46,0.15);
  border: 1px solid var(--ember-dim);
  color: var(--ember);
  border-radius: 10px;
  padding: 1px 6px;
  margin-left: 4px;
}

/* Section headers */
.section-header {
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 2px 2px;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 0.9em;
  line-height: 1.6;
}
.empty-state .empty-icon { font-size: 2em; margin-bottom: 8px; }

/* ─── Search Panel ─── */
.search-bar {
  display: flex;
  gap: 8px;
  padding-bottom: 2px;
}

.search-bar input {
  flex: 1;
  padding: 11px 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95em;
  outline: none;
}

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

.search-bar button {
  padding: 11px 16px;
  background: var(--ember);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.search-result {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.search-result:active, .search-result:hover { border-color: var(--ember-dim); }

.sr-thumb {
  width: 64px;
  height: 48px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}

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

.sr-title {
  font-size: 0.85em;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-meta {
  font-size: 0.72em;
  color: var(--text-dim);
  margin-top: 2px;
}

.sr-add {
  color: var(--ember);
  font-size: 1.4em;
  padding: 4px;
  flex-shrink: 0;
}

/* Search results now use .chat-add-btn too — ensure alignment */
.search-result .chat-add-btn {
  flex-shrink: 0;
}

.loading-msg {
  text-align: center;
  color: var(--text-dim);
  padding: 24px;
  font-size: 0.9em;
}

/* ─── Chat Hint ─── */
.chat-hint {
  font-size: 0.78em;
  color: var(--text-dim);
  text-align: center;
  padding: 6px 12px 2px;
  flex-shrink: 0;
}

/* ─── Chat Song Cards ─── */
.chat-song-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.chat-song-card {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(232,132,46,0.18);
  border-radius: 10px;
  padding: 8px;
  transition: border-color 0.15s;
}

.chat-song-thumb {
  width: 52px;
  height: 39px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}

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

.chat-song-title {
  font-size: 0.82em;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-song-artist {
  font-size: 0.72em;
  color: var(--text-dim);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Add to Pool button — amber campfire style */
.chat-add-btn {
  flex-shrink: 0;
  padding: 7px 11px;
  background: linear-gradient(135deg, #c96a10, var(--ember-bright));
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 0.72em;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, background 0.2s;
  min-width: 88px;
  text-align: center;
}

.chat-add-btn:active {
  opacity: 0.8;
}

.chat-add-btn.added {
  background: rgba(60,140,60,0.25);
  color: #6ecf6e;
  border: 1px solid rgba(60,140,60,0.4);
  cursor: default;
}

/* ─── Search Panel extras ─── */
.search-intro {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(232,132,46,0.07);
  border: 1px solid rgba(232,132,46,0.18);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
}

.search-intro-icon {
  font-size: 1.2em;
  flex-shrink: 0;
  margin-top: 1px;
}

.search-intro-text {
  font-size: 0.8em;
  color: var(--text-dim);
  line-height: 1.45;
}

.direct-search-link {
  display: block;
  width: 100%;
  background: none;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.8em;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  margin-bottom: 8px;
  transition: color 0.15s, border-color 0.15s;
}

.direct-search-link:hover {
  color: var(--ember);
  border-color: var(--ember-dim);
}

.search-hint {
  font-size: 0.78em;
  color: var(--text-dim);
  text-align: center;
  padding: 2px 0 8px;
}

/* ─── Chat Panel ─── */
#tab-chat {
  padding-bottom: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 0 8px;
  -webkit-overflow-scrolling: touch;
}

.chat-msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  align-self: flex-end;
}

.chat-msg.dj {
  background: rgba(232,132,46,0.08);
  border-color: rgba(232,132,46,0.25);
  align-self: flex-start;
}

.chat-msg.other {
  align-self: flex-start;
}

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 3px;
}

.msg-name {
  font-size: 0.72em;
  font-weight: 700;
  color: var(--ember);
}

.msg-time {
  font-size: 0.65em;
  color: var(--text-muted);
}

.msg-text {
  font-size: 0.85em;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}

.chat-input-area {
  padding: 8px 0 4px;
  display: flex;
  gap: 8px;
  background: var(--bg);
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  color: var(--text);
  font-size: 0.9em;
  outline: none;
  user-select: text;
}

.chat-input-area input:focus { border-color: var(--ember); }

.chat-input-area button {
  padding: 10px 14px;
  background: var(--ember);
  color: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.95em;
  flex-shrink: 0;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 2px; }

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  bottom: calc(var(--tab-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: var(--card2);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.8em;
  color: var(--text);
  white-space: nowrap;
  animation: toastIn 0.2s ease-out, toastOut 0.3s ease-in 2.2s 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(-6px); }
}

/* ─── YTMusic Play Buttons ────────────────────────── */

/* ─── QR Code Section ───────────────────────────── */

.qr-section {
  margin: 12px auto 4px;
  text-align: center;
}

.qr-code {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  opacity: 0.85;
}

.qr-label {
  font-size: 0.7em;
  color: var(--text-dim);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* ─── YTMusic Play Buttons ────────────────────────── */

.ytm-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: rgba(255, 0, 0, 0.15);
  border: 1px solid rgba(255, 0, 0, 0.3);
  text-decoration: none;
  font-size: 1.1em;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ytm-play-btn:hover, .ytm-play-btn:active {
  background: rgba(255, 0, 0, 0.3);
  border-color: rgba(255, 0, 0, 0.5);
  transform: scale(1.1);
}

.ytm-play-btn.now-playing-play {
  width: 48px;
  height: 48px;
  min-width: 48px;
  font-size: 1.3em;
  background: rgba(255, 60, 0, 0.2);
  border-color: var(--ember-dim);
}

.ytm-open-all {
  display: block;
  text-align: center;
  padding: 12px 16px;
  margin: 0 0 8px 0;
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.12), rgba(255, 80, 0, 0.12));
  border: 1px solid rgba(255, 60, 0, 0.25);
  border-radius: 12px;
  color: var(--ember);
  text-decoration: none;
  font-size: 0.95em;
  font-weight: 600;
  transition: all 0.2s;
}

.ytm-open-all:hover, .ytm-open-all:active {
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.22), rgba(255, 80, 0, 0.22));
  border-color: var(--ember);
}

/* ─── QR / Invite Tab ───────────────────────────────────────────────── */

.qr-share-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  text-align: center;
  width: 100%;
  flex: 1;
}

.qr-share-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.qr-share-subtitle {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.qr-share-code {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-share-img {
  width: 220px;
  height: 220px;
  image-rendering: pixelated;
  display: block;
}

.qr-share-url {
  color: var(--ember);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 1.5rem;
}

.qr-share-btn {
  background: var(--card2);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 0.75rem 2rem;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.75rem;
  width: 220px;
  transition: all 0.15s;
}

.qr-share-btn:active {
  transform: scale(0.97);
  background: var(--card);
}

.qr-native-share {
  background: linear-gradient(135deg, var(--ember) 0%, var(--ember-bright) 100%);
  color: #1a1a1a;
  border: none;
}
