:host {
  all: initial;
  color-scheme: light;
}

.wa-widget {
  --wa-color: #2563eb;
  --wa-surface: rgba(255, 255, 255, 0.98);
  --wa-surface-2: #f5f7fb;
  --wa-text: #172033;
  --wa-muted: #6b7280;
  --wa-line: rgba(15, 23, 42, 0.09);
  --wa-danger: #dc2626;
  --wa-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
  bottom: 28px;
  color: var(--wa-text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: fixed;
  z-index: 2147483647;
}

.wa-widget,
.wa-widget * {
  box-sizing: border-box;
  font-family: inherit;
}

.wa-widget * {
  border-collapse: separate;
  letter-spacing: normal;
  line-height: normal;
  margin: 0;
  max-width: none;
  min-width: 0;
  text-decoration: none;
  text-indent: 0;
  text-transform: none;
  word-break: normal;
}

.wa-widget button,
.wa-widget input,
.wa-widget select,
.wa-widget label,
.wa-widget form,
.wa-widget section,
.wa-widget header,
.wa-widget span,
.wa-widget strong,
.wa-widget em,
.wa-widget time {
  font: inherit;
}

.wa-widget button,
.wa-widget input,
.wa-widget select {
  appearance: none;
  box-shadow: none;
}

.wa-widget img,
.wa-widget svg {
  display: block;
  height: auto;
  max-width: none;
}

.wa-right { right: 28px; }
.wa-left { left: 28px; }

.wa-toggle,
.wa-compose button,
.wa-lead-form button,
.wa-handoff,
.wa-close,
.wa-suggestions button {
  appearance: none;
  border: 0;
  cursor: pointer;
}

.wa-widget button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.wa-toggle:focus-visible,
.wa-compose input:focus-visible,
.wa-lead-form input:focus-visible,
.wa-compose button:focus-visible,
.wa-lead-form button:focus-visible,
.wa-handoff:focus-visible,
.wa-close:focus-visible,
.wa-language select:focus-visible,
.wa-suggestions button:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.42);
  outline-offset: 3px;
}

.wa-toggle {
  align-items: center;
  background: #111827;
  border-radius: 999px !important;
  box-shadow: 0 18px 38px rgba(17, 24, 39, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: #fff !important;
  display: inline-flex !important;
  gap: 9px;
  height: 52px !important;
  justify-content: center;
  min-width: 52px;
  overflow: visible;
  padding: 0 18px !important;
  position: relative;
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
  width: auto !important;
}

.wa-toggle:hover {
  background: #0f172a;
  box-shadow: 0 22px 48px rgba(17, 24, 39, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
}

.wa-toggle:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 80ms;
}

.wa-open .wa-toggle {
  transform: translateY(0);
}

.wa-toggle-icon {
  align-items: center;
  color: currentColor;
  display: inline-flex;
  height: 21px;
  justify-content: center;
  width: 21px;
}

.wa-toggle-icon svg {
  display: block;
  height: 21px;
  width: 21px;
}

.wa-toggle-label {
  color: currentColor;
  font-size: 14px;
  font-weight: 720;
  white-space: nowrap;
}

.wa-window {
  background: var(--wa-surface);
  border: 1px solid var(--wa-line) !important;
  border-radius: 22px;
  bottom: 68px;
  box-shadow: var(--wa-shadow);
  color: var(--wa-text);
  display: flex;
  flex-direction: column;
  height: min(620px, calc(100vh - 128px));
  overflow: hidden;
  position: absolute;
  transform-origin: bottom right;
  width: min(390px, calc(100vw - 40px));
  animation: wa-window-in 180ms cubic-bezier(.2,.9,.2,1) both;
}

.wa-right .wa-window { right: 0; }
.wa-left .wa-window { left: 0; transform-origin: bottom left; }
.wa-window[hidden] { display: none; }

.wa-window header {
  align-items: center;
  background: var(--wa-surface);
  border-bottom: 1px solid var(--wa-line);
  color: var(--wa-text);
  display: flex;
  justify-content: space-between;
  padding: 16px;
  position: relative;
  z-index: 1;
}

.wa-title {
  align-items: center;
  display: flex;
  gap: 11px;
  min-width: 0;
}

.wa-title strong {
  color: var(--wa-text);
  display: block;
  font-size: 15px;
  font-weight: 760;
  letter-spacing: -0.012em;
}

.wa-title em {
  color: var(--wa-muted);
  display: block;
  font-size: 12px;
  font-style: normal;
  margin-top: 2px;
}

.wa-avatar {
  align-items: center;
  background: linear-gradient(135deg, var(--wa-color), #7dd3fc);
  border-radius: 12px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  height: 38px;
  justify-content: center;
  object-fit: cover;
  width: 38px;
}

.wa-header-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.wa-language {
  align-items: center;
  background: var(--wa-surface-2);
  border: 1px solid var(--wa-line);
  border-radius: 999px;
  color: var(--wa-muted);
  display: inline-flex;
  gap: 5px;
  padding: 5px 8px;
}

.wa-language span {
  color: var(--wa-muted);
  font-size: 11px;
}

.wa-language select {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--wa-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  outline: 0;
  padding: 0 2px;
}

.wa-language option {
  background: #fff;
  color: var(--wa-text);
}

.wa-close {
  align-items: center;
  background: var(--wa-surface-2);
  border-radius: 999px;
  color: var(--wa-muted) !important;
  display: inline-flex;
  font-size: 20px;
  height: 32px;
  justify-content: center;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
  width: 32px;
}

.wa-close:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--wa-danger) !important;
  transform: rotate(90deg);
}

