/* ==========================================================
   Chatbot WhatsApp WooCommerce - Pedras Preciosas (Frontend)
   Estética Luxuosa, Moderna e Responsiva
========================================================== */

:root {
  --pwb-primary: #0c7a56;
  --pwb-primary-dark: #075239;
  --pwb-accent: #d4af37;
  --pwb-accent-light: #f3e5ab;
  --pwb-whatsapp: #25D366;
  --pwb-whatsapp-dark: #128C7E;
  --pwb-bg-chat: #efeae2;
  --pwb-bubble-bot: #ffffff;
  --pwb-bubble-user: #d9fdd3;
  --pwb-text-main: #111b21;
  --pwb-text-muted: #667781;
  --pwb-shadow-card: 0 12px 36px rgba(0, 0, 0, 0.22);
  --pwb-radius: 16px;
  --pwb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Container Global */
.pwb-widget-wrap {
  position: fixed;
  bottom: 24px;
  z-index: 999999;
  font-family: var(--pwb-font);
  box-sizing: border-box;
}

.pwb-widget-wrap *,
.pwb-widget-wrap *::before,
.pwb-widget-wrap *::after {
  box-sizing: border-box;
}

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

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

/* Balão de Convite / Callout Inicial */
.pwb-callout-bubble {
  position: absolute;
  bottom: 75px;
  background: #ffffff;
  color: var(--pwb-text-main);
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  width: 270px;
  animation: pwbFadeSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 4px solid var(--pwb-accent);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.pwb-pos-right .pwb-callout-bubble {
  right: 0;
}
.pwb-pos-left .pwb-callout-bubble {
  left: 0;
}

.pwb-callout-bubble:hover {
  transform: translateY(-2px);
}

.pwb-callout-text strong {
  display: block;
  font-size: 13px;
  color: var(--pwb-primary);
  margin-bottom: 2px;
}

.pwb-callout-text span {
  font-size: 13px;
  line-height: 1.35;
  color: #333333;
}

.pwb-callout-close {
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
}
.pwb-callout-close:hover {
  color: #333;
}

/* Botão Flutuante Estilo WhatsApp */
.pwb-launcher {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pwb-whatsapp), #1ebe5d);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  outline: none;
}

.pwb-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 26px rgba(37, 211, 102, 0.6);
}

.pwb-launcher .pwb-icon-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

.pwb-launcher .pwb-icon-close {
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

/* Animação do anel de pulsação */
.pwb-pulse-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--pwb-whatsapp);
  animation: pwbPulse 2s infinite;
  pointer-events: none;
  opacity: 0.6;
}

.pwb-online-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  background-color: #25d366;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

/* Estado Aberto do Launcher */
.pwb-widget-wrap.pwb-is-open .pwb-launcher {
  background: #333333;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}
.pwb-widget-wrap.pwb-is-open .pwb-icon-whatsapp {
  display: none;
}
.pwb-widget-wrap.pwb-is-open .pwb-icon-close {
  display: flex;
}
.pwb-widget-wrap.pwb-is-open .pwb-pulse-ring {
  display: none;
}
.pwb-widget-wrap.pwb-is-open .pwb-callout-bubble {
  display: none !important;
}

/* Janela do Chatbot */
.pwb-chat-box {
  position: absolute;
  bottom: 76px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 570px;
  max-height: calc(100vh - 110px);
  background: var(--pwb-bg-chat);
  border-radius: var(--pwb-radius);
  box-shadow: var(--pwb-shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s;
}

.pwb-pos-right .pwb-chat-box {
  right: 0;
  transform-origin: bottom right;
}
.pwb-pos-left .pwb-chat-box {
  left: 0;
  transform-origin: bottom left;
}

.pwb-widget-wrap.pwb-is-open .pwb-chat-box {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Cabeçalho do Chat */
.pwb-chat-header {
  background: linear-gradient(135deg, var(--pwb-primary), var(--pwb-primary-dark));
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--pwb-accent);
}

.pwb-attendant-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwb-avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--pwb-accent);
  overflow: visible;
}

.pwb-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  background: #ffffff;
  display: block;
}

.pwb-status-indicator {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 11px;
  height: 11px;
  background-color: #25d366;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.pwb-details .pwb-name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.3px;
}

.pwb-details .pwb-role {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--pwb-accent-light);
  font-weight: 400;
}

.pwb-status-label {
  color: #a8f5c9;
  font-weight: 500;
}

.pwb-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pwb-action-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.pwb-action-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.05);
}

