:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --dark: #0f172a;
  --dark-light: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --card: #1e293b;
  --shadow: rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--dark);
  color: var(--text);
  overflow-x: hidden;
  padding-bottom: 80px;
}

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

/* Header */
.header {
  background: var(--dark-light);
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px var(--shadow);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 640px;
  margin: 0 auto;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
}

.nav-menu {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s;
}

.nav-btn:active {
  background: var(--border);
  transform: scale(0.95);
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 6px var(--shadow);
}

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

.card-title {
  font-size: 18px;
  font-weight: 600;
}

.card-badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

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

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  width: auto;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--dark-light);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  transition: all 0.3s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-select {
  width: 100%;
  padding: 14px 16px;
  background: var(--dark-light);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
}

.form-textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--dark-light);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  resize: vertical;
  min-height: 100px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Quiz List */
.quiz-item {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.quiz-item:active {
  border-color: var(--primary);
  transform: scale(0.98);
}

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

.quiz-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.quiz-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.quiz-tag {
  background: var(--dark-light);
  padding: 4px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.live-badge {
  background: var(--danger);
  color: white;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  animation: pulse 2s infinite;
}

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

/* Test Interface */
.test-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--dark);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.test-header {
  background: var(--dark-light);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px var(--shadow);
}

.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  color: var(--warning);
}

.test-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
}

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

.q-num {
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 14px;
}

.q-text {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.q-img {
  width: 100%;
  border-radius: 12px;
  margin: 16px 0;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option {
  background: var(--dark-light);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.option.selected {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.option.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.option.wrong {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.opt-label {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.opt-text {
  flex: 1;
  font-size: 15px;
}

/* Bottom Navigation */
.test-footer {
  background: var(--dark-light);
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  box-shadow: 0 -2px 10px var(--shadow);
}

.nav-grid {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--dark-light);
  padding: 16px;
  box-shadow: 0 -2px 10px var(--shadow);
  z-index: 150;
}

.q-palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.q-nav-btn {
  aspect-ratio: 1;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.q-nav-btn.answered {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.q-nav-btn.active {
  border-color: var(--warning);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

/* Bottom Nav Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--dark-light);
  padding: 12px 16px;
  display: flex;
  justify-content: space-around;
  box-shadow: 0 -2px 10px var(--shadow);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  transition: all 0.3s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item i {
  font-size: 20px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-title {
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 64px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-text {
  color: var(--text-muted);
  font-size: 16px;
}

/* Alert */
.alert {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--success);
  color: var(--success);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--warning);
  color: var(--warning);
}

/* Utility Classes */
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-600 { font-weight: 600; }
.fs-14 { font-size: 14px; }
.d-flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--dark);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Mobile Optimizations */
@media (max-width: 640px) {
  .container {
    padding: 0 12px;
  }
  
  .card {
    padding: 16px;
  }
  
  .stat-value {
    font-size: 28px;
  }
}

/* Auth Pages */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--card);
  border-radius: 20px;
  padding: 32px 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 40px var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 8px;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.divider::before {
  margin-right: 12px;
}

.divider::after {
  margin-left: 12px;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.link:hover {
  text-decoration: underline;
}
