/* =======================================================
   HeroQuest / Bento - Premium Family Gamification Platform
   Design System v2.0 — Glassmorphism + Micro-Animations
   ======================================================= */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Lexend:wght@400;500;600;700&display=swap');

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-deep: #3730a3;
  --primary-light: #e0e7ff;
  --primary-glow: rgba(99,102,241,0.35);
  --secondary: #f59e0b;
  --secondary-light: #fef3c7;
  --accent: #10b981;
  --accent-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --bg-gradient: linear-gradient(135deg, #f0f4ff 0%, #e8ecff 30%, #fef9ee 60%, #fdf2f8 100%);
  --card-bg: rgba(255,255,255,0.82);
  --card-border: rgba(255,255,255,0.65);
  --card-shadow: 0 8px 32px -8px rgba(99,102,241,0.10), 0 4px 16px -4px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 16px 48px -8px rgba(99,102,241,0.18), 0 8px 24px -4px rgba(0,0,0,0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-heading: 'Baloo 2', cursive, sans-serif;
  --font-body: 'Lexend', sans-serif;
  --ease-bounce: cubic-bezier(0.34,1.56,0.64,1);
  --ease-smooth: cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: #1e293b;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  padding-bottom: 85px;
}

/* ===================== ANIMATIONS ===================== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-8px); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pulseGlow {
  0%,100% { box-shadow: 0 0 0 0 var(--primary-glow); }
  50%     { box-shadow: 0 0 0 12px transparent; }
}
@keyframes slideInRight {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes slideInUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes sparkle {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: 0.6; transform: scale(1.15); }
}
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =============== SKELETON LOADING =============== */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius-md);
}

/* =============== GLASSMORPHISM v2 =============== */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--radius-xl);
  transition: transform 0.3s var(--ease-bounce), box-shadow 0.3s var(--ease-smooth);
  animation: fadeInUp 0.5s var(--ease-smooth) both;
}
.glass-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
}

/* =============== NAVBAR =============== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border-bottom: 1px solid rgba(226,232,240,0.6);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.navbar-container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  color: #1e1b4b;
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
}
.brand-logo span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 50%, #4f46e5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
  flex-shrink: 0;
}
.nav-user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  padding: 5px 14px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
  white-space: nowrap;
  border: 1px solid #e2e8f0;
}

/* =============== MAIN WRAPPER =============== */
.main-wrapper {
  max-width: 1080px;
  margin: 20px auto;
  padding: 0 16px;
}

/* =============== LEVEL BANNER =============== */
.level-banner {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 40%, #a78bfa 100%);
  color: white;
  padding: 22px 26px;
  border-radius: var(--radius-xl);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(99,102,241,0.3);
  animation: fadeInUp 0.5s var(--ease-smooth) both;
}
.level-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.level-banner::after {
  content: '⚡';
  position: absolute;
  right: -5px;
  bottom: -20px;
  font-size: 110px;
  opacity: 0.1;
  pointer-events: none;
  animation: sparkle 3s ease infinite;
}
.level-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  position: relative;
  z-index: 2;
}
.level-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.coin-badge {
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  padding: 7px 16px;
  border-radius: 24px;
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(255,255,255,0.25);
  color: #fbbf24;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.2);
  position: relative;
  z-index: 2;
}
.progress-bar-container {
  background: rgba(255,255,255,0.2);
  border-radius: 14px;
  height: 10px;
  overflow: hidden;
  position: relative;
  z-index: 2;
}
.progress-bar-fill {
  background: linear-gradient(90deg, #fbbf24 0%, #34d399 100%);
  height: 100%;
  border-radius: 14px;
  transition: width 0.6s var(--ease-bounce);
  position: relative;
}
.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 30px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4));
  border-radius: 14px;
}

/* =============== DAILY CHECK-IN =============== */
.checkin-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1.5px solid #fde68a;
  border-radius: var(--radius-xl);
  margin-bottom: 24px;
  animation: fadeInUp 0.5s var(--ease-smooth) 0.1s both;
}
.checkin-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245,158,11,0.35);
  transition: all 0.25s var(--ease-bounce);
  white-space: nowrap;
}
.checkin-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(245,158,11,0.45);
}
.checkin-btn:disabled {
  background: #cbd5e1;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* =============== FILTER TABS =============== */
.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 18px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-btn {
  background: rgba(255,255,255,0.75);
  border: 1.5px solid rgba(203,213,225,0.6);
  padding: 7px 16px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 0.85rem;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s var(--ease-bounce);
}
.filter-btn.active, .filter-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
  transform: translateY(-1px);
}

/* =============== CARDS GRID =============== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.task-card, .reward-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.card-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}
.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(99,102,241,0.1);
}
.card-info h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e1b4b;
  margin-bottom: 3px;
  line-height: 1.3;
}
.card-info p {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.4;
}
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(226,232,240,0.8);
}
.points-pill {
  font-weight: 700;
  font-size: 0.92rem;
  color: #d97706;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* =============== DIFFICULTY BADGES =============== */
.diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.diff-badge.easy   { background: #d1fae5; color: #065f46; }
.diff-badge.medium { background: #fef3c7; color: #92400e; }
.diff-badge.hard   { background: #fee2e2; color: #991b1b; }

/* =============== ACTION BUTTONS =============== */
.action-btn {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 0.25s var(--ease-bounce);
  position: relative;
  overflow: hidden;
}
.action-btn:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--primary-glow);
}
.action-btn:active {
  transform: translateY(0) scale(0.97);
}
.action-btn.secondary {
  background: #f1f5f9;
  color: #475569;
  box-shadow: none;
}
.action-btn.secondary:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.action-btn.danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}
.action-btn.danger:hover {
  box-shadow: 0 6px 16px rgba(239,68,68,0.35);
}
.action-btn.success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* =============== MODALS =============== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-smooth);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  background: white;
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius-xl);
  padding: 26px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.1);
  transform: scale(0.9) translateY(16px);
  transition: transform 0.3s var(--ease-bounce);
}
.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

/* =============== PIN KEYPAD =============== */
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.keypad-btn {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1.5px solid #e2e8f0;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: #1e293b;
  padding: 14px 0;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s var(--ease-bounce);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.keypad-btn:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
}
.keypad-btn:active {
  background: #c7d2fe;
  transform: scale(0.93);
  box-shadow: none;
}
.pin-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 18px 0;
}
.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: all 0.25s var(--ease-bounce);
}
.pin-dot.filled {
  background: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
  transform: scale(1.15);
}

/* =============== BOTTOM NAV =============== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-top: 1px solid rgba(226,232,240,0.7);
  display: flex;
  justify-content: space-around;
  padding: 6px 10px 8px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 14px;
  transition: all 0.25s var(--ease-bounce);
  position: relative;
}
.nav-item .nav-icon {
  font-size: 1.3rem;
  transition: transform 0.25s var(--ease-bounce);
}
.nav-item.active {
  color: var(--primary);
  background: var(--primary-light);
}
.nav-item.active .nav-icon {
  transform: scale(1.15);
}
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

/* =============== FORM STYLING =============== */
.form-group {
  margin-bottom: 14px;
}
.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: #334155;
  margin-bottom: 5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #cbd5e1;
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.25s var(--ease-smooth);
  background: #fafbfd;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
  background: white;
}

/* =============== TOASTS =============== */
.toast-container {
  position: fixed;
  top: 65px;
  right: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: white;
  padding: 12px 18px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: 0 12px 28px rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideInRight 0.3s var(--ease-bounce);
  border: 1px solid rgba(255,255,255,0.08);
}

/* =============== LOGIN SCREEN EXTRAS =============== */
.login-hero-icon {
  animation: float 4s ease-in-out infinite;
}
.login-avatar-ring {
  width: 88px;
  height: 88px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  position: relative;
  animation: pulseGlow 2.5s ease infinite;
}
.login-kid-card {
  animation: fadeInUp 0.5s var(--ease-smooth) both;
}
.login-kid-card:nth-child(1) { animation-delay: 0.1s; }
.login-kid-card:nth-child(2) { animation-delay: 0.2s; }
.login-kid-card:nth-child(3) { animation-delay: 0.3s; }
.login-kid-card:nth-child(4) { animation-delay: 0.4s; }

.parent-login-btn {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 2px solid #e2e8f0;
  padding: 14px 28px;
  border-radius: 18px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  color: #475569;
  cursor: pointer;
  transition: all 0.25s var(--ease-bounce);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.parent-login-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: white;
  box-shadow: 0 6px 20px rgba(99,102,241,0.12);
  transform: translateY(-2px);
}

/* =============== STAGGER ANIMATION UTIL =============== */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }

/* =============== ADMIN TABLE =============== */
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}
.admin-table thead tr {
  background: #f8fafc;
  color: #475569;
}
.admin-table th {
  padding: 14px 16px;
  font-weight: 700;
  border-bottom: 2px solid #e2e8f0;
  text-align: left;
}
.admin-table td {
  padding: 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.admin-table tbody tr:hover {
  background-color: #f8fafc;
}
.admin-table tbody tr:last-child td {
  border-bottom: none;
}
.badge-category {
  background: #e2e8f0;
  color: #475569;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* =============== RESPONSIVE =============== */
@media (max-width: 640px) {
  html, body { font-size: 14px; }
  .cards-grid { grid-template-columns: 1fr; }
  .level-banner { padding: 16px 18px; }
  .level-title { font-size: 1.2rem; }
  .brand-logo span { font-size: 0.95rem; }
  .checkin-card {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .checkin-btn { width: 100%; }
  .modal-card { padding: 20px; max-width: 360px; }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1025px) {
  .cards-grid { grid-template-columns: repeat(3, 1fr); }
}