.wa-messages {
  background: var(--wa-surface-2);
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 16px;
  position: relative;
  z-index: 1;
}

.wa-messages::-webkit-scrollbar,
.wa-suggestions::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.wa-messages::-webkit-scrollbar-thumb,
.wa-suggestions::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.24);
  border-radius: 999px;
}

.wa-message {
  animation: wa-message-in 180ms ease both;
  border-radius: 18px;
  box-shadow: none;
  color: var(--wa-text);
  font-size: 14px;
  line-height: 1.55;
  max-width: 86%;
  padding: 10px 12px;
  position: relative;
  white-space: pre-wrap;
}

.wa-message-assistant,
.wa-message-human,
.wa-message-event {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--wa-line);
  color: var(--wa-text);
}

.wa-message-user {
  align-self: flex-end;
  background: #111827;
  border: 0;
  color: #fff;
}

.wa-message-event {
  color: #047857;
  font-size: 12px;
  max-width: 92%;
}

.wa-message time {
  color: rgba(107, 114, 128, 0.72);
  display: block;
  font-size: 11px;
  letter-spacing: 0;
  margin-top: 4px;
  text-align: right;
}

.wa-message-user time {
  color: rgba(255, 255, 255, 0.72);
}

.wa-suggestions {
  background: var(--wa-surface);
  border-top: 1px solid var(--wa-line);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px 4px;
  position: relative;
  z-index: 1;
}

.wa-suggestions button {
  background: var(--wa-surface-2);
  border: 1px solid var(--wa-line);
  border-radius: 999px;
  color: var(--wa-text) !important;
  flex: 0 0 auto;
  font-size: 12px;
  padding: 7px 10px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.wa-suggestions button:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--wa-color) !important;
  transform: translateY(-1px);
}

.wa-compose,
.wa-lead-form {
  background: var(--wa-surface);
  border-top: 1px solid var(--wa-line);
  display: flex;
  gap: 8px;
  padding: 12px;
  position: relative;
  z-index: 1;
}

.wa-compose input,
.wa-lead-form input {
  background: var(--wa-surface-2);
  border: 1px solid transparent;
  border-radius: 16px;
  color: var(--wa-text) !important;
  flex: 1;
  font-size: 14px;
  min-width: 0;
  outline: none;
  padding: 12px 13px;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.wa-compose input::placeholder,
.wa-lead-form input::placeholder {
  color: rgba(107, 114, 128, 0.72);
}

.wa-compose input:focus,
.wa-lead-form input:focus {
  background: #fff;
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.wa-lead-form input.wa-field-invalid,
.wa-field-invalid {
  border-color: rgba(220, 38, 38, 0.5) !important;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1) !important;
}

.wa-compose button,
.wa-lead-form button {
  background: var(--wa-color);
  border: 0 !important;
  border-radius: 16px;
  color: #fff !important;
  font-weight: 750;
  padding: 11px 14px;
  transition: filter 160ms ease, transform 160ms ease;
}

.wa-compose button:hover,
.wa-lead-form button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.wa-lead-form {
  display: grid;
  grid-template-columns: 1fr;
}

.wa-lead-form[hidden] { display: none; }

.wa-lead-form label {
  color: var(--wa-muted);
  display: grid;
  font-size: 12px;
  gap: 5px;
}

.wa-form-error {
  color: var(--wa-danger);
  font-size: 12px;
  margin: 0;
}

.wa-handoff {
  background: transparent;
  border: 0 !important;
  border-radius: 0;
  border-top: 1px solid var(--wa-line) !important;
  color: var(--wa-color) !important;
  font-weight: 750;
  padding: 12px;
  position: relative;
  z-index: 1;
}

.wa-handoff:hover {
  background: rgba(37, 99, 235, 0.05);
}

.wa-handoff:disabled:hover {
  background: transparent;
}

@keyframes wa-window-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@media (prefers-reduced-motion: reduce) {
  .wa-toggle,
  .wa-window,
  .wa-message,
  .wa-close,
  .wa-suggestions button,
  .wa-compose button,
  .wa-lead-form button {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 520px) {
  .wa-widget {
    bottom: 18px;
    left: 16px;
    right: 16px;
  }

  .wa-toggle {
    float: right;
    height: 50px !important;
  }

  .wa-window {
    bottom: 64px;
    height: min(620px, calc(100vh - 100px));
    left: 0;
    right: 0;
    width: auto;
  }

  .wa-window header {
    padding: 13px;
  }

  .wa-language span {
    display: none;
  }
}