/* Corpo do Chat */
.pwb-chat-body {
  flex: 1;
  padding: 16px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--pwb-bg-chat);
  background-image: radial-gradient(#d3cbbd 0.8px, transparent 0.8px);
  background-size: 14px 14px;
  scroll-behavior: smooth;
}

.pwb-date-badge {
  align-self: center;
  background: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  color: var(--pwb-text-muted);
  padding: 4px 10px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  margin-bottom: 4px;
}

/* Mensagens */
.pwb-msg-row {
  display: flex;
  width: 100%;
}
.pwb-msg-row.pwb-msg-bot {
  justify-content: flex-start;
}
.pwb-msg-row.pwb-msg-user {
  justify-content: flex-end;
}

.pwb-msg-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--pwb-text-main);
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  word-break: break-word;
}

.pwb-msg-bot .pwb-msg-bubble {
  background: var(--pwb-bubble-bot);
  border-top-left-radius: 3px;
}

.pwb-msg-user .pwb-msg-bubble {
  background: var(--pwb-bubble-user);
  border-top-right-radius: 3px;
}

.pwb-msg-time {
  display: block;
  font-size: 10px;
  color: var(--pwb-text-muted);
  text-align: right;
  margin-top: 3px;
}

/* Card de Produto no Chat */
.pwb-product-card {
  background: #ffffff;
  border: 1px solid #e1d7c3;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.pwb-product-thumb {
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: #f8f6f0;
  display: block;
}

.pwb-product-info {
  padding: 10px;
}

.pwb-product-title {
  font-weight: 600;
  font-size: 13px;
  color: #111;
  margin: 0 0 4px;
  line-height: 1.3;
}

.pwb-product-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--pwb-primary);
  margin: 0;
}

/* Botões de Resposta Rápida (Quick Replies) */
.pwb-quick-replies {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.pwb-quick-btn {
  background: #ffffff;
  color: var(--pwb-primary);
  border: 1.5px solid var(--pwb-primary);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pwb-quick-btn:hover {
  background: var(--pwb-primary);
  color: #ffffff;
  transform: translateX(2px);
}

/* Card Resumo Final / WhatsApp CTA */
.pwb-summary-card {
  background: #ffffff;
  border: 1.5px solid var(--pwb-accent);
  border-radius: 12px;
  padding: 14px;
  margin-top: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

.pwb-summary-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--pwb-primary-dark);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pwb-summary-list {
  font-size: 12px;
  color: #444;
  margin: 0 0 12px;
  line-height: 1.5;
}

.pwb-summary-list strong {
  color: #111;
}

.pwb-whatsapp-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--pwb-whatsapp), #1ebb5d);
  color: #ffffff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  border: none;
  width: 100%;
}

.pwb-whatsapp-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.55);
  color: #ffffff;
}

/* Indicador de Digitação (Typing Indicator) */
.pwb-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--pwb-bubble-bot);
  border-radius: 12px;
  width: fit-content;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.pwb-typing-dot {
  width: 6px;
  height: 6px;
  background: #8e8e93;
  border-radius: 50%;
  animation: pwbTyping 1.4s infinite ease-in-out;
}
.pwb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.pwb-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Rodapé / Input de Digitação */
.pwb-chat-footer {
  background: #f0f2f5;
  padding: 10px 12px;
  border-top: 1px solid #e1e3e6;
}

.pwb-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pwb-text-field {
  flex: 1;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  color: #111;
}

.pwb-text-field:focus {
  border-color: var(--pwb-primary);
  box-shadow: 0 0 0 2px rgba(12, 122, 86, 0.15);
}

.pwb-submit-btn {
  background: var(--pwb-primary);
  color: #ffffff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.pwb-submit-btn:hover {
  background: var(--pwb-primary-dark);
  transform: scale(1.06);
}

.pwb-submit-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.pwb-footer-brand {
  font-size: 11px;
  color: #888;
  text-align: center;
  margin-top: 6px;
}

.pwb-footer-brand a {
  color: var(--pwb-primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.pwb-footer-brand a:hover {
  color: var(--pwb-accent);
  text-decoration: underline;
}

/* Animações */
@keyframes pwbPulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

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

@keyframes pwbTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Responsividade Mobile */
@media (max-width: 480px) {
  .pwb-widget-wrap {
    bottom: 16px;
  }
  .pwb-widget-wrap.pwb-pos-right {
    right: 16px;
  }
  .pwb-widget-wrap.pwb-pos-left {
    left: 16px;
  }
  .pwb-chat-box {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    z-index: 1000000;
  }
  .pwb-callout-bubble {
    width: calc(100vw - 32px);
    bottom: 85px;
  }
}
