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

:root {
  /* Colors */
  --primary: #6B4CE6; /* Deep Purple */
  --primary-light: #8B5CF6; /* Violet */
  --primary-lighter: #C4B5FD; /* Lavender */
  --secondary: #F472B6; /* Soft Pink */
  --accent: #60A5FA; /* Light Blue */
  --success: #34D399; /* Green */
  --warning: #FBBF24; /* Yellow */
  --danger: #EF4444; /* Red */
  
  --bg-color: #F8F7FA;
  --bg-card: #FFFFFF;
  --text-main: #1F2937;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --white: #FFFFFF;
  
  /* Styling */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(107, 76, 230, 0.06);
  --shadow-md: 0 10px 25px rgba(107, 76, 230, 0.08);
  --shadow-lg: 0 20px 40px rgba(107, 76, 230, 0.12);
  --shadow-inner: inset 0 2px 4px rgba(0,0,0,0.04);
  
  /* Layout */
  --bottom-nav-height: 70px;
  --app-max-width: 480px;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: #E5E7EB; /* Darker outside the app area for desktop */
  color: var(--text-main);
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

#app-container {
  width: 100%;
  max-width: var(--app-max-width);
  background-color: var(--bg-color);
  height: 100vh;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: block;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-main);
}

p {
  color: var(--text-muted);
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: var(--primary);
  font-weight: 500;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-light);
}

/* Utilities */
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.hidden { display: none !important; }

/* Views structure */
.view {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  flex-direction: column;
  background-color: var(--bg-color);
  padding-bottom: calc(var(--bottom-nav-height) + 20px);
  animation: fadeSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.view.active {
  display: flex;
  z-index: 10;
}

.view.no-nav {
  padding-bottom: 0;
}

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

/* Components */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 8px;
  width: 100%;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  box-shadow: 0 8px 20px rgba(107, 76, 230, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 10px 25px rgba(107, 76, 230, 0.4);
  transform: translateY(-2px);
}

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

.btn-light {
  background: var(--white);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.05);
}

/* Inputs */
.input-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  margin-left: 4px;
}

.input-field {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  background-color: #F3F4F6;
  font-size: 1rem;
  font-family: 'Outfit', sans-serif;
  color: var(--text-main);
  transition: all 0.2s ease;
  width: 100%;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--white);
  box-shadow: 0 0 0 4px rgba(107, 76, 230, 0.1);
}

.input-field::placeholder {
  color: var(--text-light);
}

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Avatars */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--white);
  background-color: var(--primary-lighter);
}

.avatar-lg {
  width: 80px;
  height: 80px;
  border: 3px solid var(--white);
  box-shadow: var(--shadow-md);
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  gap: 4px;
}

.badge-primary {
  background-color: rgba(107, 76, 230, 0.1);
  color: var(--primary);
}

.badge-warning {
  background-color: rgba(251, 191, 36, 0.15);
  color: #D97706;
}

.badge-success {
  background-color: rgba(52, 211, 153, 0.15);
  color: #059669;
}

/* Header */
.app-header {
  padding: 24px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.back-btn, .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  color: var(--text-main);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  font-size: 1.25rem;
}

.icon-btn:hover {
  background: var(--primary);
  color: var(--white);
}

/* Curved Header Background for specific pages (like Home, Profile) */
.header-curved {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
  padding: 30px 20px 40px 20px;
  margin-bottom: 20px;
  position: relative;
}

.header-curved h1, .header-curved h2, .header-curved p {
  color: var(--white);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  height: var(--bottom-nav-height);
  background: var(--white);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
  z-index: 100;
  padding: 0 10px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  gap: 4px;
  flex: 1;
  height: 100%;
  position: relative;
  transition: color 0.3s;
  cursor: pointer;
}

.nav-item i {
  font-size: 1.5rem;
  transition: transform 0.3s;
}

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

.nav-item.active i {
  transform: translateY(-2px);
}

/* Floating Action Button (FAB) */
.fab-container {
  position: relative;
  top: -20px;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  box-shadow: 0 10px 20px rgba(107, 76, 230, 0.4);
  border: 4px solid var(--white);
  cursor: pointer;
  transition: transform 0.2s;
}

.fab:hover {
  transform: scale(1.05);
}

/* --- Specific Page Styles --- */

/* Login/Register */
.auth-page {
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
}

.auth-header {
  text-align: center;
  margin-bottom: 40px;
}

.auth-logo {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--white);
  font-size: 2.5rem;
  box-shadow: 0 15px 30px rgba(107, 76, 230, 0.3);
  transform: rotate(-10deg);
}

.social-login {
  display: flex;
  gap: 15px;
  margin-top: 20px;
}

.social-btn {
  flex: 1;
}

/* Dashboard */
.recent-quiz-card {
  background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 99%, #FECFEF 100%);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 15px 30px rgba(255, 154, 158, 0.3);
  cursor: pointer;
}

.recent-quiz-card::before {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 100px;
  height: 100px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
}

