/* ==========================================================================
   EmpatIA Asesor — widget de chat
   Paleta: navy #1A3C5E · teal #5BC4C4 · oro #C9A84C
   Sin fuentes externas: hereda la tipografía del tema para no consumir
   datos móviles del colaborador.
   ========================================================================== */

.ea-root {
	--ea-navy: #1a3c5e;
	--ea-navy-dark: #142f4a;
	--ea-teal: #5bc4c4;
	--ea-teal-soft: #eaf7f7;
	--ea-gold: #c9a84c;
	--ea-ink: #21303d;
	--ea-muted: #6b7a88;
	--ea-line: #e3e8ed;
	--ea-surface: #ffffff;

	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99990;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.5;
	color: var(--ea-ink);
}

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

/* --- Botón de apertura ---------------------------------------------------- */

.ea-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 0 20px 0 16px;
	height: 52px;
	border: 0;
	border-radius: 26px;
	background: var(--ea-navy);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(26, 60, 94, 0.28);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ea-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 26px rgba(26, 60, 94, 0.34);
}

.ea-launcher:focus-visible {
	outline: 3px solid var(--ea-gold);
	outline-offset: 3px;
}

.ea-launcher-icon {
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	color: var(--ea-teal);
}

.ea-root.is-open .ea-launcher {
	display: none;
}

/* --- Ventana -------------------------------------------------------------- */

.ea-panel {
	display: none;
	flex-direction: column;
	width: 360px;
	height: 540px;
	max-height: calc(100vh - 40px);
	background: var(--ea-surface);
	border: 1px solid var(--ea-line);
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 18px 48px rgba(20, 47, 74, 0.24);
}

.ea-root.is-open .ea-panel {
	display: flex;
	animation: ea-in 0.2s ease;
}

@keyframes ea-in {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: none; }
}

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

.ea-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 14px 14px 18px;
	background: var(--ea-navy);
	color: #fff;
}

.ea-head-text { flex: 1 1 auto; min-width: 0; }

.ea-title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.01em;
}

.ea-subtitle {
	margin: 2px 0 0;
	font-size: 12.5px;
	color: rgba(255, 255, 255, 0.72);
}

.ea-close {
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
}

.ea-close:hover { background: rgba(255, 255, 255, 0.22); }

.ea-close:focus-visible {
	outline: 3px solid var(--ea-gold);
	outline-offset: 2px;
}

/* --- Mensajes ------------------------------------------------------------- */

.ea-log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 18px 16px;
	background: #fbfcfd;
	display: flex;
	flex-direction: column;
	gap: 12px;
	overscroll-behavior: contain;
}

.ea-msg {
	max-width: 88%;
	padding: 10px 14px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.ea-msg-bot {
	align-self: flex-start;
	background: var(--ea-teal-soft);
	border-left: 3px solid var(--ea-teal);
	border-top-left-radius: 4px;
}

.ea-msg-user {
	align-self: flex-end;
	background: var(--ea-navy);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.ea-msg-note {
	align-self: center;
	max-width: 100%;
	background: #fff8e6;
	border: 1px solid #f0e0b4;
	color: #6a5620;
	font-size: 13px;
	text-align: center;
}

/* Indicador de escritura */

.ea-typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 4px;
	padding: 12px 14px;
	background: var(--ea-teal-soft);
	border-left: 3px solid var(--ea-teal);
	border-radius: 14px;
	border-top-left-radius: 4px;
}

.ea-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ea-teal);
	animation: ea-bounce 1.2s infinite ease-in-out;
}

.ea-typing span:nth-child(2) { animation-delay: 0.15s; }
.ea-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ea-bounce {
	0%, 60%, 100% { transform: none; opacity: 0.45; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

/* --- Entrada -------------------------------------------------------------- */

.ea-foot {
	flex: 0 0 auto;
	padding: 12px 14px 10px;
	border-top: 1px solid var(--ea-line);
	background: var(--ea-surface);
}

.ea-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.ea-input {
	flex: 1 1 auto;
	min-height: 42px;
	max-height: 110px;
	padding: 10px 12px;
	border: 1px solid var(--ea-line);
	border-radius: 10px;
	background: #fff;
	font: inherit;
	font-size: 15px; /* 15px o más evita el zoom automático en iOS */
	color: var(--ea-ink);
	resize: none;
}

.ea-input:focus {
	outline: 0;
	border-color: var(--ea-teal);
	box-shadow: 0 0 0 3px rgba(91, 196, 196, 0.22);
}

.ea-send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 10px;
	background: var(--ea-gold);
	color: #35291a;
	cursor: pointer;
	transition: filter 0.15s ease;
}

.ea-send:hover:not(:disabled) { filter: brightness(1.07); }

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

.ea-send:focus-visible {
	outline: 3px solid var(--ea-navy);
	outline-offset: 2px;
}

.ea-send svg { width: 19px; height: 19px; }

.ea-disclaimer {
	margin: 8px 2px 0;
	font-size: 11.5px;
	line-height: 1.45;
	color: var(--ea-muted);
	text-align: center;
}

/* --- Móvil: pantalla completa -------------------------------------------- */

@media (max-width: 640px) {
	.ea-root {
		right: 14px;
		bottom: 14px;
	}

	.ea-launcher {
		width: 56px;
		height: 56px;
		padding: 0;
		justify-content: center;
		border-radius: 50%;
	}

	.ea-launcher-label { display: none; }

	.ea-root.is-open {
		inset: 0;
		right: 0;
		bottom: 0;
	}

	.ea-root.is-open .ea-panel {
		width: 100%;
		height: 100%;
		max-height: none;
		border: 0;
		border-radius: 0;
	}
}

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

@media (prefers-reduced-motion: reduce) {
	.ea-root *,
	.ea-root *::before,
	.ea-root *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}

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