/* ============================================
   MEGEDUCATIONS - SAFE HOMEPAGE ANIMATIONS
   Compatible with Bootstrap 5.3
   ============================================ */

/* ----------------------------------------
   1. SCROLL FADE-IN ANIMATION
   ---------------------------------------- */
.animate-fade-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
  will-change: opacity, transform;
}

.animate-fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ----------------------------------------
   2. TEST CARD ENHANCEMENTS (Your existing .test-card)
   ---------------------------------------- */
/* Keep your existing hover, add entrance animation */
.test-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.test-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.15) !important;
}

/* Staggered entrance for cards */
.test-card.entrance {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.test-card.entrance.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ----------------------------------------
   3. BUTTON MICRO-INTERACTIONS
   ---------------------------------------- */
.btn {
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

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

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4);
  transform: translateY(-1px);
}

.btn-success:hover {
  box-shadow: 0 4px 12px rgba(25, 135, 84, 0.4);
  transform: translateY(-1px);
}

/* ----------------------------------------
   4. SEARCH BAR FOCUS ANIMATION
   ---------------------------------------- */
.form-control-lg {
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.form-control-lg:focus {
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25), 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

/* ----------------------------------------
   5. NAVIGATION LINKS
   ---------------------------------------- */
.nav-link {
  position: relative;
  transition: color 0.2s ease;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width 0.3s ease, left 0.3s ease;
}

.nav-link:hover::after {
  width: 100%;
  left: 0;
}

/* ----------------------------------------
   6. BADGE PULSE (for premium/free badges)
   ---------------------------------------- */
.badge {
  transition: transform 0.2s ease;
}

.badge:hover {
  transform: scale(1.05);
}

/* ----------------------------------------
   7. PAGINATION ENHANCEMENTS
   ---------------------------------------- */
.page-link {
  transition: all 0.2s ease;
}

.page-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* ----------------------------------------
   8. NO RESULTS ICON ANIMATION
   ---------------------------------------- */
.fa-search.fa-5x {
  animation: gentle-bounce 2s infinite;
}

@keyframes gentle-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ----------------------------------------
   9. ACCESSIBILITY: Respect reduced motion
   ---------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .animate-fade-up,
  .test-card,
  .btn,
  .form-control-lg,
  .nav-link,
  .page-link {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
  
  .animate-fade-up,
  .test-card.entrance {
    opacity: 1;
    transform: none;
  }
}

/* ----------------------------------------
   10. MOBILE OPTIMIZATIONS
   ---------------------------------------- */
@media (max-width: 768px) {
  .test-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1) !important;
  }
  
  .btn:hover {
    transform: none;
  }
}

/* ============================================
   WHATSAPP FLOATING BUTTON
   ============================================ */

.whatsapp-float {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background-color: #25D366;
  color: white;
  border-radius: 50%;
  text-align: center;
  font-size: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.3s ease;
  animation: whatsapp-pulse 2s infinite;
}

.whatsapp-float:hover {
  background-color: #128C7E;
  transform: scale(1.1) translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  color: white;
  text-decoration: none;
}

.whatsapp-float i {
  transition: transform 0.3s ease;
}

.whatsapp-float:hover i {
  transform: rotate(15deg);
}

/* Pulse animation to attract attention */
@keyframes whatsapp-pulse {
  0% {
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
  }
  50% {
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.7);
  }
  100% {
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
  }
}

/* Tooltip on hover */
.whatsapp-float::before {
  content: 'Need Help? Chat with us!';
  position: absolute;
  right: 70px;
  background: #333;
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  transform: translateX(10px);
}

.whatsapp-float:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .whatsapp-float {
    width: 50px;
    height: 50px;
    font-size: 24px;
    bottom: 20px;
    right: 20px;
  }
  
  .whatsapp-float::before {
    display: none; /* Hide tooltip on mobile */
  }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .whatsapp-float {
    animation: none;
  }
}

/* ============================================
   HERO SECTION STYLES
   ============================================ */

.hero-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 60px 0;
  margin-bottom: 30px;
  border-radius: 15px;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.1;
}

.hero-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  padding: 8px 20px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 15px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.hero-subtitle {
  font-size: 1.2rem;
  opacity: 0.95;
  margin-bottom: 25px;
  line-height: 1.6;
}

.hero-features {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 30px;
  justify-content: center;
}

.hero-feature-item {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 10px 20px;
  border-radius: 25px;
  font-size: 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.hero-feature-item:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.hero-feature-item i {
  margin-right: 8px;
  color: #FFD700;
}

.hero-cta {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-btn-primary {
  background: white;
  color: #764ba2;
  padding: 12px 30px;
  border-radius: 50px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.hero-btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
  color: #764ba2;
}

.hero-btn-secondary {
  background: transparent;
  color: white;
  padding: 12px 30px;
  border-radius: 50px;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid rgba(255, 255, 255, 0.5);
  transition: all 0.3s ease;
}

.hero-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-color: white;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .hero-section {
    padding: 40px 20px;
  }
  
  .hero-title {
    font-size: 1.8rem;
  }
  
  .hero-subtitle {
    font-size: 1rem;
  }
  
  .hero-features {
    gap: 10px;
  }
  
  .hero-feature-item {
    font-size: 0.85rem;
    padding: 8px 15px;
  }
}

/* ============================================
   HERO SECTION - Compact
   ============================================ */

.hero-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 10px;
  margin-bottom: 20px;
  position: relative;
}