.recent-quiz-card h3 {
  color: #fff;
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.progress-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: conic-gradient(#fff 66%, rgba(255,255,255,0.3) 0);
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-circle span {
  background: #FF9A9E;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 20px;
}

.section-title h3 {
  font-size: 1.125rem;
}

.section-title a {
  font-size: 0.875rem;
}

.horizontal-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 0 20px 20px;
  scrollbar-width: none; /* Firefox */
}

.horizontal-scroll::-webkit-scrollbar {
  display: none; /* Chrome */
}

.quiz-card-sm {
  min-width: 160px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
}

.quiz-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(107, 76, 230, 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.quiz-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 20px;
}

.quiz-list-item {
  display: flex;
  align-items: center;
  padding: 16px;
  gap: 16px;
  cursor: pointer;
}

.quiz-list-item .quiz-icon {
  width: 56px;
  height: 56px;
}

.quiz-info {
  flex: 1;
}

.quiz-info h4 {
  font-size: 1rem;
  margin-bottom: 4px;
}

/* Discover */
.search-bar {
  padding: 0 20px;
  margin-bottom: 20px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper i {
  position: absolute;
  left: 16px;
  color: var(--text-light);
  font-size: 1.25rem;
}

.search-input-wrapper input {
  padding-left: 48px;
  background-color: var(--white);
  box-shadow: var(--shadow-sm);
}

.tabs {
  display: flex;
  gap: 24px;
  padding: 0 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  overflow-x: auto;
  scrollbar-width: none;
}

.tab {
  padding-bottom: 12px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}

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

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

/* Quiz Detail */
.quiz-detail-header {
  height: 250px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  position: relative;
  border-bottom-left-radius: 40px;
  border-bottom-right-radius: 40px;
  padding: 20px;
}

.quiz-detail-header .app-header {
  padding: 0;
  margin-bottom: 20px;
}

.quiz-detail-header .back-btn {
  background: rgba(255,255,255,0.2);
  color: var(--white);
}

.quiz-detail-icon {
  width: 80px;
  height: 80px;
  background: var(--white);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--primary);
  position: absolute;
  bottom: -40px;
  left: 30px;
  box-shadow: var(--shadow-md);
}

.quiz-detail-content {
  padding: 60px 30px 30px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding: 20px;
  background: #F9FAFB;
  border-radius: var(--radius-lg);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.stat-item span {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

.stat-item small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.fixed-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  padding: 20px;
  background: var(--white);
  box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
  z-index: 10;
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
}

/* Quiz Play */
.play-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
}

.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-radius: var(--radius-full);
  font-weight: 600;
}

.progress-bar {
  height: 8px;
  background: #E5E7EB;
  border-radius: 4px;
  margin: 0 20px 30px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

.question-container {
  padding: 0 20px;
  flex: 1;
}

.question-text {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 30px;
  line-height: 1.4;
}

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

.option {
  padding: 18px 24px;
  border-radius: var(--radius-lg);
  border: 2px solid #E5E7EB;
  background: var(--white);
  font-size: 1.125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.option:hover {
  border-color: var(--primary-light);
  background: rgba(107, 76, 230, 0.02);
}

.option.selected {
  border-color: var(--primary);
  background: rgba(107, 76, 230, 0.05);
}

.option.correct {
  border-color: var(--success);
  background: rgba(52, 211, 153, 0.1);
}

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

.option-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--white);
  opacity: 0;
}

.option.correct .option-icon {
  opacity: 1;
  background: var(--success);
}

.option.incorrect .option-icon {
  opacity: 1;
  background: var(--danger);
}

.option.selected .option-icon:not(.correct):not(.incorrect) {
  opacity: 1;
  background: var(--primary);
  box-shadow: inset 0 0 0 4px var(--white);
}

/* Result Page */
.result-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
}

.score-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: conic-gradient(var(--success) 0%, rgba(52,211,153,0.2) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 30px 0;
  position: relative;
}

.score-inner {
  width: 150px;
  height: 150px;
  background: var(--bg-color);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-inner);
}

.score-number {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.score-label {
  font-size: 1rem;
  color: var(--text-muted);
}

.reward-badge {
  width: 100px;
  height: 100px;
  margin: 20px auto;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Leaderboard */
.leaderboard-top {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin-top: 40px;
  padding-bottom: 40px;
  gap: 15px;
}

.podium {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.podium-avatar {
  position: relative;
  margin-bottom: 15px;
}

.crown {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--warning);
  font-size: 1.5rem;
}

.podium-step {
  width: 90px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15px;
  font-size: 2rem;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  box-shadow: inset 0 2px 5px rgba(255,255,255,0.2);
}

.step-1 { height: 160px; background: rgba(255,255,255,0.3); }
.step-2 { height: 120px; background: rgba(255,255,255,0.2); }
.step-3 { height: 100px; background: rgba(255,255,255,0.15); }

.leaderboard-list {
  background: var(--bg-color);
  border-top-left-radius: 40px;
  border-top-right-radius: 40px;
  padding: 30px 20px;
  flex: 1;
}

.rank-item {
  display: flex;
  align-items: center;
  padding: 16px;
  background: var(--white);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.rank-num {
  width: 30px;
  font-weight: 600;
  color: var(--text-light);
}

.rank-info {
  flex: 1;
  margin-left: 15px;
}

.rank-pts {
  font-weight: 600;
  color: var(--primary);
}

/* Profile */
.profile-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  border-bottom-left-radius: 40px;
  border-bottom-right-radius: 40px;
  padding: 30px 20px 80px 20px;
  position: relative;
}

.profile-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: -60px;
  position: relative;
  z-index: 2;
}

.profile-info .avatar {
  border: 4px solid var(--bg-color);
  box-shadow: var(--shadow-md);
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
}

.profile-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.profile-stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* Achievements */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px;
}

.achievement-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.achievement-icon-wrapper {
  width: 80px;
  height: 80px;
  background: var(--white);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.achievement-locked .achievement-icon-wrapper {
  background: #F3F4F6;
  color: var(--text-light);
  filter: grayscale(100%);
}

.achievement-name {
  font-size: 0.75rem;
  font-weight: 600;
}
