/* ==========================================================
   Chatbot "Sofia" (o teaser .chat está em styles.css)
   ========================================================== */
.chatbot-launcher,
.chatbot-minimize,
.chatbot-window {
  position: fixed;
  right: 18px;
  z-index: 1040;
}

.chatbot-launcher[hidden],
.chatbot-minimize[hidden],
.chatbot-window[hidden],
.chatbot-launcher__badge[hidden] {
  display: none;
}

/* Launcher (chat fechado) */
.chatbot-launcher {
  bottom: 20px;
  width: 79px;
  height: 70px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  animation: chatbotPop 0.45s var(--ease-out);
  transition: transform 0.25s var(--ease-out);
}

.chatbot-launcher:hover {
  transform: translateY(-3px) scale(1.04);
}

.chatbot-launcher__bg {
  position: absolute;
  top: 0;
  left: 0;
  filter: drop-shadow(0 6px 14px rgba(0, 41, 37, 0.3));
}

.chatbot-launcher__icon {
  position: absolute;
  top: 11px;
  left: 11px;
  object-fit: contain;
}

.chatbot-launcher__badge {
  position: absolute;
  top: 4px;
  left: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  border-radius: 55px;
  background: var(--clr-cta);
  font-size: 13px;
  font-weight: 800;
  line-height: 10px;
  color: #fff;
  animation: chatbotBadge 2s ease-in-out 1s infinite;
}

@keyframes chatbotBadge {
  0%,
  100% {
    transform: scale(1);
  }
  10% {
    transform: scale(1.2);
  }
  20% {
    transform: scale(1);
  }
}

@keyframes chatbotPop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

/* Botão para minimizar (chat aberto) */
.chatbot-minimize {
  bottom: 20px;
  width: 35px;
  height: 35px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  animation: chatbotPop 0.35s var(--ease-out);
  transition: transform 0.25s var(--ease-out);
}

.chatbot-minimize:hover {
  transform: translateY(2px);
}

.chatbot-minimize img {
  display: block;
}

/* Janela */
.chatbot-window {
  bottom: 67px;
  display: flex;
  flex-direction: column;
  width: 320px;
  max-width: calc(100vw - 24px);
  /* Altura fixa: a conversa faz scroll dentro do corpo (.chatbot-window__body) e o cabeçalho fica sempre visível */
  height: min(520px, 100vh - 90px);
  height: min(520px, 100dvh - 90px);
  padding-bottom: 12px;
  border: 1px solid var(--clr-border);
  border-radius: 25px;
  background: #fff;
  filter: drop-shadow(0 0 12px rgba(0, 41, 37, 0.2));
  transform-origin: bottom right;
  animation: chatbotOpen 0.35s var(--ease-out);
}

@keyframes chatbotOpen {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.92);
  }
}

.chatbot-window__header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  height: 65px;
  margin: -1px -1px 0;
  padding: 16px 20px;
  border-bottom: 4px solid var(--clr-dark);
  border-radius: 25px 25px 0 0;
  background: var(--clr-dark);
}

.chatbot-window__title {
  width: 130px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.chatbot-window__status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #fff;
}

.chatbot-window__status img {
  animation: chatbotOnline 2s ease-in-out infinite;
}

@keyframes chatbotOnline {
  50% {
    opacity: 0.45;
  }
}

.chatbot-window__close {
  position: absolute;
  top: -1px;
  right: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: transform 0.25s var(--ease-out);
}

.chatbot-window__close:hover {
  transform: rotate(90deg);
}

.chatbot-window__close img {
  display: block;
}

.chatbot-window__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
  padding: 20px 16px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--clr-border) transparent;
  scrollbar-width: thin;
}

.chatbot-window__body::-webkit-scrollbar {
  width: 6px;
}

.chatbot-window__body::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: var(--clr-border);
}

/* Mensagens */
.chatbot-row {
  display: flex;
  flex: none;
  gap: 8px;
  animation: chatbotMsg 0.35s var(--ease-out);
}

@keyframes chatbotMsg {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.chatbot-row--bot {
  align-items: flex-end;
}

.chatbot-row--user {
  justify-content: flex-end;
}

.chatbot-bubble {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 16px 16px 16px 4px;
  background: var(--clr-bg-soft);
  font-size: 14px;
  line-height: 1.4;
  color: var(--clr-dark);
}

.chatbot-bubble--user {
  flex: none;
  max-width: 220px;
  border-radius: 16px 16px 4px 16px;
  background: var(--clr-dark);
  color: #fff;
  overflow-wrap: anywhere;
}

.chatbot-bubble--typing {
  display: flex;
  flex: none;
  gap: 4px;
  align-items: center;
  height: 40px;
}

.chatbot-bubble--typing span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #8c9bae;
  animation: chatbotTyping 1s ease-in-out infinite;
}

