/**
 * Frontend Styles – WhatsApp Chat Integration
 *
 * Styles for the floating WhatsApp button rendered on the public website.
 * Lightweight, scoped, and fully responsive.
 *
 * @package WhatsApp_Chat_Integration
 * @version 1.0.0
 */

/* ────────────────────────────────────────────────────────────────────────────
   1. Box-sizing reset (scoped to plugin elements)
──────────────────────────────────────────────────────────────────────────── */
.waci-float-wrap *,
.waci-float-wrap *::before,
.waci-float-wrap *::after,
.waci-inline-btn,
.waci-inline-btn * {
  box-sizing: border-box;
}

/* ────────────────────────────────────────────────────────────────────────────
   2. Floating Wrapper
──────────────────────────────────────────────────────────────────────────── */
.waci-float-wrap {
  position: fixed;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Positions ── */
.waci-float-wrap.waci-pos-bottom-right {
  bottom: 28px;
  right: 28px;
  flex-direction: row-reverse;
}
.waci-float-wrap.waci-pos-bottom-left {
  bottom: 28px;
  left: 28px;
  flex-direction: row;
}
.waci-float-wrap.waci-pos-top-right {
  top: 28px;
  right: 28px;
  flex-direction: row-reverse;
  align-items: flex-start;
}
.waci-float-wrap.waci-pos-top-left {
  top: 28px;
  left: 28px;
  flex-direction: row;
  align-items: flex-start;
}

/* ────────────────────────────────────────────────────────────────────────────
   3. The Button
──────────────────────────────────────────────────────────────────────────── */
.waci-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: #25d366; /* overridden by inline style from PHP */
  color: #ffffff;
  text-decoration: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;

  /* Smooth hover transition */
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.25s ease;

  /* Drop shadow */
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
}

/* ── Pulse ring animation ── */
.waci-button::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  z-index: -1;
  animation: waciPulse 2.5s ease-out infinite;
}

@keyframes waciPulse {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }
  70% {
    transform: scale(1.6);
    opacity: 0;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* ── Hover state ── */
.waci-button:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 12px 30px rgba(37, 211, 102, 0.6);
}

/* ── Focus visible (keyboard navigation) ── */
.waci-button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(37, 211, 102, 0.4);
}

/* ── Active / pressed state ── */
.waci-button:active {
  transform: scale(0.96);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

/* ────────────────────────────────────────────────────────────────────────────
   4. WhatsApp Icon SVG
──────────────────────────────────────────────────────────────────────────── */
.waci-icon {
  display: block;
  fill: currentColor;
  flex-shrink: 0;
  pointer-events: none;
}

/* ────────────────────────────────────────────────────────────────────────────
   5. Button Sizes
──────────────────────────────────────────────────────────────────────────── */
/* Small: 48 × 48 px */
.waci-size-small .waci-button {
  width: 48px;
  height: 48px;
}
.waci-size-small .waci-icon {
  width: 26px;
  height: 26px;
}

/* Medium: 60 × 60 px (default) */
.waci-size-medium .waci-button {
  width: 60px;
  height: 60px;
}
.waci-size-medium .waci-icon {
  width: 32px;
  height: 32px;
}

/* Large: 72 × 72 px */
.waci-size-large .waci-button {
  width: 72px;
  height: 72px;
}
.waci-size-large .waci-icon {
  width: 40px;
  height: 40px;
}

/* ────────────────────────────────────────────────────────────────────────────
   6. Tooltip / Label
──────────────────────────────────────────────────────────────────────────── */
.waci-tooltip {
  background: #1f2937;
  color: #f9fafb;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Slide-in from side */
  transform: translateX(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

/* For left-side positions, slide in from the other direction */
.waci-float-wrap.waci-pos-bottom-left .waci-tooltip,
.waci-float-wrap.waci-pos-top-left .waci-tooltip {
  transform: translateX(-10px);
}

/* Show on hover */
.waci-float-wrap:hover .waci-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* ────────────────────────────────────────────────────────────────────────────
   7. Entrance Animation (applied via JS on DOMContentLoaded)
──────────────────────────────────────────────────────────────────────────── */
.waci-float-wrap.waci-enter {
  animation: waciEnter 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes waciEnter {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   8. Hidden Helper (set by JS based on device type)
──────────────────────────────────────────────────────────────────────────── */
.waci-float-wrap.waci-hidden {
  display: none !important;
}

/* ────────────────────────────────────────────────────────────────────────────
   9. Inline Button (shortcode output)
──────────────────────────────────────────────────────────────────────────── */
.waci-inline-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background-color: #25d366; /* overridden inline */
  color: #ffffff;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 50px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.35);
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  vertical-align: middle;
}
.waci-inline-btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.5);
  color: #ffffff;
  text-decoration: none;
}
.waci-inline-btn:active {
  transform: translateY(0);
  opacity: 1;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}
.waci-inline-btn:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(37, 211, 102, 0.4);
}

/* ────────────────────────────────────────────────────────────────────────────
   10. Accessibility: Respect reduced-motion preference
──────────────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .waci-button,
  .waci-button::after,
  .waci-tooltip,
  .waci-float-wrap.waci-enter,
  .waci-inline-btn {
    animation: none !important;
    transition: none !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   11. Responsive / Mobile adjustments
──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .waci-float-wrap.waci-pos-bottom-right {
    bottom: 16px;
    right: 16px;
  }
  .waci-float-wrap.waci-pos-bottom-left {
    bottom: 16px;
    left: 16px;
  }
  .waci-float-wrap.waci-pos-top-right {
    top: 16px;
    right: 16px;
  }
  .waci-float-wrap.waci-pos-top-left {
    top: 16px;
    left: 16px;
  }

  /* Slightly smaller on small screens unless explicitly set to large */
  .waci-size-large .waci-button {
    width: 62px;
    height: 62px;
  }
  .waci-size-large .waci-icon {
    width: 34px;
    height: 34px;
  }

  /* Hide tooltip on touch devices (no hover) */
  .waci-tooltip {
    display: none;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   12. High-contrast mode support
──────────────────────────────────────────────────────────────────────────── */
@media (forced-colors: active) {
  .waci-button {
    border: 2px solid ButtonText;
    forced-color-adjust: none;
  }
}
