/* ===== ANIMATIONS POUR LE BOUTON RETOUR EN HAUT ===== */

/* Masquage immédiat du bouton au chargement de la page */
#myBtn {
  display: none;
  opacity: 0;
  visibility: hidden;
}

/* Styles de base améliorés */
#myBtn.top-btn-enhanced {
  display: none; /* Masqué par défaut */
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
  border: none;
  outline: none;
  background: linear-gradient(135deg, rgba(60, 96, 145, 0.9), rgba(60, 96, 145, 0.8));
  color: white;
  cursor: pointer;
  padding: 18px;
  border-radius: 50%;
  font-size: 1.25rem;
  width: 65px;
  height: 65px;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 4px 20px rgba(60, 96, 145, 0.3);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  pointer-events: none;
}

/* État visible */
#myBtn.top-btn-enhanced.show {
  display: flex !important; /* Afficher en flex quand visible - IMPORTANT pour surcharger le masquage */
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Animation d'entrée */
#myBtn.top-btn-enhanced.fade-in {
  animation: topBtnFadeIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Animation de sortie */
#myBtn.top-btn-enhanced.fade-out {
  animation: topBtnFadeOut 0.4s cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards;
}

/* Effet de survol */
#myBtn.top-btn-enhanced.hover-effect {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 30px rgba(60, 96, 145, 0.4);
  background: linear-gradient(135deg, rgba(60, 96, 145, 1), rgba(60, 96, 145, 0.9));
}

/* Effet de clic */
#myBtn.top-btn-enhanced.click-effect {
  animation: topBtnClick 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Animation de pulsation subtile */
#myBtn.top-btn-enhanced::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(60, 96, 145, 0.3), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

#myBtn.top-btn-enhanced:hover::before {
  opacity: 1;
  animation: topBtnPulse 2s infinite;
}

/* Icône avec animation */
#myBtn.top-btn-enhanced i {
  transition: transform 0.3s ease;
}

#myBtn.top-btn-enhanced:hover i {
  transform: translateY(-2px);
}

#myBtn.top-btn-enhanced.click-effect i {
  animation: topBtnIconBounce 0.3s ease;
}

/* ===== KEYFRAMES ===== */

@keyframes topBtnFadeIn {
  0% {
    opacity: 0;
    transform: translateY(15px) scale(0.9);
  }
  50% {
    opacity: 0.8;
    transform: translateY(5px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes topBtnFadeOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  50% {
    opacity: 0.5;
    transform: translateY(10px) scale(0.95);
  }
  100% {
    opacity: 0;
    transform: translateY(15px) scale(0.9);
  }
}

@keyframes topBtnClick {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes topBtnPulse {
  0% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.1;
  }
  100% {
    transform: scale(1);
    opacity: 0.3;
  }
}

@keyframes topBtnIconBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  #myBtn.top-btn-enhanced {
    display: none !important;
  }
  
  #myBtn.top-btn-enhanced.show {
    display: none !important; /* Forcer le masquage sur mobile même si show */
  }
}

@media (max-width: 1024px) {
  #myBtn.top-btn-enhanced {
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    padding: 16px;
    font-size: 1.125rem;
  }
}

/* ===== ACCESSIBILITÉ ===== */

/* Focus visible pour l'accessibilité */
#myBtn.top-btn-enhanced:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* Réduction des animations pour les utilisateurs qui les préfèrent */
@media (prefers-reduced-motion: reduce) {
  #myBtn.top-btn-enhanced,
  #myBtn.top-btn-enhanced::before,
  #myBtn.top-btn-enhanced i {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== THÈME SOMBRE (si applicable) ===== */

@media (prefers-color-scheme: dark) {
  #myBtn.top-btn-enhanced {
    background: linear-gradient(135deg, rgba(60, 96, 145, 0.95), rgba(60, 96, 145, 0.85));
    box-shadow: 0 4px 20px rgba(60, 96, 145, 0.4);
  }
  
  #myBtn.top-btn-enhanced.hover-effect {
    box-shadow: 0 8px 30px rgba(60, 96, 145, 0.5);
  }
}
