/* ── Reset scope ───────────────────────────── */
#wa-widget, #wa-widget * { box-sizing: border-box; margin: 0; padding: 0; }

/* ── CSS custom props (match Balansis palette) */
#wa-widget {
  --wa-green:    #25D366;
  --wa-green-dk: #128C7E;
  --wa-green-lt: #dcfce7;
  --primary:     #005C63;
  --primary-dk:  #004a50;
  --accent:      #B08A6E;
  --accent-lt:   #f5ede6;
  --ink:         #1A1B2E;
  --ink2:        #3D3D4F;
  --muted:       #888899;
  --border:      #E4DFD5;
  --bg-card:     #FFFFFF;
  --serif:       'Playfair Display', Georgia, serif;
  --sans:        'DM Sans', system-ui, sans-serif;
  --shadow-pop:  0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,92,99,0.12);
  --shadow-btn:  0 6px 24px rgba(37,211,102,0.40), 0 2px 8px rgba(0,0,0,0.12);

  font-family: var(--sans);
  position: fixed !important;
  bottom: 1.5rem !important;
  right: 28px !important;
  z-index: 9999 !important;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  isolation: isolate;
}

/* ── FAB trigger button ─────────────────────── */
#wa-widget #wa-fab {
  pointer-events: all;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--wa-green);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-btn);
  position: relative;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
              background 0.2s ease,
              box-shadow 0.2s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
#wa-widget #wa-fab:hover {
  transform: scale(1.10);
  background: var(--wa-green-dk);
  box-shadow: 0 8px 32px rgba(37,211,102,0.50), 0 2px 8px rgba(0,0,0,0.15);
}
#wa-widget #wa-fab.open {
  background: var(--primary);
  box-shadow: 0 6px 24px rgba(0,92,99,0.35), 0 2px 8px rgba(0,0,0,0.12);
}
#wa-widget #wa-fab svg { transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s; position: absolute; }
#wa-widget #wa-fab .icon-wa  { opacity: 1; transform: scale(1) rotate(0deg); }
#wa-widget #wa-fab .icon-cls { opacity: 0; transform: scale(0.5) rotate(-90deg); }
#wa-widget #wa-fab.open .icon-wa  { opacity: 0; transform: scale(0.5) rotate(90deg); }
#wa-widget #wa-fab.open .icon-cls { opacity: 1; transform: scale(1) rotate(0deg); }

/* ── Pulse ring ─────────────────────────────── */
#wa-widget #wa-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--wa-green);
  opacity: 0;
  animation: wa-pulse 2.8s ease-out 2s infinite;
}
#wa-widget #wa-fab.open::before { animation: none; opacity: 0; }
@keyframes wa-pulse {
  0%   { opacity: 0.7; transform: scale(1); }
  70%  { opacity: 0;   transform: scale(1.55); }
  100% { opacity: 0;   transform: scale(1.55); }
}

@media (prefers-reduced-motion: reduce) {
  #wa-widget #wa-fab::before { animation: none; }
  #wa-widget #wa-dot { animation: none; }
  #wa-widget .wa-bubble { animation: none; opacity: 1; transform: none; }
}

/* ── Notification dot ───────────────────────── */
#wa-widget #wa-dot {
  position: absolute;
  top: 1px; right: 1px;
  width: 14px; height: 14px;
  background: #EF4444;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 8px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;
  animation: wa-dot-bounce 1.2s 1.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
#wa-widget #wa-dot.hidden { transform: scale(0); opacity: 0; }
@keyframes wa-dot-bounce {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ── Label pill ─────────────────────────────── */
#wa-widget #wa-label-pill {
  pointer-events: none;
  position: absolute;
  right: 72px;
  bottom: 14px;
  background: var(--bg-card);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.3s, transform 0.3s;
}
#wa-widget:not(.panel-open) #wa-fab:hover ~ #wa-label-pill,
#wa-widget:not(.panel-open) #wa-fab:focus ~ #wa-label-pill {
  /* handled in JS for cross-browser reliability */
}

/* ── Popup panel ────────────────────────────── */
#wa-widget #wa-panel {
  pointer-events: none;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.32s cubic-bezier(0.22,1,0.36,1),
              transform 0.32s cubic-bezier(0.22,1,0.36,1);
  width: 320px;
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
#wa-widget #wa-panel.open {
  pointer-events: all;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Panel header ───────────────────────────── */
