/**
 * Canal Sénior — Mayte
 * Estilos del asistente. Base 18px, contraste AA, objetivos táctiles de 48px.
 */

.mayte {
	--mayte-azul: #2f54b4;
	--mayte-azul-oscuro: #243f8a;
	--mayte-verde: #a8d03c;
	--mayte-verde-texto: #5f7f1e;
	--mayte-tinta: #16203a;
	--mayte-tinta-suave: #4a5678;
	--mayte-papel: #ffffff;
	--mayte-lavado: #eef1f9;
	--mayte-borde: #d5dced;
	--mayte-acento: var(--mayte-azul);

	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 99000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 18px;
	line-height: 1.65;
	color: var(--mayte-tinta);
}

.mayte *,
.mayte *::before,
.mayte *::after {
	box-sizing: border-box;
}

/* Blindaje contra el tema anfitrión.
   El widget vive en 16 portales con temas distintos: aquí se neutraliza
   lo que suelen imponer a botones, campos y enlaces.
   Va dentro de :where() a propósito: así pesa cero y nunca pisa los
   estilos propios del widget, que vienen más abajo. */

.mayte :where(button, input, textarea, a, p, span, li) {
	font-family: inherit;
	text-transform: none;
	letter-spacing: normal;
	text-shadow: none;
	float: none;
}

.mayte :where(button) {
	-webkit-appearance: none;
	appearance: none;
	width: auto;
	margin: 0;
	line-height: 1.4;
	text-decoration: none;
	box-shadow: none;
}

.mayte :where(input, textarea) {
	-webkit-appearance: none;
	appearance: none;
	margin: 0;
	max-width: 100%;
	box-shadow: none;
}

.mayte :where(p) {
	text-align: left;
}

.mayte--incrustado {
	position: static;
	right: auto;
	bottom: auto;
	margin: 32px 0;
}

/* --- Lanzador: figura redonda más globo -------------------------------- */

.mayte__llamada {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
}

.mayte__lanzador {
	position: relative;
	width: 78px;
	height: 78px;
	min-width: 78px;
	min-height: 78px;
	max-width: 78px;
	padding: 0;
	border: 3px solid #fff;
	border-radius: 50%;
	background: var(--mayte-acento);
	cursor: pointer;
	overflow: visible;
	flex: 0 0 auto;
	box-shadow: 0 8px 22px rgba(22, 32, 58, 0.28);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
	align-self: flex-end;
}

.mayte__lanzador:hover {
	transform: translateY(-3px) scale(1.03);
	box-shadow: 0 14px 30px rgba(22, 32, 58, 0.34);
}

.mayte__lanzador:focus-visible {
	outline: 3px solid var(--mayte-tinta);
	outline-offset: 4px;
}

.mayte__figura {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
	background: var(--mayte-acento);
}

.mayte__figura--inicial {
	display: grid;
	place-items: center;
	color: #fff;
	font-size: 30px;
	font-weight: 700;
}

/* Punto verde de presencia, pegado al borde de la figura. */

.mayte__pulso {
	position: absolute;
	right: 2px;
	bottom: 6px;
	width: 16px;
	height: 16px;
	border: 3px solid #fff;
	border-radius: 50%;
	background: var(--mayte-verde);
	box-shadow: 0 0 0 0 rgba(168, 208, 60, 0.7);
	animation: mayte-latido 2.6s infinite;
}

@keyframes mayte-latido {
	0% { box-shadow: 0 0 0 0 rgba(168, 208, 60, 0.7); }
	70% { box-shadow: 0 0 0 12px rgba(168, 208, 60, 0); }
	100% { box-shadow: 0 0 0 0 rgba(168, 208, 60, 0); }
}

/* Globo de invitación. */

.mayte__globo {
	position: relative;
	display: flex;
	align-items: flex-start;
	max-width: 250px;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.3s ease, transform 0.3s ease;
	pointer-events: none;
}

