/**
 * WhatsApp Button for Elementor — maquetación estructural.
 * El color, la tipografía, el borde, la sombra y el tamaño se controlan desde
 * Elementor (widget) o desde la página de ajustes (modo global). Aquí solo va
 * lo imprescindible para la posición, el globo (callout) y el badge.
 */

/* Contenedor fijo: posiciona el conjunto (globo + botón). */
.ewb-whatsapp-wrap {
	position: fixed;
	z-index: 9999;
	display: flex;
	flex-direction: column;
	gap: 12px;
	box-sizing: border-box;
	pointer-events: none; /* el hueco entre globo y botón no bloquea clics */

	/*
	 * Para que se retire y vuelva sin dar un salto cuando se abre una capa del
	 * tema (el cajón del carrito, la vista rápida, el menú móvil). Qué clases lo
	 * esconden lo decide PHP, que las imprime en línea: así la lista se puede
	 * cambiar con el filtro `ewb_capas_que_lo_esconden` sin tocar esta hoja.
	 */
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.ewb-whatsapp-wrap > * {
	pointer-events: auto;
}

/* Posición en las cuatro esquinas, con offsets configurables. */
.ewb-whatsapp-wrap--bottom-right {
	bottom: var(--ewb-offset-y, 24px);
	right: var(--ewb-offset-x, 24px);
	align-items: flex-end;
}

.ewb-whatsapp-wrap--bottom-left {
	bottom: var(--ewb-offset-y, 24px);
	left: var(--ewb-offset-x, 24px);
	align-items: flex-start;
}

/* En las posiciones superiores el botón queda arriba y el globo debajo. */
.ewb-whatsapp-wrap--top-right {
	top: var(--ewb-offset-y, 24px);
	right: var(--ewb-offset-x, 24px);
	align-items: flex-end;
	flex-direction: column-reverse;
}

.ewb-whatsapp-wrap--top-left {
	top: var(--ewb-offset-y, 24px);
	left: var(--ewb-offset-x, 24px);
	align-items: flex-start;
	flex-direction: column-reverse;
}

/* Botón redondo. */
.ewb-whatsapp {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	gap: 10px;
	padding: 16px;
	text-decoration: none;
	line-height: 1;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.ewb-whatsapp:hover,
.ewb-whatsapp:focus {
	text-decoration: none;
	transform: translateY(-2px);
}

.ewb-whatsapp:focus-visible {
	outline: 3px solid rgba(0, 0, 0, 0.15);
	outline-offset: 3px;
}

.ewb-whatsapp__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
}

.ewb-whatsapp__icon svg {
	display: block;
	width: 28px;
	height: 28px;
	fill: currentColor;
}

.ewb-whatsapp__label {
	white-space: nowrap;
}

/* El botón solo-icono mantiene proporción cuadrada para un círculo perfecto. */
.ewb-whatsapp--icon-only {
	aspect-ratio: 1 / 1;
}

/* Formas. El radio de "rounded" se sobrescribe con el control correspondiente. */
.ewb-whatsapp--round {
	border-radius: 50%;
}

.ewb-whatsapp--rounded {
	border-radius: 14px;
}

.ewb-whatsapp--square {
	border-radius: 0;
}

/* Badge de notificación (p. ej. "1"). */
.ewb-whatsapp__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 999px;
	background-color: #ff3b30;
	color: #ffffff;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	box-shadow: 0 0 0 2px #ffffff;
}

/* Globo (callout) con el mensaje. */
.ewb-whatsapp__bubble {
	position: relative;
	max-width: 240px;
	background-color: var(--ewb-bubble-bg, #ffffff);
	color: #1f2937;
	padding: 10px 14px;
	border-radius: 14px;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
	font-size: 14px;
	line-height: 1.35;
	animation: ewb-bubble-in 0.35s ease both;
}

/* Cola del globo: triángulo que apunta hacia el botón. */
.ewb-whatsapp__bubble::after {
	content: "";
	position: absolute;
	width: 0;
	height: 0;
	border: 8px solid transparent;
}

/* Globo encima (posiciones inferiores): cola hacia abajo. */
.ewb-whatsapp-wrap--bottom-right .ewb-whatsapp__bubble::after,
.ewb-whatsapp-wrap--bottom-left .ewb-whatsapp__bubble::after {
	top: 100%;
	border-bottom: 0;
	border-top-color: var(--ewb-bubble-bg, #ffffff);
}

/* Globo debajo (posiciones superiores): cola hacia arriba. */
.ewb-whatsapp-wrap--top-right .ewb-whatsapp__bubble::after,
.ewb-whatsapp-wrap--top-left .ewb-whatsapp__bubble::after {
	bottom: 100%;
	border-top: 0;
	border-bottom-color: var(--ewb-bubble-bg, #ffffff);
}

/* Cola alineada al lado del botón. */
.ewb-whatsapp-wrap--bottom-right .ewb-whatsapp__bubble::after,
.ewb-whatsapp-wrap--top-right .ewb-whatsapp__bubble::after {
	right: 22px;
}

.ewb-whatsapp-wrap--bottom-left .ewb-whatsapp__bubble::after,
.ewb-whatsapp-wrap--top-left .ewb-whatsapp__bubble::after {
	left: 22px;
}

@keyframes ewb-bubble-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* Móvil: ocultar el texto (globo o en línea). */
@media (max-width: 767px) {
	.ewb-whatsapp--hide-label-mobile .ewb-whatsapp__bubble {
		display: none;
	}

	.ewb-whatsapp--hide-label-mobile .ewb-whatsapp__label {
		display: none;
	}

	.ewb-whatsapp--hide-label-mobile .ewb-whatsapp--has-label {
		gap: 0;
		aspect-ratio: 1 / 1;
	}

	/* Ocultar todo el conjunto en móvil (modo global). */
	.ewb-whatsapp--hide-mobile {
		display: none !important;
	}
}

/* Ocultar todo el conjunto en escritorio (modo global). */
@media (min-width: 768px) {
	.ewb-whatsapp--hide-desktop {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ewb-whatsapp-wrap,
	.ewb-whatsapp {
		transition: none;
	}

	.ewb-whatsapp:hover,
	.ewb-whatsapp:focus {
		transform: none;
	}

	.ewb-whatsapp__bubble {
		animation: none;
	}
}

/* Aviso mostrado únicamente en el editor de Elementor cuando falta el número. */
.ewb-whatsapp-notice {
	padding: 12px 16px;
	border: 1px dashed #c3c4c7;
	border-radius: 6px;
	background: #f6f7f7;
	color: #50575e;
	font-size: 13px;
	line-height: 1.5;
}