#wa-widget .wa-header {
  background: var(--primary);
  padding: 1.15rem 1.25rem 1.4rem;
  position: relative;
  overflow: hidden;
}
#wa-widget .wa-header::after {
  content: '';
  position: absolute;
  bottom: -22px; right: -18px;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}
#wa-widget .wa-header::before {
  content: '';
  position: absolute;
  top: -30px; left: -20px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  pointer-events: none;
}
#wa-widget .wa-brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  z-index: 1;
}
#wa-widget .wa-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
#wa-widget .wa-avatar-text {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
#wa-widget .wa-online-dot {
  position: absolute;
  bottom: 1px; right: 1px;
  width: 12px; height: 12px;
  background: var(--wa-green);
  border-radius: 50%;
  border: 2px solid var(--primary);
  animation: wa-blink 2.5s ease-in-out infinite;
}
@keyframes wa-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
#wa-widget .wa-brand-info { flex: 1; min-width: 0; }
#wa-widget .wa-brand-name {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
#wa-widget .wa-brand-role {
  font-size: 0.7rem;
  font-weight: 300;
  color: rgba(255,255,255,0.70);
  margin-top: 0.35rem;
  letter-spacing: 0.02em;
}
#wa-widget .wa-status-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.9rem;
  position: relative;
  z-index: 1;
}
#wa-widget .wa-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 100px;
  padding: 0.25rem 0.65rem;
  font-size: 0.67rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.03em;
}
#wa-widget .wa-status-dot-sm {
  width: 6px; height: 6px;
  background: var(--wa-green);
  border-radius: 50%;
  display: inline-block;
}

/* ── Panel body ─────────────────────────────── */
#wa-widget .wa-body {
  padding: 1.1rem 1.25rem 1.25rem;
}
#wa-widget .wa-bubble-wrap {
  margin-bottom: 1rem;
}
#wa-widget .wa-bubble-label {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
#wa-widget .wa-bubble {
  background: var(--accent-lt);
  border-radius: 12px 12px 12px 4px;
  padding: 0.75rem 0.95rem;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.6;
  position: relative;
  border: 1px solid rgba(176,138,110,0.18);
  animation: wa-bubble-in 0.4s 0.15s cubic-bezier(0.22,1,0.36,1) both;
}
#wa-widget #wa-panel:not(.open) .wa-bubble { animation: none; }
@keyframes wa-bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
#wa-widget .wa-bubble::after {
  content: '';
  position: absolute;
  bottom: 0.65rem; right: 0.75rem;
  width: 28px; height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 12'%3E%3Cpath d='M2 6 C8 2, 20 2, 26 6' stroke='%23B08A6E' stroke-width='1.5' fill='none' stroke-linecap='round' opacity='0.4'/%3E%3Ccircle cx='24' cy='6' r='1.5' fill='%23B08A6E' opacity='0.4'/%3E%3Ccircle cx='26.5' cy='4.5' r='1.5' fill='%23B08A6E' opacity='0.4'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* Quick message input */
#wa-widget .wa-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
#wa-widget .wa-input {
  flex: 1;
  background: #F8F7F4;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.83rem;
  font-family: var(--sans);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  min-width: 0;
}
#wa-widget .wa-input::placeholder { color: var(--muted); }
#wa-widget .wa-input:focus {
  border-color: var(--primary);
  background: #fff;
}

/* ── CTA button ─────────────────────────────── */
#wa-widget .wa-cta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.82rem 1.25rem;
  background: var(--wa-green);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--sans);
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(37,211,102,0.30);
}
#wa-widget .wa-cta:hover {
  background: var(--wa-green-dk);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37,211,102,0.38);
}
#wa-widget .wa-cta:active { transform: translateY(0); }
#wa-widget .wa-cta svg { flex-shrink: 0; }

/* ── Footer note ─────────────────────────────── */
#wa-widget .wa-footer {
  text-align: center;
  font-size: 0.67rem;
  color: var(--muted);
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}
#wa-widget .wa-footer svg { opacity: 0.55; }

/* ── Mobile adjustments ──────────────────────── */
@media (max-width: 480px) {
  #wa-widget { bottom: 20px; right: 16px; }
  #wa-widget #wa-panel  { width: calc(100vw - 32px); }
  #wa-widget #wa-fab    { width: 54px; height: 54px; }
}
