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

:root {
  --bg: #f0f2f8;
  --surface: #ffffff;
  --surface2: #f5f6fa;
  --accent: #5b52e8;
  --accent-hover: #4840d6;
  --accent-light: #ede9ff;
  --text: #18192b;
  --text-muted: #6b7280;
  --border: #dde1ed;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --font: 'Segoe UI', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow);
}

/* ── Header / logo area ─────────────────────────────── */
.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.event-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.event-logo-placeholder {
  width: 80px;
  height: 80px;
  background: var(--accent-light);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}

h1 {
  font-size: 1.55rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

.code-badge {
  display: inline-block;
  background: var(--accent-light);
  border: 1.5px solid #c4beff;
  border-radius: 8px;
  padding: 0.25rem 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
}

/* ── Form ───────────────────────────────────────────── */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,82,232,0.12);
  background: #fff;
}

input::placeholder { color: #b0b5c8; }
select { cursor: pointer; }
select option { background: #fff; }

button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: var(--font);
  letter-spacing: 0.01em;
}

button[type="submit"]:hover { background: var(--accent-hover); }
button[type="submit"]:active { transform: scale(0.98); }
button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  display: none;
}
.alert.error  { background: var(--error-bg);   border: 1px solid #fca5a5; color: var(--error); }
.alert.success{ background: var(--success-bg); border: 1px solid #86efac; color: var(--success); }
.alert.show   { display: block; }

/* ── Share bar ──────────────────────────────────────── */
.share-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  margin-top: 0.5rem;
}
.share-bar .url-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-weight: 500;
}
.copy-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: var(--font);
  font-weight: 600;
  padding: 0;
  white-space: nowrap;
}
.copy-btn:hover { text-decoration: underline; }

.tv-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-decoration: none;
  margin-top: 0.6rem;
  justify-content: flex-end;
}
.tv-link:hover { color: var(--accent); }

/* ── Divider ────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Attendee list (grouped) ────────────────────────── */
.attendees-section { margin-top: 0.5rem; }

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.attendee-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Person card (grouped) */
.person-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

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

.person-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.contact-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.contact-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.contact-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.contact-chip .chip-icon { font-size: 0.85rem; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px dashed var(--border);
}

/* ── Live dot ───────────────────────────────────────── */
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

/* ── Display / TV page ──────────────────────────────── */
body.display-page {
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  display: block;
  overflow-x: hidden;
}

.display-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 2rem;
  box-shadow: var(--shadow);
}

/* Left column: logo on top, h1 below — grows to fill available space */
.display-header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.display-header-left img.header-logo,
.display-header-left .logo-ph {
  width: 300px;
  height: 150px;
  border-radius: 14px;
  object-fit: contain;
  flex-shrink: 0;
}

.display-header-left .logo-ph {
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  border: 1px solid var(--border);
}

/* Event name: left-aligned, wraps within the left column */
.display-header h1 {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.2;
  word-break: break-word;
  text-align: left;
  width: 100%;
}

/* Right column: counter + QR stacked, fixed width, top-aligned */
.display-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.9rem;
  flex-shrink: 0;
}

.display-header .join-qr {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
}

.display-header .join-qr img {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  border: none;
}

.display-header .join-qr .join-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.display-header .join-qr .join-url {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.display-counter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.display-counter strong {
  font-size: 2rem;
  color: var(--accent);
}

.display-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  padding: 1.5rem 2rem;
}

.display-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow);
  animation: cardPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardPop {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.display-card .avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
}

.display-card .person-name {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.display-card .contact-chips {
  justify-content: center;
}

.display-card .qr-code {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-top: 0.25rem;
}

.display-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 2rem;
  font-size: 1.1rem;
}

@media (max-width: 520px) {
  .card { padding: 1.5rem 1.25rem; }
  .display-header { flex-wrap: wrap; padding: 1rem; }
  .display-grid { padding: 1rem; }
}