.mayte--saluda .mayte__globo {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.mayte__globo-texto {
	padding: 13px 17px;
	border: 0;
	border-radius: 18px 18px 4px 18px;
	background: var(--mayte-acento);
	color: #fff;
	font: inherit;
	font-size: 17px;
	line-height: 1.45;
	text-align: left;
	cursor: pointer;
	box-shadow: 0 8px 22px rgba(22, 32, 58, 0.24);
}

.mayte__globo-texto:hover {
	filter: brightness(1.08);
}

.mayte__globo-texto:focus-visible {
	outline: 3px solid var(--mayte-tinta);
	outline-offset: 3px;
}

/* Rabito del globo, apuntando hacia la figura. */

.mayte__globo-texto::after {
	content: "";
	position: absolute;
	right: 14px;
	bottom: -7px;
	width: 14px;
	height: 14px;
	background: var(--mayte-acento);
	border-radius: 0 0 3px 0;
	transform: rotate(45deg) skew(6deg, 6deg);
}

.mayte__globo-cerrar {
	width: 28px;
	height: 28px;
	margin: -6px -6px 0 -10px;
	padding: 0;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--mayte-tinta);
	color: #fff;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	flex: 0 0 auto;
	z-index: 2;
}

.mayte__globo-cerrar:focus-visible {
	outline: 3px solid var(--mayte-acento);
	outline-offset: 2px;
}

.mayte--abierta .mayte__llamada {
	display: none;
}

/* --- Panel ---------------------------------------------------------- */

.mayte__panel {
	display: none;
	position: relative;
	width: 420px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 48px);
	background: var(--mayte-papel);
	border: 1px solid var(--mayte-borde);
	border-radius: 20px;
	overflow: hidden;
	flex-direction: column;
	box-shadow: 0 24px 60px rgba(22, 32, 58, 0.26);
}

.mayte--abierta .mayte__panel {
	display: flex;
	animation: mayte-entrada 0.24s ease-out;
}

.mayte--incrustado .mayte__panel {
	display: flex;
	width: 100%;
	max-width: 100%;
	height: 560px;
	box-shadow: none;
}

@keyframes mayte-entrada {
	from { opacity: 0; transform: translateY(12px); }
	to { opacity: 1; transform: translateY(0); }
}

/* --- Cinta de estado: sustituye a los tres puntitos ------------------ */

.mayte__cinta {
	position: absolute;
	top: 0;
	left: 0;
	height: 4px;
	width: 100%;
	background: transparent;
	overflow: hidden;
	z-index: 3;
}

.mayte__cinta::after {
	content: "";
	display: block;
	height: 100%;
	width: 40%;
	background: var(--mayte-verde);
	transform: translateX(-100%);
}

