/**
 * ============================================================================
 * WHATSAPP CHAT WIDGET — STYLES
 * ============================================================================
 * Self-contained, namespaced under #ww-root to avoid clashing with host
 * page styles (important when embedded into WordPress/any CMS).
 * ============================================================================
 */

#ww-root {
  --ww-primary: #5BAB46;
  --ww-primary-dark: #4A9038;
  --ww-bg: #FFFFFF;
  --ww-accent: #E7F3E1;
  --ww-text: #1F2937;
  --ww-text-soft: #6B7280;
  --ww-radius-lg: 24px;
  --ww-radius-md: 20px;
  --ww-shadow-soft: 0 8px 24px rgba(31, 41, 55, 0.12), 0 2px 8px rgba(31, 41, 55, 0.08);
  --ww-shadow-fab: 0 6px 20px rgba(91, 171, 70, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15);
  --ww-font: "Google Sans", "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;

  all: initial;
  font-family: var(--ww-font);
  color: var(--ww-text);
  box-sizing: border-box;
}

#ww-root *,
#ww-root *::before,
#ww-root *::after {
  box-sizing: border-box;
  font-family: var(--ww-font);
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   FLOATING ACTION BUTTON (FAB)
   ========================================================================== */

/* Update your .ww-fab class to look like this */
.ww-fab {
  position: fixed !important; 
  bottom: 24px;
  right: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  
  /* Solid official WhatsApp Green */
  background-color: #25D366; 
  
  /* Clean shadow for the circular button */
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.5);
  
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 2147483000;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease;
  overflow: hidden;
  border: none !important;
  outline: none !important;
}

/* Strip out any focus rings causing that black outer line */
.ww-fab:focus,
.ww-fab:focus-visible {
  outline: none !important;
  border: none !important;
}

.ww-fab:hover {
  transform: scale(1.07) translateY(-2px);
  box-shadow: 0 10px 28px rgba(91, 171, 70, 0.55), 0 4px 10px rgba(0, 0, 0, 0.18);
}

.ww-fab:active {
  transform: scale(0.96);
}

/* Center all SVGs perfectly using Grid */
.ww-fab svg {
  /* Stacks both SVGs in the exact same cell, eliminating the need for absolute positioning */
  grid-area: 1 / 1; 
  width: 32px;
  height: 32px;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

/* Default state: Chat is visible, Close is hidden/shrunk */
.ww-fab .ww-icon-chat {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.ww-fab .ww-icon-close {
  opacity: 0;
  transform: scale(0.5) rotate(-45deg);
}

/* Open state: Chat shrinks/hides, Close expands/shows */
.ww-fab.is-open .ww-icon-chat {
  opacity: 0;
  transform: scale(0.5) rotate(45deg);
}

.ww-fab.is-open .ww-icon-close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Gentle pulse ring, triggered periodically via .ww-pulse class */

/* Gentle pulse ring, triggered periodically via .ww-pulse class */
.ww-fab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ww-primary);
  opacity: 0;
  pointer-events: none;
}

.ww-fab.ww-pulse::after {
  animation: ww-pulse-ring 1.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes ww-pulse-ring {
  0%   { opacity: 0.55; transform: scale(1); }
  100% { opacity: 0;    transform: scale(1.9); }
}

/* Ripple effect on click */
.ww-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transform: scale(0);
  animation: ww-ripple-anim 0.6s ease-out;
  pointer-events: none;
  z-index: 3;
}

@keyframes ww-ripple-anim {
  to {
    transform: scale(1);
    opacity: 0;
  }
}

/* Unread/notification dot (optional, quiet by default) */
.ww-fab-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #EF4444;
  border: 2px solid #fff;
  z-index: 4;
}

/* ==========================================================================
   CHAT PANEL
   ========================================================================== */

.ww-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--ww-bg);
  border-radius: var(--ww-radius-lg);
  box-shadow: var(--ww-shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147482999;

  /* Morph-in animation origin: bottom-right, mimicking the FAB */
  transform-origin: bottom right;
  transform: scale(0.35) translateY(30px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.26s ease;
}

.ww-panel.is-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 480px) {
  .ww-panel {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 96px;
    height: min(600px, calc(100vh - 120px));
  }
}

/* ---- Header ---- */

.ww-header {
  background: linear-gradient(135deg, var(--ww-primary-dark) 0%, var(--ww-primary) 100%);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}

