/**
 * Floating WhatsApp button — all pages
 */
.cf-wa-float {
  position: fixed;
  z-index: 99990;
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  /* Default: near viewport edge; desktop overrides below to sit beside centered content */
  inset-inline-end: max(1rem, env(safe-area-inset-end, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #2fe066 0%, #25d366 40%, #1da851 100%);
  color: #fff;
  box-shadow:
    0 4px 18px rgba(37, 211, 102, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.2);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: cf-wa-shake 2.4s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}

.cf-wa-float svg {
  width: 1.85rem;
  height: 1.85rem;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.cf-wa-float:hover {
  animation-play-state: paused;
  transform: scale(1.08);
  box-shadow:
    0 8px 28px rgba(37, 211, 102, 0.55),
    0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.cf-wa-float:focus-visible {
  outline: 3px solid rgba(37, 211, 102, 0.65);
  outline-offset: 3px;
}

@keyframes cf-wa-shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  10% {
    transform: translate3d(-1px, 0, 0) rotate(-6deg);
  }
  20% {
    transform: translate3d(1px, 0, 0) rotate(6deg);
  }
  30% {
    transform: translate3d(-2px, 1px, 0) rotate(-5deg);
  }
  40% {
    transform: translate3d(2px, -1px, 0) rotate(5deg);
  }
  50% {
    transform: translate3d(-1px, -1px, 0) rotate(-4deg);
  }
  60% {
    transform: translate3d(1px, 1px, 0) rotate(4deg);
  }
  70% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  85% {
    transform: translate3d(0, -2px, 0) rotate(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cf-wa-float {
    animation: none;
  }
}

/* Desktop / tablet: align with max-width content column (~56rem) so the button sits next to text, not the far screen edge */
@media (min-width: 769px) {
  .cf-wa-float {
    inset-inline-end: max(1rem, calc((100vw - 56rem) / 2 + 0.75rem));
  }
}

/* Sit above fixed bottom nav on mobile (dashboard / history) */
@media (max-width: 768px) {
  body.has-bottom-nav .cf-wa-float {
    bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
  }
}
