/* ─── Zscaler Corporate Design ─────────────────────────────── */
:root {
  --zs-blue: #0078D4;
  --zs-light-blue: #00A1E0;
  --zs-navy: #002B49;
  --zs-green: #6CC24A;
  --zs-white: #FFFFFF;
  --zs-gray-light: #F4F6F8;
  --zs-gray: #8C9BAA;
  --zs-gray-dark: #4A5568;
  --zs-red: #E04355;
  --zs-gold: #FFB800;
  --zs-silver: #C0C0C0;
  --zs-bronze: #CD7F32;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--zs-gray-light);
  color: var(--zs-navy);
  min-height: 100vh;
}

/* ─── Layout ───────────────────────────────────────────────── */

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

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* ─── Header ───────────────────────────────────────────────── */

.header {
  position: relative;
  background: linear-gradient(135deg, var(--zs-navy), var(--zs-blue));
  color: white;
  padding: 20px;
  text-align: center;
  position: relative;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.header .subtitle {
  font-size: 0.85rem;
  opacity: 0.8;
}

.header .badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  margin-top: 8px;
}

.logo-img {
  max-height: 80px;
  max-width: 260px;
  margin-bottom: 12px;
  border-radius: var(--radius);
}

/* ─── Cards ────────────────────────────────────────────────── */

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-header h2 {
  font-size: 1.1rem;
  color: var(--zs-navy);
}

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

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

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--zs-blue);
  color: white;
}
.btn-primary:hover { background: #006abb; }

.btn-success {
  background: var(--zs-green);
  color: white;
}
.btn-success:hover { background: #5aaf3a; }

.btn-danger {
  background: var(--zs-red);
  color: white;
}
.btn-danger:hover { background: #c7384a; }

.btn-outline {
  background: transparent;
  color: var(--zs-blue);
  border: 2px solid var(--zs-blue);
}
.btn-outline:hover {
  background: var(--zs-blue);
  color: white;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.2rem;
}

.btn-block {
  width: 100%;
}

.btn-gold { background: var(--zs-gold); color: var(--zs-navy); }
.btn-gray { background: var(--zs-gray); color: white; }
.btn-navy { background: var(--zs-navy); color: white; }

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

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--zs-gray-dark);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--zs-blue);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%234A5568' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--zs-green);
}

/* ─── Answer buttons (Player) ──────────────────────────────── */

.answers-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

@media (min-width: 600px) {
  .answers-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.answer-btn {
  padding: 16px 20px;
  min-height: 56px;
  border: 3px solid #e2e8f0;
  border-radius: var(--radius);
  background: white;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  position: relative;
}

.answer-btn:hover:not(.selected):not(.disabled) {
  border-color: var(--zs-blue);
  background: #f0f7ff;
}

.answer-btn.selected {
  border-color: var(--zs-blue);
  background: #e8f2ff;
  font-weight: 700;
}

.answer-btn.correct {
  border-color: var(--zs-green);
  background: #edfae5;
}

.answer-btn.wrong {
  border-color: var(--zs-red);
  background: #fde8ea;
}

.answer-btn.disabled {
  cursor: default;
  opacity: 0.7;
}

.answer-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--zs-gray-light);
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 10px;
  flex-shrink: 0;
  color: var(--zs-navy);
}

.answer-btn.selected .answer-letter {
  background: var(--zs-blue);
  color: white;
}

.answer-btn.correct .answer-letter {
  background: var(--zs-green);
  color: white;
}

.answer-btn.wrong .answer-letter {
  background: var(--zs-red);
  color: white;
}

.answer-stat {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--zs-gray);
}

/* ─── Timer ────────────────────────────────────────────────── */

.timer-container {
  text-align: center;
  margin: 20px 0;
}

.timer-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--zs-blue);
  border: 6px solid var(--zs-blue);
  transition: all 0.3s;
}

.timer-circle.warning {
  color: var(--zs-gold);
  border-color: var(--zs-gold);
}

.timer-circle.danger {
  color: var(--zs-red);
  border-color: var(--zs-red);
  animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
  to { transform: scale(1.05); }
}

.timer-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  background: var(--zs-blue);
  border-radius: 4px;
  transition: width 1s linear;
}

.timer-bar-fill.warning { background: var(--zs-gold); }
.timer-bar-fill.danger { background: var(--zs-red); }

/* ─── Leaderboard ──────────────────────────────────────────── */

.leaderboard {
  width: 100%;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  transition: all var(--transition);
}

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

.leaderboard-rank {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  margin-right: 12px;
  background: var(--zs-gray-light);
  color: var(--zs-navy);
  flex-shrink: 0;
}

.leaderboard-rank.gold { background: var(--zs-gold); color: #333; }
.leaderboard-rank.silver { background: var(--zs-silver); color: #333; }
.leaderboard-rank.bronze { background: var(--zs-bronze); color: white; }

.leaderboard-name {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
}

.leaderboard-score {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--zs-blue);
}

.leaderboard-item.highlight {
  background: #f0f7ff;
  border-radius: 8px;
}

/* ─── Podium (Finale) ──────────────────────────────────────── */

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 40px 0;
  min-height: 300px;
}

.podium-place {
  text-align: center;
  opacity: 0;
  transform: translateY(40px);
  transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.podium-place.revealed {
  opacity: 1;
  transform: translateY(0);
}

.podium-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  margin-bottom: 8px;
}

.podium-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}

.podium-score {
  font-size: 0.85rem;
  color: var(--zs-gray);
  margin-bottom: 8px;
}

.podium-bar {
  width: 100px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 900;
  color: white;
}

