/* ===============================================
   BOTÃO "VOLTAR AO TOPO" - TESTFUSION
   Design System: Azul-ciano (#00eaff) com efeito neon
   =============================================== */

/* Variáveis do botão */
:root {
  --back-to-top-primary: #00eaff;
  --back-to-top-secondary: #00bcd4;
  --back-to-top-icon: #0a0a14;
  --back-to-top-size: 50px;
  --back-to-top-shadow: 0 0 10px rgba(0, 234, 255, 0.4);
  --back-to-top-shadow-hover: 0 0 20px rgba(0, 234, 255, 0.6);
  --back-to-top-transition: all 0.4s ease;
  --back-to-top-border-radius: 50%;
}

/* ===============================================
   ESTILO BASE DO BOTÃO
   =============================================== */

.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: var(--back-to-top-size);
  height: var(--back-to-top-size);
  background: var(--back-to-top-primary);
  border: none;
  border-radius: var(--back-to-top-border-radius);
  color: var(--back-to-top-icon);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  z-index: 999;
  transition: var(--back-to-top-transition);
  box-shadow: var(--back-to-top-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  
  /* Estado inicial: invisível */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.8);
}

/* ===============================================
   ESTADO VISÍVEL
   =============================================== */

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ===============================================
   EFEITOS DE HOVER
   =============================================== */

.back-to-top:hover {
  background: linear-gradient(90deg, var(--back-to-top-secondary), var(--back-to-top-primary));
  transform: translateY(-2px) scale(1.1);
  box-shadow: var(--back-to-top-shadow-hover);
}

.back-to-top:active {
  transform: translateY(0) scale(1.05);
  transition: var(--back-to-top-transition) 0.1s;
}

/* ===============================================
   ÍCONE DO BOTÃO
   =============================================== */

.back-to-top svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s ease;
}

.back-to-top:hover svg {
  transform: translateY(-2px);
}

/* ===============================================
   ANIMAÇÃO DE PULSE SUTIL
   =============================================== */

.back-to-top.visible {
  animation: subtlePulse 3s ease-in-out infinite;
}

@keyframes subtlePulse {
  0%, 100% {
    box-shadow: var(--back-to-top-shadow);
  }
  50% {
    box-shadow: 0 0 15px rgba(0, 234, 255, 0.5);
  }
}

/* ===============================================
   ANIMAÇÃO DE ENTRADA
   =============================================== */

.back-to-top.entering {
  animation: backToTopEnter 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes backToTopEnter {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.6) rotate(180deg);
  }
  50% {
    opacity: 0.8;
    transform: translateY(-5px) scale(1.1) rotate(90deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

/* ===============================================
   ANIMAÇÃO DE SAÍDA
   =============================================== */

.back-to-top.leaving {
  animation: backToTopLeave 0.4s ease-in-out forwards;
}

@keyframes backToTopLeave {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
  }
}

/* ===============================================
   RESPONSIVIDADE
   =============================================== */

@media screen and (max-width: 768px) {
  .back-to-top {
    bottom: 24px;
    right: 24px;
    width: 46px;
    height: 46px;
  }
  
  .back-to-top svg {
    width: 22px;
    height: 22px;
  }
}

@media screen and (max-width: 480px) {
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
  }
  
  .back-to-top svg {
    width: 20px;
    height: 20px;
  }
}

/* ===============================================
   INTERAÇÃO COM TOQUE (Mobile)
   =============================================== */

@media (hover: none) and (pointer: coarse) {
  .back-to-top:active {
    background: linear-gradient(90deg, var(--back-to-top-secondary), var(--back-to-top-primary));
    transform: scale(0.95);
  }
}

/* ===============================================
   ACESSIBILIDADE
   =============================================== */

.back-to-top:focus {
  outline: 2px solid var(--back-to-top-primary);
  outline-offset: 4px;
}

.back-to-top:focus:not(:focus-visible) {
  outline: none;
}

/* Para usuários que preferem animações reduzidas */
@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }
  
  .back-to-top.entering,
  .back-to-top.leaving {
    animation: none;
  }
  
  .back-to-top.visible {
    animation: none;
  }
  
  .back-to-top:hover {
    transform: none;
  }
}

/* ===============================================
   MODO ESCURO APRIMORADO
   =============================================== */

@media (prefers-color-scheme: dark) {
  .back-to-top {
    box-shadow: 
      var(--back-to-top-shadow),
      0 4px 15px rgba(0, 0, 0, 0.3);
  }
  
  .back-to-top:hover {
    box-shadow: 
      var(--back-to-top-shadow-hover),
      0 6px 20px rgba(0, 0, 0, 0.4);
  }
}

/* ===============================================
   INTEGRAÇÃO COM SCROLL SUAVE
   =============================================== */

.back-to-top.scrolling {
  pointer-events: none;
  opacity: 0.7;
}

.back-to-top.scrolling svg {
  animation: spinUp 0.6s ease-in-out;
}

@keyframes spinUp {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.1);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

/* ===============================================
   TOOLTIP PERSONALIZADO (Opcional)
   =============================================== */

.back-to-top::before {
  content: attr(title);
  position: absolute;
  bottom: 120%;
  right: 50%;
  transform: translateX(50%);
  background: rgba(10, 10, 20, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1001;
}

.back-to-top::after {
  content: '';
  position: absolute;
  bottom: 110%;
  right: 50%;
  transform: translateX(50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid rgba(10, 10, 20, 0.9);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
}

.back-to-top:hover::before,
.back-to-top:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Remove tooltip em dispositivos móveis */
@media screen and (max-width: 768px) {
  .back-to-top::before,
  .back-to-top::after {
    display: none;
  }
}