/**
 * Kalel WhatsApp Conversational Chat - Frontend Styles
 * Versão 2.0.0
 */

/* ==========================================================================
   BOTÃO FLUTUANTE
   ========================================================================== */
.kwc-widget-wrap {
  position: fixed;
  bottom: 24px;
  z-index: 999990 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.kwc-widget-wrap.kwc-pos-right {
  right: 24px;
}

.kwc-widget-wrap.kwc-pos-left {
  left: 24px;
}

.kwc-float-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 9px;
  padding: 13px 22px;
  background-color: #25D366;
  color: #FFFFFF !important;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none !important;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 24px -4px rgba(37, 211, 102, 0.45);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, background-color 0.2s ease;
  line-height: 1;
  outline: none;
}

.kwc-float-btn:hover {
  transform: translateY(-2px) scale(1.02);
  background-color: #20bd5a;
  box-shadow: 0 14px 28px -4px rgba(37, 211, 102, 0.55);
  color: #FFFFFF !important;
}

.kwc-float-btn:active {
  transform: translateY(0) scale(0.98);
}

.kwc-float-btn__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kwc-float-btn__icon svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.kwc-float-btn__arrow {
  font-size: 1.05em;
  opacity: 0.9;
  transition: transform 0.2s ease;
}

.kwc-float-btn:hover .kwc-float-btn__arrow {
  transform: translate(2px, -2px);
}

/* ==========================================================================
   MODAL / JANELA DE CHAT
   ========================================================================== */
.kwc-modal {
  position: fixed;
  inset: 0;
  z-index: 999999 !important;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

.kwc-widget-wrap.kwc-pos-left .kwc-modal {
  justify-content: flex-start;
}

.kwc-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.kwc-modal__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(10, 10, 12, 0.7);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.26s ease;
}

.kwc-modal.is-open .kwc-modal__backdrop {
  opacity: 1;
}

.kwc-modal__card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 395px;
  margin-bottom: 68px; /* Acima do botão flutuante */
  background-color: #111418;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 24px 56px -8px rgba(0, 0, 0, 0.75), 0 0 1px rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
  transform: translateY(18px) scale(0.96);
  transform-origin: bottom right;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  color: #e9edef;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.kwc-widget-wrap.kwc-pos-left .kwc-modal__card {
  transform-origin: bottom left;
}

.kwc-modal.is-open .kwc-modal__card {
  transform: translateY(0) scale(1);
}

/* ==========================================================================
   HEADER DO CHAT
   ========================================================================== */
.kwc-modal__header {
  background-color: #1e2429;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.kwc-modal__user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.kwc-modal__avatar-wrap {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

.kwc-modal__avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #25D366;
  display: block;
}

.kwc-modal__online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background-color: #25D366;
  border: 2px solid #1e2429;
  border-radius: 50%;
  animation: kwcPulseDot 2s infinite;
}

