/* ================================================================
   Quatrix WhatsApp Widget — Front-end
   Classes match render_widget() output exactly
   ================================================================ */

/* ── Container (fixed, follows scroll) ───────────────────────── */
#qwacWidget,
.qwac-widget {
  position: fixed !important;
  bottom: 96px !important;
  right: 28px !important;
  z-index: 999999 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  gap: 12px !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  line-height: 1.5 !important;
  box-sizing: border-box !important;
}

.qwac-widget.qwac-left {
  right: auto !important;
  left: 28px !important;
  align-items: flex-start !important;
}

/* ── FAB button ───────────────────────────────────────────────── */
.qwac-widget .qwac-fab {
  position: relative !important;
  width: 60px !important;
  height: 60px !important;
  border-radius: 50% !important;
  background: #25D366 !important;
  border: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 6px 24px rgba(37,211,102,.45) !important;
  transition: transform .2s ease, box-shadow .2s ease !important;
  padding: 0 !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
  outline: none !important;
}

.qwac-widget .qwac-fab:hover {
  transform: scale(1.08) !important;
  box-shadow: 0 10px 32px rgba(37,211,102,.55) !important;
}

/* Pulse ring */
.qwac-widget .qwac-fab::before {
  content: '' !important;
  position: absolute !important;
  inset: -8px !important;
  border-radius: 50% !important;
  background: rgba(37,211,102,.22) !important;
  animation: qwacPulse 2.2s ease-out infinite !important;
  pointer-events: none !important;
}

