/**
 * WhatsApp Conversational Form - Frontend Styles
 */

:root {
  --wcf-wa-green: #25D366;
  --wcf-wa-dark-green: #075E54;
  --wcf-wa-teal: #128C7E;
  --wcf-wa-bg: #EFEAE2;
  --wcf-user-bubble: #E1FFC7;
  --wcf-bot-bubble: #FFFFFF;
  --wcf-font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Container Geral Flutuante */
.wcf-widget-container {
  position: fixed;
  z-index: 2147483647;
  font-family: var(--wcf-font-stack);
  box-sizing: border-box;
}

.wcf-widget-container *,
.wcf-widget-container *::before,
.wcf-widget-container *::after {
  box-sizing: border-box;
}

.wcf-pos-right {
  bottom: 25px;
  right: 25px;
}

.wcf-pos-left {
  bottom: 25px;
  left: 25px;
}

/* Balão Tooltip de Notificação */
.wcf-floating-badge {
  position: absolute;
  bottom: 75px;
  background: #ffffff;
  color: #333333;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  font-weight: 500;
  width: max-content;
  max-width: min(300px, calc(100vw - 32px));
  white-space: normal;
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: wcfFadeSlideUp 0.4s ease forwards;
}

.wcf-pos-right .wcf-floating-badge {
  right: 0;
}

.wcf-pos-left .wcf-floating-badge {
  left: 0;
}

.wcf-floating-badge::after {
  content: "";
  position: absolute;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  transform: rotate(45deg);
}

/* A posição do balão é calculada em relação à área visível durante o arraste. */
.wcf-floating-badge::after { display: none; }
.wcf-widget-container.wcf-snapping { transition: left 0.22s ease-out, top 0.22s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .wcf-widget-container.wcf-snapping { transition: none; }
}

.wcf-pos-right .wcf-floating-badge::after {
  right: 24px;
}

.wcf-pos-left .wcf-floating-badge::after {
  left: 24px;
}

#wcf-widget-container .wcf-badge-close {
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: #888888;
  cursor: pointer;
  padding: 0 2px;
}

#wcf-widget-container .wcf-badge-close:hover {
  color: #333333;
}

/* Botão Flutuante do WhatsApp */
#wcf-widget-container .wcf-trigger-btn {
  touch-action: none;
  position: relative;
  padding: 0;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--wcf-primary, var(--wcf-wa-green));
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 5px 20px rgba(18, 140, 126, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease;
  outline: none;
}

#wcf-widget-container .wcf-trigger-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 25px rgba(18, 140, 126, 0.55);
}

#wcf-widget-container .wcf-trigger-btn:active {
  transform: scale(0.95);
}

.wcf-icon-wa {
  color: #ffffff;
}

/* Anel de Pulso Animado */
.wcf-pulse-ring {
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  border-radius: 50%;
  border: 2px solid var(--wcf-primary, var(--wcf-wa-green));
  animation: wcfPulse 2.5s infinite;
  pointer-events: none;
}

@keyframes wcfPulse {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.2);
    opacity: 0;
  }
  100% {
    transform: scale(0.95);
    opacity: 0;
  }
}

.wcf-unread-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ff3b30;
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
}

