#wa-tooltip,
#wa-fab,
#wa-panel {
  font-family: var(--font, Inter, system-ui, sans-serif);
}

.wa-widget-root { position: relative; z-index: 9997; }

#wa-fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 9999;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(124, 131, 230, 0.58);
  border-radius: 50%;
  color: #fff;
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.22), transparent 32%),
    linear-gradient(135deg, #7C83E6 0%, #6F75D8 42%, #262B67 100%);
  box-shadow: 0 18px 44px rgba(4, 7, 30, 0.3), 0 0 0 7px rgba(124, 131, 230, 0.14);
  cursor: pointer;
  outline: none;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

#wa-fab:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.72);
  box-shadow: 0 22px 52px rgba(4, 7, 30, 0.38), 0 0 0 8px rgba(124, 131, 230, 0.2);
}

#wa-fab:active { transform: translateY(0) scale(0.98); }
#wa-fab:focus-visible { outline: 3px solid rgba(124, 131, 230, 0.44); outline-offset: 4px; }

#wa-fab::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(124, 131, 230, 0.38);
  border-radius: 50%;
  animation: wa-pulse 3.8s ease-out infinite;
}

@keyframes wa-pulse {
  0% { transform: scale(1); opacity: 0.62; }
  70%, 100% { transform: scale(1.38); opacity: 0; }
}

#wa-fab .wa-icon-wa { transition: opacity 0.2s, transform 0.2s; }
#wa-fab .wa-icon-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(0.6); transition: opacity 0.2s, transform 0.2s; }
#wa-fab.open .wa-icon-wa { opacity: 0; transform: rotate(90deg) scale(0.6); }
#wa-fab.open .wa-icon-close { opacity: 1; transform: rotate(0) scale(1); }

#wa-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 19px;
  height: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #11143A;
  border-radius: 50%;
  background: #7C83E6;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 950;
  animation: wa-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 2s both;
}

