/* ═══════════════════════════════════════════════════════════
   EuroMóveis — Botão flutuante WhatsApp (Opção A)
   ═══════════════════════════════════════════════════════════ */

.em-wa-float {
  --emwa-color:    #25D366;
  --emwa-color-d:  #128C7E;
  --emwa-size:     58px;
  --emwa-offset:   22px;
  --emwa-z:        9998;

  position: fixed;
  bottom: var(--emwa-offset);
  z-index: var(--emwa-z);
  /* Container tem apenas o tamanho do botão. Tooltip é posicionado
     absolutamente para NÃO afectar o clamp do drag nem provocar
     saltos visuais ao trocar de hemisfério (--left/--right). */
  width: var(--emwa-size);
  height: var(--emwa-size);
  /* Container invisível clicável — o botão reactiva pointer-events.
     Evita bloquear cliques na área do tooltip quando escondido. */
  pointer-events: none;
}
/* Posicionamento inicial do container (antes do drag do utilizador) */
.em-wa-float--right { right: var(--emwa-offset); }
.em-wa-float--left  { left:  var(--emwa-offset); }

/* Botão principal */
.em-wa-float__btn {
  width: var(--emwa-size);
  height: var(--emwa-size);
  border-radius: 50%;
  background: var(--emwa-color);
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  cursor: grab;
  /* Re-activa clicks — container tem pointer-events:none. */
  pointer-events: auto;
  /* touch-action: none permite drag em todas as direções via Pointer Events
     sem interferir com scroll do browser. Tap/click continua a funcionar. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.em-wa-float__btn:hover,
.em-wa-float__btn:focus {
  transform: scale(1.1);
  box-shadow: 0 8px 22px rgba(37, 211, 102, 0.55), 0 4px 8px rgba(0, 0, 0, 0.2);
  background: var(--emwa-color);
  color: #fff !important;
  text-decoration: none !important;
}
/* Durante drag activo: cursor "a agarrar" + sem transições para fluidez */
.em-wa-float--dragging .em-wa-float__btn {
  cursor: grabbing;
  transition: none;
  transform: none;
}
.em-wa-float--dragging .em-wa-float__btn:hover {
  transform: none;
}
.em-wa-float__btn svg {
  width: 58%;
  height: 58%;
  display: block;
}

/* Pulse animation */
.em-wa-float--pulse .em-wa-float__btn::before,
.em-wa-float--pulse .em-wa-float__btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--emwa-color);
  opacity: 0.5;
  z-index: -1;
  animation: emWaPulse 2.4s cubic-bezier(0.25, 0.25, 0.35, 1) infinite;
  pointer-events: none;
}
.em-wa-float--pulse .em-wa-float__btn::after {
  animation-delay: 1.2s;
}
@keyframes emWaPulse {
  0%   { transform: scale(1);    opacity: 0.55; }
  100% { transform: scale(1.85); opacity: 0; }
}
/* Reduced motion — respeita user preference */
@media (prefers-reduced-motion: reduce) {
  .em-wa-float--pulse .em-wa-float__btn::before,
  .em-wa-float--pulse .em-wa-float__btn::after {
    animation: none;
  }
}

/* Tooltip — absolutamente posicionado relativo ao container (botão).
   Não afecta o tamanho do container nem o layout do botão. */
.em-wa-float__tip {
  position: absolute;
  top: 50%;
  background: #fff;
  color: #2a2622;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 260px;
}
/* Posição RIGHT: tooltip à ESQUERDA do botão, seta aponta para a DIREITA */
.em-wa-float--right .em-wa-float__tip {
  right: 100%;
  margin-right: 12px;
  transform: translate(8px, -50%);
}
.em-wa-float--right .em-wa-float__tip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  margin-top: -7px;
  border-left: 7px solid #fff;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
}
/* Posição LEFT: tooltip à DIREITA do botão, seta aponta para a ESQUERDA */
.em-wa-float--left .em-wa-float__tip {
  left: 100%;
  margin-left: 12px;
  transform: translate(-8px, -50%);
}
.em-wa-float--left .em-wa-float__tip::after {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  margin-top: -7px;
  border-right: 7px solid #fff;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
}

/* Mostrar tooltip: hover no botão (apenas dispositivos com rato), focus
   teclado, ou classe show-tip via JS. Em touch o :hover é "sticky" — evitamos.
   Usamos :has() no container porque este tem pointer-events:none. */
@media (hover: hover) {
  .em-wa-float:has(.em-wa-float__btn:hover) .em-wa-float__tip {
    opacity: 1;
    transform: translate(0, -50%);
    pointer-events: auto;
  }
}
.em-wa-float--show-tip .em-wa-float__tip,
.em-wa-float:has(.em-wa-float__btn:focus-visible) .em-wa-float__tip {
  opacity: 1;
  transform: translate(0, -50%);
  pointer-events: auto;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .em-wa-float {
    --emwa-size: 54px;
    --emwa-offset: 16px;
    /* Clear do Journal3 mobile bottom menu (Home/Account/Wishlist/Email/...).
       O tema expõe estas variáveis quando o menu está presente; fallback 0 quando
       não existe — mantém o offset original. Mesmo padrão que o scroll-top usa. */
    bottom: calc(var(--emwa-offset) + var(--bottom-menu-display, 0px) + var(--bottom-menu-margin, 0px));
  }
  .em-wa-float__tip {
    font-size: 12px;
    padding: 9px 13px;
    max-width: 190px;
  }
  /* Impede o browser de interpretar o toque como scroll/zoom → JS drag
     pode usar touchmove + preventDefault com fiabilidade. */
  .em-wa-float__btn {
    touch-action: none;
  }
}

/* ── Drag state (mobile) ── */
.em-wa-float--dragging {
  transition: none !important;
}
.em-wa-float--dragging .em-wa-float__btn {
  transform: scale(1.15);
  box-shadow: 0 10px 28px rgba(37, 211, 102, 0.6), 0 6px 12px rgba(0, 0, 0, 0.25);
  cursor: grabbing;
}
/* Esconder tooltip durante o drag — evita "fantasmas" visuais */
.em-wa-float--dragging .em-wa-float__tip {
  opacity: 0 !important;
}

/* ── Recolhido: está por cima de um formulário (ver o script do template, Gate 4 de 01/10) ── */
.em-wa-float { transition: opacity .2s ease; }
/* Só transparência: um deslocamento mudava a posição medida, e num toque marginal o botão alternava entre
   visível e escondido (medido no sofá a 360 px, 01/10). */
.em-wa-float--recolhido {
  opacity: 0 !important;
}
.em-wa-float--recolhido .em-wa-float__btn,
.em-wa-float--recolhido .em-wa-float__tip { pointer-events: none !important; visibility: hidden; }

/* ── Print / no-print ── */
@media print {
  .em-wa-float { display: none !important; }
}