/* Janela do Chat Estilo WhatsApp */
.wcf-chat-window {
  display: none;
  position: absolute;
  bottom: 80px;
  width: 375px;
  height: 540px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  flex-direction: column;
  animation: wcfChatOpen 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.wcf-chat-window.wcf-active {
  display: flex;
}

.wcf-pos-right .wcf-chat-window {
  right: 0;
  transform-origin: bottom right;
}

.wcf-pos-left .wcf-chat-window {
  left: 0;
  transform-origin: bottom left;
}

@keyframes wcfChatOpen {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Cabeçalho do Chat */
.wcf-chat-header {
  background: linear-gradient(135deg, var(--wcf-wa-teal), var(--wcf-wa-dark-green));
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.wcf-header-avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.wcf-header-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
}

.wcf-online-indicator {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #25D366;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.wcf-header-info {
  flex: 1;
  min-width: 0;
}

.wcf-header-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wcf-header-status {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

#wcf-widget-container .wcf-header-close {
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 6px;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#wcf-widget-container .wcf-header-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Corpo do Chat / Mensagens */
.wcf-chat-body {
  flex: 1;
  min-height: 0;
  background-color: var(--wcf-wa-bg);
  background-image: radial-gradient(#d4cdb4 10%, transparent 11%), radial-gradient(#d4cdb4 10%, transparent 11%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  padding: 16px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.wcf-chat-date-badge {
  align-self: center;
  background: rgba(255, 255, 255, 0.8);
  color: #667781;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wcf-messages-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Balões de Conversa */
.wcf-bubble {
  max-width: 85%;
  padding: 9px 13px;
  font-size: 13.5px;
  line-height: 1.45;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  animation: wcfBubblePop 0.25s ease forwards;
}

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

/* Balão do Atendente / Bot */
.wcf-bot-bubble {
  align-self: flex-start;
  background: var(--wcf-bot-bubble);
  color: #111b21;
  border-radius: 0 12px 12px 12px;
}

/* Balão do Usuário */
.wcf-user-bubble {
  align-self: flex-end;
  background: var(--wcf-user-bubble);
  color: #111b21;
  border-radius: 12px 0 12px 12px;
}

/* Horário no Balão */
.wcf-bubble-meta {
  font-size: 10.5px;
  color: #667781;
  float: right;
  margin-left: 10px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.wcf-check-icon {
  color: #53bdeb;
  font-weight: bold;
}

/* Indicador de Digitação (Typing Indicator) */
.wcf-typing-indicator {
  align-self: flex-start;
}

.wcf-typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.wcf-dot {
  width: 7px;
  height: 7px;
  background: #999999;
  border-radius: 50%;
  animation: wcfBlink 1.4s infinite ease-in-out both;
}

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

@keyframes wcfBlink {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* CTA Final - Iniciar no WhatsApp */
#wcf-widget-container .wcf-final-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--wcf-wa-green);
  color: #ffffff !important;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 25px;
  margin-top: 8px;
  box-shadow: 0 3px 10px rgba(37, 211, 102, 0.35);
  transition: transform 0.2s, background 0.2s;
  cursor: pointer;
  border: none;
}

#wcf-widget-container .wcf-final-cta-btn:hover {
  background: #20ba59;
  transform: translateY(-1px);
}

/* Rodapé / Input de Dados */
.wcf-chat-footer {
  background: #f0f2f5;
  padding: 10px 12px;
  border-top: 1px solid #e1e4e8;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* Opções Rápidas (Pills) */
.wcf-quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
  padding-bottom: 2px;
}

#wcf-widget-container .wcf-option-pill {
  background: #ffffff;
  color: var(--wcf-wa-teal);
  border: 1.5px solid var(--wcf-wa-teal);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

#wcf-widget-container .wcf-option-pill:hover {
  background: var(--wcf-wa-teal);
  color: #ffffff;
}

/* Barra de Digitação */
.wcf-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border-radius: 22px;
  padding: 4px 6px 4px 14px;
  border: 1px solid #d1d7db;
  transition: border-color 0.2s;
}

.wcf-input-wrapper:focus-within {
  border-color: var(--wcf-wa-teal);
}

#wcf-widget-container .wcf-user-input {
  flex: 1;
  min-width: 0;
  width: 0;
  border: none;
  outline: none;
  font-size: 13.5px;
  background: transparent;
  color: #111b21;
  padding: 6px 0;
}

#wcf-widget-container .wcf-send-btn {
  padding: 0;
  background: var(--wcf-wa-teal);
  color: #ffffff;
  border: none;
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

#wcf-widget-container .wcf-send-btn:hover {
  background: var(--wcf-wa-dark-green);
}

#wcf-widget-container .wcf-send-btn:disabled {
  background: #b0bec5;
  cursor: not-allowed;
}

/* Link Pular Formulário */
.wcf-skip-wrap {
  text-align: center;
  padding-top: 2px;
}

.wcf-skip-link {
  font-size: 11.5px;
  color: #667781;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s;
}

.wcf-skip-link:hover {
  color: var(--wcf-wa-teal);
}

/* Animações Auxiliares */
@keyframes wcfFadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Adaptação para Celulares / Mobile */
.wcf-widget-container.wcf-moved .wcf-chat-window {
  position: fixed;
  bottom: 90px;
  right: 16px;
  left: auto;
}
@media (max-width: 480px) {
  .wcf-pos-right,
  .wcf-pos-left {
    bottom: 18px;
    right: 18px;
    left: auto;
  }

  .wcf-chat-window, .wcf-widget-container.wcf-moved .wcf-chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    z-index: 1000000;
  }
  .wcf-chat-header, .wcf-chat-footer { flex-shrink: 0; }
}
