/**
 * Gamifikasi Literasi Siswa - Perpustakaan Wanawidya SMK Negeri 1 Wanareja
 * Leveling, XP Experience, Badges, Quests, Class Leaderboard & Audio Fanfare
 */

:root {
  --xp-bronze: #cd7f32;
  --xp-silver: #94a3b8;
  --xp-gold: #f59e0b;
  --xp-diamond: #06b6d4;
  --xp-master: #8b5cf6;
  --xp-grandmaster: #ec4899;
}

/* 1. GAMIFICATION HERO BAR (Di Atas Dashboard Member) */
.gamification-hero-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  border-radius: 20px;
  padding: 24px 28px;
  color: white;
  margin-bottom: 20px;
  box-shadow: 0 10px 25px -5px rgba(67, 56, 202, 0.35), 0 0 1px 1px rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.gamification-hero-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.18) 0%, transparent 70%);
  pointer-events: none;
}

.game-profile-side {
  display: flex;
  align-items: center;
  gap: 18px;
}

.game-level-badge-ring {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4), inset 0 0 0 2px rgba(255, 255, 255, 0.3);
  position: relative;
  animation: pulseCrown 3s infinite ease-in-out;
  flex-shrink: 0;
}

@keyframes pulseCrown {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 12px 28px rgba(245, 158, 11, 0.6); }
}

.game-level-badge-ring .mini-badge-lvl {
  position: absolute;
  bottom: -6px;
  background: #0f172a;
  color: #fcd34d;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid #f59e0b;
  letter-spacing: 0.5px;
}

.game-profile-info {
  display: flex;
  flex-direction: column;
}

.game-title-role {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
  color: #fbbf24;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-user-name {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 4px 0;
}

.game-rank-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  padding: 3px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e0e7ff;
}

.btn-fanfare {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border: none;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 3px 8px rgba(245, 158, 11, 0.3);
  transition: all 0.2s;
}

.btn-fanfare:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(245, 158, 11, 0.5);
  color: #fff;
}

/* XP Progress Bar Section */
.game-progress-side {
  flex: 1;
  min-width: 260px;
  max-width: 480px;
}

.game-xp-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 13px;
}

.game-xp-total {
  font-weight: 800;
  font-size: 18px;
  color: #fcd34d;
}

.game-xp-total span {
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.game-next-lvl {
  font-weight: 600;
  color: #94a3b8;
  font-size: 12px;
}

.game-progress-bar-track {
  height: 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-progress-bar-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, #10b981 0%, #06b6d4 50%, #f59e0b 100%);
  position: relative;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}

.game-progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 100%);
  animation: shimmerProgress 2s infinite;
}

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

/* LITERASI SCHEDULE ALERT */
.literasi-schedule-strip {
  background: #ffffff;
  border-radius: 14px;
  padding: 12px 18px;
  border: 1px solid #e2e8f0;
  border-left: 5px solid #3b82f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.03);
}

.schedule-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eff6ff;
  color: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* 2. STATS CARDS (XP Breakdowns) */
.gamification-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.game-stat-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 18px -3px rgba(0, 0, 0, 0.08);
  border-color: #cbd5e1;
}

.game-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.game-stat-icon.loans { background: #eff6ff; color: #2563eb; }
.game-stat-icon.ebooks { background: #ecfeff; color: #0891b2; }
.game-stat-icon.literasi { background: #fefce8; color: #ca8a04; }
.game-stat-icon.visits { background: #f0fdf4; color: #16a34a; }

.game-stat-meta .stat-num {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.game-stat-meta .stat-label {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 2px;
}

/* 3. QUESTS GRID */
.gamification-quest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.quest-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: all 0.2s;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.02);
}

.quest-card:hover {
  border-color: #93c5fd;
  transform: translateY(-2px);
}

.quest-card.completed {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.quest-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #eff6ff;
  color: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.quest-card.completed .quest-icon {
  background: #dcfce7;
  color: #16a34a;
}

.quest-content {
  flex: 1;
}

.quest-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #1e293b;
}

.quest-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.35;
}

.quest-reward-pill {
  background: #fef3c7;
  color: #b45309;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
}

.quest-progress-text {
  font-size: 11.5px;
  color: #475569;
  font-weight: 600;
}

/* 4. LEVEL PERKS SHOWCASE */
.level-perks-box {
  background: #ffffff;
  border-radius: 18px;
  padding: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.perks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.perk-card {
  background: #f8fafc;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #e2e8f0;
}

.perk-card.active {
  background: #f0fdf4;
  border-color: #86efac;
}

.perk-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #dcfce7;
  color: #16a34a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.perk-label {
  font-size: 11.5px;
  color: #64748b;
}

.perk-val {
  font-size: 15px;
  font-weight: 800;
  color: #15803d;
}

/* 5. BADGES GRID */
.badges-container {
  background: #ffffff;
  border-radius: 20px;
  padding: 24px;
  border: 1px solid #e2e8f0;
  margin-bottom: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03);
}

.section-head-flair {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.section-head-flair h3 {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.badge-item-card {
  background: #f8fafc;
  border-radius: 16px;
  padding: 18px 14px;
  text-align: center;
  border: 1px solid #e2e8f0;
  transition: all 0.25s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
}

.badge-item-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.08);
}

.badge-item-card.unlocked {
  background: #ffffff;
  border-color: #cbd5e1;
}

.badge-item-card.locked {
  opacity: 0.65;
  filter: grayscale(85%);
  background: #f1f5f9;
}

.badge-icon-holder {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  margin: 0 auto 12px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  position: relative;
}

.badge-item-card.unlocked .badge-icon-holder {
  animation: badgeShine 3s infinite ease-in-out;
}

@keyframes badgeShine {
  0%, 100% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06); }
  50% { box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35); }
}

