/* Asistente de soporte Workie: chat. Hereda la tipografía del tema (Quicksand). */
#workie-soporte {
	position: relative;
	--ws-primario: #6f6ee6;
	--ws-primario-osc: #5352c9;
	--ws-texto: #1f2233;
	--ws-suave: #5d6075;
	--ws-borde: #e3e3f1;
	--ws-fondo: #ffffff;
	--ws-fondo-chat: #f5f5fc;

	display: flex;
	flex-direction: column;
	max-width: 520px;
	/* Valor inicial; el JS lo ajusta al alto disponible de la pantalla. */
	height: calc(100vh - 140px);
	height: calc(100dvh - 140px);
	min-height: 360px;
	margin: 0 auto;
	overflow: hidden;
	background: var(--ws-fondo);
	color: var(--ws-texto);
	border-radius: 20px;
	box-shadow: 0 18px 50px rgba(40, 40, 110, 0.16);
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	text-align: left;
}

#workie-soporte *,
#workie-soporte *::before,
#workie-soporte *::after {
	box-sizing: border-box;
}

#workie-soporte [hidden] {
	display: none !important;
}

/* Cabecera */
#workie-soporte .ws-cabecera {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	color: #fff;
	background: linear-gradient(135deg, #7877e9 0%, #5352c9 100%);
}

/* Mascota en el encabezado: se puede tocar y salta. */
#workie-soporte .ws-avatar {
	flex: none;
	width: 46px;
	height: 46px;
	padding: 3px;
	background-color: rgba(255, 255, 255, 0.95);
	border: 0;
	border-radius: 50%;
	box-shadow: 0 3px 10px rgba(30, 20, 120, 0.25);
}

#workie-soporte .ws-avatar:hover,
#workie-soporte .ws-avatar:focus {
	background-color: #fff;
}

#workie-soporte .ws-avatar img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	transition: transform 0.2s;
}

#workie-soporte .ws-avatar:hover img {
	transform: rotate(-10deg) scale(1.08);
}

#workie-soporte .ws-avatar.ws-salto img {
	animation: ws-saltar 0.7s ease-out;
}

#workie-soporte .ws-cabecera-texto {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
}

#workie-soporte .ws-cabecera-texto strong,
#workie-soporte .ws-cabecera-texto span {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

#workie-soporte .ws-cabecera-texto strong {
	font-size: 16px;
	line-height: 1.3;
}

#workie-soporte .ws-cabecera-texto span {
	font-size: 12.5px;
	opacity: 0.9;
}

/* Conversación */
#workie-soporte .ws-chat {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 8px;
	padding: 16px;
	overflow-y: auto;
	background: var(--ws-fondo-chat);
	scroll-behavior: smooth;
}

#workie-soporte .ws-msj {
	max-width: 86%;
	padding: 10px 14px;
	border-radius: 16px;
	word-wrap: break-word;
	animation: ws-entrar 0.2s ease-out;
}

#workie-soporte .ws-bot {
	position: relative;
	align-self: flex-start;
	max-width: calc(90% - 40px);
	margin-left: 40px;
	background: var(--ws-fondo);
	border: 1px solid var(--ws-borde);
	border-bottom-left-radius: 4px;
}

/* La mascota acompaña al último mensaje de cada tanda del bot, como en las apps de chat. */
#workie-soporte .ws-bot::before {
	content: "";
	position: absolute;
	left: -40px;
	bottom: -2px;
	width: 32px;
	height: 32px;
	background: var(--ws-mascota) center / contain no-repeat;
}

#workie-soporte .ws-bot.ws-agrupado::before {
	visibility: hidden;
}

/* Mientras "escribe", la mascota se balancea. */
#workie-soporte .ws-escribiendo::before {
	animation: ws-balanceo 0.9s ease-in-out infinite;
}

/* Bienvenida: la mascota grande, flotando, al empezar. */
#workie-soporte .ws-bienvenida {
	display: flex;
	justify-content: center;
	padding: 6px 0 4px;
}

#workie-soporte .ws-bienvenida img {
	width: 116px;
	height: 116px;
	filter: drop-shadow(0 10px 14px rgba(83, 82, 201, 0.25));
	animation: ws-aparecer 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both, ws-flotar 3.2s ease-in-out 0.6s infinite;
}

