.twc,
.twc * {
  box-sizing: border-box;
}

.twc {
  --twc-surface: var(--wp--preset--color--base, #ffffff);
  --twc-text: var(--wp--preset--color--contrast, #1f2933);
  --twc-muted: #6b7280;
  --twc-border: rgba(0, 0, 0, 0.12);
  --twc-radius: 12px;
  --twc-shadow: 0 12px 36px rgba(0, 0, 0, 0.16);

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99998;
  font: inherit;
  color: var(--twc-text);
}

.twc button,
.twc a,
.twc p,
.twc strong,
.twc span,
.twc textarea {
  font: inherit;
}

.twc__launcher,
.twc__close {
  appearance: none;
}

.twc__launcher {
  width: 56px;
  height: 56px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--twc-border);
  border-radius: 50%;
  background: var(--twc-surface);
  color: var(--twc-text);
  box-shadow: var(--twc-shadow);
  cursor: pointer;
}

.twc__launcher:hover {
  opacity: 0.9;
}

.twc__launcher:focus-visible,
.twc__close:focus-visible,
.twc__cta:focus-visible,
.twc__textarea:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 1px;
}

.twc svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.twc__launcher svg {
  width: 25px;
  height: 25px;
}

.twc__panel {
  width: min(350px, calc(100vw - 32px));
  min-height: 320px;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid var(--twc-border);
  border-radius: var(--twc-radius);
  background: var(--twc-surface);
  color: var(--twc-text);
  box-shadow: var(--twc-shadow);
}

.twc__panel[hidden],
.twc__typing[hidden],
.twc__conversation[hidden] {
  display: none;
}

.twc__header {
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--twc-border);
  background-color: var(
    --twc-user-header-bg,
    var(--twc-user-surface, var(--twc-surface))
  );
  color: var(--twc-user-header-text, inherit);
}

.twc__identity {
  min-width: 0;
}

.twc__title {
  display: block;
  margin: 0 0 3px;
  color: inherit;
  font-weight: 600;
  line-height: 1.3;
}

.twc__status {
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid var(--twc-border);
  color: var(--twc-muted);
  font-size: 0.85em;
}

.twc__close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(
    --twc-user-close,
    var(--twc-user-text, var(--twc-text))
  );
  cursor: pointer;
}

.twc__close:hover {
  background: rgba(127, 127, 127, 0.1);
}

.twc__body {
  min-height: 250px;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
}

.twc__typing {
  width: fit-content;
  min-height: 38px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--twc-border);
  border-radius: 999px;
}

.twc__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: twcTyping 850ms infinite ease-in-out;
}

.twc__typing span:nth-child(2) {
  animation-delay: 120ms;
}

.twc__typing span:nth-child(3) {
  animation-delay: 240ms;
}

.twc__message {
  margin: 0 0 16px;
  color: inherit;
  line-height: 1.55;
}

.twc__field {
  display: block;
  margin: 0 0 14px;
}

.twc__field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--twc-muted);
  font-size: 0.82em;
}

.twc__textarea {
  width: 100%;
  min-height: calc(1.45em + 22px);
  max-height: calc(21.75em + 22px);
  resize: none;
  overflow-y: hidden;
  padding: 10px 11px;
  border: 1px solid var(--twc-border);
  border-radius: calc(var(--twc-radius) - 2px);
  background: transparent;
  color: inherit;
  line-height: 1.45;
}

.twc__textarea::placeholder {
  color: var(--twc-muted);
}

.twc__cta {
  min-height: 44px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  border: 1px solid var(--twc-border);
  border-radius: calc(var(--twc-radius) - 2px);
  background: transparent;
  color: inherit;
  text-decoration: none;
}

.twc__cta:hover {
  opacity: 0.88;
  color: inherit;
}

@keyframes twcTyping {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }

  30% {
    transform: translateY(-3px);
    opacity: 0.9;
  }
}

@media (min-width: 783px) {
  .twc--hide-desktop {
    display: none;
  }
}

@media (max-width: 782px) {
  .twc {
    right: 16px;
    bottom: 16px;
  }

  .twc--hide-mobile {
    display: none;
  }

  .twc__panel {
    min-height: 300px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .twc__typing span {
    animation: none;
  }
}

/* R2.3 frontend status + logo */

.twc__launcher {
  position: relative;
  border-color: rgba(0, 0, 0, 0.08);
  background: #ffffff;
  color: #25d366;
}

.twc__whatsapp-mark {
  width: 30px !important;
  height: 30px !important;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
}

.twc__launcher-status {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ef4444;
}

.twc--available .twc__launcher-status,
.twc--available .twc__status-dot {
  background: #22c55e;
}

.twc--closed .twc__launcher-status,
.twc--closed .twc__status-dot {
  background: #ef4444;
}

.twc__brand {
  min-width: 0;
  max-width: 180px;
  min-height: 32px;
  display: flex;
  align-items: center;
}

.twc__brand img {
  display: block;
  width: auto;
  max-width: 180px;
  height: auto;
  max-height: 44px;
  object-fit: contain;
  object-position: left center;
}

.twc__status {
  margin-top: 0;
}

.twc__status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
}

.twc__textarea {
  background: #f1f2f3;
  color: #1f2933;
}

.twc__textarea::placeholder {
  color: #7a828a;
}

.twc__closed-note {
  margin: -7px 0 15px;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.08);
  color: inherit;
  font-size: 0.86em;
  line-height: 1.45;
}