.badge-lock-tag {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  background: #64748b;
  color: #ffffff;
  font-size: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
}

.badge-title {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

.badge-desc {
  font-size: 11px;
  color: #64748b;
  line-height: 1.35;
  margin-bottom: 12px;
  min-height: 32px;
}

.badge-status-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}

.badge-status-pill.success {
  background: #ecfdf5;
  color: #059669;
}

.badge-status-pill.pending {
  background: #f1f5f9;
  color: #64748b;
}

/* 6. RECENT JOURNALS GRID */
.recent-journals-box {
  background: #ffffff;
  border-radius: 18px;
  padding: 20px;
  border: 1px solid #e2e8f0;
}

.journal-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.journal-item-card {
  background: #f8fafc;
  border-radius: 14px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
}

.journal-item-card:hover {
  border-color: #93c5fd;
  background: #fff;
  transform: translateY(-2px);
}

/* 7. LEADERBOARD / HALL OF FAME */
.leaderboard-section {
  background: #ffffff;
  border-radius: 20px;
  padding: 24px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03);
}

.leaderboard-tab-toggle {
  display: inline-flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.tab-toggle-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-toggle-btn.active {
  background: #ffffff;
  color: #3b82f6;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* 3D PODIUM (Juara 1, 2, 3) */
.podium-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  padding: 30px 10px 10px 10px;
  margin-bottom: 24px;
}

.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 140px;
  position: relative;
}

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

.podium-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #cbd5e1;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
  background: #ffffff;
}

.podium-slot.rank-1 .podium-avatar {
  width: 76px;
  height: 76px;
  border-color: #f59e0b;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
}

.podium-crown {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 20px;
  color: #f59e0b;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  animation: crownFloat 2.5s infinite ease-in-out;
}

@keyframes crownFloat {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -4px); }
}

.podium-user-name {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.podium-user-score {
  font-size: 12px;
  font-weight: 800;
  color: #64748b;
  margin-bottom: 8px;
}

.podium-pillar {
  width: 100%;
  border-radius: 14px 14px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 28px;
  color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

.podium-slot.rank-1 .podium-pillar {
  height: 110px;
  background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
}

.podium-slot.rank-2 .podium-pillar {
  height: 80px;
  background: linear-gradient(180deg, #94a3b8 0%, #475569 100%);
}

.podium-slot.rank-3 .podium-pillar {
  height: 65px;
  background: linear-gradient(180deg, #d97706 0%, #78350f 100%);
}

/* Leaderboard Table List (Rank 1 - 10) */
.leaderboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.leaderboard-row {
  background: #f8fafc;
  border-radius: 12px;
  transition: all 0.2s;
}

.leaderboard-row:hover {
  background: #f1f5f9;
  transform: translateX(4px);
}

.leaderboard-row.is-current-user {
  background: #e0e7ff;
  border: 1px solid #818cf8;
}

.leaderboard-row td {
  padding: 12px 16px;
  vertical-align: middle;
}

.leaderboard-row td:first-child {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}

.leaderboard-row td:last-child {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}

.leaderboard-rank-badge {
  font-weight: 800;
  font-size: 14px;
  color: #64748b;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.leaderboard-rank-badge.top-1 { background: #fef3c7; color: #d97706; }
.leaderboard-rank-badge.top-2 { background: #f1f5f9; color: #475569; }
.leaderboard-rank-badge.top-3 { background: #ffedd5; color: #c2410c; }

.leaderboard-user-flex {
  display: flex;
  align-items: center;
  gap: 12px;
}

.leaderboard-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e2e8f0;
}

.class-avatar-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eff6ff;
  color: #3b82f6;
  font-size: 16px;
}

.class-avatar-badge.rank-1 {
  background: #fef3c7;
  color: #d97706;
}

.leaderboard-user-title {
  font-weight: 700;
  color: #0f172a;
  font-size: 14px;
}

.leaderboard-user-sub {
  font-size: 11.5px;
  color: #64748b;
}

.leaderboard-score-chip {
  background: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 13px;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 8. CELEBRATION MODAL */
.badge-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.badge-modal-card {
  background: #ffffff;
  border-radius: 24px;
  max-width: 420px;
  width: 100%;
  padding: 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid #e2e8f0;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.badge-modal-header {
  text-align: center;
  position: relative;
  margin-bottom: 12px;
}

.badge-modal-close {
  position: absolute;
  top: -10px;
  right: -6px;
  background: none;
  border: none;
  font-size: 24px;
  color: #94a3b8;
  cursor: pointer;
}

.badge-modal-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fef3c7;
  color: #d97706;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px auto;
  box-shadow: 0 8px 16px rgba(245, 158, 11, 0.25);
}

.badge-modal-title {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}

.badge-modal-desc {
  font-size: 13.5px;
  color: #64748b;
  text-align: center;
  line-height: 1.5;
  margin: 0;
}

/* 9. HOMEPAGE LEADERBOARD SECTION */
.home-leaderboard-section {
  background: linear-gradient(180deg, #f8fafc 0%, #eff6ff 100%);
  padding: 70px 0;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.home-leaderboard-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}

/* Responsiveness */
@media (max-width: 768px) {
  .gamification-hero-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .game-progress-side {
    max-width: 100%;
  }
  .podium-container {
    gap: 8px;
  }
  .podium-avatar {
    width: 48px;
    height: 48px;
  }
  .podium-slot.rank-1 .podium-avatar {
    width: 60px;
    height: 60px;
  }
}
