/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Alexandria:wght@300;400;500;600;700;800;900&family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

/* =============================================
   N4M BRAND COLOR SYSTEM
   Primary: Orange #F97316 / #EA580C
   Background: #0E0E0F / #1A1A1C
   Surface: #1C1C1E / #252528
   Text: #F5F5F7 / #A1A1AA
   ============================================= */
:root {
  --n4m-orange: #F97316;
  --n4m-orange-dark: #EA580C;
  --n4m-orange-light: #FB923C;
  --n4m-purple: #6D28D9;
  --n4m-purple-dark: #5B21B6;
  --n4m-purple-light: #8B5CF6;
  --n4m-bg: #F8F9FA;
  --n4m-bg2: #F1F3F5;
  --n4m-surface: #FFFFFF;
  --n4m-surface2: #F1F3F5;
  --n4m-border: rgba(109, 40, 217, 0.28);
  --n4m-border-hover: rgba(109, 40, 217, 0.55);
  --n4m-text: #18181B;
  --n4m-text-secondary: #52525B;
  --n4m-text-muted: #71717A;
  --n4m-emerald: #10B981;
  --n4m-rose: #F43F5E;
  --n4m-amber: #D97706;
  --n4m-blue: #2563EB;
}

/* =============================================
   BASE RESET & TYPOGRAPHY
   ============================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  font-family: 'Alexandria', 'Cairo', system-ui, -apple-system, sans-serif;
  background-color: var(--n4m-bg);
  color: var(--n4m-text);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--n4m-bg); }
::-webkit-scrollbar-thumb { background: var(--n4m-surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3F3F46; }

/* =============================================
   GLASSMORPHISM COMPONENTS
   ============================================= */
.glass-panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--n4m-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05), 0 1px 0 rgba(255,255,255,0.8) inset;
}

.glass-card {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--n4m-border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--n4m-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(0,0,0,0.06), 0 0 0 1px rgba(109,40,217,0.08);
}

/* =============================================
   N4M BRAND GRADIENTS
   ============================================= */
.n4m-gradient {
  background: linear-gradient(135deg, var(--n4m-purple) 0%, var(--n4m-purple-dark) 100%);
}

.n4m-gradient-text {
  background: linear-gradient(135deg, var(--n4m-purple-light) 0%, var(--n4m-purple-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.n4m-gradient-glow {
  box-shadow: 0 0 20px rgba(109, 40, 217, 0.25), 0 4px 15px rgba(91, 33, 182, 0.15);
}

/* =============================================
   NAVBAR
   ============================================= */
.navbar-glass {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--n4m-border);
  box-shadow: 0 2px 20px rgba(0,0,0,0.04);
}

/* Mobile Hamburger Menu */
.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  gap: 5px;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.2s;
  border: 1px solid var(--n4m-border);
}

.hamburger-btn:hover {
  background: rgba(249,115,22,0.1);
  border-color: rgba(249,115,22,0.3);
}

.hamburger-line {
  width: 20px;
  height: 2px;
  background: var(--n4m-text);
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hamburger-btn.open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.open .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.hamburger-btn.open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile Drawer */
.mobile-drawer {
  position: fixed;
  top: 0;
  right: -100%;
  width: min(300px, 85vw);
  height: 100dvh;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-left: 1px solid var(--n4m-border);
  z-index: 200;
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: 0;
  box-shadow: -8px 0 40px rgba(0,0,0,0.08);
}

.mobile-drawer.open {
  right: 0;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.drawer-nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--n4m-text-secondary);
  border-radius: 14px;
  margin: 2px 12px;
  transition: all 0.2s ease;
  position: relative;
  text-decoration: none;
}

.drawer-nav-link:hover, .drawer-nav-link.active-link {
  background: rgba(249,115,22,0.12);
  color: var(--n4m-text);
  border: 1px solid rgba(249,115,22,0.2);
}

.drawer-nav-link .link-icon {
  font-size: 1.3rem;
  width: 32px;
  text-align: center;
}

/* =============================================
   TOUCH TARGETS
   ============================================= */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* =============================================
   INTERACTIVE BUTTONS
   ============================================= */
button, a {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:active:not(:disabled), a:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--n4m-orange) 0%, var(--n4m-orange-dark) 100%);
  color: white;
  font-weight: 800;
  border-radius: 14px;
  padding: 12px 24px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(249,115,22,0.35);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(249,115,22,0.5);
  transform: translateY(-1px);
}

/* =============================================
   EXAM CHOICE BUTTONS
   ============================================= */
.btn-choice {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   ANIMATIONS
   ============================================= */

/* Shake on incorrect */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-6px); }
  30%, 60%, 90% { transform: translateX(6px); }
}
.animate-shake {
  animation: shake 0.45s cubic-bezier(.36,.07,.19,.97) both;
}