.hero-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.hero-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.hero-subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 10px;
}

.hero-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 15px;
}

.hero-feature-item {
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 15px;
  font-size: 0.8rem;
}

.hero-feature-item i {
  color: #FFD700;
  margin-right: 4px;
  font-size: 0.75rem;
}

.hero-btn-primary {
  background: white;
  color: #764ba2;
  padding: 8px 20px;
  border-radius: 25px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s ease;
}

.hero-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  color: #764ba2;
}

@media (max-width: 768px) {
  .hero-title { font-size: 1.2rem; }
  .hero-subtitle { font-size: 0.85rem; }
  .hero-feature-item { font-size: 0.75rem; padding: 3px 8px; }
}

/* Fix hero section clickability - CRITICAL */
.hero-section {
  position: relative;
  z-index: 1;
}

.hero-section::before {
  pointer-events: none !important;
  z-index: -1;
}

.hero-section .container {
  position: relative;
  z-index: 2;
}

.hero-btn-primary {
  position: relative;
  z-index: 10;
  display: inline-block;
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* ============================================
   MOBILE RESPONSIVE - QUESTION NAVIGATION
   Added: Collapsible question panel for mobile
   ============================================ */

/* Question Navigation Card Styles */
.question-nav-card {
    transition: all 0.3s ease;
}

/* Mobile Toggle Button */
#questionToggleBtn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: transform 0.3s ease;
}

#questionToggleBtn[aria-expanded="true"] i {
    transform: rotate(180deg);
}

/* Question Grid Layout - Mobile Optimized */
.question-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Mobile: Grid layout with 5 columns */
@media (max-width: 991.98px) {
    .question-grid {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        max-height: 50vh;
        overflow-y: auto;
        padding-right: 4px;
    }
    
    .question-grid-item {
        margin-bottom: 0 !important;
    }
    
    .question-nav-btn {
        min-height: 44px; /* Touch-friendly */
        min-width: 44px;
        padding: 8px 4px;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
    }
    
    .question-nav-btn small {
        display: flex;
        flex-direction: column;
        align-items: center;
        line-height: 1.2;
    }
    
    /* Icons in buttons */
    .question-nav-btn .answered-icon,
    .question-nav-btn .review-icon {
        font-size: 0.7rem;
        margin-bottom: 2px;
    }
    
    .question-nav-btn .review-icon {
        color: #ffc107;
    }
    
    /* Collapsible body styling */
    .question-nav-body {
        max-height: 60vh !important;
        overflow-y: auto;
    }
    
    /* Smooth collapse animation */
    #questionNavCollapse.collapsing {
        transition: height 0.35s ease;
    }
    
    /* Ensure collapse is hidden by default on mobile */
    #questionNavCollapse:not(.show) {
        display: none;
    }
    
    /* When expanded, show as block */
    #questionNavCollapse.show {
        display: block;
    }
}

/* Desktop: Keep original list layout */
@media (min-width: 992px) {
    .question-grid {
        display: flex;
        flex-direction: column;
    }
    
    .question-nav-btn {
        min-height: 36px;
    }
    
    /* Ensure collapse is always visible on desktop */
    #questionNavCollapse {
        display: block !important;
    }
    
    #questionToggleBtn {
        display: none !important;
    }
}

/* Touch-friendly improvements for mobile */
@media (max-width: 768px) {
    /* Larger touch targets for all buttons */
    .btn-lg {
        min-height: 48px;
        font-size: 1rem;
    }
    
    /* Option labels more touch-friendly */
    .list-group-item.option {
        min-height: 48px;
        display: flex;
        align-items: center;
        padding: 12px 16px;
    }
    
    .form-check-input {
        width: 1.3em;
        height: 1.3em;
        margin-right: 12px;
    }
    
    /* Timer card more prominent */
    #timerCard .card-body {
        padding: 12px;
    }
    
    #timerCard h5 {
        font-size: 1.1rem;
    }
    
    /* Progress bar taller on mobile */
    .progress {
        height: 36px !important;
    }
    
    .progress-bar {
        font-size: 1rem;
        font-weight: 600;
    }
    
    /* Question text larger for readability */
    .question-box h3 {
        font-size: 1.25rem;
        line-height: 1.5;
    }
    
    /* Better spacing for action buttons */
    #skipBtn, #submitBtn {
        flex: 1;
        min-width: 140px;
    }
    
    /* Submit test button full width on small screens */
    .btn-danger.btn-lg {
        width: 100%;
        max-width: 400px;
    }
}

/* Extra small devices */
@media (max-width: 575.98px) {
    .question-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
    }
    
    .question-nav-btn {
        min-height: 40px;
        font-size: 0.8rem;
        padding: 6px 2px;
    }
    
    /* Stack action buttons vertically on very small screens */
    .d-flex.justify-content-between.flex-wrap.gap-2 {
        flex-direction: column;
        width: 100%;
    }
    
    #skipBtn, #submitBtn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .form-check-inline {
        margin: 8px 0;
        text-align: center;
    }
}

/* Animation for review flag */
.review-flag-pulse {
    animation: flagPulse 0.5s ease;
}

@keyframes flagPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Scrollbar styling for question grid */
.question-grid::-webkit-scrollbar {
    width: 6px;
}

.question-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.question-grid::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.question-grid::-webkit-scrollbar-thumb:hover {
    background: #555;
}
