:root {
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8FAFC;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --border-color: #E5E7EB;
}

.dark {
  --bg-primary: #181818;
  --bg-secondary: #1F2937;
  --text-primary: #F9FAFB;
  --text-secondary: #D1D5DB;
  --border-color: #374151;
}

body { 
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
  min-height: 100vh; 
  margin: 0; 
  padding: 0; 
  transition: background-color 0.3s ease, color 0.3s ease;
}

.light-mode { background: linear-gradient(135deg, #dbeafe 0%, #fef3c7 100%); }
.dark-mode { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); }

#app { 
  padding-bottom: 5rem; 
  width: 100%; 
  max-width: 6xl; 
  margin-left: auto; 
  margin-right: auto; 
  padding-left: 1rem; 
  padding-right: 1rem; 
  padding-top: 2rem; 
}

@media (min-width: 640px) { 
  #app { 
    padding-left: 1.5rem; 
    padding-right: 1.5rem; 
    padding-bottom: 2rem !important; 
  } 
}

.card { transition: all 0.3s ease; }
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); }
.progress-bar { transition: width 0.5s ease-in-out; }
.fade-in { animation: fadeIn 0.5s ease-in; }

@keyframes fadeIn { 
  from { opacity: 0; transform: translateY(10px); } 
  to { opacity: 1; transform: translateY(0); } 
}

@keyframes fireFlicker {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  25% { transform: scale(1.05) rotate(1deg); }
  50% { transform: scale(1.1) rotate(-0.5deg); }
  75% { transform: scale(1.05) rotate(0.5deg); }
}

@keyframes streakPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(251, 191, 36, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

@keyframes badgeGlow {
  0%, 100% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.5); }
  50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.6); }
}

.fire-animation { animation: fireFlicker 0.8s ease-in-out infinite; }
.streak-animation { animation: streakPulse 2s infinite; }
.badge-glow { animation: badgeGlow 2s ease-in-out infinite; }

.video-container, .ebook-container { 
  position: relative; 
  overflow: hidden; 
  border-radius: 1rem; 
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); 
  width: 100%; 
  padding-top: 56.25%; 
  height: 0; 
}
.ebook-container { padding-top: 141.42%; }
.video-container iframe, .ebook-container iframe { 
  position: absolute; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%; 
  border: none; 
  border-radius: 0.75rem; 
  transition: all 0.3s ease; 
}

.video-overlay-block {
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 50px;
  background: transparent;
  z-index: 10;
  pointer-events: auto;
}

.nav-button { transition: all 0.2s ease; }
.nav-button:hover { transform: translateY(-2px); }
.material-link { transition: all 0.2s ease; }
.material-link:hover { transform: translateX(3px); }
.module-complete { background: linear-gradient(to right, rgba(16, 185, 129, 0.1), transparent); }
.pulse { animation: pulse 2s infinite; }

@keyframes pulse { 
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7); } 
  70% { box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); } 
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); } 
}