/* Pulse on correct */
@keyframes pulse-success {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  50% { transform: scale(1.015); box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.animate-pulse-success {
  animation: pulse-success 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}

/* Page transition */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.view-fade-in {
  animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Toast animations */
@keyframes slideIn {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes slideOut {
  from { transform: translateY(0) scale(1); opacity: 1; }
  to { transform: translateY(20px) scale(0.95); opacity: 0; }
}
.toast-enter { animation: slideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.toast-exit { animation: slideOut 0.25s cubic-bezier(0.4, 0, 1, 1) forwards; }

/* Combo pop */
@keyframes combo-pop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}
.animate-combo-pop {
  animation: combo-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Card entrance */
@keyframes cardEntrance {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.animate-card {
  animation: cardEntrance 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Orange glow pulse */
@keyframes orangePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249,115,22,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(249,115,22,0); }
}
.orange-pulse {
  animation: orangePulse 2s ease-in-out infinite;
}

/* =============================================
   PROGRESS BAR
   ============================================= */
.progress-bar-fill {
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--n4m-orange) 0%, var(--n4m-orange-dark) 100%);
}

/* =============================================
   STATS CARDS
   ============================================= */
.stat-card {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--n4m-border);
  border-radius: 18px;
  padding: 20px 16px;
  text-align: center;
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: rgba(249,115,22,0.25);
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-2px);
}

/* =============================================
   SETTINGS MODAL
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-container {
  width: 100%;
  max-width: 480px;
  margin: 16px;
  transform: scale(0.95) translateY(12px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .modal-container {
  transform: scale(1) translateY(0);
}

@media (max-width: 640px) {
  .modal-overlay { align-items: flex-end; }
  .modal-container {
    margin: 0;
    border-radius: 24px 24px 0 0 !important;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .modal-overlay.active .modal-container { transform: translateY(0); }
}

/* =============================================
   STREAK POPUP
   ============================================= */
.streak-popup {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-140px) scale(0.85);
  z-index: 300;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
  width: 90%;
  max-width: 320px;
}
.streak-popup.active {
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 1;
}
.streak-popup.broken {
  animation: streak-broken-shake 0.6s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes streak-broken-shake {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(0deg) scale(1); }
  15% { transform: translateX(-50%) translateY(0) rotate(-8deg) scale(0.98); }
  30% { transform: translateX(-50%) translateY(0) rotate(7deg) scale(0.96); }
  45% { transform: translateX(-50%) translateY(0) rotate(-5deg) scale(0.94); }
  60% { transform: translateX(-50%) translateY(0) rotate(3deg) scale(0.92); }
  75% { transform: translateX(-50%) translateY(0) rotate(-1deg) scale(0.9); }
}

/* =============================================
   SKELETON LOADING
   ============================================= */
.skeleton {
  background: linear-gradient(90deg,
    rgba(241, 243, 245, 0.6) 25%,
    rgba(228, 231, 235, 0.8) 50%,
    rgba(241, 243, 245, 0.6) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
}

@keyframes skeleton-wave {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =============================================
   LAST EXAM WIDGET
   ============================================= */
.last-exam-widget {
  background: linear-gradient(135deg,
    rgba(249,115,22,0.08) 0%,
    rgba(234,88,12,0.04) 100%
  );
  border: 1px solid rgba(249,115,22,0.2);
  border-radius: 24px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.last-exam-widget::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(249,115,22,0.15) 0%, transparent 70%);
  pointer-events: none;
}

/* =============================================
   ORANGE ACCENT HELPERS
   ============================================= */
.accent-orange-glow {
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.25);
}

.border-orange-subtle {
  border-color: rgba(249, 115, 22, 0.25);
}

/* =============================================
   ACHIEVEMENT BADGES
   ============================================= */
.achievement-card-unlocked {
  background: linear-gradient(135deg, rgba(109,40,217,0.06) 0%, rgba(255,255,255,0.95) 100%);
  border: 1px solid rgba(109,40,217,0.2);
}

.achievement-card-locked {
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.06);
  opacity: 0.55;
  filter: grayscale(0.8);
}

/* =============================================
   NAV LINK & ACTIVE STATES (SaaS Style)
   ============================================= */
.nav-link {
  border: 1px solid transparent;
  transition: all 0.15s ease-in-out;
}
.nav-link:hover {
  background: rgba(0, 0, 0, 0.04) !important;
  color: var(--n4m-text) !important;
}
.nav-active {
  background: rgba(249, 115, 22, 0.06) !important;
  color: var(--n4m-orange-dark) !important;
  border: 1px solid rgba(249, 115, 22, 0.16) !important;
}
.dark .nav-active {
  background: rgba(249, 115, 22, 0.1) !important;
  color: var(--n4m-orange) !important;
  border: 1px solid rgba(249, 115, 22, 0.3) !important;
}

/* =============================================
   MOBILE RESPONSIVE IMPROVEMENTS
   ============================================= */
