/* ═══════════════════════════════════════════════════════════════
   Floating Buttons Pro – Frontend CSS v2.0
   ═══════════════════════════════════════════════════════════════ */

/* ── Wrapper ─────────────────────────────────────────────────── */
.fbpro-wrapper {
  position: fixed;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ── Base button ─────────────────────────────────────────────── */
.fbpro-btn {
  position: relative;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #fff !important;
  text-decoration: none !important;
  cursor: pointer;
  overflow: visible;
  border: none !important;
  outline: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              filter 0.25s ease !important;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

/* SVG e imagen: tamaño y color vienen del CSS dinámico por data-btn-id */
.fbpro-btn svg,
.fbpro-btn .fbpro-btn__img {
  flex-shrink: 0;
  pointer-events: none;
}
.fbpro-btn .fbpro-btn__img {
  display: block;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}

/* ── Tooltip ─────────────────────────────────────────────────── */
.fbpro-tooltip {
  position: absolute;
  right: calc(100% + 10px);
  left: auto;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: 12px;
  font-family: sans-serif;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
/* En wrapper izquierdo, tooltip va a la derecha */
.fbpro-wrapper--left .fbpro-tooltip {
  right: auto;
  left: calc(100% + 10px);
}
.fbpro-btn:hover .fbpro-tooltip,
.fbpro-btn:focus-visible .fbpro-tooltip {
  opacity: 1;
}

/* ── Pulse ring ──────────────────────────────────────────────── */
.fbpro-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: fbpro-pulse 2.8s ease-out infinite;
  z-index: -1;
  /* display y background vienen del CSS dinámico por data-btn-id */
}

/* Stagger para el segundo botón en adelante (manejado por delay en CSS dinámico) */

@keyframes fbpro-pulse {
  0%   { transform: scale(1);   opacity: .5; }
  60%  { transform: scale(1.8); opacity: 0;  }
  100% { transform: scale(1.8); opacity: 0;  }
}

/* ── Animación de entrada ────────────────────────────────────── */
@keyframes fbpro-enter {
  from { opacity: 0; transform: scale(0.4) translateY(20px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Hover pulse keyframe ────────────────────────────────────── */
@keyframes fbpro-hover-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* ── Active ──────────────────────────────────────────────────── */
.fbpro-btn:active {
  transform: scale(0.93) !important;
}

/* ═══════════════════════════════════════════════════════════════
   POPUP OVERLAY
   ═══════════════════════════════════════════════════════════════ */
.fbpro-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.fbpro-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

.fbpro-popup {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 40px 32px 32px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.92) translateY(16px);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.fbpro-overlay.is-open .fbpro-popup {
  transform: scale(1) translateY(0);
}

/* ── Reset base: neutraliza cualquier estilo de tema (Divi, Elementor, etc.) ── */
.fbpro-popup__close,
.fbpro-bubble__close {
  all: unset;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  border-radius: 50% !important;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-family: inherit !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  transition: background 0.2s, color 0.2s, border-color 0.2s !important;
}

.fbpro-popup__close {
  position: absolute !important;
  top: 14px !important;
  right: 14px !important;
  width: 34px !important;
  height: 34px !important;
  background: #f0f0f0 !important;
  color: #555 !important;
  border: 1px solid transparent !important;
}
.fbpro-popup__close:hover { background: #e0e0e0 !important; color: #111 !important; }

.fbpro-popup__close svg,
.fbpro-bubble__close svg {
  fill: none !important;
  stroke: currentColor !important;
  pointer-events: none;
  display: block;
}
.fbpro-popup__close svg { width: 20px !important; height: 20px !important; }
.fbpro-bubble__close svg { width: 14px !important; height: 14px !important; }

.fbpro-popup__body { margin-top: 4px; }

/* ── Reduce motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .fbpro-btn,
  .fbpro-btn::before,
  .fbpro-overlay,
  .fbpro-popup { animation: none !important; transition: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   BUTTON WRAPPER (bocadillo positioning context)
   ═══════════════════════════════════════════════════════════════ */
.fbpro-btn-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ═══════════════════════════════════════════════════════════════
   BOCADILLO / CHAT BUBBLE
   ═══════════════════════════════════════════════════════════════ */

/* ── Base ── */
.fbpro-bubble {
  position: absolute;
  pointer-events: auto;
  z-index: 99998;
  box-sizing: border-box;
  font-family: sans-serif;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.fbpro-bubble.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ── Posición ── */
.fbpro-bubble--left {
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
}
.fbpro-bubble--right {
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
}
.fbpro-bubble--top {
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%);
}
.fbpro-bubble--bottom {
  top: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%);
}

/* ── Alineación automática para top/bottom según borde del viewport ── */
.fbpro-bubble--top.fbpro-bubble--align-right,
.fbpro-bubble--bottom.fbpro-bubble--align-right {
  left: auto;
  right: 0;
  transform: none;
}
.fbpro-bubble--top.fbpro-bubble--align-left,
.fbpro-bubble--bottom.fbpro-bubble--align-left {
  left: 0;
  right: auto;
  transform: none;
}

/* ── Contenido ── */
.fbpro-bubble__title {
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
}
.fbpro-bubble__message {
  line-height: 1.45;
  margin: 0;
}

/* ── Botón cerrar ── */
.fbpro-bubble__close {
  position: absolute !important;
  top: -8px !important;
  right: -8px !important;
  width: 22px !important;
  height: 22px !important;
  background: #fff !important;
  color: #6b7280 !important;
  border: 1px solid #e5e7eb !important;
  z-index: 2 !important;
}
.fbpro-bubble__close:hover { color: #111 !important; border-color: #9ca3af !important; }

/* ── Flechita ── */
.fbpro-bubble__arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  background: inherit;
  border: inherit;
  transform: rotate(45deg);
}
.fbpro-bubble--left .fbpro-bubble__arrow {
  right: -6px;
  top: 50%;
  margin-top: -5px;
  border-left: none;
  border-bottom: none;
}
.fbpro-bubble--right .fbpro-bubble__arrow {
  left: -6px;
  top: 50%;
  margin-top: -5px;
  border-right: none;
  border-top: none;
}
.fbpro-bubble--top .fbpro-bubble__arrow {
  bottom: -6px;
  left: 50%;
  margin-left: -5px;
  border-top: none;
  border-left: none;
}
.fbpro-bubble--bottom .fbpro-bubble__arrow {
  top: -6px;
  left: 50%;
  margin-left: -5px;
  border-bottom: none;
  border-right: none;
}

/* Flecha anclada al lado derecho del bubble */
.fbpro-bubble--top.fbpro-bubble--align-right .fbpro-bubble__arrow,
.fbpro-bubble--bottom.fbpro-bubble--align-right .fbpro-bubble__arrow {
  left: auto;
  right: 20px;
  margin-left: 0;
}

/* Flecha anclada al lado izquierdo del bubble */
.fbpro-bubble--top.fbpro-bubble--align-left .fbpro-bubble__arrow,
.fbpro-bubble--bottom.fbpro-bubble--align-left .fbpro-bubble__arrow {
  left: 20px;
  margin-left: 0;
}

/* ── Animaciones ── */
.fbpro-bubble--anim-fade.is-visible {
  animation: fbpro-bubble-fade 0.3s ease;
}
.fbpro-bubble--anim-slide.is-visible {
  animation: fbpro-bubble-slide 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fbpro-bubble--right.fbpro-bubble--anim-slide.is-visible {
  animation-name: fbpro-bubble-slide-left;
}
.fbpro-bubble--anim-bounce.is-visible {
  animation: fbpro-bubble-bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fbpro-bubble-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fbpro-bubble-slide {
  from { opacity: 0; transform: translateY(-50%) translateX(20px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}
@keyframes fbpro-bubble-slide-left {
  from { opacity: 0; transform: translateY(-50%) translateX(-20px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}
@keyframes fbpro-bubble-bounce {
  0%   { opacity: 0; transform: translateY(-50%) scale(0.6); }
  60%  { opacity: 1; transform: translateY(-50%) scale(1.05); }
  100% { opacity: 1; transform: translateY(-50%) scale(1); }
}

/* ── Móvil: protección contra desbordamiento ── */
@media (max-width: 480px) {
  .fbpro-bubble { max-width: calc(100vw - 40px) !important; }
}

/* ── Reduce motion ── */
@media (prefers-reduced-motion: reduce) {
  .fbpro-bubble { animation: none !important; transition: opacity 0.2s !important; }
}