/* Festejo: la mascota salta con destellos sobre la conversación. */
#workie-soporte .ws-festejo {
	position: absolute;
	left: 50%;
	bottom: 90px;
	z-index: 5;
	width: 120px;
	height: 120px;
	margin-left: -60px;
	pointer-events: none;
}

#workie-soporte .ws-festejo img {
	width: 100%;
	height: 100%;
	filter: drop-shadow(0 12px 18px rgba(83, 82, 201, 0.35));
	animation: ws-festejo 2.1s ease-in-out forwards;
}

#workie-soporte .ws-festejo i {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	background: #ffc93c;
	clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
	opacity: 0;
	animation: ws-destello 1.3s ease-out 0.35s forwards;
}

#workie-soporte .ws-festejo i:nth-of-type(1) { --x: -78px; --y: -62px; }
#workie-soporte .ws-festejo i:nth-of-type(2) { --x: 80px; --y: -54px; background: #f6a6e8; }
#workie-soporte .ws-festejo i:nth-of-type(3) { --x: -92px; --y: 14px; background: #a9a8f5; }
#workie-soporte .ws-festejo i:nth-of-type(4) { --x: 94px; --y: 20px; }
#workie-soporte .ws-festejo i:nth-of-type(5) { --x: -30px; --y: -96px; background: #f6a6e8; }
#workie-soporte .ws-festejo i:nth-of-type(6) { --x: 36px; --y: -98px; background: #a9a8f5; }

#workie-soporte .ws-usuario {
	align-self: flex-end;
	color: #fff;
	background: var(--ws-primario);
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}

#workie-soporte .ws-bot a {
	color: var(--ws-primario-osc);
	font-weight: 700;
}

#workie-soporte .ws-pasos {
	margin: 8px 0 0;
	padding-left: 20px;
}

#workie-soporte .ws-pasos li {
	margin-bottom: 6px;
}

#workie-soporte .ws-pasos li::marker {
	color: var(--ws-primario);
	font-weight: 700;
}

#workie-soporte .ws-resumen {
	margin: 6px 0 0;
	padding-left: 18px;
}

/* Mail de pedido de acceso armado por el bot */
#workie-soporte .ws-mail {
	margin-top: 8px;
	padding: 10px 12px;
	font-size: 14px;
	background: var(--ws-fondo-chat);
	border: 1px dashed var(--ws-borde);
	border-radius: 10px;
}

#workie-soporte .ws-mail > div {
	margin-bottom: 2px;
}

#workie-soporte .ws-mail-cuerpo {
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid var(--ws-borde);
	white-space: pre-wrap;
}

#workie-soporte .ws-aviso {
	display: block;
	margin-top: 4px;
	padding: 8px 10px;
	font-weight: 700;
	color: #8a4b00;
	background: #fff4e0;
	border-left: 4px solid #f0a020;
	border-radius: 6px;
}

/* Indicador "escribiendo…" */
#workie-soporte .ws-escribiendo {
	display: flex;
	gap: 4px;
	padding: 14px;
}

#workie-soporte .ws-escribiendo span {
	width: 7px;
	height: 7px;
	background: #a9a8e6;
	border-radius: 50%;
	animation: ws-punto 1s infinite ease-in-out;
}

#workie-soporte .ws-escribiendo span:nth-child(2) {
	animation-delay: 0.15s;
}

#workie-soporte .ws-escribiendo span:nth-child(3) {
	animation-delay: 0.3s;
}

/*
 * Opciones que ofrece el bot: van de su lado (izquierda), debajo de su mensaje,
 * con forma de botón para que se entienda que se tocan. Las respuestas del
 * usuario, en cambio, son burbujas violetas a la derecha.
 */
#workie-soporte .ws-opciones {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
	gap: 8px;
	max-width: calc(90% - 40px);
	margin: 2px 0 6px 40px;
	animation: ws-entrar 0.2s ease-out;
}

#workie-soporte .ws-opciones--apiladas {
	flex-direction: column;
	align-items: stretch;
}