@media (max-width: 640px) {
  /* Larger tap targets on mobile */
  .btn-choice {
    padding: 16px 14px;
    font-size: 0.9rem;
  }

  /* Tighter spacing */
  .mobile-tight {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Full-width cards on mobile */
  #module-list-container {
    grid-template-columns: 1fr !important;
  }

  /* Bigger stat numbers */
  .stat-number-mobile {
    font-size: 2rem;
  }

  /* Bottom safe area */
  footer {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}

/* =============================================
   FOOTER STYLING
   ============================================= */
.site-footer {
  border-top: 1px solid var(--n4m-border);
  background: rgba(255, 255, 255, 0.75);
}

/* =============================================
   TYPOGRAPHY RESPONSIVE
   ============================================= */
h1 {
  font-size: clamp(1.6rem, 4vw + 0.5rem, 2.8rem);
  line-height: 1.2;
}
h2 {
  font-size: clamp(1.2rem, 3vw + 0.4rem, 1.8rem);
  line-height: 1.3;
}
h3 {
  font-size: clamp(1rem, 2vw + 0.4rem, 1.4rem);
  line-height: 1.4;
}

/* =============================================
   TOGGLE BUTTONS (ON/OFF)
   ============================================= */
.toggle-on {
  background: linear-gradient(135deg, var(--n4m-orange) 0%, var(--n4m-orange-dark) 100%) !important;
  box-shadow: 0 2px 8px rgba(249,115,22,0.4);
}

.toggle-off {
  background: rgba(228, 231, 235, 0.8) !important;
  color: #71717A !important;
}

/* =============================================
   EXAM VIEW MOBILE IMPROVEMENTS
   ============================================= */
@media (max-width: 640px) {
  #exam-choices-container .btn-choice {
    min-height: 54px;
  }

  #btn-next-question {
    width: 100%;
    justify-content: center;
  }
}

/* =============================================
   CUSTOM RANGE INPUT
   ============================================= */
input[type="range"] {
  accent-color: var(--n4m-orange);
}

/* =============================================
   MISC UTILITIES
   ============================================= */


.divider-orange {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(249,115,22,0.3) 50%, transparent 100%);
}

/* Neon glows for stats */
.glow-orange { box-shadow: 0 0 15px rgba(249,115,22,0.2); }
.glow-emerald { box-shadow: 0 0 15px rgba(16,185,129,0.2); }
.glow-rose { box-shadow: 0 0 15px rgba(244,63,94,0.2); }
.glow-amber { box-shadow: 0 0 15px rgba(245,158,11,0.2); }

/* =============================================
   DARK THEME BRANDING & COMPONENT STYLING
   ============================================= */
.dark {
  --n4m-bg: #0E0E0F;
  --n4m-bg2: #18181B;
  --n4m-surface: #1C1C1E;
  --n4m-surface2: #252528;
  --n4m-border: rgba(109, 40, 217, 0.16);
  --n4m-border-hover: rgba(109, 40, 217, 0.45);
  --n4m-text: #F5F5F7;
  --n4m-text-secondary: #A1A1AA;
  --n4m-text-muted: #71717A;
}

.dark .glass-panel {
  background: rgba(28, 28, 30, 0.75);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255,255,255,0.05) inset;
}

.dark .glass-card {
  background: rgba(28, 28, 30, 0.45);
}

.dark .glass-card:hover {
  background: rgba(28, 28, 30, 0.85);
  box-shadow: 0 16px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(109,40,217,0.15);
}

.dark .navbar-glass {
  background: rgba(14, 14, 15, 0.8) !important;
}

.dark .mobile-drawer {
  background: rgba(20, 20, 22, 0.98);
}

.dark img[alt="N4M Logo"] {
  mix-blend-mode: screen;
  filter: invert(1);
}

.dark .nav-link:hover, .dark #btn-settings-toggle:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #FFFFFF !important;
}

.dark .site-footer {
  background: rgba(20, 20, 22, 0.4);
}

.dark .btn-choice {
  background: rgba(255, 255, 255, 0.03);
  color: #E4E4E7;
  border-color: rgba(109, 40, 217, 0.15);
}

.dark .btn-choice:hover {
  background: rgba(109, 40, 217, 0.1);
  border-color: rgba(109, 40, 217, 0.4);
}

.dark .btn-choice span.uppercase {
  background: rgba(109, 40, 217, 0.15);
  color: var(--n4m-purple-light);
  border-color: rgba(109, 40, 217, 0.2);
}

.dark .text-zinc-800 {
  color: #E4E4E7 !important;
}

.dark .text-zinc-700 {
  color: #D4D4D8 !important;
}

.dark .text-zinc-600 {
  color: #A1A1AA !important;
}

.dark .text-zinc-500 {
  color: #71717A !important;
}

.dark .bg-white {
  background-color: var(--n4m-surface) !important;
}

.dark .bg-zinc-50 {
  background-color: rgba(255, 255, 255, 0.02) !important;
  border-color: rgba(255, 255, 255, 0.05) !important;
}

.dark .bg-zinc-100 {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

.dark .hover\:bg-zinc-100:hover {
  background-color: rgba(255, 255, 255, 0.06) !important;
}

.dark .border-zinc-200 {
  border-color: rgba(255, 255, 255, 0.08) !important;
}

.dark .toggle-off {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--n4m-text-secondary) !important;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
