/* ==========================================================================
   Toscano – Asistente (Toscanito). Prefijo .tas.
   Botón flotante con un rayo, globo de saludo y panel tipo chat guiado.
   ========================================================================== */

.tas {
	--tas-accent: var(--toscano-brand-teal, #009a9d);
	--tas-accent-2: #2fc4c7;
	--tas-deep: var(--toscano-brand-deep, #032d35);
	--tas-text: #3d4f53;
	--tas-muted: #7b8a8d;
	--tas-bot: #f1f7f7;
	--tas-line: #e3ecee;
	--tas-bottom: 24px;
	--tas-side: 24px;

	position: fixed;
	z-index: 9980; /* por debajo de los Popups de Elementor */
	/* --tas-extra lo pone script.js mientras el aviso de cookies ocupa el pie de la pantalla */
	--tas-b: calc(var(--tas-bottom) + var(--tas-extra, 0px));
	bottom: var(--tas-b);
	font-family: "Inter", sans-serif;
	-webkit-font-smoothing: antialiased;
	color: var(--tas-text);
}

.tas *,
.tas *::before,
.tas *::after {
	box-sizing: border-box;
}

.tas--right {
	right: var(--tas-side);
}

.tas--left {
	left: var(--tas-side);
}

.tas button {
	margin: 0;
	font-family: "Inter", sans-serif;
	letter-spacing: normal;
	text-transform: none;
	box-shadow: none;
	cursor: pointer;
}

/* ---------- Botón flotante ---------- */

.tas button.tas__launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: radial-gradient(circle at 30% 25%, #2fc4c7 0%, var(--tas-accent) 55%, #007b7e 100%);
	box-shadow: 0 14px 30px -10px rgba(0, 123, 126, .65), 0 0 0 4px rgba(255, 255, 255, .9);
	color: #ffffff;
	transition: transform .35s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s ease;
}

.tas button.tas__launcher:hover,
.tas button.tas__launcher:focus-visible {
	background: radial-gradient(circle at 30% 25%, #2fc4c7 0%, var(--tas-accent) 55%, #007b7e 100%);
	color: #ffffff;
	transform: scale(1.07);
	box-shadow: 0 18px 36px -10px rgba(0, 123, 126, .8), 0 0 0 4px rgba(255, 255, 255, .95), 0 0 24px rgba(47, 196, 199, .55);
}

.tas button.tas__launcher:focus-visible {
	outline: 2px solid var(--tas-deep);
	outline-offset: 4px;
}

/* Anillo de energía que late mientras está cerrado */
.tas .tas__launcher-ring {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--tas-accent-2);
	opacity: 0;
	animation: tas-ring 2.8s cubic-bezier(.2, .6, .3, 1) 1.5s infinite;
	pointer-events: none;
}

.tas.is-open .tas__launcher-ring {
	animation: none;
}

@keyframes tas-ring {
	0% { opacity: .7; transform: scale(1); }
	70%, 100% { opacity: 0; transform: scale(1.6); }
}

.tas .tas__launcher-ico {
	position: absolute;
	display: flex;
	transition: opacity .25s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1);
}

.tas .tas__launcher-ico svg {
	display: block;
}

.tas .tas-toski {
	display: block;
	overflow: visible;
}

/* ---------- Toscanito ----------
   Los gestos, el parpadeo, la mirada y el habla los mueve script.js sobre el SVG.
   Aquí sólo van la entrada, el salto al pasar el ratón y la sombra. */

/* --- Botón: cuerpo entero (de pie sobre una sombra) --- */
.tas--body button.tas__launcher,
.tas--body button.tas__launcher:hover,
.tas--body button.tas__launcher:focus-visible {
	background: transparent;
	box-shadow: none;
	transform: none;
}

/* Abierto: vuelve a ser el círculo con la X */
.tas--body.is-open button.tas__launcher {
	background: radial-gradient(circle at 30% 25%, #2fc4c7 0%, var(--tas-accent) 55%, #007b7e 100%);
	box-shadow: 0 14px 30px -10px rgba(0, 123, 126, .65), 0 0 0 4px rgba(255, 255, 255, .9);
}

.tas--body .tas__launcher-ring {
	display: none;
}

/* Los pies, en la base del botón (el icono está centrado en él) */
.tas--body .tas__toski {
	position: absolute;
	bottom: -32px;
	left: 50%;
	display: block;
	width: 88px;
	height: 108px;
	margin-left: -44px;
	transform-origin: 50% 100%;
	animation: tas-enter .9s cubic-bezier(.34, 1.4, .64, 1) .3s both;
}

/* Sombra en el suelo */
.tas--body .tas__toski::before {
	content: "";
	position: absolute;
	bottom: 2px;
	left: 50%;
	width: 66px;
	height: 10px;
	margin-left: -33px;
	border-radius: 50%;
	background: radial-gradient(closest-side, rgba(3, 45, 53, .32), rgba(3, 45, 53, 0));
	opacity: calc(1 - var(--tas-lift, 0) * .6);
	transform: scale(calc(1 - var(--tas-lift, 0) * .45)); /* script.js: sube al saltar */
}

.tas--body .tas__toski .tas-toski {
	position: relative;
	width: 100%;
	height: 100%;
	filter: drop-shadow(0 6px 10px rgba(3, 45, 53, .18));
	transform-origin: 50% 100%;
}

.tas--body button.tas__launcher:hover .tas-toski {
	animation: tas-hop .7s cubic-bezier(.34, 1.4, .64, 1);
}

.tas--body button.tas__launcher:hover .tas__toski::before {
	animation: tas-hop-shadow .7s cubic-bezier(.34, 1.4, .64, 1);
}

/* Entra de un salto al cargar la página */
@keyframes tas-enter {
	0% { opacity: 0; transform: translateY(46px) scale(.5, .4); }
	45% { opacity: 1; transform: translateY(-16px) scale(.92, 1.12); }
	68% { transform: translateY(0) scale(1.12, .86); }
	84% { transform: translateY(-4px) scale(.97, 1.03); }
	100% { opacity: 1; transform: none; }
}

@keyframes tas-hop {
	0% { transform: none; }
	20% { transform: translateY(3px) scale(1.1, .86); }
	50% { transform: translateY(-18px) scale(.94, 1.08) rotate(-3deg); }
	75% { transform: translateY(0) scale(1.08, .9); }
	90% { transform: translateY(-2px) scale(.98, 1.02); }
	100% { transform: none; }
}

@keyframes tas-hop-shadow {
	0%, 100% { transform: scale(1); opacity: 1; }
	50% { transform: scale(.55); opacity: .4; }
}

/* --- Botón: asomando de un círculo ---
   Lienzo de 170 × 150 px centrado en el círculo (centro del círculo = 85, 120).
   Por encima del ecuador del círculo Toscanito se ve entero (cabeza y brazos pueden
   salir); por debajo, sólo dentro del círculo, como si saliera de un agujero. */
.tas--bust button.tas__launcher,
.tas--bust button.tas__launcher:hover,
.tas--bust button.tas__launcher:focus-visible {
	background: radial-gradient(circle at 50% 38%, #f4fcfc 0%, #d3f0f0 58%, #9fdcdd 100%);
	box-shadow: inset 0 -6px 12px -4px rgba(0, 123, 126, .35), 0 12px 26px -10px rgba(0, 92, 95, .55), 0 0 0 3px #ffffff;
	color: var(--tas-deep);
	transform: none;
}

.tas--bust.is-open button.tas__launcher {
	background: radial-gradient(circle at 30% 25%, #2fc4c7 0%, var(--tas-accent) 55%, #007b7e 100%);
	box-shadow: 0 14px 30px -10px rgba(0, 123, 126, .65), 0 0 0 3px #ffffff;
	color: #ffffff;
}

.tas--bust .tas__launcher-ico--open,
.tas--bust.is-open .tas__launcher-ico--open {
	opacity: 1;
	transform: none;
}

.tas--bust .tas__toski {
	position: absolute;
	top: -120px;
	left: -85px;
	display: block;
	width: 170px;
	height: 150px;
	/* Visible: el círculo + todo lo que hay por encima, que se desvanece suave hacia el
	   ecuador (así nada queda cortado con una línea recta a los lados). */
	-webkit-mask-image: radial-gradient(circle at 85px 120px, #000 0 29.5px, transparent 30px), linear-gradient(#000 0 106px, transparent 119px);
	mask-image: radial-gradient(circle at 85px 120px, #000 0 29.5px, transparent 30px), linear-gradient(#000 0 106px, transparent 119px);
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	pointer-events: none;
}

.tas--bust .tas__toski .tas-toski {
	position: absolute;
	top: 0;
	left: 0;
	width: 170px;
	height: 150px;
	pointer-events: none;
	transition: transform .5s cubic-bezier(.34, 1.4, .64, 1), opacity .3s ease;
}

/* Sólo lo pintado recibe el clic (la cabeza que sobresale también abre el chat) */
.tas--bust .tas__toski .tas-t {
	pointer-events: visiblePainted;
}

.tas--bust button.tas__launcher:hover .tas-toski {
	transform: translateY(-5px);
}

/* Al abrir el chat se mete en el agujero; al cerrarlo vuelve a asomar */
.tas--bust.is-open .tas__toski .tas-toski {
	opacity: 0;
	transform: translateY(78px);
	transition: transform .38s cubic-bezier(.55, 0, .75, .1), opacity .2s ease .18s;
}

/* Entra asomando al cargar la página (en unidades del dibujo: 480 ≈ 80 px) */
.tas--bust .tas__launcher .tas-t {
	animation: tas-peek .9s cubic-bezier(.34, 1.4, .64, 1) .3s both;
}

@keyframes tas-peek {
	from { transform: translateY(480px); }
	to { transform: none; }
}

.tas .tas__launcher-ico--close {
	opacity: 0;
	transform: rotate(-90deg) scale(.6);
}

.tas.is-open .tas__launcher-ico--open {
	opacity: 0;
	transform: rotate(90deg) scale(.6);
	pointer-events: none;
}

.tas.is-open .tas__launcher-ico--close {
	opacity: 1;
	transform: none;
}


/* ---------- Globo de saludo ---------- */

.tas .tas__teaser {
	position: absolute;
	bottom: 74px;
	display: flex;
	align-items: flex-start;
	gap: 4px;
	width: max-content;
	max-width: 240px;
	animation: tas-pop .45s cubic-bezier(.34, 1.56, .64, 1) both;
}

.tas--right .tas__teaser {
	right: 0;
	transform-origin: bottom right;
}

.tas--left .tas__teaser {
	left: 0;
	transform-origin: bottom left;
}

/* Por encima de la cabeza de Toscanito */
.tas--body .tas__teaser {
	bottom: 120px;
}

.tas--bust .tas__teaser {
	bottom: 94px;
}

.tas .tas__teaser[hidden] {
	display: none;
}

.tas button.tas__teaser-msg {
	padding: 12px 16px;
	border: 1px solid var(--tas-line);
	border-radius: 16px 16px 4px 16px;
	background: #ffffff;
	box-shadow: 0 18px 40px -16px rgba(3, 45, 53, .35);
	color: var(--tas-deep);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	text-align: left;
}

.tas--left button.tas__teaser-msg {
	order: 2;
	border-radius: 16px 16px 16px 4px;
}

.tas button.tas__teaser-msg:hover {
	border-color: var(--tas-accent);
	background: #ffffff;
	color: var(--tas-deep);
}

.tas button.tas__teaser-x {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	padding: 0;
	border: 1px solid var(--tas-line);
	border-radius: 50%;
	background: #ffffff;
	color: var(--tas-muted);
}

.tas button.tas__teaser-x:hover {
	background: #ffffff;
	color: var(--tas-deep);
}

.tas button.tas__teaser-x svg {
	width: 12px;
	height: 12px;
}

@keyframes tas-pop {
	from { opacity: 0; transform: translateY(10px) scale(.85); }
	to { opacity: 1; transform: none; }
}

/* Se retira solo pasados unos segundos (script.js) */
.tas .tas__teaser.is-leaving {
	animation: tas-unpop .3s ease-in both;
}

@keyframes tas-unpop {
	to { opacity: 0; transform: translateY(8px) scale(.9); }
}

/* ---------- Panel ---------- */

.tas .tas__panel {
	position: absolute;
	bottom: 76px;
	display: flex;
	flex-direction: column;
	width: 370px;
	height: min(580px, calc(100vh - var(--tas-b) - 110px));
	height: min(580px, calc(100dvh - var(--tas-b) - 110px));
	overflow: hidden;
	border-radius: 20px;
	background: #ffffff;
	box-shadow: 0 30px 70px -20px rgba(3, 45, 53, .45), 0 0 0 1px rgba(3, 45, 53, .06);
	transform-origin: bottom right;
}

.tas--right .tas__panel {
	right: 0;
}

.tas--left .tas__panel {
	left: 0;
	transform-origin: bottom left;
}

.tas .tas__panel[hidden] {
	display: none;
}

.tas.is-opening .tas__panel {
	animation: tas-open .45s cubic-bezier(.16, .84, .24, 1) both;
}

.tas.is-closing .tas__panel {
	animation: tas-close .25s ease-in both;
}

@keyframes tas-open {
	from { opacity: 0; transform: translateY(18px) scale(.9); }
	to { opacity: 1; transform: none; }
}

@keyframes tas-close {
	to { opacity: 0; transform: translateY(12px) scale(.94); }
}

/* Cabecera oscura */
.tas .tas__head {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 14px 16px 16px;
	background:
		radial-gradient(80% 140% at 100% 0%, rgba(47, 196, 199, .28) 0%, transparent 60%),
		linear-gradient(135deg, var(--tas-deep) 0%, #064a54 100%);
	color: #ffffff;
}

.tas .tas__head-edge {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	height: 2px;
	background: linear-gradient(90deg, var(--tas-accent), var(--tas-accent-2), #ffffff, var(--tas-accent-2), var(--tas-accent));
	background-size: 300% 100%;
	animation: tas-edge 4s linear infinite;
}

@keyframes tas-edge {
	to { background-position: -300% 0; }
}

.tas .tas__avatar {
	position: relative;
	display: flex;
	flex: 0 0 42px;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: radial-gradient(circle at 50% 30%, #ffffff, #dff4f4);
	box-shadow: 0 0 0 3px rgba(255, 255, 255, .14), 0 0 18px rgba(47, 196, 199, .45);
	color: #ffffff;
}

.tas .tas__avatar svg {
	width: 42px;
	height: 42px;
	clip-path: circle(50%);
}

/* En la cabecera sólo la cabeza: brazos, manos y piernas fuera */
.tas .tas__avatar .tas-t-arm,
.tas .tas__avatar .tas-t-hand,
.tas .tas__avatar .tas-t-leg {
	display: none;
}

/* Punto «activo» */
.tas .tas__avatar::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: 1px;
	width: 11px;
	height: 11px;
	border: 2px solid var(--tas-deep);
	border-radius: 50%;
	background: #3cc38a;
}

.tas .tas__who {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
}

.tas .tas__name {
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
}

.tas .tas__role {
	margin-top: 2px;
	font-size: 12px;
	line-height: 1.3;
	color: rgba(255, 255, 255, .7);
}

.tas button.tas__icon-btn {
	display: flex;
	flex: 0 0 34px;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .08);
	color: #ffffff;
	transition: background-color .2s ease, transform .35s ease;
}

.tas button.tas__icon-btn:hover,
.tas button.tas__icon-btn:focus-visible {
	background: rgba(255, 255, 255, .18);
	color: #ffffff;
}

.tas button.tas__restart:hover {
	transform: rotate(-180deg);
}

.tas button.tas__icon-btn svg {
	display: block;
}

/* Conversación */
.tas .tas__log {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 8px;
	padding: 18px 16px 10px;
	overflow-y: auto;
	overscroll-behavior: contain;
	background:
		linear-gradient(rgba(3, 45, 53, .025) 1px, transparent 1px) 0 0 / 24px 24px,
		linear-gradient(90deg, rgba(3, 45, 53, .025) 1px, transparent 1px) 0 0 / 24px 24px,
		#fbfdfd;
	scroll-behavior: smooth;
}

.tas .tas__msg {
	max-width: 86%;
	margin: 0;
	padding: 10px 14px;
	font-size: 14px;
	line-height: 1.5;
	white-space: pre-line;
	animation: tas-msg .35s cubic-bezier(.16, .84, .24, 1) both;
}

.tas .tas__msg--bot {
	align-self: flex-start;
	border: 1px solid var(--tas-line);
	border-radius: 4px 16px 16px 16px;
	background: #ffffff;
	color: var(--tas-text);
}

.tas .tas__msg--bot + .tas__msg--bot {
	border-top-left-radius: 16px;
}

.tas .tas__msg--user {
	align-self: flex-end;
	border-radius: 16px 16px 4px 16px;
	background: var(--tas-accent);
	color: #ffffff;
	font-weight: 600;
}

@keyframes tas-msg {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: none; }
}

/* «Escribiendo…» */
.tas .tas__typing {
	display: inline-flex;
	align-self: flex-start;
	gap: 4px;
	padding: 12px 14px;
	border: 1px solid var(--tas-line);
	border-radius: 4px 16px 16px 16px;
	background: #ffffff;
}

.tas .tas__typing i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--tas-accent);
	opacity: .35;
	animation: tas-dot 1s ease-in-out infinite;
}

.tas .tas__typing i:nth-child(2) { animation-delay: .15s; }
.tas .tas__typing i:nth-child(3) { animation-delay: .3s; }

@keyframes tas-dot {
	0%, 100% { opacity: .35; transform: none; }
	40% { opacity: 1; transform: translateY(-4px); }
}

/* Botones de acción dentro de la conversación */
.tas .tas__actions {
	display: flex;
	flex-direction: column;
	align-self: flex-start;
	gap: 6px;
	width: 86%;
	animation: tas-msg .35s cubic-bezier(.16, .84, .24, 1) both;
}

.tas a.tas__action,
.tas button.tas__action {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	padding: 12px 14px;
	overflow: hidden;
	border: 0;
	border-radius: 10px;
	background: var(--tas-accent);
	box-shadow: 0 10px 22px -12px rgba(0, 154, 157, .9);
	color: #ffffff;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	text-align: left;
	text-decoration: none;
	transition: background-color .25s ease, transform .2s ease;
}

.tas a.tas__action:hover,
.tas button.tas__action:hover,
.tas a.tas__action:focus-visible,
.tas button.tas__action:focus-visible {
	background: var(--toscano-text-accent, #007b7e);
	color: #ffffff;
	text-decoration: none;
}

.tas .tas__action::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: -40%;
	width: 30%;
	background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .45), transparent);
	transform: skewX(-18deg);
	transition: left .7s ease;
}

.tas .tas__action:hover::before {
	left: 120%;
}

.tas .tas__action svg {
	flex: 0 0 auto;
	transition: transform .25s ease;
}

.tas .tas__action:hover svg {
	transform: translateX(3px);
}

/* Opciones (abajo) */
.tas .tas__choices {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 12px 16px 16px;
	border-top: 1px solid var(--tas-line);
	background: #ffffff;
}

.tas .tas__choices:empty {
	display: none;
}

.tas button.tas__chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 9px 14px;
	border: 1px solid color-mix(in srgb, var(--tas-accent) 35%, var(--tas-line));
	border-radius: 999px;
	background: #ffffff;
	color: var(--tas-deep);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	text-align: left;
	animation: tas-msg .3s cubic-bezier(.16, .84, .24, 1) both;
	animation-delay: calc(var(--k, 0) * .05s);
	transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .15s ease;
}

.tas button.tas__chip:hover,
.tas button.tas__chip:focus-visible {
	border-color: var(--tas-accent);
	background: var(--tas-accent);
	color: #ffffff;
}

.tas button.tas__chip:active {
	transform: scale(.96);
}

.tas button.tas__chip svg {
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
	color: var(--tas-accent);
	transition: color .2s ease;
}

.tas button.tas__chip:hover svg,
.tas button.tas__chip:focus-visible svg {
	color: #ffffff;
}

.tas button.tas__chip--back {
	border-style: dashed;
	color: var(--tas-muted);
}

.tas button.tas__chip--back svg {
	color: var(--tas-muted);
}

/* ---------- Móvil ---------- */

@media (max-width: 767px) {
	.tas {
		--tas-side: 16px;
		--tas-bottom: 16px;
	}

	.tas button.tas__launcher {
		width: 56px;
		height: 56px;
	}

	.tas--body .tas__toski {
		bottom: -30px;
		width: 74px;
		height: 92px;
		margin-left: -37px;
	}

	.tas--body .tas__toski::before {
		width: 54px;
		margin-left: -27px;
	}

	/* Círculo de 56 px: el mismo lienzo a escala */
	.tas--bust .tas__toski {
		transform: scale(.9333);
		transform-origin: 85px 120px;
	}

	.tas--body .tas__teaser {
		bottom: 104px;
	}

	.tas--bust .tas__teaser {
		bottom: 86px;
	}

	/* Panel casi a pantalla completa, con 12 px de margen */
	.tas .tas__panel {
		position: fixed;
		right: 12px;
		bottom: calc(var(--tas-b) + 66px);
		left: 12px;
		width: auto;
		height: calc(100vh - var(--tas-b) - 90px);
		height: calc(100dvh - var(--tas-b) - 90px);
		max-height: 640px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tas *,
	.tas.is-opening .tas__panel {
		animation: none !important;
	}
}
