/* ============================================
   GAMIFICATION STYLES
   ============================================ */

/* ============================================
   HEADER GAMIFICATION BADGE
   ============================================ */
.header-btn.gamification-btn {
  position: relative;
  align-items: center;
}

.gamification-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 4px 8px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  align-self: center;
}

.level-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
}

.streak-indicator {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1;
}

.streak-indicator.active {
  color: #f97316;
}

.icon-md {
  width: 20px;
  height: 20px;
}

/* ============================================
   XP GAIN NOTIFICATION
   ============================================ */
.xp-gain-notification {
  position: fixed;
  top: 80px;
  right: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10001;
  font-weight: 500;
}

.xp-gain-notification.show {
  transform: translateX(0);
}

.xp-gain-notification .xp-amount {
  font-size: 18px;
  font-weight: 700;
}

.xp-gain-notification .xp-source {
  font-size: 13px;
  opacity: 0.9;
}

/* ============================================
   LEVEL UP MODAL
   ============================================ */
.level-up-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.level-up-modal.show {
  opacity: 1;
}

.level-up-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}

.level-up-content {
  position: relative;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border-radius: 24px;
  padding: 48px;
  text-align: center;
  max-width: 400px;
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid var(--primary);
  box-shadow: 0 0 60px rgba(139, 92, 246, 0.5);
}

.level-up-modal.show .level-up-content {
  transform: scale(1);
}

.level-up-badge {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.6);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.6); }
  50% { box-shadow: 0 0 60px rgba(139, 92, 246, 0.8); }
}

.level-up-badge .level-number {
  font-size: 48px;
  font-weight: 800;
  color: white;
}

.level-up-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.level-up-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.level-up-rewards {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  margin-bottom: 24px;
}

.level-up-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 40px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.level-up-btn:hover {
  background: #7c3aed;
  transform: translateY(-2px);
}

/* ============================================
   ACHIEVEMENT NOTIFICATION
   ============================================ */
.achievement-notification {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  border: 2px solid;
  z-index: 10001;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 350px;
}

.achievement-notification.show {
  transform: translateX(-50%) translateY(0);
}