.podium-place.first .podium-bar {
  height: 160px;
  background: linear-gradient(to top, #e6a200, var(--zs-gold));
}

.podium-place.second .podium-bar {
  height: 120px;
  background: linear-gradient(to top, #a0a0a0, var(--zs-silver));
}

.podium-place.third .podium-bar {
  height: 80px;
  background: linear-gradient(to top, #a06828, var(--zs-bronze));
}

@media (min-width: 600px) {
  .podium-bar { width: 140px; }
}

/* ─── Status badge ─────────────────────────────────────────── */

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-idle { background: #e2e8f0; color: var(--zs-gray-dark); }
.status-active { background: #dcfce7; color: #166534; }
.status-closed { background: #fde8ea; color: #991b1b; }

/* ─── Stats bar ────────────────────────────────────────────── */

.stat-bar {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.stat-bar-label {
  width: 40%;
  font-size: 0.85rem;
  padding-right: 8px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-bar-track {
  flex: 1;
  height: 24px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.stat-bar-fill.correct { background: var(--zs-green); }
.stat-bar-fill.wrong { background: var(--zs-gray); }

.stat-bar-value {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 700;
}

/* ─── Player count bubble ──────────────────────────────────── */

.player-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  font-size: 0.85rem;
  color: white;
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--zs-green);
  animation: blink 2s infinite;
}

@keyframes blink {
  50% { opacity: 0.4; }
}

/* ─── Result feedback ──────────────────────────────────────── */

.result-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s;
}

.result-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  text-align: center;
  max-width: 360px;
  width: 90%;
}

.result-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.result-text {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.result-points {
  font-size: 1.2rem;
  color: var(--zs-blue);
  font-weight: 600;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── Admin layout ─────────────────────────────────────────── */

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.admin-sidebar {
  position: sticky;
  top: 16px;
}

/* ─── Admin category/question list ─────────────────────────── */

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 8px;
  background: white;
  transition: all var(--transition);
}

.list-item:hover { border-color: var(--zs-blue); }

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.list-item-subtitle {
  font-size: 0.8rem;
  color: var(--zs-gray);
}

.list-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: transparent;
  color: var(--zs-gray);
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--zs-gray-light);
  color: var(--zs-navy);
}

.icon-btn.danger:hover {
  background: #fde8ea;
  color: var(--zs-red);
}

/* ─── Modal ────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ─── Presenter view ───────────────────────────────────────── */

.presenter-body {
  background: var(--zs-navy);
  color: white;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.presenter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
}

.presenter-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.presenter-question {
  text-align: center;
  max-width: 900px;
}

.presenter-question h2 {
  font-size: 2.5rem;
  margin-bottom: 30px;
  line-height: 1.3;
}

.presenter-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.presenter-answer {
  padding: 24px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.1);
  font-size: 1.3rem;
  text-align: left;
  display: flex;
  align-items: center;
  transition: all 0.3s;
}

.presenter-answer.correct {
  background: var(--zs-green);
}

.presenter-answer.wrong {
  opacity: 0.4;
}

.presenter-timer {
  font-size: 6rem;
  font-weight: 900;
  text-align: center;
}

.presenter-timer.warning { color: var(--zs-gold); }
.presenter-timer.danger { color: var(--zs-red); }

.presenter-leaderboard {
  width: 100%;
  max-width: 700px;
}

.presenter-leaderboard .leaderboard-item {
  color: white;
  font-size: 1.3rem;
  padding: 16px 20px;
  border-color: rgba(255,255,255,0.1);
}

.presenter-leaderboard .leaderboard-score {
  color: var(--zs-light-blue);
  font-size: 1.5rem;
}

.presenter-leaderboard .leaderboard-rank {
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
}

.presenter-waiting {
  text-align: center;
}

.presenter-waiting h2 {
  font-size: 3rem;
  margin-bottom: 16px;
}

.presenter-waiting p {
  font-size: 1.3rem;
  opacity: 0.7;
}

.presenter-player-names {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 600px;
  margin: 0 auto;
}

.player-chip {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.95rem;
  animation: chipIn 0.3s ease;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.presenter-stats {
  margin-top: 30px;
  max-width: 600px;
  width: 100%;
}

.presenter-stats .stat-bar { margin-bottom: 12px; }
.presenter-stats .stat-bar-label { color: white; font-size: 1rem; }
.presenter-stats .stat-bar-track { height: 32px; }

/* ─── QR Code display ──────────────────────────────────────── */

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

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

.qr-url {
  margin-top: 12px;
  font-size: 1rem;
  color: var(--zs-blue);
  word-break: break-all;
}

/* ─── Confetti canvas ──────────────────────────────────────── */

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}

/* ─── Utilities ────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-muted { color: var(--zs-gray); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

/* ─── Animations ───────────────────────────────────────────── */

.slide-in {
  animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.fade-in {
  animation: fadeIn 0.5s;
}

/* ─── Tab navigation (admin) ───────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 16px;
}

.tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--zs-gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}

.tab:hover { color: var(--zs-navy); }

.tab.active {
  color: var(--zs-blue);
  border-bottom-color: var(--zs-blue);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Login overlay ────────────────────────────────────────── */

.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--zs-navy), var(--zs-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.login-box {
  background: white;
  border-radius: var(--radius);
  padding: 40px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.login-box h2 {
  text-align: center;
  margin-bottom: 24px;
  color: var(--zs-navy);
}

/* ─── Responsive ───────────────────────────────────────────── */

@media (max-width: 480px) {
  .header h1 { font-size: 1.2rem; }
  .btn { padding: 10px 18px; font-size: 0.9rem; }
  .btn-lg { padding: 14px 24px; font-size: 1.1rem; }
  .container { padding: 12px; }
  .card { padding: 16px; }
  .presenter-question h2 { font-size: 1.5rem; }
  .presenter-answers { grid-template-columns: 1fr; }
  .presenter-timer { font-size: 4rem; }
}
