/* style.css — Karaoke SPA, mobile-first dark theme */

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

:root {
  --bg:           #0f0f1a;
  --surface:      #1a1a2e;
  --surface2:     #22223a;
  --border:       #2e2e4e;
  --accent:       #7c3aed;
  --accent-hover: #6d28d9;
  --text:         #e2e8f0;
  --muted:        #94a3b8;
  --error:        #f87171;
  --success:      #34d399;
  --warning:      #fbbf24;
  --live:         #ef4444;
  --radius:       10px;
  --gap:          1rem;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  padding: 0.75rem 1rem 2rem;
}

#app { max-width: 700px; margin: 0 auto; }

.view { display: flex; flex-direction: column; gap: var(--gap); }
.hidden { display: none !important; }

/* ── Typography ─────────────────────────────────────────────────────────── */

h1.app-title  { font-size: 1.75rem; }
h2            { font-size: 1.15rem; margin-bottom: 0.5rem; }

/* ── Auth view ──────────────────────────────────────────────────────────── */

#view-auth { padding-top: 2rem; }
#view-auth .app-title { text-align: center; margin-bottom: 1.25rem; }

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.auth-tab {
  flex: 1;
  padding: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── App header ─────────────────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.event-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 99px;
  padding: 0.15rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ── Tab nav ────────────────────────────────────────────────────────────── */

.tab-nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0.25rem;
}

.tab-btn {
  position: relative;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.unread-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--live);
  border-radius: 50%;
}

.tab-pane { display: flex; flex-direction: column; gap: 0.75rem; }

/* ── Card ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hint-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
}

/* ── Forms ──────────────────────────────────────────────────────────────── */

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.label-hint { font-weight: 400; opacity: 0.75; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 500px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-row-inline {
  display: flex;
  gap: 0.5rem;
}
.form-row-inline .btn-primary,
.form-row-inline .btn-secondary {
  width: auto;
  flex: 1;
}

.form-error   { color: var(--error);   font-size: 0.9rem; }
.form-success { color: var(--success); font-size: 0.9rem; }
.hint         { color: var(--muted);   font-size: 0.9rem; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

button { cursor: pointer; font-size: 1rem; border: none; border-radius: 6px; transition: background 0.15s, color 0.15s; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-link {
  background: none;
  color: var(--muted);
  padding: 0.2rem 0.4rem;
  font-size: 0.9rem;
}
.btn-link:hover { color: var(--text); }

.btn-danger-outline {
  background: none;
  color: var(--error);
  border: 1px solid var(--error);
  padding: 0.5rem 1rem;
  width: 100%;
}
.btn-danger-outline:hover:not(:disabled) { background: rgba(248,113,113,0.1); }

.btn-danger-sm {
  background: none;
  color: var(--error);
  border: 1px solid var(--error);
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.btn-up, .btn-dn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
}
.btn-up:hover, .btn-dn:hover { background: var(--border); }

/* ── Section header ─────────────────────────────────────────────────────── */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Event cards ────────────────────────────────────────────────────────── */

.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.event-card--active {
  border-color: var(--accent);
}

.event-card-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.event-name   { font-weight: 600; }
.event-date   { font-size: 0.85rem; color: var(--muted); }
.event-slug   { font-size: 0.8rem; color: var(--muted); background: var(--surface2); padding: 0.1rem 0.5rem; border-radius: 4px; font-family: monospace; }

.event-card-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── Badges ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-live     { background: var(--live);   color: #fff; }
.badge-selected { background: var(--accent); color: #fff; }

/* ── Status badges ──────────────────────────────────────────────────────── */

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-pending  { background: #1e3a5f; color: #60a5fa; }
.status-up_next  { background: #3b2800; color: var(--warning); }
.status-playing  { background: #064e3b; color: var(--success); }
.status-played   { background: #1f1f1f; color: var(--muted); }
.status-skipped  { background: #2d0f0f; color: #f87171; }

.you-tag {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.key-tag {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--warning);
  font-family: monospace;
}

.duet-tag {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--success);
}
.song-notes {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.2rem;
}

/* ── Queue ──────────────────────────────────────────────────────────────── */

.queue-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.status-border-up_next  { border-color: var(--warning); }
.status-border-playing  { border-color: var(--success); }
.status-border-played   { opacity: 0.55; }
.status-border-skipped  { opacity: 0.45; border-color: #f87171; }

.queue-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.queue-pos  { font-size: 1.1rem; font-weight: 700; color: var(--accent); min-width: 2rem; }
.queue-name { font-weight: 600; flex: 1; }

.queue-songs { display: flex; flex-direction: column; gap: 0.25rem; padding-left: 0.25rem; }

.song-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.request-row {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.request-row .song-info { flex: 1; color: var(--text); }
.btn-danger-link { color: var(--live); background: none; border: none; cursor: pointer; font-size: 0.8rem; padding: 0; }
.btn-danger-link:hover { text-decoration: underline; }

.song-count { font-size: 0.85rem; color: var(--muted); font-style: italic; }

.queue-admin-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.queue-admin-controls select {
  width: auto;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

/* ── Requests form ──────────────────────────────────────────────────────── */

.song-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.song-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.song-controls { display: flex; }
.song-controls .btn-secondary { width: auto; }

.song-list { display: flex; flex-direction: column; gap: 0.4rem; }

.song-num { color: var(--muted); min-width: 1.5rem; }

/* ── Chat ───────────────────────────────────────────────────────────────── */

#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 22rem;
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chat-msg {
  display: block;
  font-size: 0.9rem;
  line-height: 1.45;
  padding: 0.1rem 0;
  word-break: break-word;
}

.chat-author-wrap { display: inline; }

.chat-punct { color: var(--muted); }

.chat-msg--me .chat-author { color: var(--accent); }

.chat-msg--dm {
  font-style: italic;
}

/* DM header: [sender -> recipient] */
.chat-dm-header {
  display: inline;
}
.chat-dm-punct {
  font-weight: 600;
  color: var(--accent);
}
.chat-dm-self {
  font-weight: 600;
  color: var(--accent);
}
.chat-dm-other {
  font-weight: 600;
  color: var(--live);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  font-style: italic;
}
.chat-dm-other:hover { text-decoration: underline; }

.chat-author {
  font-weight: 600;
  color: var(--success);
  display: inline;
}

.chat-author--clickable {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--success);
  display: inline;
}
.chat-author--clickable:hover { text-decoration: underline; }


.chat-text { display: inline; word-break: break-word; }

.chat-date-sep {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.5rem 0 0.25rem;
  letter-spacing: 0.03em;
}

.chat-bar { display: flex; gap: 0.5rem; align-items: stretch; }
.chat-bar input { flex: 1; }
.chat-bar .btn-primary { width: auto; white-space: nowrap; }

.chat-commands {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}
.chat-commands code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.3em;
  font-size: 0.85em;
}
