/* ================================================
   KidsCode - Main Stylesheet
   Playful & Fun Design untuk Anak SD
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Fredoka+One&display=swap');

:root {
  --primary: #7C3AED;
  --primary-light: #EDE9FE;
  --secondary: #F59E0B;
  --success: #10B981;
  --danger: #EF4444;
  --info: #3B82F6;
  --dark: #1E1B4B;
  --text: #374151;
  --text-muted: #6B7280;
  --bg: #F5F3FF;
  --white: #FFFFFF;
  --card-shadow: 0 4px 24px rgba(124,58,237,0.10);
  --radius: 18px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3 { font-family: 'Fredoka One', cursive; }

a { text-decoration: none; color: inherit; }

/* ---- NAVBAR ---- */
.navbar {
  background: var(--white);
  box-shadow: 0 2px 16px rgba(124,58,237,0.10);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--primary-light);
}

.navbar-brand {
  font-family: 'Fredoka One', cursive;
  font-size: 1.8rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-brand span { font-size: 1.6rem; }

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  list-style: none;
}

.navbar-nav a {
  font-weight: 700;
  color: var(--text);
  padding: 0.4rem 0.9rem;
  border-radius: 99px;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.navbar-nav a:hover, .navbar-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.4rem 1rem;
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.65rem 1.4rem;
  border-radius: 99px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 0 #5B21B6; }
.btn-primary:hover { background: #6D28D9; transform: translateY(-2px); box-shadow: 0 6px 0 #5B21B6; }

.btn-success { background: var(--success); color: white; box-shadow: 0 4px 0 #047857; }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #047857; }

.btn-warning { background: var(--secondary); color: white; box-shadow: 0 4px 0 #B45309; }
.btn-warning:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #B45309; }

.btn-danger { background: var(--danger); color: white; box-shadow: 0 4px 0 #B91C1C; }
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #B91C1C; }

.btn-outline {
  background: white;
  color: var(--primary);
  border: 2.5px solid var(--primary);
  box-shadow: 0 4px 0 #DDD6FE;
}
.btn-outline:hover { background: var(--primary-light); transform: translateY(-2px); }

.btn-lg { padding: 0.85rem 2rem; font-size: 1.15rem; }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.88rem; }

/* ---- CARDS ---- */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(124,58,237,0.15); }

.card-header {
  border-bottom: 2px dashed #EDE9FE;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  font-family: 'Fredoka One', cursive;
  font-size: 1.2rem;
  color: var(--primary);
}

/* ---- LEVEL CARDS ---- */
.level-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.3rem;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  border: 3px solid transparent;
}

.level-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: var(--kelas-warna, var(--primary));
  border-radius: 0 0 6px 6px;
}

.level-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
  border-color: var(--kelas-warna, var(--primary));
}

.level-card .level-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.level-card .level-label {
  display: inline-block;
  background: var(--kelas-warna, var(--primary));
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 99px;
  margin-bottom: 0.4rem;
}
.level-card .level-title { font-family: 'Fredoka One', cursive; font-size: 1.05rem; color: var(--dark); margin-bottom: 0.25rem; }
.level-card .level-sub { font-size: 0.82rem; color: var(--text-muted); }

/* ---- PROGRESS BAR ---- */
.progress-wrap { background: #F3F4F6; border-radius: 99px; height: 10px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), #A78BFA); transition: width 0.4s; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 800;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-info { background: #DBEAFE; color: #1E40AF; }

/* ---- STAT CARDS ---- */
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--card-shadow);
}
.stat-icon { font-size: 2.2rem; }
.stat-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 700; }
.stat-value { font-family: 'Fredoka One', cursive; font-size: 1.8rem; color: var(--dark); line-height: 1; }