@keyframes wa-badge-pop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#wa-panel {
  position: fixed;
  right: 28px;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  z-index: 9998;
  width: 370px;
  max-width: calc(100vw - 32px);
  max-height: min(660px, calc(100vh - 128px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(38, 43, 103, 0.14);
  border-radius: 18px;
  background: #FFFFFF;
  box-shadow: 0 24px 70px rgba(4, 7, 30, 0.24), 0 0 0 1px rgba(255, 255, 255, 0.42) inset;
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(0.94);
  transform-origin: bottom right;
  transition: transform 0.3s cubic-bezier(0.34, 1.3, 0.64, 1), opacity 0.25s ease;
}

#wa-panel[hidden] { display: none; }
#wa-panel.open { opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }

.wa-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 1.1rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  background:
    radial-gradient(circle at 18% 18%, rgba(124, 131, 230, 0.34), transparent 34%),
    linear-gradient(135deg, #262B67 0%, #414790 58%, #6F75D8 100%);
}

.wa-avatar-wrap { position: relative; flex-shrink: 0; }
.wa-avatar { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1.5px solid rgba(255,255,255,0.46); border-radius: 50%; background: rgba(255,255,255,0.08); }
.wa-avatar img { width: 34px; height: 34px; border-radius: 9px; object-fit: contain; }
.wa-online-dot { position: absolute; right: 1px; bottom: 1px; width: 10px; height: 10px; border: 2px solid #262B67; border-radius: 50%; background: #C9CEFF; }
.wa-header-info { flex: 1; min-width: 0; }
.wa-agent-name { margin: 0; overflow: hidden; color: #fff; font-size: 0.9rem; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.wa-agent-name:focus { outline: none; }
.wa-status { display: flex; align-items: center; gap: 0.3rem; margin-top: 2px; color: rgba(255,255,255,0.8); font-size: 0.72rem; font-weight: 750; }
.wa-status::before { content: ""; width: 5px; height: 5px; flex-shrink: 0; border-radius: 50%; background: #C9CEFF; }
.wa-close-btn { display: flex; align-items: center; padding: 0.28rem; border: 0; border-radius: 7px; color: rgba(255,255,255,0.74); background: transparent; cursor: pointer; transition: color 0.15s, background 0.15s; }
.wa-close-btn:hover, .wa-close-btn:focus { color: #fff; background: rgba(255,255,255,0.1); }
.wa-close-btn:focus-visible { outline: 2px solid rgba(201, 206, 255, 0.7); outline-offset: 2px; }

.wa-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem 1rem 0.85rem;
  background: linear-gradient(180deg, #F4F5FF, #FFFFFF);
  overscroll-behavior: contain;
}

.wa-bubble {
  position: relative;
  max-width: 94%;
  padding: 0.74rem 0.9rem;
  border: 1px solid rgba(38, 43, 103, 0.12);
  border-radius: 4px 12px 12px 12px;
  background: #FFFFFF;
  box-shadow: 0 14px 36px rgba(22, 27, 72, 0.08);
}

@keyframes wa-bubble-in {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.wa-bubble::before { content: ""; position: absolute; top: 0; left: -6px; border-width: 0 6px 6px 0; border-style: solid; border-color: transparent rgba(38, 43, 103, 0.12) transparent transparent; }
.wa-bubble p { margin: 0 0 0.35rem; color: #1B1F55; font-size: 0.84rem; line-height: 1.55; }
.wa-bubble-meta { margin-top: 0.3rem; color: #6B7090; font-size: 0.62rem; text-align: right; }

.wa-options { display: grid; gap: 0.52rem; margin-top: 0.9rem; }
.wa-option {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.68rem 0.78rem;
  border: 1px solid rgba(38, 43, 103, 0.14);
  border-radius: 11px;
  background: #FFFFFF;
  color: #11143A;
  box-shadow: 0 10px 26px rgba(22, 27, 72, 0.06);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.22;
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.wa-option::after { content: "›"; flex-shrink: 0; color: #6F75D8; font-size: 1.05rem; line-height: 1; }
.wa-option:hover, .wa-option:focus { transform: translateY(-1px); border-color: rgba(124, 131, 230, 0.5); background: #F0F2FF; color: #262B67; box-shadow: 0 14px 30px rgba(38, 43, 103, 0.12); }
.wa-option:active { transform: translateY(0) scale(0.99); border-color: rgba(124, 131, 230, 0.7); background: #E7EAFF; }
.wa-option:focus-visible { outline: 3px solid rgba(124, 131, 230, 0.28); outline-offset: 2px; }
.wa-option-primary { color: #fff; border-color: rgba(124, 131, 230, 0.52); background: linear-gradient(135deg, #7C83E6, #262B67); }
.wa-option-primary::after { color: #fff; }
.wa-option-primary:hover, .wa-option-primary:focus, .wa-option-primary:active { color: #fff; background: linear-gradient(135deg, #6F75D8, #1B1F55); }
.wa-option-primary:hover::after, .wa-option-primary:focus::after, .wa-option-primary:active::after { color: #fff; }

.wa-input-wrap { flex: 0 0 auto; display: grid; gap: 0.48rem; padding: 0.82rem 1rem; border-top: 1px solid rgba(38, 43, 103, 0.12); background: #FFFFFF; }
.wa-compose-row { display: flex; align-items: flex-end; gap: 0.55rem; }
.wa-context-note, .wa-compose-status { margin: 0; color: #4B4F73; font-size: 0.72rem; font-weight: 850; line-height: 1.35; }
.wa-compose-status { min-height: 1rem; color: #262B67; }
#wa-msg-input { min-height: 38px; max-height: 112px; flex: 1; padding: 0.58rem 0.8rem; border: 1px solid rgba(38, 43, 103, 0.18); border-radius: 10px; background: #FFFFFF; color: #11143A; font-size: 0.84rem; line-height: 1.4; outline: none; resize: none; transition: border-color 0.2s, box-shadow 0.2s; }
#wa-msg-input:focus { border-color: rgba(124, 131, 230, 0.7); box-shadow: 0 0 0 3px rgba(124, 131, 230, 0.16); }
#wa-msg-input::placeholder { color: #667085; }
#wa-send-btn { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid rgba(124, 131, 230, 0.5); border-radius: 10px; color: #fff; background: linear-gradient(135deg, #7C83E6, #262B67); cursor: pointer; transition: transform 0.15s, box-shadow 0.2s; }
#wa-send-btn:hover, #wa-send-btn:focus { box-shadow: 0 10px 22px rgba(38, 43, 103, 0.24); }
#wa-send-btn:active { transform: scale(0.92); }
#wa-send-btn:focus-visible { outline: 2px solid rgba(124, 131, 230, 0.42); outline-offset: 2px; }
.wa-footer { flex: 0 0 auto; padding: 0.45rem; border-top: 1px solid rgba(38, 43, 103, 0.1); background: #F7F8FF; color: #64748B; font-size: 0.62rem; text-align: center; }

#wa-tooltip {
  position: fixed;
  right: 28px;
  bottom: 100px;
  z-index: 9997;
  padding: 0.5rem 0.85rem;
  border: 1px solid rgba(124, 131, 230, 0.24);
  border-radius: 10px 10px 0 10px;
  background: #FFFFFF;
  box-shadow: 0 16px 38px rgba(4, 7, 30, 0.16);
  color: #11143A;
  font-size: 0.78rem;
  font-weight: 850;
  pointer-events: none;
  white-space: nowrap;
  animation: wa-tip-in 0.4s cubic-bezier(0.34, 1.2, 0.64, 1) 3s both, wa-tip-out 0.3s ease 8s forwards;
}

#wa-tooltip.is-hidden { animation: wa-tip-out 0.3s ease forwards; }
@keyframes wa-tip-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes wa-tip-out { to { opacity: 0; transform: translateY(5px); } }

@media (max-width: 640px) { #wa-tooltip { display: none; } }

@media (max-width: 420px) {
  #wa-panel { right: 12px; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); width: calc(100vw - 24px); max-height: calc(100vh - 110px - env(safe-area-inset-bottom, 0px)); }
  #wa-fab { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); }
}

@supports (height: 100dvh) {
  #wa-panel { max-height: min(660px, calc(100dvh - 128px)); }
  @media (max-width: 420px) { #wa-panel { max-height: calc(100dvh - 110px - env(safe-area-inset-bottom, 0px)); } }
}

@media (prefers-reduced-motion: reduce) {
  #wa-fab,
  #wa-panel,
  #wa-fab::before,
  .wa-bubble,
  #wa-tooltip,
  #wa-badge,
  #wa-fab .wa-icon-wa,
  #wa-fab .wa-icon-close,
  .wa-option {
    animation: none !important;
    transition: none !important;
  }
}