@keyframes kwcPulseDot {
  0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
  70% { box-shadow: 0 0 0 5px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

.kwc-modal__meta {
  flex: 1;
  min-width: 0;
}

.kwc-modal__name {
  font-size: 0.98rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kwc-modal__status {
  font-size: 0.74rem;
  color: #25D366;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

.kwc-modal__status.is-typing {
  color: #25D366;
  font-weight: 600;
}

.kwc-modal__close {
  background: transparent;
  border: none;
  color: #8b98a5;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.kwc-modal__close:hover {
  background-color: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}

/* ==========================================================================
   CORPO DO CHAT (MENSAGENS & DIGITAÇÃO)
   ========================================================================== */
.kwc-modal__body {
  padding: 18px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  background-color: #0c0f12;
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 16px 16px;
  min-height: 300px;
}

.kwc-date-pill {
  text-align: center;
  margin-bottom: 6px;
}

.kwc-date-pill span {
  display: inline-block;
  background-color: #1a2026;
  color: #8696a0;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 8px;
}

.kwc-chat-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Balões de Mensagem */
.kwc-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: kwcMsgIn 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes kwcMsgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.kwc-bubble-wrap--bot {
  align-self: flex-start;
}

.kwc-bubble-wrap--bot .kwc-bubble {
  background-color: #20272b;
  color: #e9edef;
  border-radius: 16px 16px 16px 3px;
  padding: 10px 14px;
  font-size: 0.89rem;
  line-height: 1.45;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.kwc-bubble-wrap--bot .kwc-bubble p {
  margin: 0;
}

.kwc-bubble-wrap--bot .kwc-bubble strong {
  color: #FFFFFF;
}

.kwc-bubble-wrap--user {
  align-self: flex-end;
}

.kwc-bubble-wrap--user .kwc-bubble {
  background-color: #005c4b;
  color: #FFFFFF;
  border-radius: 16px 16px 3px 16px;
  padding: 10px 14px;
  font-size: 0.89rem;
  line-height: 1.45;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.kwc-bubble-wrap--user .kwc-bubble p {
  margin: 0;
}

.kwc-bubble-time {
  font-size: 0.65rem;
  color: #8696a0;
  margin-top: 3px;
  padding: 0 4px;
}

.kwc-bubble-wrap--user .kwc-bubble-time {
  text-align: right;
  color: #8cd6c5;
}

/* ==========================================================================
   EFEITO REALISTA DE DIGITAÇÃO ("DIGITANDO...")
   ========================================================================== */
.kwc-typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: kwcMsgIn 0.2s ease-out;
}

.kwc-typing-bubble {
  background-color: #20272b;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 3px;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.kwc-dot {
  width: 7px;
  height: 7px;
  background-color: #8696a0;
  border-radius: 50%;
  animation: kwcDotBounce 1.4s infinite ease-in-out both;
}

.kwc-dot:nth-child(1) { animation-delay: -0.32s; }
.kwc-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes kwcDotBounce {
  0%, 80%, 100% { transform: scale(0.65); opacity: 0.35; }
  40% { transform: scale(1.15); opacity: 1; background-color: #25D366; }
}

.kwc-typing-label {
  font-size: 0.72rem;
  color: #8696a0;
  font-style: italic;
}

/* ==========================================================================
   INTERAÇÃO (INPUTS E CHIPS)
   ========================================================================== */
.kwc-interaction-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: kwcMsgIn 0.25s ease-out;
}

/* Linha de Input com Botão */
.kwc-input-row {
  display: flex;
  gap: 8px;
  background-color: #1a2026;
  padding: 6px 8px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kwc-input-row:focus-within {
  border-color: #25D366;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.2);
}

.kwc-input-field {
  flex: 1;
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 0.9rem;
  padding: 8px 10px;
  outline: none;
  font-family: inherit;
}

.kwc-input-field::placeholder {
  color: #8696a0;
}

.kwc-send-btn {
  background-color: #00a884;
  color: #FFFFFF;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.kwc-send-btn:hover {
  background-color: #25D366;
  transform: scale(1.05);
}

.kwc-send-btn svg {
  fill: currentColor;
}

/* Opções em Botões (Chips) */
.kwc-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}

.kwc-chip-btn {
  background-color: #1e262c;
  color: #e9edef;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  line-height: 1.3;
}

.kwc-chip-btn:hover {
  background-color: #005c4b;
  border-color: #25D366;
  color: #FFFFFF;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 92, 75, 0.4);
}

.kwc-chip-btn:active {
  transform: translateY(0);
}

/* ==========================================================================
   CARD FINAL DE CONCLUSÃO
   ========================================================================== */
.kwc-final-card {
  background-color: #1a2026;
  border: 1px solid rgba(37, 211, 102, 0.35);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: kwcMsgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.kwc-preview-box {
  background-color: #111519;
  border-left: 3px solid #25D366;
  padding: 10px 12px;
  border-radius: 6px;
}

.kwc-preview-box__tag {
  font-size: 0.68rem;
  color: #8696a0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-bottom: 4px;
}

.kwc-preview-box p {
  margin: 0;
  font-size: 0.84rem;
  color: #e9edef;
  line-height: 1.45;
}

.kwc-preview-box strong {
  color: #25D366;
}

.kwc-launch-btn {
  background-color: #25D366;
  color: #0c1c14 !important;
  text-decoration: none !important;
  font-size: 0.94rem;
  font-weight: 800;
  padding: 13px 20px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
  transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
  border: none;
}

.kwc-launch-btn:hover {
  background-color: #20bd5a;
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(37, 211, 102, 0.5);
  color: #0c1c14 !important;
}

.kwc-launch-btn svg {
  fill: currentColor;
  flex-shrink: 0;
}

.kwc-reset-btn {
  background: transparent;
  border: none;
  color: #8696a0;
  font-size: 0.76rem;
  cursor: pointer;
  align-self: center;
  padding: 4px 10px;
  transition: color 0.15s ease;
  font-family: inherit;
}

.kwc-reset-btn:hover {
  color: #FFFFFF;
  text-decoration: underline;
}

/* ==========================================================================
   RODAPÉ DO CHAT
   ========================================================================== */
.kwc-modal__footer {
  background-color: #161b20;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px 14px;
  text-align: center;
  flex-shrink: 0;
}

.kwc-skip-link {
  color: #8696a0;
  text-decoration: none !important;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s ease;
}

.kwc-skip-link:hover {
  color: #25D366;
}

/* ==========================================================================
   RESPONSIVIDADE MOBILE
   ========================================================================== */
@media (max-width: 640px) {
  .kwc-widget-wrap.kwc-pos-right,
  .kwc-widget-wrap.kwc-pos-left {
    right: 16px;
    left: auto;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .kwc-float-btn {
    padding: 11px 18px;
    font-size: 0.85rem;
  }

  .kwc-modal {
    padding: 0 !important;
    align-items: flex-end !important;
    justify-content: center !important;
  }

  .kwc-modal__card {
    max-width: 100% !important;
    margin-bottom: 0 !important;
    border-radius: 24px 24px 0 0 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    max-height: 88vh !important;
    max-height: 88dvh !important;
    transform: translateY(100%) !important;
    transform-origin: bottom center !important;
  }

  .kwc-modal.is-open .kwc-modal__card {
    transform: translateY(0) !important;
  }
}