.twc__sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* R2.3-R1 frontend polish */

.twc .twc__textarea {
  background-color: #f1f2f3;
  color: #1f2933;
}

.twc__launcher {
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font: initial;
  line-height: 0;
  overflow: visible;
  transition:
    transform 150ms ease,
    filter 150ms ease;
}

.twc__launcher:hover {
  background: transparent;
  opacity: 1;
  transform: translateY(-2px) scale(1.025);
}

.twc .twc__launcher,
.twc .twc__launcher:hover,
.twc .twc__launcher:focus,
.twc .twc__launcher:focus-visible,
.twc .twc__launcher:active {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

.twc__launcher:focus-visible {
  border-radius: 14px;
}

.twc__whatsapp-mark {
  display: block;
  width: 58px !important;
  height: 58px !important;
  overflow: visible;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.16));
}

.twc__launcher-status {
  top: 0;
  right: -1px;
  z-index: 2;
  width: 13px;
  height: 13px;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.twc__feedback {
  position: relative;
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 10px;
  background-color: rgba(127, 127, 127, 0.09);
  color: inherit;
  font: inherit;
  font-size: 0.88em;
  line-height: 1.45;
}

.twc__feedback[hidden] {
  display: none;
}

.twc__cta {
  font: inherit;
}

@media (prefers-reduced-motion: reduce) {
  .twc__launcher {
    transition: none;
  }

  .twc__launcher:hover {
    transform: none;
  }
}

/* R2.3-R2 frontend appearance + mobile */

.twc {
  color: var(--twc-user-text, var(--twc-text));
  font-family: var(--twc-user-font, inherit);
}

.twc__panel {
  background-color: var(--twc-user-surface, var(--twc-surface));
}

.twc .twc__body,
.twc .twc__status,
.twc .twc__message,
.twc .twc__field-label,
.twc .twc__closed-note,
.twc .twc__feedback {
  color: var(--twc-user-text, var(--twc-text));
}

.twc .twc__field .twc__textarea {
  background: #ffffff;
  background-color: #ffffff;
  background-image: none;
  color: var(--twc-user-text, var(--twc-text));
  scrollbar-color: rgba(31, 41, 51, 0.42) transparent;
  scrollbar-width: thin;
}

.twc .twc__field .twc__textarea::-webkit-scrollbar {
  width: 6px;
}

.twc .twc__field .twc__textarea::-webkit-scrollbar-track {
  background: transparent;
}

.twc .twc__field .twc__textarea::-webkit-scrollbar-thumb {
  border: 1px solid #ffffff;
  border-radius: 999px;
  background-color: rgba(31, 41, 51, 0.42);
}

.twc .twc__field .twc__textarea::-webkit-scrollbar-thumb:hover {
  background-color: rgba(31, 41, 51, 0.62);
}

.twc .twc__cta {
  background-color: var(--twc-user-cta-bg, transparent);
  color: var(--twc-user-cta-text, inherit);
  font: inherit;
  transition:
    background-color 150ms ease,
    color 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.twc .twc__cta:hover,
.twc .twc__cta:focus-visible {
  border-color: transparent;
  background-color: var(
    --twc-user-cta-hover-bg,
    rgba(31, 41, 51, 0.92)
  );
  color: var(--twc-user-cta-hover-text, #ffffff);
  opacity: 1;
}

.twc .twc__cta:hover {
  transform: translateY(-1px);
}

.twc .twc__cta:active {
  transform: translateY(0);
}

.twc .twc__whatsapp-mark,
.twc .twc__whatsapp-mark path,
.twc .twc__whatsapp-mark circle {
  stroke: none;
  stroke-width: 0;
}

.twc__launcher--mobile {
  display: none;
  text-decoration: none;
}

@media (min-width: 783px) {
  .twc__launcher--desktop {
    display: inline-flex;
  }

  .twc__launcher--mobile {
    display: none;
  }
}

@media (max-width: 782px) {
  .twc__panel {
    display: none;
  }

  .twc__launcher--desktop {
    display: none;
  }

  .twc__launcher--mobile {
    display: inline-flex;
  }

  .twc--hide-mobile {
    display: none;
  }
}

/* R3.1 - keep desktop launcher fixed while panel opens */

@media (min-width: 783px) {
  .twc {
    width: 60px;
    height: 60px;
  }

  .twc__panel {
    position: absolute;
    right: 0;
    bottom: 72px;
  }

  .twc__launcher--desktop {
    position: absolute;
    right: 0;
    bottom: 0;
    margin: 0;
  }
}

/* 0.9.1 - protect CTA from generic link underline effects */

/*
 * Generic theme link effects must not replace the widget CTA
 * Appearance contract.
 */

.twc .twc__cta {
  background-color: var(--twc-user-cta-bg, transparent);
  color: var(--twc-user-cta-text, inherit);
  background-image: none;
  text-decoration: none;
}

.twc .twc__cta:hover,
.twc .twc__cta:focus-visible,
.twc .twc__cta:active {
  background-color: var(--twc-user-cta-hover-bg, transparent);
  color: var(--twc-user-cta-hover-text, inherit);
}

.links-underline .twc a.twc__cta:not(.button):not(.tag):hover,
.links-underline .twc a.twc__cta:not(.button):not(.tag):focus-visible,
.links-underline .twc a.twc__cta:not(.button):not(.tag):active {
  background-image: none;
  animation: none;
  text-decoration: none;
}
