/* ═══════════════════════════════════════════════════════════════
   IVENTT Gamification & Achievement System CSS
   Emotional Design inspired by Duolingo
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --badge-bronze: #CD7F32;
  --badge-silver: #C0C0C0;
  --badge-gold: #FFD700;
  --badge-platinum: #E5E4E2;
  --badge-legendary: #9B59B6;
  --xp-bar-bg: #e8e8e8;
  --xp-bar-fill: #58cc02;
  --streak-fire: #ff9600;
  --celebration-bg: rgba(0,0,0,0.75);
  --card-shadow: 0 4px 15px rgba(0,0,0,0.1);
  --card-hover-shadow: 0 8px 30px rgba(0,0,0,0.18);
  --transition-smooth: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══════════════════════════════════════════════════════════════
   ACHIEVEMENT DASHBOARD
   ═══════════════════════════════════════════════════════════════ */

.achievements-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

/* ── Stats Bar (XP, Level, Streak) ── */
.achievement-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.3s var(--transition-smooth), box-shadow 0.3s ease;
}

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

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.stat-icon.xp { background: linear-gradient(135deg, #58cc02, #46a302); color: #fff; }
.stat-icon.level { background: linear-gradient(135deg, #1cb0f6, #0095da); color: #fff; }
.stat-icon.streak { background: linear-gradient(135deg, #ff9600, #ff7700); color: #fff; }
.stat-icon.badges { background: linear-gradient(135deg, #ce82ff, #a855f7); color: #fff; }

.stat-info h3 { margin: 0; font-size: 14px; color: #777; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 28px; font-weight: 800; color: #1a1a1a; margin: 2px 0; }
.stat-sub { font-size: 12px; color: #999; }

/* ── XP Progress Bar ── */
.xp-progress-bar {
  width: 100%;
  height: 12px;
  background: var(--xp-bar-bg);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 8px;
}

.xp-progress-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #58cc02, #78e000);
  transition: width 1s var(--transition-smooth);
  position: relative;
}

.xp-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Streak Flame Animation ── */
.streak-flame {
  display: inline-block;
  animation: flicker 1.5s infinite alternate;
}

@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  25% { transform: scale(1.05) rotate(1deg); }
  50% { transform: scale(0.98) rotate(-1deg); }
  75% { transform: scale(1.03) rotate(2deg); }
}

/* ═══════════════════════════════════════════════════════════════
   CATEGORY TABS
   ═══════════════════════════════════════════════════════════════ */

.achievement-categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 8px;
  border-bottom: 2px solid #f0f0f0;
}

.category-tab {
  padding: 10px 20px;
  border: none;
  background: #f5f5f5;
  border-radius: 25px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  color: #666;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-tab:hover {
  background: #e8e8e8;
  color: #333;
}

.category-tab.active {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.category-tab .tab-count {
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

.category-tab.active .tab-count {
  background: rgba(255,255,255,0.3);
}

/* ═══════════════════════════════════════════════════════════════
   BADGE GRID
   ═══════════════════════════════════════════════════════════════ */

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.badge-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
  transition: all 0.4s var(--transition-smooth);
  cursor: default;
}

.badge-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--card-hover-shadow);
}

.badge-card.earned {
  border: 2px solid var(--tier-color, var(--badge-bronze));
}

.badge-card.earned .badge-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--tier-color, var(--badge-gold)) 0%, transparent 70%);
  opacity: 0.04;
  pointer-events: none;
}

.badge-card.locked {
  opacity: 0.55;
  filter: grayscale(0.6);
}

.badge-card.locked:hover {
  opacity: 0.75;
  filter: grayscale(0.3);
}

.badge-card.secret {
  background: repeating-linear-gradient(
    45deg,
    #fafafa,
    #fafafa 10px,
    #f5f5f5 10px,
    #f5f5f5 20px
  );
}

/* ── Badge Icon ── */
.badge-icon-container {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  position: relative;
}

.badge-icon-container.bronze { background: linear-gradient(135deg, #CD7F32, #a56420); }
.badge-icon-container.silver { background: linear-gradient(135deg, #C0C0C0, #a0a0a0); }
.badge-icon-container.gold { background: linear-gradient(135deg, #FFD700, #e6be00); }
.badge-icon-container.platinum { background: linear-gradient(135deg, #E5E4E2, #c8c7c5); }
.badge-icon-container.legendary { background: linear-gradient(135deg, #9B59B6, #8e44ad); }

.badge-icon-container .material-symbols-outlined {
  font-size: 36px;
  color: #fff;
}

.badge-card.locked .badge-icon-container {
  background: linear-gradient(135deg, #ddd, #ccc);
}

.badge-card.locked .badge-icon-container .material-symbols-outlined {
  color: #aaa;
}

/* Earned badge shimmer ring */
.badge-card.earned .badge-icon-container::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  border: 3px solid var(--tier-color, var(--badge-gold));
  animation: pulse-ring 2s infinite;
}

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

/* ── Badge Text ── */
.badge-name {
  font-size: 16px;
  font-weight: 800;
  color: #1a1a1a;
  text-align: center;
  margin-bottom: 4px;
}

.badge-tier-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
  margin-bottom: 8px;
  padding: 2px 12px;
  border-radius: 10px;
  display: inline-block;
}

.badge-tier-label.bronze { background: #fef3e0; color: #CD7F32; }
.badge-tier-label.silver { background: #f5f5f5; color: #888; }
.badge-tier-label.gold { background: #fff9e6; color: #b8960f; }
.badge-tier-label.platinum { background: #f0f0f0; color: #666; }
.badge-tier-label.legendary { background: #f3e8ff; color: #9B59B6; }

.badge-description {
  font-size: 13px;
  color: #666;
  text-align: center;
  line-height: 1.4;
  margin-bottom: 12px;
}

.badge-xp {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--xp-bar-fill);
}

/* ── Progress Bar (on badge card) ── */
.badge-progress {
  margin-top: 12px;
}

.badge-progress-bar {
  width: 100%;
  height: 8px;
  background: #eeeeee;
  border-radius: 4px;
  overflow: hidden;
}

.badge-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s var(--transition-smooth);
}

.badge-progress-fill.bronze { background: linear-gradient(90deg, #CD7F32, #d99a5b); }
.badge-progress-fill.silver { background: linear-gradient(90deg, #C0C0C0, #d0d0d0); }
.badge-progress-fill.gold { background: linear-gradient(90deg, #FFD700, #ffe44d); }
.badge-progress-fill.platinum { background: linear-gradient(90deg, #bbb, #E5E4E2); }
.badge-progress-fill.legendary { background: linear-gradient(90deg, #9B59B6, #c084fc); }

.badge-progress-text {
  font-size: 11px;
  color: #999;
  text-align: center;
  margin-top: 4px;
  font-weight: 600;
}

/* Earned date */
.badge-earned-date {
  font-size: 11px;
  color: #aaa;
  text-align: center;
  margin-top: 8px;
}

.badge-earned-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: var(--tier-color, #58cc02);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ═══════════════════════════════════════════════════════════════
   CELEBRATION MODAL (MOTD)
   ═══════════════════════════════════════════════════════════════ */

.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--celebration-bg);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(8px);
}

.celebration-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.celebration-modal {
  background: #fff;
  border-radius: 24px;
  padding: 40px 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  transform: scale(0.5) translateY(50px);
  transition: transform 0.6s var(--transition-smooth);
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.celebration-overlay.active .celebration-modal {
  transform: scale(1) translateY(0);
}

/* Animated background gradient */
.celebration-modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: var(--celebration-gradient, linear-gradient(135deg, #FFD700, #ff9600));
  opacity: 0.1;
}

/* Large badge icon in celebration */
.celebration-badge-icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  position: relative;
  z-index: 1;
  animation: badge-pop 0.8s var(--transition-smooth) forwards;
  transform: scale(0);
}

@keyframes badge-pop {
  0% { transform: scale(0) rotate(-20deg); }
  60% { transform: scale(1.2) rotate(5deg); }
  80% { transform: scale(0.95) rotate(-2deg); }
  100% { transform: scale(1) rotate(0); }
}

.celebration-badge-icon .material-symbols-outlined {
  font-size: 48px;
  color: #fff;
}

/* Celebration sparkle particles */
.celebration-particles {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: sparkle-fly 1.5s ease-out forwards;
}

@keyframes sparkle-fly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0);
  }
}

/* Confetti */
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 6px;
  top: -10px;
  animation: confetti-fall 3s linear forwards;
}

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

.celebration-title {
  font-size: 20px;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.celebration-body {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.celebration-body .badge-hint {
  display: block;
  margin-top: 12px;
  padding: 10px 16px;
  background: #f8f9fa;
  border-radius: 12px;
  border-left: 4px solid #a855f7;
  font-size: 13px;
  color: #555;
  text-align: left;
}

.celebration-xp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: linear-gradient(135deg, #58cc02, #46a302);
  color: #fff;
  border-radius: 20px;
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 20px;
  animation: xp-bounce 0.6s var(--transition-smooth) 0.5s both;
}

@keyframes xp-bounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.celebration-btn {
  display: inline-block;
  padding: 14px 40px;
  border: none;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.celebration-btn.primary {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.35);
}

.celebration-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

/* ═══════════════════════════════════════════════════════════════
   NEAR-COMPLETION TOAST (Anticipation)
   ═══════════════════════════════════════════════════════════════ */

.achievement-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #fff;
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 380px;
  z-index: 9000;
  transform: translateY(120%) scale(0.9);
  transition: transform 0.5s var(--transition-smooth);
  border-left: 4px solid #a855f7;
}

.achievement-toast.visible {
  transform: translateY(0) scale(1);
}

.achievement-toast .toast-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.achievement-toast .toast-text {
  flex: 1;
}

.achievement-toast .toast-title {
  font-size: 13px;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.achievement-toast .toast-message {
  font-size: 12px;
  color: #666;
  line-height: 1.3;
}

.achievement-toast .toast-close {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

/* ── Progress mini in toast ── */
.toast-progress {
  width: 100%;
  height: 4px;
  background: #eee;
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.toast-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #a855f7, #c084fc);
  transition: width 1s var(--transition-smooth);
}

/* ═══════════════════════════════════════════════════════════════
   ACTION HINT BANNER (Before action)
   ═══════════════════════════════════════════════════════════════ */

.action-hint-banner {
  background: linear-gradient(135deg, #f0e6ff, #e8f4ff);
  border: 1px solid #d4bfff;
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  animation: hint-slide-in 0.5s var(--transition-smooth);
}

@keyframes hint-slide-in {
  0% { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 1; transform: translateY(0); }
}

.action-hint-banner .hint-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.action-hint-banner .hint-text {
  font-size: 13px;
  color: #4a3580;
  font-weight: 600;
  line-height: 1.4;
}

.action-hint-banner .hint-xp {
  font-size: 12px;
  color: #58cc02;
  font-weight: 800;
}

/* ═══════════════════════════════════════════════════════════════
   STREAK CALENDAR (Mini display)
   ═══════════════════════════════════════════════════════════════ */

.streak-display {
  display: flex;
  align-items: center;
  gap: 4px;
}

.streak-day {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #aaa;
}

.streak-day.active {
  background: linear-gradient(135deg, #ff9600, #ff7700);
  color: #fff;
}

.streak-day.today {
  border: 2px solid #ff9600;
  background: #fff;
  color: #ff9600;
}

/* ═══════════════════════════════════════════════════════════════
   PROFILE BADGE SECTION (Updated)
   ═══════════════════════════════════════════════════════════════ */

.profile-badges-showcase {
  margin-top: 24px;
}

.profile-badges-showcase h2 {
  font-size: 20px;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-badge-mini {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.3s var(--transition-smooth);
  cursor: pointer;
}

.profile-badge-mini:hover {
  transform: scale(1.15);
}

.profile-badge-mini .material-symbols-outlined {
  font-size: 24px;
  color: #fff;
}

.profile-badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Badge tooltip on hover */
.profile-badge-mini .badge-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: #1a1a1a;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 10;
}

.profile-badge-mini:hover .badge-tooltip {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.profile-badge-mini .badge-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1a1a1a;
}

/* ═══════════════════════════════════════════════════════════════
   NOTIFICATION DOT (unseen badges)
   ═══════════════════════════════════════════════════════════════ */

.badge-notification-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #ff4444;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  animation: dot-pulse 2s infinite;
}

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

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .badges-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .achievement-stats {
    grid-template-columns: 1fr 1fr;
  }

  .celebration-modal {
    padding: 28px 20px;
  }

  .achievement-categories {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .category-tab {
    flex-shrink: 0;
    font-size: 12px;
    padding: 8px 14px;
  }

  .achievement-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .achievement-stats {
    grid-template-columns: 1fr;
  }

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