/*
 * WhatsApp Lead Bubble — estilos del frontend.
 * Los colores vienen de variables CSS (--wlb-primary / --wlb-header)
 * inyectadas por PHP según los ajustes del administrador.
 */

#wlb-root,
#wlb-root * {
	box-sizing: border-box;
}

.wlb-root {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/*
 * Botón flotante circular.
 * `all: unset` + !important en cada propiedad: muchos temas y los
 * estilos globales de Elementor (Site Settings → Buttons) aplican su
 * propio color de acento y forma a TODOS los elementos <button> del
 * sitio. Sin esto, el botón hereda ese estilo del tema (típicamente
 * cuadrado/rectangular y del color de acento del sitio) en vez de ser
 * un círculo con los colores nativos de WhatsApp.
 */
.wlb-toggle {
	all: unset !important;
	box-sizing: border-box !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 60px !important;
	height: 60px !important;
	min-width: 60px !important;
	min-height: 60px !important;
	border-radius: 50% !important;
	background-color: var(--wlb-primary, #25D366) !important;
	color: #fff !important;
	cursor: pointer !important;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important;
	transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.wlb-toggle:hover,
.wlb-toggle:focus-visible {
	transform: scale(1.06);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3) !important;
}

.wlb-toggle:focus-visible {
	outline: 2px solid #fff !important;
	outline-offset: 2px !important;
}

.wlb-icon-whatsapp {
	width: 30px;
	height: 30px;
}

/* Icono cambia a "cerrar" cuando el panel está abierto, vía estado en JS */
.wlb-root.is-open .wlb-toggle .wlb-icon-whatsapp {
	display: none;
}

.wlb-root.is-open .wlb-toggle::after {
	content: "\00d7";
	font-size: 30px;
	line-height: 1;
}

/* Panel de chat */
.wlb-panel {
	position: fixed;
	right: 16px;
	bottom: 88px;
	left: 16px;
	width: auto;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	opacity: 0;
	transform: translateY(12px);
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.wlb-root.is-open .wlb-panel {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

@media (min-width: 480px) {
	.wlb-panel {
		left: auto;
		width: 340px;
	}
}

.wlb-panel__header {
	background: var(--wlb-header, #075E54);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
}

.wlb-panel__title {
	margin: 0;
	font-weight: 600;
	font-size: 15px;
}

.wlb-panel__subtitle {
	margin: 2px 0 0;
	font-size: 12px;
	opacity: 0.85;
}

.wlb-panel__close {
	all: unset !important;
	background: transparent !important;
	color: #fff !important;
	font-size: 22px !important;
	line-height: 1 !important;
	cursor: pointer !important;
	padding: 0 4px !important;
}

.wlb-panel__body {
	padding: 16px;
	overflow-y: auto;
}

.wlb-welcome {
	background: #f0f2f5;
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 14px;
	line-height: 1.4;
	margin: 0 0 16px;
	color: #222;
}

.wlb-field {
	margin-bottom: 14px;
}

.wlb-field label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 4px;
	color: #333;
}

.wlb-field input,
.wlb-field select,
.wlb-field textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #ccc;
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	resize: vertical;
}

.wlb-field input:focus,
.wlb-field select:focus,
.wlb-field textarea:focus {
	outline: none;
	border-color: var(--wlb-primary, #25D366);
	box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.25);
}

/* Estado de error de validación (las casillas de "opción múltiple"
   se marcan aparte, en su contenedor — ver .wlb-checkbox-group) */
.wlb-field.has-error input:not([type="checkbox"]),
.wlb-field.has-error select,
.wlb-field.has-error textarea {
	border-color: #d63638;
	box-shadow: 0 0 0 2px rgba(214, 54, 56, 0.15);
}

.wlb-error-text {
	display: none;
	color: #d63638;
	font-size: 12px;
	margin-top: 4px;
}

.wlb-field.has-error .wlb-error-text {
	display: block;
}

.wlb-form-warning {
	background: #fcebea;
	color: #8a1f1f;
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 13px;
	margin: 0 0 12px;
}

.wlb-submit {
	all: unset !important;
	box-sizing: border-box !important;
	display: block !important;
	width: 100% !important;
	text-align: center !important;
	background-color: var(--wlb-primary, #25D366) !important;
	color: #fff !important;
	border-radius: 10px !important;
	padding: 12px 16px !important;
	font-size: 15px !important;
	font-weight: 600 !important;
	font-family: inherit !important;
	cursor: pointer !important;
	transition: filter 0.15s ease !important;
}

.wlb-submit:hover,
.wlb-submit:focus-visible {
	filter: brightness(0.95);
}

.wlb-submit:focus-visible {
	outline: 2px solid var(--wlb-header, #075E54) !important;
	outline-offset: 2px !important;
}

/*
 * Botón CTA ([wlb_cta]) — pensado para ponerse en medio del contenido de
 * una página (no flotante), así que usa forma de botón normal en vez de
 * círculo. Misma protección "all: unset" que el resto de los botones del
 * plugin contra los estilos globales de botones del tema/Elementor.
 */
.wlb-cta-button {
	all: unset !important;
	box-sizing: border-box !important;
	display: inline-block !important;
	background-color: var(--wlb-cta, #25D366) !important;
	color: #fff !important;
	border-radius: var(--wlb-cta-radius, 10px) !important;
	padding: var(--wlb-cta-padding, 14px 28px) !important;
	font-size: var(--wlb-cta-font-size, 16px) !important;
	font-weight: 600 !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
	text-align: center !important;
	cursor: pointer !important;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
	transition: filter 0.15s ease, transform 0.15s ease !important;
}

.wlb-cta-button:hover {
	filter: brightness(0.95);
	transform: translateY(-1px);
}

.wlb-cta-button:focus-visible {
	outline: 2px solid var(--wlb-header, #075E54) !important;
	outline-offset: 2px !important;
}

/* Preguntas de "opción múltiple" (varias casillas) */
.wlb-checkbox-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.wlb-checkbox-option {
	display: flex !important;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	font-weight: 400 !important;
	color: #333;
	cursor: pointer;
}

.wlb-checkbox-option input[type="checkbox"] {
	/* Pisa el ancho/padding/borde de la regla genérica ".wlb-field
	   input" (pensada para campos de texto), que si no quedaría
	   también aplicada a cada casilla. */
	width: auto !important;
	min-width: 16px;
	padding: 0 !important;
	margin: 0;
	border: 1px solid #999 !important;
	border-radius: 3px !important;
	accent-color: var(--wlb-primary, #25D366);
}

/* El estado de error de un grupo de casillas se marca en el contenedor,
   no en cada casilla individual (sería demasiado ruido visual). */
.wlb-field.has-error .wlb-checkbox-group {
	border: 1px solid #d63638;
	border-radius: 8px;
	padding: 8px;
	box-shadow: 0 0 0 2px rgba(214, 54, 56, 0.15);
}

/*
 * Popup de los botones [wlb_cta] — un modal centrado con fondo oscuro,
 * independiente del panel anclado de la burbuja flotante (aunque
 * reutiliza las clases .wlb-panel__header / __body / __title, etc. para
 * que se vea consistente con ella).
 */
.wlb-cta-modal,
.wlb-cta-modal * {
	box-sizing: border-box;
}

.wlb-cta-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/*
 * El atributo HTML `hidden` normalmente esconde el elemento (lo hace
 * `display:none` vía la hoja de estilos del navegador), pero la regla
 * de arriba le pone `display:flex` a `.wlb-cta-modal` sin condición —
 * un estilo del propio sitio siempre gana sobre el estilo por defecto
 * del navegador, así que sin esta regla el popup se quedaría visible
 * aunque wlb-script.js le ponga `hidden`. Esta regla, más específica,
 * restaura el escondido real.
 */
.wlb-cta-modal[hidden] {
	display: none;
}

.wlb-cta-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(17, 22, 27, 0.55);
}

.wlb-cta-modal__dialog {
	position: relative;
	width: 100%;
	max-width: 400px;
	max-height: calc(100vh - 32px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.wlb-cta-modal .wlb-panel__body {
	overflow-y: auto;
}

/* Evita que la página de fondo se desplace mientras el popup está abierto. */
body.wlb-modal-open {
	overflow: hidden;
}

/*
 * Efectos para llamar la atención, opcionales (Ajustes → WhatsApp Bubble →
 * Apariencia / Botón CTA). Tanto la burbuja flotante como el botón CTA
 * pueden tener uno, independiente entre sí.
 *
 * Importante: el efecto se anima en el CONTENEDOR (#wlb-root para la
 * burbuja, el <span class="wlb-cta-wrap"> que envuelve a cada botón CTA),
 * nunca en el propio <button>. El botón usa "all: unset !important" para
 * protegerse de los estilos globales del tema (ver .wlb-toggle y
 * .wlb-cta-button más abajo), y eso deja su "transform" fijo en
 * "none !important" — una animación de CSS jamás puede ganarle a una
 * declaración !important, así que animar el botón directamente no se
 * vería. El contenedor no tiene ese reset, así que ahí sí funciona.
 * En la burbuja, además, el efecto se detiene en cuanto el panel está
 * abierto (":not(.is-open)"), para no competir con el formulario.
 */
.wlb-cta-wrap {
	display: inline-block;
}

@keyframes wlb-fx-pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.08); }
}

@keyframes wlb-fx-bounce {
	0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
	40% { transform: translateY(-10px); }
	60% { transform: translateY(-5px); }
}

@keyframes wlb-fx-shake {
	0%, 100% { transform: rotate(0); }
	10%, 30%, 50%, 70%, 90% { transform: rotate(-8deg); }
	20%, 40%, 60%, 80% { transform: rotate(8deg); }
}

.wlb-root.wlb-fx-pulse:not(.is-open),
.wlb-cta-wrap.wlb-fx-pulse {
	animation: wlb-fx-pulse 1.6s ease-in-out infinite;
}

.wlb-root.wlb-fx-bounce:not(.is-open),
.wlb-cta-wrap.wlb-fx-bounce {
	animation: wlb-fx-bounce 2s ease-in-out infinite;
}

.wlb-root.wlb-fx-shake:not(.is-open),
.wlb-cta-wrap.wlb-fx-shake {
	animation: wlb-fx-shake 2.4s ease-in-out infinite;
}

/* Pausa el efecto mientras se interactúa con el botón, para que no estorbe. */
.wlb-root.wlb-fx-pulse:hover,
.wlb-root.wlb-fx-bounce:hover,
.wlb-root.wlb-fx-shake:hover,
.wlb-cta-wrap.wlb-fx-pulse:hover,
.wlb-cta-wrap.wlb-fx-bounce:hover,
.wlb-cta-wrap.wlb-fx-shake:hover,
.wlb-cta-wrap.wlb-fx-pulse:focus-within,
.wlb-cta-wrap.wlb-fx-bounce:focus-within,
.wlb-cta-wrap.wlb-fx-shake:focus-within {
	animation-play-state: paused;
}

/* Respeta la preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
	.wlb-toggle,
	.wlb-panel,
	.wlb-root.wlb-fx-pulse,
	.wlb-root.wlb-fx-bounce,
	.wlb-root.wlb-fx-shake,
	.wlb-cta-wrap.wlb-fx-pulse,
	.wlb-cta-wrap.wlb-fx-bounce,
	.wlb-cta-wrap.wlb-fx-shake {
		transition: none;
		animation: none;
	}
}