.popup-message { 
  position: fixed; 
  top: 20px; 
  right: 20px; 
  padding: 15px 20px; 
  border: 1px solid transparent; 
  border-radius: 8px; 
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); 
  z-index: 1000; 
  opacity: 0; 
  visibility: hidden; 
  transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out; 
  max-width: 90%; 
  width: 300px; 
  font-size: 0.9rem; 
  pointer-events: none; 
}
.popup-message.show { opacity: 1; visibility: visible; pointer-events: auto; }
.error-popup { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; } 
.success-popup { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.info-popup { background-color: #d1ecf1; color: #0c5460; border-color: #bee5eb; } 
.warning-popup { background-color: #fff3cd; color: #856404; border-color: #ffeeba; }

.dark .error-popup { background-color: #7f1d1d; color: #fecaca; border-color: #991b1b; }
.dark .success-popup { background-color: #14532d; color: #bbf7d0; border-color: #166534; }
.dark .info-popup { background-color: #0c4a6e; color: #bae6fd; border-color: #0369a1; }
.dark .warning-popup { background-color: #92400e; color: #fde68a; border-color: #d97706; }

@media (max-width: 639px) { 
  .popup-message { 
    left: 50%; 
    right: auto; 
    transform: translateX(-50%); 
    width: 90%; 
    max-width: 90%; 
  } 
}

.mobile-fixed-buttons { 
  position: fixed; 
  bottom: 0; 
  left: 0; 
  right: 0; 
  width: 100%; 
  padding: 0.75rem 1rem; 
  display: flex; 
  justify-content: space-around; 
  gap: 0.5rem; 
  background: var(--bg-primary); 
  z-index: 50; 
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05); 
  overflow-x: auto; 
  -webkit-overflow-scrolling: touch; 
  scrollbar-width: none; 
  -ms-overflow-style: none; 
  border-top: 1px solid var(--border-color); 
}
.mobile-fixed-buttons::-webkit-scrollbar { display: none; }
.mobile-fixed-buttons .nav-button { flex-shrink: 0; padding: 0.6rem 1rem; font-size: 0.85rem; }
@media (min-width: 640px) { .mobile-fixed-buttons { display: none; } }

.modal-overlay { 
  position: fixed; 
  top: 0; 
  left: 0; 
  right: 0; 
  bottom: 0; 
  background-color: rgba(0, 0, 0, 0.5); 
  z-index: 1040; 
  display: none; 
}
.modal { 
  position: fixed; 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%); 
  background-color: var(--bg-primary); 
  padding: 1.5rem; 
  border-radius: 0.75rem; 
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); 
  z-index: 1050; 
  width: 90%; 
  max-width: 500px; 
  display: none; 
  color: var(--text-primary); 
  max-height: 80vh;
  overflow-y: auto;
}
.modal textarea, .modal input, .modal select { 
  width: 100%; 
  border: 1px solid var(--border-color); 
  border-radius: 0.375rem; 
  padding: 0.5rem 0.75rem; 
  background: var(--bg-primary); 
  color: var(--text-primary); 
}

.badge { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  width: 2.5rem; 
  height: 2.5rem; 
  border-radius: 50%; 
  font-size: 1.25rem; 
  font-weight: bold; 
  margin: 0.25rem; 
  position: relative; 
}
.badge-bronze { 
  background: linear-gradient(135deg, #cd7f32, #a0522d); 
  color: white; 
  border: 2px solid #8b4513; 
}
.badge-bronze::before { content: "🥉"; position: absolute; font-size: 1rem; }
.badge-silver { 
  background: linear-gradient(135deg, #c0c0c0, #999999); 
  color: white; 
  border: 2px solid #708090; 
}
.badge-silver::before { content: "🥈"; position: absolute; font-size: 1rem; }
.badge-gold { 
  background: linear-gradient(135deg, #ffd700, #ffb347); 
  color: white; 
  border: 2px solid #daa520; 
}
.badge-gold::before { content: "🥇"; position: absolute; font-size: 1rem; }

.streak-container { 
  display: flex; 
  align-items: center; 
  gap: 0.5rem; 
  background: var(--bg-secondary); 
  padding: 0.5rem 1rem; 
  border-radius: 9999px; 
  border: 1px solid var(--border-color); 
  cursor: pointer; 
  transition: all 0.3s ease; 
}
.streak-container:hover { background: rgba(251, 191, 36, 0.1); transform: scale(1.05); }

.points-display { 
  background: linear-gradient(135deg, #8b5cf6, #3b82f6); 
  color: white; 
  padding: 0.5rem 1rem; 
  border-radius: 9999px; 
  font-weight: bold; 
  cursor: pointer; 
  transition: all 0.3s ease; 
}
.points-display:hover { transform: scale(1.05); box-shadow: 0 4px 8px rgba(0,0,0,0.2); }

.theme-toggle { 
  position: relative; 
  width: 3rem; 
  height: 1.5rem; 
  background: var(--bg-secondary); 
  border-radius: 9999px; 
  border: 1px solid var(--border-color); 
  cursor: pointer; 
  transition: all 0.3s ease; 
}
.theme-toggle-handle { 
  position: absolute; 
  top: 0.125rem; 
  left: 0.125rem; 
  width: 1.25rem; 
  height: 1.25rem; 
  background: var(--bg-primary); 
  border-radius: 50%; 
  transition: transform 0.3s ease; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 0.75rem; 
}
.theme-toggle.dark .theme-toggle-handle { transform: translateX(1.5rem); }

.chat-container {
  background: var(--bg-secondary);
  border-radius: 1rem;
  padding: 1rem;
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.message-bubble {
  max-width: 80%;
  margin: 0.5rem 0;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  position: relative;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease-in;
}

.message-bubble.own {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 0.25rem;
}

.message-bubble.other {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  margin-right: auto;
  border-bottom-left-radius: 0.25rem;
}

.message-bubble.reply {
  margin-left: 2rem;
  max-width: 70%;
}

.message-bubble.reply-level-2 {
  margin-left: 4rem;
  max-width: 65%;
}

.message-bubble.reply-level-3 {
  margin-left: 6rem;
  max-width: 60%;
}

.message-meta {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-bottom: 0.25rem;
}

.message-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  justify-content: flex-end;
}

.reaction-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 1rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.reaction-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.reaction-btn.active {
  background: #10b981;
  color: white;
  border-color: #10b981;
}

.reply-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.reply-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  opacity: 1;
}

.unread-badge {
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
}

.community-note {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid #8b5cf6;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.note-author {
  font-size: 0.875rem;
  color: #8b5cf6;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.note-content {
  color: var(--text-primary);
  white-space: pre-wrap;
  line-height: 1.5;
}

.note-timestamp {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.tooltip { position: relative; display: inline-block; }
.tooltiptext { 
  visibility: hidden; 
  width: 280px; 
  background-color: rgba(51, 51, 51, 0.95); 
  color: #fff; 
  text-align: center; 
  border-radius: 6px; 
  padding: 12px; 
  position: absolute; 
  z-index: 1000; 
  bottom: 125%; 
  left: 50%; 
  margin-left: -140px; 
  opacity: 0; 
  transition: opacity 0.3s; 
  font-size: 13px; 
  backdrop-filter: blur(4px); 
  box-shadow: 0 4px 12px rgba(0,0,0,0.3); 
}
.tooltip:hover .tooltiptext { visibility: visible; opacity: 1; }
.tooltiptext::after { 
  content: ""; 
  position: absolute; 
  top: 100%; 
  left: 50%; 
  margin-left: -5px; 
  border-width: 5px; 
  border-style: solid; 
  border-color: rgba(51, 51, 51, 0.95) transparent transparent transparent; 
}

@media (max-width: 640px) {
  .tooltiptext { width: 250px; margin-left: -125px; font-size: 12px; padding: 10px; }
}

.header-mobile { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 0.75rem; 
  width: 100%; 
}
.header-desktop { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  width: 100%; 
}
@media (min-width: 640px) { 
  .header-mobile { display: none; } 
  .header-desktop { display: flex; } 
}
@media (max-width: 639px) { 
  .header-mobile { display: flex; } 
  .header-desktop { display: none; } 
}

.google-btn { transition: all 0.3s ease; }
.google-btn:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
.google-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.verification-notice {
  background: linear-gradient(135deg, #fef3c7, #fed7aa);
  border: 2px solid #f59e0b;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin: 1rem 0;
  animation: pulse 2s infinite;
}

.dark .verification-notice {
  background: linear-gradient(135deg, #92400e, #b45309);
  border-color: #d97706;
}

.collapsible-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  transition: all 0.3s ease;
}

.collapsible-header:hover {
  background: rgba(139, 92, 246, 0.1);
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible-content.open {
  max-height: 500px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  background: var(--bg-secondary);
  transition: all 0.3s ease;
}

.leaderboard-item:hover {
  background: rgba(139, 92, 246, 0.1);
}

.leaderboard-item.current-user {
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  color: white;
  font-weight: bold;
}

.leaderboard-position {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.leaderboard-trophy {
  font-size: 1.5rem;
}

.user-courses {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  line-height: 1.2;
}

.forum-input-container {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.forum-input-wrapper {
  flex: 1;
  position: relative;
}

.forum-textarea {
  width: 100%;
  min-height: 2.5rem;
  max-height: 8rem;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.4;
  transition: all 0.3s ease;
}

.forum-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.forum-send-btn {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 1.1rem;
}

.forum-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.forum-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.message-quote {
  background: rgba(139, 92, 246, 0.1);
  border-left: 3px solid #8b5cf6;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.message-thread-line {
  position: absolute;
  left: -1rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(139, 92, 246, 0.3);
}

.reply-indicator {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 0.5rem;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cancel-reply-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: background 0.2s ease;
}

.cancel-reply-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

.load-more-btn {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.load-more-btn:hover {
  background: rgba(139, 92, 246, 0.1);
}

.load-more-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ranking-card {
  background: linear-gradient(135deg, #fef3c7, #fed7aa, #fbbf24);
  position: relative;
  overflow: hidden;
}

.ranking-card::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #f59e0b, #d97706, #b45309, #92400e);
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ranking-card:hover::before {
  opacity: 1;
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: -468px 0; }
  100% { background-position: 468px 0; }
}

.dark .ranking-card {
  background: linear-gradient(135deg, #92400e, #b45309, #d97706);
}