.mayte--pensando .mayte__cinta::after {
	animation: mayte-cinta 1.5s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes mayte-cinta {
	0% { transform: translateX(-100%); }
	100% { transform: translateX(350%); }
}

/* Mientras llegan palabras, un cursor al final del último párrafo. */

.mayte--escribiendo .mayte__mensaje--asistente:last-of-type .mayte__texto > p:last-child::after,
.mayte--escribiendo .mayte__mensaje--asistente:last-of-type .mayte__texto > ol:last-child li:last-child::after,
.mayte--escribiendo .mayte__mensaje--asistente:last-of-type .mayte__texto > ul:last-child li:last-child::after {
	content: "";
	display: inline-block;
	width: 3px;
	height: 1.05em;
	margin-left: 3px;
	vertical-align: -0.15em;
	background: var(--mayte-acento);
	animation: mayte-cursor 1s steps(2, start) infinite;
}

@keyframes mayte-cursor {
	0%, 50% { opacity: 1; }
	51%, 100% { opacity: 0; }
}

/* --- Cabecera ------------------------------------------------------- */

.mayte__cabecera {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 20px 16px 18px 22px;
	background: var(--mayte-acento);
	color: #fff;
}

.mayte__retrato {
	width: 46px;
	height: 46px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	display: grid;
	place-items: center;
	font-weight: 700;
	font-size: 19px;
	flex: 0 0 auto;
	overflow: hidden;
}

.mayte__retrato img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.mayte__identidad {
	flex: 1 1 auto;
	min-width: 0;
}

.mayte__nombre {
	margin: 0;
	font-size: 19px;
	font-weight: 700;
	letter-spacing: 0.01em;
}

.mayte__rol {
	margin: 0;
	font-size: 14px;
	opacity: 0.9;
}

.mayte__cerrar {
	width: 48px;
	height: 48px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	flex: 0 0 auto;
}

.mayte__cerrar:hover {
	background: rgba(255, 255, 255, 0.26);
}

.mayte__cerrar:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

.mayte--incrustado .mayte__cerrar {
	display: none;
}

/* --- Hilo de mensajes ----------------------------------------------- */

.mayte__hilo {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 22px 22px 8px;
	scroll-behavior: smooth;
}

.mayte__mensaje {
	margin: 0 0 20px;
}

.mayte__mensaje--asistente {
	border-left: 3px solid var(--mayte-acento);
	padding-left: 16px;
}

.mayte__mensaje--asistente p {
	margin: 0 0 12px;
}

.mayte__mensaje--asistente p:last-child {
	margin-bottom: 0;
}

.mayte__mensaje--asistente a {
	color: var(--mayte-azul-oscuro);
	text-decoration: underline;
	text-underline-offset: 3px;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.mayte__mensaje--asistente ol,
.mayte__mensaje--asistente ul {
	margin: 0 0 12px;
	padding-left: 26px;
	list-style-position: outside;
}

.mayte__mensaje--asistente ol {
	list-style: decimal;
}

.mayte__mensaje--asistente ul {
	list-style: disc;
}

.mayte__mensaje--asistente li {
	margin: 0 0 12px;
	padding-left: 4px;
}

.mayte__mensaje--asistente li:last-child {
	margin-bottom: 0;
}

.mayte__mensaje--asistente li::marker {
	color: var(--mayte-acento);
	font-weight: 700;
}

.mayte__mensaje--usuario {
	display: flex;
	justify-content: flex-end;
}

.mayte__mensaje--usuario span {
	display: inline-block;
	max-width: 85%;
	padding: 12px 18px;
	border-radius: 18px 18px 4px 18px;
	background: var(--mayte-lavado);
	color: var(--mayte-tinta);
}

.mayte__aviso {
	margin: 0 0 20px;
	padding: 14px 16px;
	border-radius: 12px;
	background: #fdf3e2;
	border: 1px solid #e8cfa0;
	color: #6b4a10;
	font-size: 16px;
}

/* --- Botón de escuchar ---------------------------------------------- */

.mayte__escuchar {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	min-height: 44px;
	margin-top: 12px;
	padding: 8px 18px 8px 14px;
	border: 1px solid var(--mayte-borde);
	border-radius: 22px;
	background: #fff;
	color: var(--mayte-azul-oscuro);
	font: inherit;
	font-size: 16px;
	cursor: pointer;
}

.mayte__escuchar:hover {
	background: var(--mayte-lavado);
	border-color: var(--mayte-acento);
}

.mayte__escuchar:focus-visible {
	outline: 3px solid var(--mayte-acento);
	outline-offset: 2px;
}

/* Triángulo de reproducir, dibujado con bordes. */

.mayte__escuchar-icono {
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 8px 0 8px 13px;
	border-color: transparent transparent transparent var(--mayte-acento);
	flex: 0 0 auto;
	margin-left: 2px;
}

.mayte__escuchar--sonando {
	background: var(--mayte-acento);
	border-color: var(--mayte-acento);
	color: #fff;
}

/* Cuadrado de parar. */

.mayte__escuchar--sonando .mayte__escuchar-icono {
	width: 13px;
	height: 13px;
	border: 0;
	border-radius: 2px;
	background: #fff;
	margin-left: 0;
}

/* Aro girando mientras ElevenLabs prepara el audio. */

.mayte__escuchar--cargando .mayte__escuchar-icono {
	width: 15px;
	height: 15px;
	border: 2px solid var(--mayte-borde);
	border-top-color: var(--mayte-acento);
	border-radius: 50%;
	margin-left: 0;
	animation: mayte-gira 0.8s linear infinite;
}

@keyframes mayte-gira {
	to { transform: rotate(360deg); }
}

.mayte__escuchar--error {
	border-color: #e8cfa0;
	background: #fdf3e2;
	color: #6b4a10;
}

.mayte__escuchar--error .mayte__escuchar-icono {
	display: none;
}

/* --- Sugerencias ---------------------------------------------------- */

.mayte__sugerencias {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding: 0 22px 16px;
}

.mayte__sugerencia {
	min-height: 44px;
	padding: 8px 16px;
	border: 1px solid var(--mayte-borde);
	border-radius: 22px;
	background: #fff;
	color: var(--mayte-azul-oscuro);
	font: inherit;
	font-size: 16px;
	cursor: pointer;
}

.mayte__sugerencia:hover {
	background: var(--mayte-lavado);
	border-color: var(--mayte-acento);
}

.mayte__sugerencia:focus-visible {
	outline: 3px solid var(--mayte-acento);
	outline-offset: 2px;
}

/* --- Barra de escritura --------------------------------------------- */

.mayte__barra {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 14px 16px 16px;
	border-top: 1px solid var(--mayte-borde);
	background: #fff;
}

.mayte__campo {
	flex: 1 1 auto;
	min-height: 52px;
	max-height: 140px;
	padding: 13px 16px;
	border: 1px solid var(--mayte-borde);
	border-radius: 14px;
	font: inherit;
	line-height: 1.5;
	resize: none;
	color: var(--mayte-tinta);
	background: #fff;
}

.mayte__campo:focus {
	outline: 3px solid var(--mayte-acento);
	outline-offset: 1px;
	border-color: var(--mayte-acento);
}

.mayte__campo::placeholder {
	color: var(--mayte-tinta-suave);
}

.mayte__enviar {
	min-width: 52px;
	min-height: 52px;
	border: 0;
	border-radius: 14px;
	background: var(--mayte-acento);
	color: #fff;
	cursor: pointer;
	display: grid;
	place-items: center;
	flex: 0 0 auto;
}

.mayte__enviar:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.mayte__enviar:focus-visible {
	outline: 3px solid var(--mayte-tinta);
	outline-offset: 2px;
}

.mayte__enviar svg {
	width: 24px;
	height: 24px;
	fill: currentColor;
}

.mayte__pie {
	padding: 0 16px 14px;
	margin: 0;
	font-size: 13px;
	color: var(--mayte-tinta-suave);
	text-align: center;
}

.mayte__pie button {
	border: 0;
	background: none;
	padding: 0;
	font: inherit;
	color: var(--mayte-verde-texto);
	text-decoration: underline;
	cursor: pointer;
}

/* --- Accesibilidad -------------------------------------------------- */

.mayte__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.mayte *,
	.mayte *::before,
	.mayte *::after {
		animation: none !important;
		transition: none !important;
		scroll-behavior: auto !important;
	}
}

@media (max-width: 600px) {
	.mayte {
		right: 12px;
		bottom: 12px;
		left: 12px;
	}

	.mayte__panel {
		width: 100%;
		height: calc(100vh - 24px);
		max-height: none;
		border-radius: 16px;
	}

	.mayte__lanzador {
		width: 66px;
		height: 66px;
		min-width: 66px;
		min-height: 66px;
		max-width: 66px;
	}

	.mayte__globo {
		max-width: 210px;
	}

	.mayte__globo-texto {
		font-size: 16px;
		padding: 11px 15px;
	}
}