/* ---- MODUL CARD ---- */
.modul-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  border: 2.5px solid transparent;
}
.modul-card:hover { transform: translateX(4px); border-color: var(--primary-light); }
.modul-card.selesai { border-color: #D1FAE5; background: #F0FDF4; }
.modul-card.terkunci { opacity: 0.5; cursor: not-allowed; }

.modul-icon-wrap {
  width: 54px; height: 54px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.modul-title { font-weight: 800; color: var(--dark); font-size: 0.95rem; }
.modul-meta { font-size: 0.8rem; color: var(--text-muted); }
.modul-status { margin-left: auto; flex-shrink: 0; }

/* ---- LEADERBOARD ---- */
.lb-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.lb-item:hover { background: var(--primary-light); }
.lb-rank { font-family: 'Fredoka One', cursive; font-size: 1.1rem; color: var(--text-muted); width: 28px; text-align: center; }
.lb-rank.gold { color: #D97706; }
.lb-rank.silver { color: #6B7280; }
.lb-rank.bronze { color: #92400E; }
.lb-avatar { font-size: 1.6rem; }
.lb-nama { font-weight: 800; font-size: 0.92rem; color: var(--dark); }
.lb-kelas { font-size: 0.78rem; color: var(--text-muted); }
.lb-poin { margin-left: auto; font-family: 'Fredoka One', cursive; font-size: 1.05rem; color: var(--primary); }

/* ---- FORMS ---- */
.form-group { margin-bottom: 1.2rem; }
.form-label { display: block; font-weight: 800; margin-bottom: 0.4rem; color: var(--dark); font-size: 0.92rem; }
.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2.5px solid #DDD6FE;
  border-radius: 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: white;
  transition: border-color 0.2s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 4px #EDE9FE; }

/* ---- ALERTS ---- */
.alert {
  padding: 0.85rem 1.2rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-danger { background: #FEE2E2; color: #991B1B; border: 1.5px solid #FECACA; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1.5px solid #A7F3D0; }
.alert-info { background: #DBEAFE; color: #1E40AF; border: 1.5px solid #BFDBFE; }

/* ---- CODE EDITOR ---- */
.code-area {
  font-family: 'Courier New', monospace;
  background: #1E1B4B;
  color: #E0E7FF;
  border-radius: 12px;
  padding: 1rem;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 200px;
  border: none;
  outline: none;
  width: 100%;
  line-height: 1.6;
}

.preview-frame {
  width: 100%;
  border: 3px solid #DDD6FE;
  border-radius: 12px;
  min-height: 200px;
  background: white;
}

/* ---- DRAG & DROP EDITOR ---- */
.dnd-toolbar {
  background: white;
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dnd-element {
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.5rem 1rem;
  border-radius: 99px;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: grab;
  user-select: none;
  transition: all 0.15s;
}
.dnd-element:hover { background: var(--primary); color: white; }
.dnd-canvas {
  background: white;
  border: 3px dashed #DDD6FE;
  border-radius: var(--radius);
  min-height: 300px;
  padding: 1.5rem;
  position: relative;
}
.dnd-canvas.drag-over { border-color: var(--primary); background: var(--primary-light); }

/* ---- LENCANA ---- */
.badge-card {
  background: white;
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--card-shadow);
  transition: all 0.2s;
}
.badge-card:hover { transform: scale(1.05); }
.badge-icon { font-size: 2.5rem; display: block; margin-bottom: 0.4rem; }
.badge-name { font-weight: 800; font-size: 0.85rem; color: var(--dark); }
.badge-desc { font-size: 0.75rem; color: var(--text-muted); }
.badge-card.locked { filter: grayscale(1); opacity: 0.4; }

/* ---- TOAST NOTIFIKASI ---- */
.toast-container { position: fixed; top: 80px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: white;
  border-radius: 14px;
  padding: 0.85rem 1.2rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.92rem;
  animation: slideIn 0.3s ease, fadeOut 0.4s ease 2.6s forwards;
  border-left: 4px solid var(--primary);
  max-width: 300px;
}
.toast.success { border-color: var(--success); }
.toast.warning { border-color: var(--secondary); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }

/* ---- MODAL LENCANA BARU ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(30,27,75,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  animation: fadeIn 0.3s;
}
.modal-box {
  background: white;
  border-radius: 24px;
  padding: 2.5rem;
  text-align: center;
  max-width: 340px;
  width: 90%;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-icon { font-size: 5rem; display: block; margin-bottom: 0.5rem; }
.modal-title { font-family: 'Fredoka One', cursive; font-size: 1.8rem; color: var(--primary); margin-bottom: 0.4rem; }
.modal-sub { color: var(--text-muted); font-weight: 700; }

/* ---- LAYOUT ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.2rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 800; }
.section-title { font-family: 'Fredoka One', cursive; font-size: 1.5rem; color: var(--dark); margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 640px) {
  .navbar { padding: 0.75rem 1rem; }
  .navbar-nav { display: none; }
  .container { padding: 0 1rem; }
}

/* ---- HALAMAN LOGIN ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #EDE9FE 0%, #FEF3C7 100%); }
.login-card { background: white; border-radius: 24px; padding: 2.5rem; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(124,58,237,0.2); }
.login-logo { font-family: 'Fredoka One', cursive; font-size: 2.5rem; color: var(--primary); text-align: center; margin-bottom: 0.3rem; }
.login-sub { text-align: center; color: var(--text-muted); font-weight: 700; margin-bottom: 2rem; font-size: 0.92rem; }

/* Kode unik input besar */
.kode-input {
  text-align: center;
  font-size: 2rem;
  font-family: 'Fredoka One', cursive;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 1rem;
}

/* ---- HERO DASHBOARD ---- */
.hero-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #A78BFA 100%);
  border-radius: var(--radius);
  padding: 1.8rem 2rem;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  overflow: hidden;
  position: relative;
}
.hero-banner::after {
  content: '⭐';
  position: absolute;
  right: -10px; top: -20px;
  font-size: 8rem;
  opacity: 0.1;
}
.hero-name { font-family: 'Fredoka One', cursive; font-size: 1.8rem; }
.hero-sub { font-size: 0.92rem; opacity: 0.85; margin-top: 0.2rem; }
.hero-avatar { font-size: 4rem; }

/* Stars animation on lencana */
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.bounce { animation: bounce 1s infinite; }

/* ---- MAP PETUALANGAN ---- */
.map-container { background: linear-gradient(135deg, #EDE9FE, #DBEAFE); border-radius: var(--radius); padding: 1.5rem; overflow-x: auto; }
.map-path { display: flex; align-items: center; gap: 0; flex-wrap: nowrap; min-width: 700px; }
.map-node {
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
  width: 100px;
}
.map-node-circle {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 0.4rem;
  border: 4px solid white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: all 0.2s;
  background: var(--node-color, #8B5CF6);
}
.map-node-circle:hover { transform: scale(1.15); }
.map-node-circle.locked { filter: grayscale(1); opacity: 0.5; cursor: not-allowed; }
.map-node-label { font-size: 0.75rem; font-weight: 800; color: var(--dark); }
.map-connector { flex: 1; height: 4px; background: rgba(255,255,255,0.6); border-radius: 2px; min-width: 20px; }

/* ---- ADMIN PANEL ---- */
.admin-sidebar {
  width: 240px;
  background: var(--dark);
  min-height: 100vh;
  padding: 1.5rem 1rem;
  position: fixed;
  left: 0; top: 0;
}
.admin-content { margin-left: 240px; padding: 2rem; }
.admin-brand { font-family: 'Fredoka One', cursive; font-size: 1.5rem; color: white; margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.admin-nav a { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,0.7); padding: 0.6rem 0.8rem; border-radius: 8px; font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; transition: all 0.15s; }
.admin-nav a:hover, .admin-nav a.active { background: rgba(255,255,255,0.1); color: white; }
.admin-table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--card-shadow); }
.admin-table th { background: var(--primary-light); color: var(--primary); font-weight: 800; padding: 0.85rem 1rem; text-align: left; font-size: 0.88rem; }
.admin-table td { padding: 0.8rem 1rem; border-bottom: 1px solid #F3F4F6; font-size: 0.92rem; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #FAFAFA; }
