/* =========================================================
   WHATSAPP INTELLIGENCE — FRONTEND CTA SYSTEM
   Colores: ver tokens.css (se carga antes que este archivo).
   Aquí solo hay estructura, forma y animación.

   Índice
   1. Contenedor
   2. Botón base
   3. Icono / logo
   4. Nube de mensaje
   5. Estilos (forma): 01 Classic … 11 Mobile bar
   6. Responsive y accesibilidad
   ========================================================= */

/* 1. Contenedor ------------------------------------------- */
.wi-whatsapp-widget {
	position: fixed;
	/* El área transparente del widget no debe bloquear clics del sitio. */
	pointer-events: none;
	right: 22px;
	bottom: 22px;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
	font-family: Inter, Arial, Helvetica, sans-serif;
}
.wi-whatsapp-widget.wi-position-left { left: 22px; right: auto; align-items: flex-start; }

/* 2. Botón base ------------------------------------------- */
.wi-whatsapp-button {
	position: relative;
	/* Reactivar interacción únicamente sobre el CTA. */
	pointer-events: auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 11px;
	min-height: 52px;
	padding: 12px 19px 12px 14px;
	box-sizing: border-box;
	border: 1px solid var(--wi-border);
	border-radius: 999px;
	background: var(--wi-bg);
	color: var(--wi-fg);
	text-decoration: none;
	font-size: 14px;
	font-weight: 700;
	line-height: 1;
	box-shadow: var(--wi-shadow);
	transition: transform .22s ease, box-shadow .22s ease, background .22s ease;
}
.wi-whatsapp-button:hover,
.wi-whatsapp-button:focus { color: var(--wi-fg); transform: translateY(-2px); box-shadow: var(--wi-shadow-hover); outline: none; }
.wi-whatsapp-label { white-space: nowrap; }

