/* =============================================
   WhatsApp Floating Widget
   ============================================= */

/* Container principal */
.wa-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  font-family: 'Segoe UI', Arial, sans-serif;
}

/* ── Botón flotante ── */
.wa-fab {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #25d366;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.22s ease,
              box-shadow 0.25s ease;
  position: relative;
  flex-shrink: 0;
}

.wa-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 10px 28px rgba(37, 211, 102, 0.55);
}

/* FAB desaparece cuando el chat está abierto */
.wa-widget.active .wa-fab {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

.wa-fab svg {
  width: 34px;
  height: 34px;
  fill: #fff;
}

/* Pulso animado */
.wa-fab::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.25);
  animation: wa-pulse 2s ease-out infinite;
  pointer-events: none;
}

@keyframes wa-pulse {
  0%   { transform: scale(0.9); opacity: 1; }
  70%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(0.9); opacity: 0; }
}

/* ── Animación de rebote cada 15 s ── */
@keyframes wa-bounce {
  0%   { transform: translateY(0)    scale(1); }
  20%  { transform: translateY(-13px) scale(1.06); }
  40%  { transform: translateY(-4px)  scale(1); }
  60%  { transform: translateY(-8px)  scale(1.03); }
  80%  { transform: translateY(-2px)  scale(1); }
  100% { transform: translateY(0)    scale(1); }
}

.wa-fab.wa-bounce {
  animation: wa-bounce 0.85s ease;
}

/* Evitar conflicto hover + bounce */
.wa-fab.wa-bounce:hover {
  animation: wa-bounce 0.85s ease;
}

/* ── Tooltip hover ── */
.wa-tooltip {
  position: absolute;
  bottom: 10px;
  right: 76px;
  background: #fff;
  color: #111;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  padding: 9px 16px;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
  pointer-events: none;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.wa-tooltip::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  border: 8px solid transparent;
  border-left-color: #fff;
  border-right-width: 0;
}

.wa-widget:hover .wa-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* Ocultar tooltip cuando el chat está abierto */
.wa-widget.active .wa-tooltip {
  opacity: 0 !important;
  transform: translateX(8px) !important;
  pointer-events: none;
}

/* ── Chat panel: se expande desde la esquina del FAB ── */
.wa-chat {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 320px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.20);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Origen en la esquina inferior derecha = misma posición que el FAB */
  transform-origin: bottom right;
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              opacity 0.24s ease;
}

.wa-widget.active .wa-chat {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Header del chat */
.wa-chat-header {
  background: #075e54;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.wa-chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.wa-chat-avatar svg {
  width: 26px;
  height: 26px;
  fill: #fff;
}

.wa-chat-info {
  flex: 1;
}

.wa-chat-name {
  display: block;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.wa-chat-status {
  display: block;
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  margin-top: 2px;
}

.wa-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
  flex-shrink: 0;
}

.wa-chat-close:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.wa-chat-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

/* Cuerpo del chat */
.wa-chat-body {
  background: #ece5dd url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' opacity='.04'%3E%3Cpath d='M0 0h80v80H0z' fill='none'/%3E%3C/svg%3E") repeat;
  padding: 18px 14px;
  min-height: 120px;
}

/* Burbuja de mensaje */
.wa-bubble {
  background: #fff;
  border-radius: 0 12px 12px 12px;
  padding: 12px 14px 22px;
  max-width: 90%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  position: relative;
  font-size: 14px;
  line-height: 1.55;
  color: #111;
}

.wa-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  border: 8px solid transparent;
  border-top-color: #fff;
  border-left-width: 0;
}

.wa-bubble-time {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 11px;
  color: #999;
}

/* Footer del chat */
.wa-chat-footer {
  padding: 12px 14px 16px;
  background: #f0f0f0;
}

.wa-open-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 13px 0;
  background: #25d366;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border-radius: 30px;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.15s ease;
  box-shadow: 0 3px 10px rgba(37, 211, 102, 0.35);
}

.wa-open-btn:hover {
  background: #1ebe5d;
  transform: translateY(-1px);
  color: #fff;
  text-decoration: none;
}

.wa-open-btn svg {
  width: 20px;
  height: 20px;
  fill: #fff;
  flex-shrink: 0;
}

/* ── Responsive mobile ── */
@media (max-width: 480px) {
  .wa-widget {
    bottom: 18px;
    right: 16px;
  }

  .wa-chat {
    width: calc(100vw - 32px);
    right: 0;
  }

  .wa-tooltip {
    font-size: 12.5px;
    padding: 8px 13px;
    right: 72px;
  }
}
