@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #6C5CE7;
  --primary-dark: #5A4BD1;
  --primary-light: #A29BFE;
  --secondary: #00CEC9;
  --accent: #FD79A8;
  --success: #00B894;
  --warning: #FDCB6E;
  --danger: #E17055;
  --bg: #0F0F1A;
  --bg-card: #1A1A2E;
  --bg-card-hover: #222240;
  --bg-input: #16213E;
  --text: #FFFFFF;
  --text-secondary: #B2BEC3;
  --text-muted: #636E72;
  --border: #2D3436;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

/* Animated background */
.bg-pattern {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(108,92,231,0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0,206,201,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(253,121,168,0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* Navigation */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 40px;
}

.navbar .logo {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.navbar .logo span {
  -webkit-text-fill-color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.nav-links a, .nav-links button {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

.nav-links a:hover, .nav-links button:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.nav-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(108,92,231,0.4);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108,92,231,0.6);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #00A884);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #D63031);
  color: white;
}

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-lg { padding: 16px 32px; font-size: 1.1rem; }
.btn-block { width: 100%; justify-content: center; }

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px;
  transition: var(--transition);
}
.card:hover {
  border-color: rgba(108,92,231,0.3);
  box-shadow: var(--shadow);
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.2);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 32px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.95);
  transition: var(--transition);
}
.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal h2 {
  margin-bottom: 24px;
  font-size: 1.3rem;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* Stats */
.stat-card {
  text-align: center;
  padding: 24px;
}
.stat-card .stat-number {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; text-align: left; }
th {
  background: rgba(108,92,231,0.1);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
td { border-top: 1px solid var(--border); font-size: 0.95rem; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* Badge */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.badge-active { background: rgba(0,184,148,0.15); color: var(--success); }
.badge-inactive { background: rgba(225,112,85,0.15); color: var(--danger); }
.badge-primary { background: rgba(108,92,231,0.15); color: var(--primary-light); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { margin-bottom: 8px; color: var(--text-secondary); }

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  animation: slideIn 0.3s ease;
  min-width: 280px;
  box-shadow: var(--shadow);
}
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--primary); color: white; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Quiz specific */
.quiz-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
}
.quiz-option:hover {
  border-color: var(--primary);
  background: rgba(108,92,231,0.05);
  transform: translateX(4px);
}
.quiz-option.selected {
  border-color: var(--primary);
  background: rgba(108,92,231,0.1);
}
.quiz-option.correct {
  border-color: var(--success) !important;
  background: rgba(0,184,148,0.1) !important;
}
.quiz-option.wrong {
  border-color: var(--danger) !important;
  background: rgba(225,112,85,0.1) !important;
}

.option-letter {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.opt-a .option-letter { background: rgba(108,92,231,0.2); color: var(--primary-light); }
.opt-b .option-letter { background: rgba(0,206,201,0.2); color: var(--secondary); }
.opt-c .option-letter { background: rgba(253,121,168,0.2); color: var(--accent); }
.opt-d .option-letter { background: rgba(253,203,110,0.2); color: var(--warning); }

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 32px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Timer */
.timer {
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
}
.timer.warning { color: var(--warning); }
.timer.danger { color: var(--danger); animation: pulse 0.5s infinite; }

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

/* Hero */
.hero {
  text-align: center;
  padding: 80px 20px;
}
.hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -1px;
  line-height: 1.1;
}
.hero h1 span {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.join-form {
  display: flex;
  gap: 12px;
  max-width: 450px;
  margin: 0 auto;
}
.join-form input {
  flex: 1;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  outline: none;
  transition: var(--transition);
}
.join-form input:focus {
  border-color: var(--primary);
}
.join-form input::placeholder {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  opacity: 0.5;
}

/* Leaderboard page */
.leaderboard-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
}
.rank-1 { background: linear-gradient(135deg, #FFD700, #FFA500); color: #000; }
.rank-2 { background: linear-gradient(135deg, #C0C0C0, #A0A0A0); color: #000; }
.rank-3 { background: linear-gradient(135deg, #CD7F32, #B8860B); color: #fff; }

/* QR Code display */
.qr-display {
  text-align: center;
  padding: 24px;
}
.qr-display img {
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.qr-code-text {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--primary-light);
  margin-bottom: 8px;
}
.qr-url {
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-all;
}

/* Score display */
.score-display {
  text-align: center;
  padding: 40px;
}
.score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 6px solid var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}
.score-circle .score-num {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}
.score-circle .score-total {
  font-size: 1rem;
  color: var(--text-muted);
}

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2.2rem; }
  .navbar { flex-direction: column; gap: 16px; }
  .join-form { flex-direction: column; }
  .modal { width: 95%; padding: 24px; }
}

/* Animations */
.fade-in {
  animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Auth card */
.auth-container {
  max-width: 420px;
  margin: 60px auto;
}
.auth-container h2 {
  text-align: center;
  margin-bottom: 32px;
  font-size: 1.6rem;
}
.auth-toggle {
  text-align: center;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.auth-toggle a {
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 500;
}
.auth-toggle a:hover { text-decoration: underline; }

/* Tab bar for admin */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition);
  color: var(--text-muted);
  border: none;
  background: none;
  font-family: inherit;
}
.tab.active {
  background: var(--primary);
  color: white;
}
.tab:hover:not(.active) {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}
