/**
 * Asesor de Cuchillos TeLoAfilo — estilos del widget.
 * Todo bajo .tla- para no chocar con el tema ni con Elementor.
 */

.tla-asesor {
	--tla-tinta: #1c1c1c;
	--tla-papel: #ffffff;
	--tla-borde: #e2e0dc;
	--tla-acento: #1f3864;
	--tla-cliente: #eef1f6;
	--tla-suave: #6b6b6b;

	/**
	 * Separación desde el borde inferior. Sube el asesor por encima del botón
	 * flotante de WhatsApp, que vive en la misma esquina. Se ajusta desde PHP
	 * con el filtro teloafilo_asesor_separacion_abajo si el botón cambia de
	 * tamaño; no hace falta editar este archivo.
	 */
	--tla-abajo: 96px;
	--tla-lado: 20px;

	position: fixed;
	right: var(--tla-lado);
	bottom: var(--tla-abajo);
	z-index: 99998;
	font-family: inherit;
	line-height: 1.5;
}

/* ---------------------------------------------------------- burbuja */

.tla-burbuja {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
	padding: 13px 20px;
	border: 0;
	border-radius: 999px;
	background: var(--tla-acento);
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
	transition: transform .15s ease, box-shadow .15s ease;
}

.tla-burbuja:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 22px rgba(0, 0, 0, .24);
}

.tla-burbuja::before {
	content: "";
	width: 18px;
	height: 18px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 11.5a8.4 8.4 0 0 1-9 8.4 9 9 0 0 1-3.3-.6L3 21l1.8-5.1A8.2 8.2 0 0 1 3.6 11.5 8.4 8.4 0 0 1 12 3a8.4 8.4 0 0 1 9 8.5z'/%3E%3C/svg%3E") center/contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 11.5a8.4 8.4 0 0 1-9 8.4 9 9 0 0 1-3.3-.6L3 21l1.8-5.1A8.2 8.2 0 0 1 3.6 11.5 8.4 8.4 0 0 1 12 3a8.4 8.4 0 0 1 9 8.5z'/%3E%3C/svg%3E") center/contain no-repeat;
	flex: 0 0 auto;
}

.tla-abierto .tla-burbuja {
	display: none;
}

/* ---------------------------------------------------------- panel */

/**
 * El atributo hidden tiene que ganarle a los display de abajo.
 * Sin esto el panel aparecería abierto siempre: una regla de autor con
 * `display: flex` le gana al `[hidden] { display: none }` del navegador.
 */
.tla-asesor [hidden],
.tla-asesor[hidden] {
	display: none !important;
}

.tla-panel {
	display: flex;
	flex-direction: column;
	width: min(390px, calc(100vw - 40px));
	height: min(560px, calc(100vh - var(--tla-abajo) - 60px));
	border: 1px solid var(--tla-borde);
	border-radius: 14px;
	background: var(--tla-papel);
	color: var(--tla-tinta);
	overflow: hidden;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}

.tla-cabecera {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--tla-borde);
	background: var(--tla-acento);
	color: #fff;
}

.tla-titulo {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
}

.tla-subtitulo {
	margin: 2px 0 0;
	font-size: 12.5px;
	opacity: .8;
}

.tla-cerrar {
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 26px;
	line-height: 1;
	padding: 0 4px;
	cursor: pointer;
	opacity: .85;
}

.tla-cerrar:hover {
	opacity: 1;
}

/* ---------------------------------------------------------- mensajes */

.tla-mensajes {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #fbfaf8;
}

.tla-mensaje {
	max-width: 85%;
	padding: 10px 13px;
	border-radius: 12px;
	font-size: 14.5px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.tla-mensaje-asesor {
	align-self: flex-start;
	background: var(--tla-papel);
	border: 1px solid var(--tla-borde);
	border-bottom-left-radius: 4px;
}

.tla-mensaje-cliente {
	align-self: flex-end;
	background: var(--tla-cliente);
	border-bottom-right-radius: 4px;
}

.tla-mensaje strong {
	font-weight: 700;
}

.tla-mensaje .tla-enlace {
	color: var(--tla-acento);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.tla-mensaje .tla-enlace:hover {
	text-decoration-thickness: 2px;
}

/* puntos suspensivos mientras responde */

.tla-esperando {
	display: flex;
	gap: 4px;
	align-items: center;
	padding: 14px 13px;
}

.tla-esperando span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--tla-suave);
	animation: tla-latir 1.2s infinite ease-in-out;
}

.tla-esperando span:nth-child(2) { animation-delay: .15s; }
.tla-esperando span:nth-child(3) { animation-delay: .3s; }

@keyframes tla-latir {
	0%, 60%, 100% { opacity: .25; transform: translateY(0); }
	30%           { opacity: 1;   transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
	.tla-esperando span { animation: none; opacity: .5; }
	.tla-burbuja        { transition: none; }
}

/* ---------------------------------------------------------- formulario */

.tla-formulario {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--tla-borde);
	background: var(--tla-papel);
}

.tla-etiqueta {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.tla-entrada {
	flex: 1;
	resize: none;
	min-height: 42px;
	max-height: 120px;
	padding: 10px 12px;
	border: 1px solid var(--tla-borde);
	border-radius: 10px;
	font: inherit;
	font-size: 14.5px;
	color: inherit;
	background: var(--tla-papel);
}

.tla-entrada:focus {
	outline: 2px solid var(--tla-acento);
	outline-offset: -1px;
}

.tla-enviar {
	flex: 0 0 auto;
	padding: 11px 16px;
	border: 0;
	border-radius: 10px;
	background: var(--tla-acento);
	color: #fff;
	font-size: 14.5px;
	font-weight: 600;
	cursor: pointer;
}

.tla-enviar:disabled {
	opacity: .5;
	cursor: default;
}

/* ---------------------------------------------------------- móvil */

@media (max-width: 560px) {
	.tla-asesor {
		--tla-lado: 12px;
		/* En móvil el botón de WhatsApp suele ser más chico y estar más abajo. */
		--tla-abajo: 84px;
	}

	/* El botón NO ocupa el ancho completo: dejaría al de WhatsApp debajo,
	   tapado o desalineado. Se queda compacto contra el borde derecho. */
	.tla-burbuja {
		font-size: 14px;
		padding: 12px 16px;
	}

	/* El panel abierto sí usa todo el ancho disponible. */
	.tla-abierto {
		left: var(--tla-lado);
	}

	.tla-panel {
		width: 100%;
		height: min(68vh, 500px);
	}
}
