
/* ========================================
   BOTÃO VOLTAR AO TOPO (Versão SVG)
   ======================================== */

.back-to-top {
  /* Posicionamento */
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 999;
  
  /* Tamanho e Forma */
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  padding: 0; /* Remove padding nativo */
  
  /* Cores */
  background: var(--accent, #38bdf8);
  color: #05080f; /* Cor da seta (escuro para contraste) */
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
  
  /* O SEGREDO DO ALINHAMENTO PERFEITO */
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* Comportamento */
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Garante que o ícone não tenha comportamento estranho */
.back-to-top svg {
  display: block;
  width: 24px;
  height: 24px;
  pointer-events: none; /* O clique vai no botão, não no ícone */
}

/* Estado visível */
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Hover */
.back-to-top:hover {
  background: var(--text-main, #fff); /* Fica branco no hover */
  color: var(--accent, #38bdf8);      /* Seta fica azul */
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.5);
}

/* Active (ao clicar) */
.back-to-top:active {
  transform: translateY(-3px) scale(1.05);
}

/* Animação de pulso */
.back-to-top::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  background: var(--accent, #38bdf8);
  opacity: 0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Ícone da seta */
.back-to-top-icon {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  animation: bounceArrow 1.5s ease-in-out infinite;
}

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

/* Tooltip */
.back-to-top-tooltip {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-right: 15px;
  background: var(--panel, #1e293b);
  color: var(--text, #f1f5f9);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border, #334155);
}

.back-to-top-tooltip::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: var(--panel, #1e293b);
}

.back-to-top:hover .back-to-top-tooltip {
  opacity: 1;
  visibility: visible;
  margin-right: 20px;
}

/* Contador de progresso (opcional) */
.back-to-top-progress {
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: conic-gradient(
    var(--accent, #38bdf8) var(--scroll-progress, 0%),
    transparent var(--scroll-progress, 0%)
  );
  opacity: 0.3;
  transition: --scroll-progress 0.1s linear;
}

/* Mobile */
@media (max-width: 768px) {
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
  }

  /* Esconder tooltip no mobile */
  .back-to-top-tooltip {
    display: none;
  }

  /* Ajustar posição se tiver botão de ajuda/chat */
  .back-to-top.with-help-button {
    bottom: 90px; /* Acima do botão de ajuda */
  }
}

@media (max-width: 480px) {
  .back-to-top {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    bottom: 15px;
    right: 15px;
  }
}

/* Variante com contador de scroll */
.back-to-top.with-counter {
  background: transparent;
  border: 3px solid var(--accent, #38bdf8);
  color: var(--accent, #38bdf8);
}

.back-to-top.with-counter:hover {
  background: var(--accent, #38bdf8);
  color: #000;
}

/* Posição alternativa (esquerda) */
.back-to-top.left {
  right: auto;
  left: 30px;
}

@media (max-width: 768px) {
  .back-to-top.left {
    left: 20px;
  }
}

/* Tema alternativo (quadrado) */
.back-to-top.square {
  border-radius: 12px;
}

.back-to-top.square::before {
  border-radius: 12px;
}

/* Animação de entrada suave */
@keyframes slideInFromBottom {
  from {
    opacity: 0;
    transform: translateY(100px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.back-to-top.visible {
  animation: slideInFromBottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus para acessibilidade */
.back-to-top:focus {
  outline: 3px solid var(--accent, #38bdf8);
  outline-offset: 3px;
}

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

/* Estado de loading (durante scroll) */
.back-to-top.scrolling {
  animation: spin 0.6s linear;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
