/* WHATSAPP WIDGET */
.whatsapp-widget {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none; /* Let clicks pass through widget container */
}

@media (min-width: 1024px) {
  .whatsapp-widget {
    bottom: 24px;
    right: 24px;
  }
}

/* Bubble Wrapper */
.whatsapp-bubble-wrapper {
  position: relative;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  max-width: 260px;
  pointer-events: auto; /* Enable clicks */
  
  /* Hidden state */
  opacity: 0;
  transform: translateY(10px);
  visibility: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
}

/* Bubble Inner Link */
.whatsapp-bubble {
  display: block;
  padding: 12px 36px 12px 16px; /* Space for close button */
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  border-radius: inherit;
  outline-offset: -2px;
}

@media (min-width: 768px) {
  .whatsapp-bubble-wrapper {
    max-width: 280px;
  }
}

/* Active state */
.whatsapp-bubble-wrapper.is-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .whatsapp-bubble {
    transform: none;
    transition: opacity 0.2s ease, visibility 0.2s;
  }
  .whatsapp-bubble-wrapper.is-visible {
    transform: none;
  }
}

/* Close button inside bubble */
.whatsapp-bubble__close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  padding: 4px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.whatsapp-bubble__close:hover,
.whatsapp-bubble__close:focus-visible {
  color: var(--color-text);
  background-color: rgba(0,0,0,0.05);
}

.whatsapp-bubble__close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* Button */
.whatsapp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background-color: #25D366;
  color: #FFFFFF;
  border-radius: 50%;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.3);
  pointer-events: auto; /* Enable clicks */
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

@media (min-width: 1024px) {
  .whatsapp-btn {
    width: 60px;
    height: 60px;
  }
}

.whatsapp-btn:hover,
.whatsapp-btn:focus-visible {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.4);
  background-color: #20BA5A;
}

.whatsapp-btn:focus-visible {
  outline: 3px solid var(--color-surface);
  outline-offset: 2px;
}

.whatsapp-btn svg {
  width: 32px;
  height: 32px;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .whatsapp-btn {
    transition: background-color 0.2s ease;
  }
  .whatsapp-btn:hover,
  .whatsapp-btn:focus-visible {
    transform: none;
  }
}

.whatsapp-widget.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}
.whatsapp-widget { transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease; }

/* 44x44px touch target */
.whatsapp-bubble__close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}
