/* WhatsApp Chat Widget — styles
 * Namespaced under .wa-* so the widget cannot collide with host-page styles.
 * The palette is exposed as custom properties on `.wa-widget` for theming.
 */

.wa-widget,
.wa-widget *,
.wa-widget *::before,
.wa-widget *::after { box-sizing: border-box; }

.wa-widget {
  --wa-green:        #25D366;
  --wa-green-hover:  #1ebe5d;
  --wa-green-dark:   #128C7E;
  --wa-bg:           #ffffff;
  --wa-text:         #111b21;
  --wa-muted:        #667781;
  --wa-bubble-in:    #ffffff;
  --wa-bubble-out:   #d9fdd3;
  --wa-composer-bg:  #f0f2f5;
  --wa-border:       #e9edef;
  --wa-shadow:       0 12px 48px rgba(11, 20, 26, 0.18);
  --wa-radius:       16px;
  --wa-z:            2147483000;

  position: fixed; inset: 0;
  pointer-events: none;
  z-index: var(--wa-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                "Helvetica Neue", Arial, sans-serif;
  color: var(--wa-text);
}

/* ────────────────────────────── Launcher ───────────────────────────── */

.wa-button {
  pointer-events: auto;
  position: absolute;
  right: 20px; bottom: 20px;
  width: 60px; height: 60px;
  border: none; border-radius: 50%;
  background: var(--wa-green); color: #fff;
  cursor: grab;
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45),
              0 2px 6px  rgba(0, 0, 0, 0.12);
  transition:
    transform 220ms cubic-bezier(.2, .9, .3, 1.2),
    box-shadow 220ms ease,
    background-color 200ms ease;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  will-change: transform, left, top;
}
.wa-button:hover {
  transform: scale(1.08);
  background: var(--wa-green-hover);
  box-shadow: 0 10px 28px rgba(37, 211, 102, 0.55),
              0 4px 10px  rgba(0, 0, 0, 0.14);
}
.wa-button:active { transform: scale(0.94); }
.wa-button.wa-dragging { cursor: grabbing; transition: none; }
.wa-button:focus-visible {
  outline: 3px solid #fff; outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(37, 211, 102, 0.55);
}
.wa-button > svg { width: 32px; height: 32px; }

.wa-button::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55);
  animation: wa-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
.wa-button.wa-dragging::after,
.wa-widget[data-open="true"] .wa-button::after { animation: none; }
@keyframes wa-pulse {
  0%   { box-shadow: 0 0 0 0    rgba(37, 211, 102, 0.55); }
  80%  { box-shadow: 0 0 0 22px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0    rgba(37, 211, 102, 0); }
}

.wa-button.wa-enter {
  animation: wa-enter 540ms cubic-bezier(.2, .9, .3, 1.4) both;
}
@keyframes wa-enter {
  0%   { transform: translateY(40px) scale(0.4);  opacity: 0; }
  60%  { transform: translateY(-6px) scale(1.08); opacity: 1; }
  100% { transform: translateY(0)    scale(1);    opacity: 1; }
}

.wa-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 20px;
  text-align: center; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transform: scale(0); transform-origin: center;
  transition: transform 260ms cubic-bezier(.2, .9, .3, 1.4);
  pointer-events: none;
}
.wa-badge.wa-visible { transform: scale(1); }

/* ─────────────────────────────── Popup ─────────────────────────────── */

