/* ready-check — Mobile-first responsive stylesheet */

:root {
  --color-bg: #f8f9fc;
  --color-surface: #ffffff;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-text: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-ready: #10b981;
  --color-ready-bg: #ecfdf5;
  --color-not-ready: #ef4444;
  --color-not-ready-bg: #fef2f2;
  --color-help: #f59e0b;
  --color-help-bg: #fffbeb;
  --color-no-response: #9ca3af;
  --color-online: #10b981;
  --color-offline: #d1d5db;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* --- Layout --- */

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

/* --- Typography --- */

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 1.75rem;
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-ready {
  background: var(--color-ready);
  color: #fff;
  font-size: 1.25rem;
  padding: 20px 32px;
}

.btn-ready:hover:not(:disabled) { background: #059669; }

.btn-not-ready {
  background: var(--color-not-ready);
  color: #fff;
  font-size: 1.25rem;
  padding: 20px 32px;
}

.btn-not-ready:hover:not(:disabled) { background: #dc2626; }

.btn-help {
  background: var(--color-help);
  color: #fff;
  font-size: 1.25rem;
  padding: 20px 32px;
}

.btn-help:hover:not(:disabled) { background: #d97706; }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--color-primary);
  color: #fff;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-danger {
  background: var(--color-not-ready);
  color: #fff;
}

.btn-danger:hover:not(:disabled) { background: #dc2626; }

/* --- Forms --- */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  transition: border-color 0.15s ease;
}

.input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.pin-input {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 8px;
  max-width: 240px;
}

/* --- Status Indicators --- */

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.online { background: var(--color-online); }
.status-dot.offline { background: var(--color-offline); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-ready { background: var(--color-ready-bg); color: var(--color-ready); }
.badge-not-ready { background: var(--color-not-ready-bg); color: var(--color-not-ready); }
.badge-help { background: var(--color-help-bg); color: var(--color-help); }
.badge-no-response { background: #f3f4f6; color: var(--color-no-response); }

/* --- Progress Bar --- */

.progress-bar {
  width: 100%;
  height: 12px;
  background: #e5e7eb;
  border-radius: 100px;
  overflow: hidden;
  display: flex;
}

.progress-bar .segment-ready { background: var(--color-ready); }
.progress-bar .segment-not-ready { background: var(--color-not-ready); }
.progress-bar .segment-help { background: var(--color-help); }

/* --- QR Code --- */

.qr-container {
  text-align: center;
  padding: 24px;
}

.qr-container img {
  max-width: 280px;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.join-url {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f3f4f6;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  font-family: monospace;
  font-size: 0.875rem;
  word-break: break-all;
}

.join-url .copy-btn {
  flex-shrink: 0;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
}

/* --- Roster --- */

.roster-list {
  list-style: none;
}

.roster-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.roster-item:last-child { border-bottom: none; }

.roster-name {
  display: flex;
  align-items: center;
  font-weight: 500;
}

.roster-count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* --- Ready Check Panel (Participant) --- */

.check-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  z-index: 100;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.check-panel.active {
  transform: translateY(0);
}

.check-panel .check-label {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
}

.check-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.check-response-confirmed {
  text-align: center;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 600;
}

/* --- Facilitator Results Grid --- */

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.result-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
}

.result-card.ready { background: var(--color-ready-bg); }
.result-card.not_ready { background: var(--color-not-ready-bg); }
.result-card.need_help { background: var(--color-help-bg); }
.result-card.no_response { background: #f3f4f6; }

/* --- Stats Row --- */

.stats-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  min-width: 80px;
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-item.ready { background: var(--color-ready-bg); color: var(--color-ready); }
.stat-item.not-ready { background: var(--color-not-ready-bg); color: var(--color-not-ready); }
.stat-item.help { background: var(--color-help-bg); color: var(--color-help); }
.stat-item.no-response { background: #f3f4f6; color: var(--color-no-response); }

/* --- History --- */

.history-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.history-item:last-child { border-bottom: none; }

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

.history-details {
  margin-top: 12px;
  display: none;
}

.history-details.expanded { display: block; }

/* --- Centered hero layout --- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 24px;
}

.hero .card {
  width: 100%;
  max-width: 440px;
}

/* --- Alerts / Messages --- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.alert-error {
  background: var(--color-not-ready-bg);
  color: var(--color-not-ready);
  border: 1px solid #fecaca;
}

.alert-success {
  background: var(--color-ready-bg);
  color: var(--color-ready);
  border: 1px solid #a7f3d0;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* --- Connection Status --- */

.connection-status {
  position: fixed;
  top: 12px;
  right: 12px;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 200;
  display: none;
}

.connection-status.disconnected {
  display: block;
  background: var(--color-not-ready-bg);
  color: var(--color-not-ready);
}

/* --- Waiting State --- */

.waiting-state {
  text-align: center;
  padding: 48px 24px;
}

.waiting-state .pulse {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: var(--color-primary);
  border-radius: 50%;
  animation: pulse 2s infinite;
  margin-bottom: 16px;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

/* --- Utility --- */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ============================
   Responsive Breakpoints
   ============================ */

/* Laptop (768px+) — Primary for participants */
@media (min-width: 768px) {
  .container {
    padding: 32px 24px;
  }

  .card {
    padding: 32px;
  }

  h1 { font-size: 2rem; }

  .check-panel {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    max-width: 640px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
  }

  .check-panel.active {
    transform: translateX(-50%) translateY(0);
  }

  .check-buttons {
    flex-wrap: nowrap;
  }

  .check-buttons .btn {
    flex: 1;
    min-width: 160px;
  }

  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .qr-container img {
    max-width: 320px;
  }
}

/* Large display / Projector (1200px+) — Primary for facilitator */
@media (min-width: 1200px) {
  .container {
    max-width: 1200px;
    padding: 40px 32px;
  }

  h1 { font-size: 2.5rem; }

  .qr-container img {
    max-width: 400px;
  }

  .roster-count {
    font-size: 3rem;
  }

  .stat-number {
    font-size: 2.5rem;
  }

  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .facilitator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
  }

  .facilitator-layout .full-width {
    grid-column: 1 / -1;
  }
}
