/* ============================================
   AI Math Tutor - Design System
   ============================================ */

:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --primary-light: #EEF2FF;
  --success: #059669;
  --warning: #D97706;
  --danger: #DC2626;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-500: #6B7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.6;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: white; color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Cards */
.card {
  background: white; border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); border: 1px solid var(--gray-100);
}

/* Input */
input, select, textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--gray-200);
  border-radius: 8px; font-size: 14px; outline: none; transition: border 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }

label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; color: var(--gray-700); }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

/* Nav */
.nav {
  background: rgba(255,255,255,0.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(241,245,249,0.8);
  padding: 10px 0; position: sticky; top: 0; z-index: 100;
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; }
.nav-brand { font-size: 18px; font-weight: 700; color: var(--primary); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-links a { color: var(--gray-700); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--primary); }

/* Zeluu Mascot (appears in nav on all pages) */
.zeluu-mascot {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}
.zeluu-mascot .z-eyes { display: flex; gap: 6px; }
.zeluu-mascot .z-eye {
  width: 8px; height: 10px;
  background: white; border-radius: 50%;
  position: relative;
  animation: zBlink 4s infinite;
}
.zeluu-mascot .z-eye::after {
  content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; background: #1E293B; border-radius: 50%;
}
@keyframes zBlink {
  0%, 94%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}
.zeluu-mascot .z-antenna {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 8px; background: #A78BFA; border-radius: 2px;
}
.zeluu-mascot .z-antenna::after {
  content: ''; position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  width: 6px; height: 6px; background: #10B981; border-radius: 50%;
  animation: zPulse 2s infinite;
}
@keyframes zPulse {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.5; transform: translateX(-50%) scale(1.4); }
}
.zeluu-brand-text {
  font-size: 22px; font-weight: 800;
  background: linear-gradient(135deg, #6366F1, #EC4899);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.zeluu-beta {
  font-size: 10px; font-weight: 700;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: white; padding: 2px 7px; border-radius: 6px;
  letter-spacing: 0.5px; text-transform: uppercase;
  margin-left: -2px; align-self: flex-start; margin-top: 2px;
}

/* Credit badge */
.credit-badge {
  background: var(--primary-light); color: var(--primary); padding: 6px 14px;
  border-radius: 20px; font-size: 13px; font-weight: 600;
}
.credit-badge.low { background: #FEF3C7; color: var(--warning); }
.credit-badge.empty { background: #FEE2E2; color: var(--danger); }

/* Chat — Kid-friendly theme */
.chat-container {
  display: flex; flex-direction: column; height: calc(100vh - 130px);
  max-width: 800px; margin: 0 auto;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px 0;
  display: flex; flex-direction: column; gap: 16px;
}
.chat-bubble {
  max-width: 80%; padding: 16px 20px; border-radius: 20px;
  font-size: 16px; line-height: 1.7; animation: fadeIn 0.3s;
  white-space: pre-line;
}
.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: white;
  border-bottom-right-radius: 6px;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: white;
  border: 2px solid #E0E7FF;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  color: #1E293B;
}
.chat-bubble.assistant::before {
  content: '🧮 ';
  font-size: 14px;
}
.chat-input-area {
  display: flex; gap: 10px; padding: 16px 0; border-top: 2px solid #E0E7FF;
  align-items: flex-end;
}
.chat-input-area textarea {
  flex: 1; resize: none; min-height: 52px; max-height: 120px;
  border-radius: 16px; padding: 14px 18px; font-size: 15px;
  border: 2px solid #E0E7FF;
}
.chat-input-area textarea:focus {
  border-color: #8B5CF6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}
.chat-input-area .btn-primary {
  border-radius: 16px; padding: 14px 24px; font-size: 15px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
}
.chat-input-area .btn-secondary {
  border-radius: 16px; padding: 14px; border: 2px solid #E0E7FF;
}
.flag-btn {
  font-size: 12px; color: var(--gray-500); cursor: pointer;
  background: none; border: none; margin-top: 8px; opacity: 0.6;
}
.flag-btn:hover { color: var(--danger); opacity: 1; }

/* Chat page specific overrides */
body.chat-page {
  background: linear-gradient(180deg, #F0F0FF 0%, #FAFAFF 50%, #F8F7FF 100%);
}
body.chat-page .nav {
  background: white;
  border-bottom: 2px solid #E0E7FF;
}
body.chat-page .nav-brand {
  font-size: 20px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Landing */
.hero {
  padding: 80px 0 60px; text-align: center;
}
.hero h1 { font-size: 48px; font-weight: 800; line-height: 1.1; margin-bottom: 16px; }
.hero h1 span { color: var(--primary); }
.hero p { font-size: 18px; color: var(--gray-500); max-width: 600px; margin: 0 auto 32px; }

.features-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; padding: 40px 0;
}
.feature-card { text-align: center; padding: 32px 20px; }
.feature-card .icon { font-size: 40px; margin-bottom: 12px; }
.feature-card h3 { font-size: 18px; margin-bottom: 8px; }
.feature-card p { font-size: 14px; color: var(--gray-500); }

.pricing-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; padding: 40px 0;
}
.price-card { text-align: center; padding: 32px 24px; position: relative; }
.price-card.featured { border: 2px solid var(--primary); }
.price-card .badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: white; padding: 4px 16px;
  border-radius: 12px; font-size: 12px; font-weight: 600;
}
.price-card h3 { font-size: 20px; margin-bottom: 8px; }
.price-card .price { font-size: 36px; font-weight: 800; color: var(--primary); }
.price-card .price span { font-size: 16px; color: var(--gray-500); font-weight: 400; }
.price-card .credits { color: var(--gray-500); margin-bottom: 20px; }

/* Auth page */
.auth-container {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-card p { color: var(--gray-500); margin-bottom: 24px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; }
.auth-tab {
  flex: 1; padding: 10px; text-align: center; cursor: pointer;
  border-bottom: 2px solid var(--gray-200); font-weight: 500; color: var(--gray-500);
}
.auth-tab.active { border-color: var(--primary); color: var(--primary); }
.form-group { margin-bottom: 16px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 6px; display: none; }

/* Notification bell */
.notif-bell { position: relative; cursor: pointer; font-size: 20px; }
.notif-count {
  position: absolute; top: -6px; right: -8px;
  background: var(--danger); color: white; font-size: 11px;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { text-align: center; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--gray-500); }

.session-list { display: flex; flex-direction: column; gap: 8px; }
.session-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: white; border-radius: 8px;
  border: 1px solid var(--gray-100);
}
.session-item .meta { font-size: 13px; color: var(--gray-500); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Loading spinner */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--gray-200);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center; z-index: 200;
}
.modal-overlay.active { display: flex; }
.modal { background: white; border-radius: var(--radius); padding: 32px; max-width: 480px; width: 90%; }
.modal h2 { margin-bottom: 16px; }

/* Responsive */
@media (max-width: 768px) {
  .features-grid, .pricing-grid, .stats-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 32px; }
  .chat-bubble { max-width: 90%; }
}