.wa-popup {
  pointer-events: auto;
  position: absolute;
  width: 360px; max-width: calc(100vw - 24px);
  height: 520px; max-height: calc(100vh - 120px);
  background: var(--wa-bg);
  border-radius: var(--wa-radius);
  box-shadow: var(--wa-shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0; transform: translateY(16px) scale(0.96);
  visibility: hidden;
  transition:
    opacity 220ms ease,
    transform 260ms cubic-bezier(.2, .9, .3, 1.2),
    visibility 0s linear 260ms;
}
.wa-widget[data-open="true"] .wa-popup {
  opacity: 1; transform: translateY(0) scale(1);
  visibility: visible;
  transition:
    opacity 220ms ease,
    transform 260ms cubic-bezier(.2, .9, .3, 1.2),
    visibility 0s;
}
.wa-widget[data-dragging="true"] .wa-popup {
  opacity: 0; visibility: hidden;
}

.wa-header {
  background: var(--wa-green-dark); color: #fff;
  padding: 16px 18px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.wa-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: grid; place-items: center; flex-shrink: 0;
}
.wa-avatar svg  { width: 24px; height: 24px; }
.wa-header-text { flex: 1; min-width: 0; }
.wa-header-title { font-size: 15px; font-weight: 600; line-height: 1.2; }
.wa-header-sub {
  font-size: 12px; opacity: 0.9; margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.wa-online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 6px rgba(74, 222, 128, 0.85);
}
.wa-close {
  background: transparent; border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background-color 160ms ease;
}
.wa-close:hover         { background: rgba(255, 255, 255, 0.18); }
.wa-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.wa-close svg           { width: 18px; height: 18px; }

.wa-messages {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  background-color: #efeae2;
  background-image:
    radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  background-size: 18px 18px, 36px 36px;
  background-position: 0 0, 9px 9px;
  display: flex; flex-direction: column; gap: 6px;
  overscroll-behavior: contain;
}

.wa-bubble {
  max-width: 78%;
  padding: 8px 12px 6px;
  border-radius: 10px;
  font-size: 14px; line-height: 1.4;
  word-wrap: break-word; overflow-wrap: anywhere;
  white-space: pre-wrap;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  animation: wa-bubble-in 240ms ease-out both;
}
@keyframes wa-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wa-bubble-in  { align-self: flex-start; background: var(--wa-bubble-in);  border-top-left-radius: 2px; }
.wa-bubble-out { align-self: flex-end;   background: var(--wa-bubble-out); border-top-right-radius: 2px; }
.wa-bubble-time {
  font-size: 10px; color: var(--wa-muted);
  margin-left: 8px; float: right; padding-top: 4px;
}

.wa-typing {
  align-self: flex-start;
  background: var(--wa-bubble-in);
  padding: 12px 14px;
  border-radius: 10px; border-top-left-radius: 2px;
  display: inline-flex; gap: 4px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}
.wa-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9aa5ad;
  animation: wa-typing 1.2s infinite ease-in-out;
}
.wa-typing span:nth-child(2) { animation-delay: 0.18s; }
.wa-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes wa-typing {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.5; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

.wa-form {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px;
  background: var(--wa-composer-bg);
  border-top: 1px solid var(--wa-border);
  flex-shrink: 0;
}
.wa-input {
  flex: 1;
  min-height: 40px; max-height: 120px;
  padding: 10px 14px;
  border-radius: 22px;
  border: 1px solid transparent;
  background: #fff; color: var(--wa-text);
  font: inherit; font-size: 14px; line-height: 1.4;
  resize: none; outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.wa-input:focus {
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18);
}
.wa-send {
  flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 50%;
  border: none;
  background: var(--wa-green); color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 160ms ease, background-color 160ms ease;
}
.wa-send:hover         { background: var(--wa-green-hover); transform: scale(1.06); }
.wa-send:active        { transform: scale(0.92); }
.wa-send:disabled      { background: #b6bfc4; cursor: not-allowed; transform: none; }
.wa-send:focus-visible { outline: 2px solid var(--wa-green-dark); outline-offset: 2px; }
.wa-send svg           { width: 20px; height: 20px; }

.wa-footer {
  text-align: center; font-size: 11px; color: var(--wa-muted);
  padding: 6px;
  background: var(--wa-composer-bg);
  border-top: 1px solid var(--wa-border);
}

@media (max-width: 480px) {
  .wa-popup {
    width: calc(100vw - 16px);
    height: calc(100dvh - 100px);
    max-height: none;
  }
  .wa-button       { width: 56px; height: 56px; }
  .wa-button > svg { width: 28px; height: 28px; }
  .wa-input        { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .wa-widget *,
  .wa-widget *::before,
  .wa-widget *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