.achievement-notification.tier-bronze { border-color: #CD7F32; }
.achievement-notification.tier-silver { border-color: #C0C0C0; }
.achievement-notification.tier-gold { border-color: #FFD700; }
.achievement-notification.tier-platinum { border-color: #E5E4E2; }
.achievement-notification.tier-diamond { border-color: #B9F2FF; }

.achievement-notification .achievement-icon {
  font-size: 40px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.achievement-notification .achievement-info {
  flex: 1;
}

.achievement-notification .achievement-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.achievement-notification .achievement-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.achievement-notification .achievement-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.achievement-notification .achievement-xp {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  background: var(--bg-tertiary);
  padding: 8px 12px;
  border-radius: 8px;
}

/* ============================================
   GAMIFIED ANALYTICS PANEL
   ============================================ */
.analytics-panel.gamified-panel {
  max-width: 1000px;
  max-height: 85vh;
}

.analytics-panel.gamified-panel .analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.analytics-panel.gamified-panel .header-actions {
  display: flex;
  gap: 8px;
}

.analytics-panel.gamified-panel .tab-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.analytics-panel.gamified-panel .tab-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.analytics-panel.gamified-panel .tab-btn.active {
  background: var(--primary);
  color: white;
}

.analytics-content {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(85vh - 80px);
}

.tab-content {
  display: none;
}

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

/* ============================================
   GAMIFICATION HERO SECTION
   ============================================ */
.gamification-hero {
  display: flex;
  gap: 24px;
  margin-bottom: 32px;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.level-display {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
}

.level-badge {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

.level-badge .level-number {
  font-size: 32px;
  font-weight: 800;
  color: white;
}

.level-info {
  flex: 1;
}

.level-info h4 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.xp-bar {
  width: 100%;
  height: 10px;
  background: var(--bg-primary);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 8px;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #7c3aed 100%);
  border-radius: 5px;
  transition: width 0.5s ease;
}

.xp-text {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Streak Display */
.streak-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 32px;
  background: var(--bg-primary);
  border-radius: 12px;
  min-width: 140px;
}

.streak-display.at-risk {
  border: 2px solid #f97316;
  animation: risk-pulse 2s ease-in-out infinite;
}

@keyframes risk-pulse {
  0%, 100% { border-color: #f97316; }
  50% { border-color: #fb923c; }
}

.streak-flame {
  font-size: 24px;
  margin-bottom: 4px;
}

.streak-flame .flame {
  display: inline-block;
  animation: flame-dance 0.5s ease-in-out infinite alternate;
}

.streak-flame .flame svg,
.streak-flame .flame i {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
  color: #f97316;
}

.streak-flame .flame:nth-child(2) { animation-delay: 0.1s; }
.streak-flame .flame:nth-child(3) { animation-delay: 0.2s; }
.streak-flame .flame:nth-child(4) { animation-delay: 0.3s; }
.streak-flame .flame:nth-child(5) { animation-delay: 0.4s; }

@keyframes flame-dance {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-3px) scale(1.1); }
}

.streak-count {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.streak-label {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.streak-freeze-btn {
  margin-top: 12px;
  padding: 8px 16px;
  background: #38bdf8;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.streak-freeze-btn:hover:not(:disabled) {
  background: #0ea5e9;
}

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

/* ============================================
   PROGRESS RINGS GRID
   ============================================ */
.progress-rings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.progress-ring-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  background: var(--bg-tertiary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.ring-container {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 12px;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-progress {
  transition: stroke-dashoffset 0.5s ease;
}

.ring-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.ring-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.ring-max {
  font-size: 14px;
  color: var(--text-tertiary);
}

.ring-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ============================================
   STATS GRID
   ============================================ */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  background: var(--primary-alpha, rgba(139, 92, 246, 0.1));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--primary);
}

.stat-icon-svg {
  background: transparent;
}

.stat-icon-svg svg {
  width: 40px;
  height: 40px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ============================================
   RECENT ACHIEVEMENTS
   ============================================ */
.recent-achievements {
  background: var(--bg-tertiary);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border-color);
}

.recent-achievements h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.achievements-preview {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.no-achievements {
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ============================================
   ACHIEVEMENT BADGES
   ============================================ */
.achievement-badge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.achievement-badge.small {
  width: 50px;
  height: 50px;
  font-size: 24px;
}

.achievement-badge.medium {
  width: 70px;
  height: 70px;
  font-size: 32px;
}

.achievement-badge.large {
  width: 90px;
  height: 90px;
  font-size: 40px;
}

.achievement-badge.locked {
  opacity: 0.4;
  filter: grayscale(100%);
}

.achievement-badge.unlocked {
  background: var(--bg-tertiary);
  border: 2px solid;
}

.achievement-badge.tier-bronze { border-color: #CD7F32; }
.achievement-badge.tier-silver { border-color: #C0C0C0; }
.achievement-badge.tier-gold { border-color: #FFD700; }
.achievement-badge.tier-platinum { border-color: #E5E4E2; }
.achievement-badge.tier-diamond { border-color: #B9F2FF; }

.badge-lock {
  position: absolute;
  font-size: 14px;
  bottom: -4px;
  right: -4px;
}

.achievement-badge .badge-icon svg,
.achievement-badge .badge-icon i {
  width: 18px;
  height: 18px;
  stroke-width: 2.1;
  color: var(--primary);
}

.badge-lock svg,
.badge-lock i {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

/* ============================================
   ACHIEVEMENTS GRID
   ============================================ */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.achievement-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.achievement-card.locked {
  opacity: 0.6;
}

.achievement-card.unlocked {
  border-color: var(--primary);
}

.achievement-card .achievement-icon {
  font-size: 36px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: 12px;
}

.achievement-card .achievement-icon svg,
.achievement-card .achievement-icon i {
  width: 28px;
  height: 28px;
  stroke-width: 2;
}

.achievement-card .achievement-icon.tier-gold {
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.achievement-card .achievement-details {
  flex: 1;
}

.achievement-card .achievement-details h5 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.achievement-card .achievement-details p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.achievement-card .achievement-xp {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.achievement-card .lock-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 16px;
}

.achievement-card .check-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  background: var(--success, #22c55e);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.achievement-card .lock-overlay svg,
.achievement-card .lock-overlay i {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  color: var(--text-tertiary);
}

.achievement-card .check-mark svg,
.achievement-card .check-mark i {
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
  color: white;
}

/* ============================================
   CHALLENGES TAB
   ============================================ */
.challenges-reset {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
}

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

.challenge-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.challenge-card.completed {
  border-color: var(--success, #22c55e);
  background: rgba(34, 197, 94, 0.05);
}

.challenge-card .challenge-icon {
  font-size: 28px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: 10px;
}

.challenge-card .challenge-icon svg,
.challenge-card .challenge-icon i {
  width: 22px;
  height: 22px;
  stroke-width: 2.1;
  color: var(--primary);
}

.challenge-card .challenge-info {
  flex: 1;
}

.challenge-card .challenge-info h5 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.challenge-card .challenge-info p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.challenge-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

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

.challenge-progress-text {
  font-size: 12px;
  color: var(--text-tertiary);
}

.challenge-reward {
  display: flex;
  align-items: center;
}

.challenge-reward .xp-reward {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: var(--bg-primary);
  padding: 8px 14px;
  border-radius: 8px;
}

.challenge-reward .claim-btn {
  background: var(--success, #22c55e);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: pulse-claim 2s ease-in-out infinite;
}

@keyframes pulse-claim {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.challenge-reward .claim-btn:hover {
  background: #16a34a;
}

.challenge-reward .claimed {
  font-size: 14px;
  font-weight: 600;
  color: var(--success, #22c55e);
}

/* ============================================
   LEADERBOARD PLACEHOLDER
   ============================================ */
.leaderboard-placeholder {
  text-align: center;
  padding: 60px 40px;
  background: var(--bg-tertiary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.leaderboard-placeholder .placeholder-icon {
  font-size: 60px;
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.leaderboard-placeholder .placeholder-icon svg {
  width: 80px;
  height: 80px;
}

.leaderboard-placeholder h4 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.leaderboard-placeholder p {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.leaderboard-placeholder .your-rank {
  margin-top: 20px;
  padding: 12px 20px;
  background: var(--bg-primary);
  border-radius: 8px;
  display: inline-block;
  color: var(--text-secondary);
}

/* ============================================
   CONFETTI
   ============================================ */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -10px;
  z-index: 10003;
  pointer-events: none;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .gamification-hero {
    flex-direction: column;
    gap: 20px;
  }

  .progress-rings-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .analytics-panel.gamified-panel .header-actions {
    display: none;
  }
}

@media (max-width: 480px) {
  .progress-rings-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .achievements-grid {
    grid-template-columns: 1fr;
  }
}