/* 3. Icono / logo ----------------------------------------- */
.wi-whatsapp-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 30px;
	width: 30px;
	height: 30px;
	box-sizing: border-box;
	border: 1px solid var(--wi-icon-border);
	border-radius: 50%;
	background: var(--wi-icon-bg);
	color: var(--wi-icon-fg);
	overflow: hidden;
}
.wi-whatsapp-icon svg { display: block; width: 21px; height: 21px; fill: currentColor; }
/* Logo propio subido desde Configuración: se muestra tal cual, sin círculo ni recolor */
.wi-whatsapp-icon.has-logo { border: 0; border-radius: 0; background: transparent; overflow: visible; }
.wi-whatsapp-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* 4. Nube de mensaje -------------------------------------- */
.wi-whatsapp-bubble {
	position: relative;
	/* La nube solo captura clics cuando está visible. */
	pointer-events: none;
	max-width: 285px;
	padding: 13px 38px 13px 15px;
	border: 1px solid var(--wi-bubble-border);
	border-radius: 15px;
	background: var(--wi-bubble-bg);
	color: var(--wi-bubble-fg);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.45;
	box-shadow: 0 16px 42px rgba(0,0,0,.13);
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px) scale(.97);
	transform-origin: bottom right;
	transition: opacity .25s ease, transform .25s ease, visibility .25s ease;
}
.wi-whatsapp-widget.wi-position-left .wi-whatsapp-bubble { transform-origin: bottom left; }
.wi-whatsapp-bubble:after {
	content: "";
	position: absolute;
	right: 20px;
	bottom: -7px;
	width: 13px;
	height: 13px;
	background: var(--wi-bubble-bg);
	border-right: 1px solid var(--wi-bubble-border);
	border-bottom: 1px solid var(--wi-bubble-border);
	transform: rotate(45deg);
}
.wi-whatsapp-widget.wi-position-left .wi-whatsapp-bubble:after { left: 20px; right: auto; }
.wi-whatsapp-bubble.is-visible { pointer-events: auto; opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.wi-whatsapp-bubble-close { position: absolute; top: 7px; right: 8px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #999; cursor: pointer; font-size: 18px; line-height: 20px; }
.wi-whatsapp-bubble-close:hover { background: #f2f2f2; color: #222; }

/* 5. Estilos (forma) --------------------------------------- */
/* 01 Classic: sin reglas propias, es la base */

/* 02 Minimal */
.wi-style-minimal .wi-whatsapp-button { width: 58px; height: 58px; min-height: 58px; padding: 0; border-radius: 50%; }
.wi-style-minimal .wi-whatsapp-label { display: none; }
.wi-style-minimal .wi-whatsapp-icon { flex-basis: 38px; width: 38px; height: 38px; }
.wi-style-minimal .wi-whatsapp-icon svg { width: 26px; height: 26px; }

/* 03 Premium, 04 Glass, 05 Icon+text, 08 Personalized */
.wi-style-glass .wi-whatsapp-button { backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

/* 06 Vertical */
.wi-style-vertical { bottom: 35px; }
.wi-style-vertical .wi-whatsapp-button { width: 58px; min-height: 132px; padding: 12px 0; flex-direction: column; border-radius: 29px; gap: 8px; }
.wi-style-vertical .wi-whatsapp-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; }

/* 07 Pulse */
.wi-style-pulse .wi-whatsapp-button { width: 64px; height: 64px; min-height: 64px; padding: 0; border-radius: 50%; animation: wiPulse 2.4s infinite; }
.wi-style-pulse .wi-whatsapp-label { display: none; }
.wi-style-pulse .wi-whatsapp-icon { flex-basis: 42px; width: 42px; height: 42px; }
.wi-style-pulse .wi-whatsapp-icon svg { width: 28px; height: 28px; }
@keyframes wiPulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(var(--wi-accent-rgb), .32), 0 10px 30px rgba(var(--wi-accent-rgb), .20); }
	50%      { box-shadow: 0 0 0 11px rgba(var(--wi-accent-rgb), 0), 0 14px 35px rgba(var(--wi-accent-rgb), .28); }
}

/* 09 Sidebar */
.wi-style-sidebar { right: 0; bottom: 110px; }
.wi-style-sidebar .wi-whatsapp-button { min-height: 48px; padding: 11px 16px 11px 12px; border-radius: 12px 0 0 12px; writing-mode: vertical-rl; flex-direction: row; }
.wi-style-sidebar .wi-whatsapp-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; }
.wi-style-sidebar .wi-whatsapp-icon { flex-basis: 28px; width: 28px; height: 28px; }

/* 10 Compact (la nube oscura viene de tokens.css) */
.wi-style-compact .wi-whatsapp-button { width: 52px; height: 52px; min-height: 52px; padding: 0; border-radius: 50%; }
.wi-style-compact .wi-whatsapp-label { display: none; }
.wi-style-compact .wi-whatsapp-bubble { margin-bottom: 2px; box-shadow: 0 15px 35px rgba(0,0,0,.22); }
.wi-style-compact .wi-whatsapp-bubble-close { color: #aaa; }

/* 11 Mobile bar */
.wi-style-mobile-bar { right: 20px; left: 20px; bottom: 15px; align-items: stretch; }
.wi-style-mobile-bar .wi-whatsapp-button { width: 100%; min-height: 54px; justify-content: center; border-radius: 18px; }
.wi-style-mobile-bar .wi-whatsapp-bubble { align-self: flex-end; }

/* 6. Responsive y accesibilidad ---------------------------- */
@media (max-width: 600px) {
	.wi-whatsapp-widget { right: 14px; bottom: 14px; }
	.wi-whatsapp-widget.wi-position-left { left: 14px; right: auto; }
	.wi-whatsapp-button { min-height: 50px; padding: 11px 16px 11px 12px; font-size: 13px; }
	.wi-whatsapp-bubble { max-width: min(285px, calc(100vw - 34px)); font-size: 12px; }
	.wi-style-sidebar { right: 0; left: auto; bottom: 105px; }
	.wi-style-mobile-bar { left: 12px; right: 12px; bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
	.wi-whatsapp-button, .wi-whatsapp-bubble { transition: none; }
	.wi-style-pulse .wi-whatsapp-button { animation: none; }
}