.chatbot-bubble--typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chatbot-bubble--typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chatbotTyping {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* Opções */
.chatbot-options {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
  animation: chatbotMsg 0.35s var(--ease-out);
}

.chatbot-option {
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--clr-border);
  border-radius: 15px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  line-height: 15px;
  color: var(--clr-dark);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background-color 0.2s,
    transform 0.2s var(--ease-out);
}

.chatbot-option:hover,
.chatbot-option:focus-visible {
  border-color: var(--clr-cta);
  background: #f3faf6;
  outline: 0;
  transform: translateY(-2px);
}

/* Escolha múltipla */
.chatbot-multi {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: chatbotMsg 0.35s var(--ease-out);
}

.chatbot-multi .chatbot-options {
  align-self: stretch;
  padding-top: 0;
}

.chatbot-options__hint {
  align-self: flex-start;
  font-size: 12px;
  color: var(--clr-muted);
}

.chatbot-option.is-selected {
  border-color: var(--clr-cta);
  background: #f3faf6;
  box-shadow: 0 0 0 1px var(--clr-cta);
}

.chatbot-options--inline {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 0;
}

.chatbot-options--inline .chatbot-option {
  min-width: 100px;
  padding: 10px 15px;
  border-radius: 10px;
  font-weight: 700;
  line-height: 1.3;
}

.chatbot-options--inline .chatbot-option:first-child {
  border-color: var(--clr-cta);
  background: var(--clr-cta);
  color: #fff;
}

/* Inputs */
.chatbot-form {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  animation: chatbotMsg 0.35s var(--ease-out);
}

.chatbot-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin: 0;
}

.chatbot-field__label {
  font-size: 12px;
  color: var(--clr-dark);
}

.chatbot-field__input {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid #bbb;
  border-radius: 12px;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--clr-dark);
  outline: 0;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.chatbot-field__input--labeled {
  border-color: var(--clr-border);
}

.chatbot-field__input::placeholder {
  color: #bbb;
  opacity: 1;
}

.chatbot-field__input:focus {
  border-color: var(--clr-cta);
  box-shadow: 0 0 0 1px var(--clr-cta);
}

.chatbot-field__input.is-invalid {
  border-color: var(--clr-error);
}

.chatbot-field__error {
  padding-left: 4px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--clr-error);
  animation: errorIn 0.25s var(--ease-out);
}

.chatbot-form__note {
  align-self: flex-start;
  font-size: 11px;
  line-height: 1.1;
  color: var(--clr-muted);
}

.chatbot-form__note a {
  font-weight: 700;
  color: var(--clr-dark);
}

.chatbot-form__note span {
  font-size: clamp(8px, 2vw, 9px);
}

.chatbot-form__error {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  color: var(--clr-error);
}

.chatbot-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  margin-top: 6px;
  padding: 10px 25px;
  border: 0;
  border-radius: 10px;
  background: var(--clr-cta);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition:
    background-color 0.2s,
    transform 0.2s var(--ease-out),
    box-shadow 0.2s;
}

.chatbot-cta:hover {
  background: var(--clr-cta-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(54, 169, 112, 0.3);
}

.chatbot-cta:disabled {
  opacity: 0.7;
  pointer-events: none;
}

.chatbot-cta--finish {
  height: 46px;
}

/* Fim de conversa */
.chatbot-celebration {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  animation: chatbotMsg 0.45s var(--ease-out);
}

.chatbot-celebration__bubble {
  width: 100%;
  padding: 16px 20px;
  border: 1px solid var(--clr-border);
  border-radius: 20px;
  background: var(--clr-bg-soft);
  font-size: 14px;
  line-height: 1.4;
  color: var(--clr-dark);
  text-align: center;
}

@media (max-width: 576px) {
  .chatbot-window {
    right: 12px;
    bottom: 63px;
    height: min(520px, 100vh - 80px);
    height: min(520px, 100dvh - 80px);
  }

  .chatbot-launcher,
  .chatbot-minimize {
    right: 12px;
    bottom: 14px;
  }
}