/*
 * Botones. El tema (Hello + kit de Elementor) estiliza todos los <button>
 * con fondo, sombra de texto, 18px y "nowrap": acá se resetea todo eso.
 */
#workie-soporte button,
#workie-soporte .ws-op {
	-webkit-appearance: none;
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: auto;
	height: auto;
	min-height: 0;
	margin: 0;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	text-decoration: none;
	white-space: normal;
	box-shadow: none;
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

#workie-soporte .ws-reiniciar {
	flex: none;
	gap: 6px;
	padding: 7px 12px;
	font-size: 13px;
	color: #fff;
	background-color: rgba(255, 255, 255, 0.16);
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 999px;
}

#workie-soporte .ws-reiniciar svg {
	width: 14px;
	height: 14px;
	flex: none;
}

#workie-soporte .ws-reiniciar:hover,
#workie-soporte .ws-reiniciar:focus,
#workie-soporte .ws-reiniciar:focus-visible {
	color: #fff;
	background-color: rgba(255, 255, 255, 0.3);
	border-color: rgba(255, 255, 255, 0.6);
}

#workie-soporte .ws-op {
	position: relative;
	justify-content: flex-start;
	padding: 11px 36px 11px 16px;
	text-align: left;
	color: var(--ws-primario-osc);
	background-color: var(--ws-fondo);
	border: 1.5px solid var(--ws-primario);
	border-radius: 12px;
	box-shadow: 0 2px 6px rgba(83, 82, 201, 0.12);
}

/* Flecha que indica que la opción se puede tocar. */
#workie-soporte .ws-op::after {
	content: "";
	position: absolute;
	right: 14px;
	top: 50%;
	width: 8px;
	height: 8px;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
	transform: translateY(-50%) rotate(45deg);
}

#workie-soporte a.ws-op::after {
	transform: translateY(-50%) rotate(45deg);
}

#workie-soporte .ws-op:hover,
#workie-soporte .ws-op:focus,
#workie-soporte .ws-op:focus-visible,
#workie-soporte .ws-op--principal {
	color: #fff;
	background-color: var(--ws-primario);
	border-color: var(--ws-primario);
	outline: none;
}

#workie-soporte .ws-op--principal:hover,
#workie-soporte .ws-op--principal:focus {
	background-color: var(--ws-primario-osc);
	border-color: var(--ws-primario-osc);
}

#workie-soporte .ws-enviar {
	flex: none;
	width: 42px;
	height: 42px;
	padding: 0;
	color: #fff;
	background-color: var(--ws-primario);
	border: 0;
	border-radius: 50%;
}

#workie-soporte .ws-enviar svg {
	width: 18px;
	height: 18px;
}

#workie-soporte .ws-enviar:hover,
#workie-soporte .ws-enviar:focus {
	color: #fff;
	background-color: var(--ws-primario-osc);
}

/* Campo para escribir */
#workie-soporte .ws-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	background: var(--ws-fondo);
	border-top: 1px solid var(--ws-borde);
}

#workie-soporte .ws-composer textarea {
	flex: 1;
	width: auto;
	margin: 0;
	line-height: 1.4;
	box-shadow: none;
	min-height: 42px;
	max-height: 120px;
	padding: 10px 14px;
	font: inherit;
	font-size: 16px; /* Evita el zoom automático en iPhone. */
	color: var(--ws-texto);
	background: var(--ws-fondo-chat);
	border: 1px solid var(--ws-borde);
	border-radius: 20px;
	resize: none;
}

#workie-soporte .ws-composer textarea:focus {
	border-color: var(--ws-primario);
	outline: none;
}

#workie-soporte .ws-trampa {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

@keyframes ws-entrar {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
}

@keyframes ws-punto {
	0%,
	80%,
	100% {
		opacity: 0.35;
		transform: translateY(0);
	}

	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* Con el teclado abierto en el celular: el alto lo fija el JS y se oculta la mascota grande para ganar lugar. */
#workie-soporte.ws-con-teclado {
	max-height: none;
	border-radius: 14px;
	transition: height 0.15s;
}

#workie-soporte.ws-con-teclado .ws-bienvenida {
	display: none;
}

