/* ==========================================================================
   PV WhatsApp Chat & Leads Pro - Stylesheet (Ultra Lightweight & Modern UI)
   ========================================================================== */

:root {
  --pvw-green: #25D366;
  --pvw-green-dark: #128C7E;
  --pvw-green-header: #075E54;
  --pvw-bg-chat: #E5DDD5;
  --pvw-white: #ffffff;
  --pvw-dark: #111827;
  --pvw-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  --pvw-radius: 16px;
  --pvw-transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Contenedor Flotante Principal --- */
.pv-wa-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.pv-wa-wrapper.position-left {
  right: auto;
  left: 24px;
  align-items: flex-start;
}

/* --- Botón Flotante (FAB) --- */
.pv-wa-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pvw-green) 0%, var(--pvw-green-dark) 100%);
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--pvw-transition);
  border: none;
  outline: none;
  color: #ffffff;
  user-select: none;
}

.pv-wa-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(37, 211, 102, 0.6);
}

.pv-wa-btn svg {
  width: 34px;
  height: 34px;
  fill: #ffffff;
  transition: var(--pvw-transition);
}

/* Onda Radar Animada */
.pv-wa-pulse {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--pvw-green);
  opacity: 0.6;
  animation: pvWaRadar 2.2s infinite;
  z-index: -1;
  pointer-events: none;
}

@keyframes pvWaRadar {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Insignia de Notificación (Badge 1) */
.pv-wa-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #EF4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  animation: pvWaBadgeBounce 0.5s ease-out;
}

@keyframes pvWaBadgeBounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* --- Globo de Llamada (Callout Tooltip) --- */
.pv-wa-tooltip {
  background: #ffffff;
  color: var(--pvw-dark);
  padding: 12px 18px;
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  margin-bottom: 14px;
  max-width: 260px;
  font-size: 13.5px;
  line-height: 1.45;
  position: relative;
  display: none;
  animation: pvWaFadeUp 0.35s ease-out forwards;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.pv-wa-tooltip.is-visible {
  display: block;
}

.pv-wa-tooltip-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #9CA3AF;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 2px;
}

.pv-wa-tooltip-close:hover {
  color: var(--pvw-dark);
}

/* Flecha del Tooltip */
.pv-wa-tooltip::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 24px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  transform: rotate(45deg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.pv-wa-wrapper.position-left .pv-wa-tooltip::after {
  right: auto;
  left: 24px;
}

/* ==========================================================================
   VENTANA DE CHAT POPUP (ESTILO WHATSAPP APP)
   ========================================================================== */
.pv-wa-popup {
  width: 350px;
  background: #ffffff;
  border-radius: var(--pvw-radius);
  box-shadow: var(--pvw-shadow);
  margin-bottom: 16px;
  overflow: hidden;
  display: none;
  flex-direction: column;
  animation: pvWaPopupScale 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: bottom right;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.pv-wa-wrapper.position-left .pv-wa-popup {
  transform-origin: bottom left;
}

.pv-wa-popup.is-open {
  display: flex;
}

/* Cabecera del Chat */
.pv-wa-header {
  background: linear-gradient(135deg, var(--pvw-green-header) 0%, var(--pvw-green-dark) 100%);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pv-wa-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pv-wa-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  position: relative;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.pv-wa-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pv-wa-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: var(--pvw-green);
  border-radius: 50%;
  border: 2px solid #ffffff;
}

.pv-wa-header-info h4 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.pv-wa-header-info p {
  margin: 0;
  font-size: 11.5px;
  opacity: 0.85;
}

.pv-wa-close-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.8;
  transition: var(--pvw-transition);
}

.pv-wa-close-btn:hover {
  opacity: 1;
  transform: rotate(90deg);
}

/* Cuerpo del Chat */
.pv-wa-body {
  background-color: var(--pvw-bg-chat);
  background-image: radial-gradient(#d1d7db 1px, transparent 1px);
  background-size: 16px 16px;
  padding: 18px 16px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pv-wa-msg-bubble {
  background: #ffffff;
  padding: 12px 14px;
  border-radius: 0 12px 12px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--pvw-dark);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
  position: relative;
  align-self: flex-start;
  max-width: 88%;
}

.pv-wa-msg-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid #ffffff;
  border-left: 8px solid transparent;
}

.pv-wa-msg-time {
  display: block;
  text-align: right;
  font-size: 10px;
  color: #9CA3AF;
  margin-top: 4px;
}

/* Píldoras de Respuestas Rápidas (Quick Replies) */
.pv-wa-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.pv-wa-chip {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(18, 140, 126, 0.25);
  color: var(--pvw-green-dark);
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--pvw-transition);
  user-select: none;
}

.pv-wa-chip:hover {
  background: var(--pvw-green);
  color: #ffffff;
  border-color: var(--pvw-green);
  transform: translateY(-1px);
}

/* Pie / Entrada de Texto */
.pv-wa-footer {
  background: #F3F4F6;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #E5E7EB;
}

.pv-wa-input {
  flex-grow: 1;
  background: #ffffff;
  border: 1px solid #D1D5DB;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  resize: none;
  height: 36px;
  box-sizing: border-box;
}

.pv-wa-input:focus {
  border-color: var(--pvw-green);
}

.pv-wa-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--pvw-green);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--pvw-transition);
}

.pv-wa-send-btn:hover {
  background: var(--pvw-green-dark);
  transform: scale(1.06);
}

.pv-wa-send-btn svg {
  width: 18px;
  height: 18px;
  fill: #ffffff;
  transform: translateX(1px);
}

/* Animaciones */
@keyframes pvWaFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pvWaPopupScale {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

/* Responsive Móvil */
@media (max-width: 480px) {
  .pv-wa-wrapper {
    bottom: 16px;
    right: 16px;
  }

  .pv-wa-popup {
    width: calc(100vw - 32px);
    max-width: 360px;
  }
}