@keyframes qwacPulse {
  0%   { transform: scale(.88); opacity: 1; }
  70%  { transform: scale(1.45); opacity: 0; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* Icon swap */
.qwac-widget .qwac-fab__ico {
  position: absolute !important;
  transition: opacity .2s, transform .2s !important;
  display: block !important;
}

.qwac-widget .qwac-fab__ico--wa {
  opacity: 1 !important;
  transform: scale(1) !important;
}

.qwac-widget .qwac-fab__ico--x {
  opacity: 0 !important;
  transform: scale(.5) rotate(-90deg) !important;
}

.qwac-widget.is-open .qwac-fab__ico--wa {
  opacity: 0 !important;
  transform: scale(.5) rotate(90deg) !important;
}

.qwac-widget.is-open .qwac-fab__ico--x {
  opacity: 1 !important;
  transform: scale(1) rotate(0) !important;
}

/* Badge */
.qwac-widget .qwac-fab__badge {
  position: absolute !important;
  top: -3px !important;
  right: -3px !important;
  width: 20px !important;
  height: 20px !important;
  background: #e11d74 !important;
  border-radius: 50% !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  color: #fff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 2px solid #fff !important;
  line-height: 1 !important;
  transition: opacity .2s, transform .2s !important;
}

.qwac-widget.is-open .qwac-fab__badge {
  opacity: 0 !important;
  transform: scale(.4) !important;
  pointer-events: none !important;
}

/* ── Chat popup ───────────────────────────────────────────────── */
.qwac-widget .qwac-chat {
  width: 320px !important;
  background: #fff !important;
  border-radius: 18px !important;
  box-shadow: 0 16px 56px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.08) !important;
  overflow: hidden !important;
  transform: scale(.88) translateY(16px) !important;
  transform-origin: bottom right !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .22s ease !important;
}

.qwac-widget.qwac-left .qwac-chat {
  transform-origin: bottom left !important;
}

.qwac-widget.is-open .qwac-chat {
  transform: scale(1) translateY(0) !important;
  opacity: 1 !important;
  pointer-events: all !important;
}

/* ── Chat header ──────────────────────────────────────────────── */
.qwac-widget .qwac-chat__head {
  background: #075E54 !important;
  padding: 14px 16px !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

.qwac-widget .qwac-chat__avatar {
  position: relative !important;
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  border-radius: 50% !important;
  background: rgba(255,255,255,.15) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  border: 2px solid rgba(255,255,255,.25) !important;
  flex-shrink: 0 !important;
}

.qwac-widget .qwac-chat__avatar img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

.qwac-widget .qwac-chat__dot {
  position: absolute !important;
  bottom: 1px !important;
  right: 1px !important;
  width: 11px !important;
  height: 11px !important;
  background: #25D366 !important;
  border-radius: 50% !important;
  border: 2px solid #075E54 !important;
  display: block !important;
}

.qwac-widget .qwac-chat__info {
  flex: 1 !important;
  min-width: 0 !important;
}

.qwac-widget .qwac-chat__info strong {
  display: block !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  color: #fff !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  margin: 0 !important;
  padding: 0 !important;
  background: none !important;
  border: none !important;
}

.qwac-widget .qwac-chat__info small {
  display: block !important;
  font-size: 12px !important;
  color: rgba(255,255,255,.72) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  font-weight: normal !important;
}

.qwac-widget .qwac-chat__close {
  background: none !important;
  border: none !important;
  cursor: pointer !important;
  color: rgba(255,255,255,.75) !important;
  padding: 6px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background .15s, color .15s !important;
  flex-shrink: 0 !important;
  line-height: 1 !important;
}

.qwac-widget .qwac-chat__close:hover {
  background: rgba(255,255,255,.15) !important;
  color: #fff !important;
}

/* ── Chat body ────────────────────────────────────────────────── */
.qwac-widget .qwac-chat__body {
  background: #E5DDD5 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cdefs%3E%3Cpattern id='wp' width='20' height='20' patternUnits='userSpaceOnUse'%3E%3Ccircle cx='1' cy='1' r='1' fill='%23b39e8a' opacity='.2'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='100' height='100' fill='url(%23wp)'/%3E%3C/svg%3E") !important;
  padding: 16px 14px !important;
  min-height: 100px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}

/* Typing indicator */
.qwac-widget .qwac-chat__typing {
  display: inline-flex !important;
  gap: 5px !important;
  background: #fff !important;
  border-radius: 0 14px 14px 14px !important;
  padding: 12px 16px !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.1) !important;
  align-self: flex-start !important;
}

.qwac-widget .qwac-chat__typing span {
  width: 8px !important;
  height: 8px !important;
  background: #aaa !important;
  border-radius: 50% !important;
  display: inline-block !important;
  animation: qwacDot 1.3s infinite ease-in-out !important;
}

.qwac-widget .qwac-chat__typing span:nth-child(2) { animation-delay: .18s !important; }
.qwac-widget .qwac-chat__typing span:nth-child(3) { animation-delay: .36s !important; }

@keyframes qwacDot {
  0%, 80%, 100% { transform: scale(.55); opacity: .5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* Message bubble */
.qwac-widget .qwac-chat__bubble {
  background: #fff !important;
  border-radius: 0 14px 14px 14px !important;
  padding: 10px 14px 6px !important;
  max-width: 92% !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.1) !important;
  align-self: flex-start !important;
  animation: qwacBubbleIn .28s ease !important;
  font-size: 14px !important;
  color: #303030 !important;
  line-height: 1.5 !important;
}

@keyframes qwacBubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.qwac-widget .qwac-chat__bubble p {
  margin: 0 0 2px !important;
  font-size: 14px !important;
  color: #303030 !important;
  line-height: 1.5 !important;
}

.qwac-widget .qwac-chat__time {
  display: block !important;
  text-align: right !important;
  font-size: 11px !important;
  color: #999 !important;
  margin-top: 4px !important;
}

/* ── Chat footer ──────────────────────────────────────────────── */
.qwac-widget .qwac-chat__foot {
  padding: 12px 14px !important;
  background: #f0f0f0 !important;
  border-top: 1px solid rgba(0,0,0,.06) !important;
}

.qwac-widget .qwac-chat__cta {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  background: #25D366 !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  padding: 12px 20px !important;
  border-radius: 100px !important;
  text-decoration: none !important;
  transition: background .18s, transform .15s !important;
  box-shadow: 0 2px 8px rgba(37,211,102,.3) !important;
  border: none !important;
  cursor: pointer !important;
  line-height: 1.4 !important;
}

.qwac-widget .qwac-chat__cta:hover {
  background: #1da851 !important;
  color: #fff !important;
  transform: translateY(-1px) !important;
  text-decoration: none !important;
}

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #qwacWidget,
  .qwac-widget {
    bottom: 86px !important;
    right: 18px !important;
  }
  .qwac-widget.qwac-left {
    right: auto !important;
    left: 18px !important;
  }
  .qwac-widget .qwac-chat {
    width: calc(100vw - 36px) !important;
  }
}

/* ── Hide on mobile if configured ────────────────────────────── */
.qwac-widget.qwac-hide-mobile {
  display: none !important;
}

@media (min-width: 769px) {
  .qwac-widget.qwac-hide-mobile {
    display: flex !important;
  }
}