@keyframes ws-flotar {
	0%,
	100% {
		transform: translateY(0) rotate(0);
	}

	50% {
		transform: translateY(-8px) rotate(-3deg);
	}
}

@keyframes ws-aparecer {
	from {
		opacity: 0;
		transform: scale(0.4) rotate(-20deg);
	}
}

@keyframes ws-balanceo {
	0%,
	100% {
		transform: rotate(-8deg);
	}

	50% {
		transform: rotate(8deg) translateY(-2px);
	}
}

@keyframes ws-saltar {
	30% {
		transform: translateY(-10px) rotate(-12deg) scale(1.1);
	}

	60% {
		transform: translateY(0) rotate(8deg);
	}
}

@keyframes ws-festejo {
	0% {
		opacity: 0;
		transform: translateY(60px) scale(0.5);
	}

	20% {
		opacity: 1;
		transform: translateY(-24px) scale(1.08) rotate(-8deg);
	}

	35% {
		transform: translateY(0) scale(1) rotate(6deg);
	}

	50% {
		transform: translateY(-14px) rotate(-4deg);
	}

	65% {
		opacity: 1;
		transform: translateY(0) rotate(0);
	}

	100% {
		opacity: 0;
		transform: translateY(-10px) scale(0.9);
	}
}

@keyframes ws-destello {
	0% {
		opacity: 0;
		transform: translate(0, 0) scale(0.3);
	}

	30% {
		opacity: 1;
	}

	100% {
		opacity: 0;
		transform: translate(var(--x), var(--y)) scale(1.2) rotate(90deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	#workie-soporte .ws-msj,
	#workie-soporte .ws-opciones,
	#workie-soporte .ws-escribiendo span,
	#workie-soporte .ws-escribiendo::before,
	#workie-soporte .ws-bienvenida img,
	#workie-soporte .ws-avatar img {
		animation: none;
	}
}

@media (max-width: 480px) {
	#workie-soporte {
		border-radius: 14px;
	}

	#workie-soporte .ws-msj {
		max-width: 92%;
	}

	#workie-soporte .ws-msj.ws-bot,
	#workie-soporte .ws-opciones {
		max-width: calc(100% - 44px);
	}

	#workie-soporte .ws-bienvenida img {
		width: 96px;
		height: 96px;
	}

	#workie-soporte .ws-reiniciar {
		padding: 9px;
	}

	#workie-soporte .ws-reiniciar-texto {
		display: none;
	}
}

#workie-soporte .ws-composer-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/*
 * Plantilla de pantalla completa (templates/pantalla-completa.php): la página
 * es solo el chat. En el celular ocupa la pantalla de borde a borde; en la
 * computadora queda centrado, con todo el alto, sobre el degradé de la marca.
 */
html:has(body.ws-pantalla-completa),
body.ws-pantalla-completa {
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
}

body.ws-pantalla-completa {
	background: linear-gradient(155deg, #f2f2ff 0%, #c9c8f6 55%, #7877e9 100%);
	font-family: "Quicksand", sans-serif;
}

body.ws-pantalla-completa .ws-pagina {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	padding: 24px 16px;
	box-sizing: border-box;
}

body.ws-pantalla-completa #workie-soporte {
	width: 100%;
	max-width: 560px;
	height: calc(100vh - 48px);
	height: calc(100dvh - 48px);
	min-height: 0;
}

@media (max-width: 768px) {
	body.ws-pantalla-completa .ws-pagina {
		padding: 0;
	}

	/* Fijo a la pantalla: así no lo mueve el desplazamiento que hace el navegador al abrir el teclado. */
	body.ws-pantalla-completa #workie-soporte {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		max-width: none;
		height: 100vh;
		height: 100dvh;
		border-radius: 0;
		box-shadow: none;
	}

		/* Respeta la muesca y la barra de gestos del teléfono. */
	body.ws-pantalla-completa .ws-cabecera {
		padding-top: calc(14px + env(safe-area-inset-top));
	}

	body.ws-pantalla-completa .ws-composer {
		padding-bottom: calc(10px + env(safe-area-inset-bottom));
	}

	body.ws-pantalla-completa .ws-chat {
		padding-bottom: calc(16px + env(safe-area-inset-bottom));
	}
}
