.whatsapp-launcher {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 990;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3.5rem;
  padding: 0.75rem 1.1rem;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: #25d366;
  color: #092e18;
  font-family: Arial, sans-serif;
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  appearance: none;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(9, 46, 24, 0.28);
  transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.whatsapp-launcher:hover {
  background: #42df7b;
  color: #092e18;
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(9, 46, 24, 0.34);
}

.whatsapp-launcher:focus-visible,
.whatsapp-form-button:focus-visible,
.emesa-chat-close:focus-visible,
.emesa-chat-option:focus-visible,
.emesa-chat-whatsapp:focus-visible,
.emesa-chat-restart:focus-visible,
.emesa-chat-form input:focus-visible,
.emesa-chat-form button:focus-visible {
  outline: 3px solid rgba(37, 211, 102, 0.42);
  outline-offset: 3px;
}

.whatsapp-launcher svg,
.whatsapp-form-button svg {
  width: 1.55rem;
  height: 1.55rem;
  flex: 0 0 auto;
  fill: currentColor;
}

.whatsapp-form-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 2.85rem;
  padding: 0.65rem 1.2rem;
  border: 2px solid #128c4b;
  border-radius: 0.75rem;
  background: #ffffff;
  color: #0b6b38;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.whatsapp-form-button:hover {
  background: #128c4b;
  color: #ffffff;
  transform: translateY(-1px);
}

.emesa-chat-widget[hidden] {
  display: none;
}

.emesa-chat-widget {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 4.5rem);
  z-index: 991;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 2rem));
  height: min(640px, calc(100dvh - 7rem));
  overflow: hidden;
  border: 1px solid rgba(9, 46, 24, 0.16);
  border-radius: 1.25rem;
  background: #ffffff;
  color: #163c25;
  font-family: Arial, sans-serif;
  box-shadow: 0 24px 70px rgba(9, 46, 24, 0.28);
}

.emesa-chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: linear-gradient(135deg, #0f6b3a, #128c4b);
  color: #ffffff;
}

.emesa-chat-logo {
  display: grid;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border-radius: 50%;
  background: #25d366;
  color: #073d21;
}

.emesa-chat-logo svg {
  width: 1.45rem;
  height: 1.45rem;
  fill: currentColor;
}

.emesa-chat-heading {
  display: grid;
  flex: 1 1 auto;
  gap: 0.16rem;
  min-width: 0;
}

.emesa-chat-heading strong {
  font-size: 1rem;
  line-height: 1.2;
}

.emesa-chat-heading small {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.74rem;
}

.emesa-chat-close {
  display: grid;
  flex: 0 0 auto;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
}

.emesa-chat-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.emesa-chat-close svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.emesa-chat-log {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 8.5rem;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f5faf6;
}

.emesa-chat-message {
  max-width: 86%;
  padding: 0.7rem 0.82rem;
  border-radius: 1rem;
  font-size: 0.86rem;
  line-height: 1.48;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.emesa-chat-message.is-assistant {
  align-self: flex-start;
  border-bottom-left-radius: 0.3rem;
  background: #ffffff;
  color: #214a31;
  box-shadow: 0 3px 12px rgba(9, 46, 24, 0.08);
}

.emesa-chat-message.is-visitor {
  align-self: flex-end;
  border-bottom-right-radius: 0.3rem;
  background: #dcf8e6;
  color: #153c24;
}

.emesa-chat-options {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid rgba(9, 46, 24, 0.1);
  background: #ffffff;
}

.emesa-chat-options.is-service-list {
  max-height: 13.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.emesa-chat-option {
  display: flex;
  align-items: center;
  gap: 0.58rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(18, 140, 75, 0.2);
  border-radius: 0.75rem;
  background: #f8fcf9;
  color: #17472a;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.emesa-chat-option:hover {
  border-color: rgba(18, 140, 75, 0.55);
  background: #eef9f1;
}

.emesa-chat-option span {
  display: grid;
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  place-items: center;
  border-radius: 50%;
  background: #128c4b;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
}

.emesa-chat-whatsapp,
.emesa-chat-restart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.75rem;
  font: inherit;
  font-size: 0.79rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.emesa-chat-whatsapp {
  border: 1px solid #128c4b;
  background: #25d366;
  color: #092e18;
}

.emesa-chat-whatsapp:hover {
  background: #42df7b;
  color: #092e18;
}

.emesa-chat-whatsapp svg {
  width: 1.3rem;
  height: 1.3rem;
  flex: 0 0 auto;
  fill: currentColor;
}

.emesa-chat-restart {
  border: 1px solid rgba(18, 140, 75, 0.24);
  background: #ffffff;
  color: #0b6b38;
}

.emesa-chat-restart:hover {
  background: #eef9f1;
}

.emesa-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.6rem;
  gap: 0.55rem;
  padding: 0.75rem 0.9rem 0.55rem;
  border-top: 1px solid rgba(9, 46, 24, 0.1);
  background: #ffffff;
}

.emesa-chat-form input {
  width: 100%;
  min-width: 0;
  min-height: 2.6rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(9, 46, 24, 0.2);
  border-radius: 0.75rem;
  background: #ffffff;
  color: #163c25;
  font: inherit;
  font-size: 0.84rem;
}

.emesa-chat-form input::placeholder {
  color: #6b8071;
}

.emesa-chat-form button {
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0.75rem;
  background: #128c4b;
  color: #ffffff;
  cursor: pointer;
}

.emesa-chat-form button:hover {
  background: #0f743f;
}

.emesa-chat-form button svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.emesa-chat-privacy {
  margin: 0;
  padding: 0 0.9rem 0.7rem;
  background: #ffffff;
  color: #687c6e;
  font-size: 0.66rem;
  line-height: 1.35;
  text-align: center;
}

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

@media (max-width: 520px) {
  .whatsapp-launcher {
    width: 3.5rem;
    padding: 0;
    justify-content: center;
  }

  .whatsapp-launcher-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .emesa-chat-widget {
    right: 0.75rem;
    bottom: calc(max(0.75rem, env(safe-area-inset-bottom)) + 4.5rem);
    width: calc(100vw - 1.5rem);
    height: min(620px, calc(100dvh - 6.25rem));
    border-radius: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .whatsapp-launcher,
  .whatsapp-form-button,
  .emesa-chat-widget * {
    transition: none;
  }
}