.ww-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.ww-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ww-header-info {
  flex: 1;
  min-width: 0;
}

.ww-header-name {
  color: #fff;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ww-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 1px;
}

.ww-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.ww-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.ww-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  position: relative;
  overflow: hidden;
}

.ww-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.ww-icon-btn:active {
  transform: scale(0.9);
}

.ww-icon-btn svg {
  width: 18px;
  height: 18px;
}

.ww-icon-btn.ww-back-btn {
  opacity: 0;
  width: 0;
  margin-right: -8px;
  pointer-events: none;
  transition: opacity 0.2s ease, width 0.25s ease, margin 0.25s ease;
}

.ww-icon-btn.ww-back-btn.is-active {
  opacity: 1;
  width: 34px;
  margin-right: 0;
  pointer-events: auto;
}

/* ---- Body / conversation area ---- */

.ww-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    radial-gradient(circle at 20% 10%, rgba(220, 252, 231, 0.55) 0%, transparent 45%),
    #F7FBF8;
  scroll-behavior: smooth;
}

.ww-body::-webkit-scrollbar {
  width: 6px;
}
.ww-body::-webkit-scrollbar-thumb {
  background: rgba(91, 171, 70, 0.25);
  border-radius: 10px;
}
.ww-body::-webkit-scrollbar-track {
  background: transparent;
}

/* ---- Message bubbles ---- */

.ww-msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: ww-msg-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ww-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ww-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ww-primary-dark);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.ww-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ww-bubble {
  background: #fff;
  border-radius: var(--ww-radius-md);
  border-bottom-left-radius: 6px;
  padding: 11px 15px;
  font-size: 14.5px;
  line-height: 1.48;
  color: var(--ww-text);
  max-width: 78%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 1px 8px rgba(0,0,0,0.04);
}

/* Typing indicator */
.ww-typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}

.ww-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9CA3AF;
  animation: ww-typing-bounce 1.1s infinite ease-in-out;
}

.ww-typing span:nth-child(2) { animation-delay: 0.15s; }
.ww-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ww-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Quick reply options ---- */

.ww-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: 34px;
  animation: ww-msg-in 0.34s cubic-bezier(0.16, 1, 0.3, 1);
}

.ww-option-btn {
  position: relative;
  overflow: hidden;
  text-align: left;
  background: var(--ww-accent);
  border: 1.5px solid transparent;
  color: var(--ww-primary-dark);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.ww-option-btn:hover {
  background: #cff5da;
  border-color: rgba(91, 171, 70, 0.35);
  transform: translateY(-1px);
}

.ww-option-btn:active {
  transform: translateY(0) scale(0.98);
}

.ww-option-btn.ww-option-cta {
  background: linear-gradient(135deg, var(--ww-primary) 0%, var(--ww-primary-dark) 100%);
  color: #fff;
  text-align: center;
  box-shadow: 0 4px 14px rgba(91, 171, 70, 0.35);
}

.ww-option-btn.ww-option-cta:hover {
  box-shadow: 0 6px 18px rgba(91, 171, 70, 0.45);
}

.ww-option-btn .ww-ripple {
  background: rgba(255, 255, 255, 0.5);
}

/* Selected / disabled state once a choice has been made in a step */
.ww-option-btn.is-picked {
  outline: 2px solid var(--ww-primary-dark);
}

.ww-option-btn[disabled] {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

/* ---- Footer ---- */

.ww-footer {
  flex-shrink: 0;
  padding: 10px 16px 14px;
  text-align: center;
  border-top: 1px solid rgba(31, 41, 55, 0.06);
  background: #fff;
}

.ww-restart-btn {
  background: none;
  border: none;
  color: var(--ww-text-soft);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  transition: background 0.2s ease, color 0.2s ease;
}

.ww-restart-btn:hover {
  background: var(--ww-accent);
  color: var(--ww-primary-dark);
}

.ww-restart-btn svg {
  width: 13px;
  height: 13px;
}

.ww-footer-brand {
  margin-top: 6px;
  font-size: 10.5px;
  color: #B0B7C0;
  letter-spacing: 0.2px;
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  #ww-root * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   FOCUS VISIBILITY (accessibility)
   ========================================================================== */

#ww-root button:focus-visible {
  outline: 2px solid var(--ww-primary-dark);
  outline-offset: 2px;
}