/*
 * assets/css/talo.css — Interfaz del asistente Talo.
 *
 * Paleta y tipografía alineadas con el design system de Grupo Talía.
 * Todo el CSS está namespaced con .talo para no interferir con el theme.
 */

.talo {
	--talo-accent: #d88329;
	--talo-accent-strong: #c4621c;
	--talo-ink: #10202f;
	--talo-ink-2: #192d3f;
	--talo-text: #252930;
	--talo-muted: #5a6470;
	--talo-surface: #ffffff;
	--talo-surface-soft: #f4f7fb;
	--talo-line: rgba(37, 41, 48, 0.12);
	--talo-radius: 20px;
	--talo-shadow: 0 28px 70px rgba(16, 32, 47, 0.24);

	position: fixed;
	inset-block-end: 22px;
	z-index: 99990;
	font-family: "Barlow", "Barlow Semi Condensed", system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 15px;
	line-height: 1.55;
	color: var(--talo-text);
}

.talo--right { inset-inline-end: 22px; }
.talo--left  { inset-inline-start: 22px; }

/* ─── Botón lanzador ───────────────────────────────────────────────────── */

.talo-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 20px 12px 14px;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--talo-accent) 0%, var(--talo-accent-strong) 100%);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 16px 34px rgba(196, 98, 28, 0.34);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.talo-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 20px 42px rgba(196, 98, 28, 0.42);
}

.talo-launcher:focus-visible {
	outline: 3px solid rgba(16, 32, 47, 0.55);
	outline-offset: 3px;
}

.talo-launcher__avatar {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
}

.talo-launcher__label { white-space: nowrap; }

.talo-launcher__close { display: none; }

/* Pulso discreto para llamar la atención sin ser intrusivo. */
.talo-launcher::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 999px;
	box-shadow: 0 0 0 0 rgba(216, 131, 41, 0.55);
	animation: talo-pulse 3.4s ease-out 2s 3;
	pointer-events: none;
}

@keyframes talo-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(216, 131, 41, 0.5); }
	70%  { box-shadow: 0 0 0 18px rgba(216, 131, 41, 0); }
	100% { box-shadow: 0 0 0 0 rgba(216, 131, 41, 0); }
}

.talo-launcher { position: relative; }

/* Estado abierto: el lanzador se convierte en un botón circular de cierre. */
.talo[data-state="open"] .talo-launcher__label,
.talo[data-state="open"] .talo-launcher__avatar { display: none; }

.talo[data-state="open"] .talo-launcher {
	padding: 14px;
	border-radius: 50%;
}

.talo[data-state="open"] .talo-launcher::after { animation: none; }

.talo[data-state="open"] .talo-launcher__close {
	display: grid;
	place-items: center;
	width: 20px;
	height: 20px;
}

/* ─── Panel de conversación ────────────────────────────────────────────── */

.talo-panel {
	position: absolute;
	inset-block-end: 68px;
	width: min(390px, calc(100vw - 44px));
	max-height: min(640px, calc(100vh - 130px));
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--talo-surface);
	border: 1px solid var(--talo-line);
	border-radius: var(--talo-radius);
	box-shadow: var(--talo-shadow);
	transform-origin: bottom right;
	animation: talo-in 0.22s ease-out;
}

.talo--left .talo-panel {
	inset-inline-start: 0;
	transform-origin: bottom left;
}

.talo--right .talo-panel { inset-inline-end: 0; }

@keyframes talo-in {
	from { opacity: 0; transform: translateY(12px) scale(0.97); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.talo-panel[hidden] { display: none; }

/* Cabecera */

.talo-panel__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 15px;
	background: linear-gradient(135deg, var(--talo-ink) 0%, var(--talo-ink-2) 100%);
	color: #f4f7fb;
}

.talo-avatar {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	flex: 0 0 auto;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--talo-accent) 0%, var(--talo-accent-strong) 100%);
	color: #fff;
	font-weight: 700;
	font-size: 18px;
	text-transform: uppercase;
}

.talo-panel__id { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.talo-panel__id strong { font-size: 17px; font-weight: 600; letter-spacing: 0.01em; }

.talo-panel__id small {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12.5px;
	color: rgba(244, 247, 251, 0.72);
}

.talo-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.22);
}

.talo-icon-btn {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.1);
	color: inherit;
	cursor: pointer;
	transition: background 0.15s ease;
}

.talo-icon-btn:hover { background: rgba(255, 255, 255, 0.2); }
.talo-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Conversación */

.talo-log {
	flex: 1 1 auto;
	min-height: 210px;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 16px 6px;
	background: var(--talo-surface-soft);
	display: flex;
	flex-direction: column;
	gap: 12px;
	scrollbar-width: thin;
}

.talo-msg { display: flex; max-width: 100%; }
.talo-msg--user { justify-content: flex-end; }

.talo-bubble {
	max-width: 84%;
	padding: 11px 14px;
	border-radius: 16px;
	background: var(--talo-surface);
	border: 1px solid var(--talo-line);
	box-shadow: 0 2px 8px rgba(16, 32, 47, 0.05);
	animation: talo-bubble-in 0.2s ease-out;
}

@keyframes talo-bubble-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.talo-msg--bot .talo-bubble  { border-start-start-radius: 5px; }

.talo-msg--user .talo-bubble {
	background: linear-gradient(135deg, var(--talo-accent) 0%, var(--talo-accent-strong) 100%);
	border-color: transparent;
	color: #fff;
	border-end-end-radius: 5px;
}

.talo-bubble p { margin: 0 0 8px; }
.talo-bubble p:last-child { margin-bottom: 0; }
.talo-bubble ul { margin: 0 0 8px; padding-inline-start: 18px; }
.talo-bubble li { margin-bottom: 4px; }
.talo-bubble strong { font-weight: 600; }

/* Fuentes citadas */

.talo-sources {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 10px;
	padding-top: 9px;
	border-top: 1px dashed var(--talo-line);
}

.talo-sources__lead {
	width: 100%;
	margin: 0 0 2px;
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--talo-muted);
}

.talo-source {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	max-width: 100%;
	padding: 5px 10px;
	border-radius: 999px;
	background: rgba(216, 131, 41, 0.1);
	color: var(--talo-accent-strong);
	font-size: 12.5px;
	font-weight: 600;
	text-decoration: none;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.talo-source:hover { background: rgba(216, 131, 41, 0.2); text-decoration: underline; }

/* Acciones destacadas (contacto) */

.talo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.talo-action {
	display: inline-flex;
	align-items: center;
	padding: 8px 14px;
	border-radius: 999px;
	background: var(--talo-ink);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
}

.talo-action:hover { background: var(--talo-ink-2); color: #fff; }

/* Indicador de escritura */

.talo-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }

.talo-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--talo-muted);
	animation: talo-blink 1.3s infinite ease-in-out;
}

.talo-typing span:nth-child(2) { animation-delay: 0.18s; }
.talo-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes talo-blink {
	0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
	40%           { opacity: 1;    transform: translateY(-3px); }
}

/* Sugerencias */

.talo-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 10px 16px 4px;
	background: var(--talo-surface-soft);
}

.talo-chips:empty { display: none; }

.talo-chip {
	padding: 7px 13px;
	border: 1px solid var(--talo-line);
	border-radius: 999px;
	background: var(--talo-surface);
	color: var(--talo-text);
	font: inherit;
	font-size: 13px;
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.talo-chip:hover {
	border-color: var(--talo-accent);
	color: var(--talo-accent-strong);
	background: rgba(216, 131, 41, 0.07);
}

.talo-chip:focus-visible { outline: 2px solid var(--talo-accent); outline-offset: 2px; }

/* Composición */

.talo-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 14px 8px;
	background: var(--talo-surface);
	border-top: 1px solid var(--talo-line);
}

.talo-input {
	flex: 1 1 auto;
	max-height: 110px;
	padding: 11px 14px;
	border: 1px solid var(--talo-line);
	border-radius: 16px;
	background: var(--talo-surface-soft);
	font: inherit;
	color: var(--talo-text);
	resize: none;
	overflow-y: auto;
}

.talo-input:focus {
	outline: none;
	border-color: var(--talo-accent);
	box-shadow: 0 0 0 3px rgba(216, 131, 41, 0.18);
}

.talo-send {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	flex: 0 0 auto;
	border: 0;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--talo-accent) 0%, var(--talo-accent-strong) 100%);
	color: #fff;
	cursor: pointer;
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.talo-send:hover:not(:disabled) { transform: scale(1.06); }
.talo-send:disabled { opacity: 0.45; cursor: not-allowed; }
.talo-send:focus-visible { outline: 2px solid var(--talo-ink); outline-offset: 2px; }

.talo-note {
	margin: 0;
	padding: 0 16px 12px;
	background: var(--talo-surface);
	font-size: 11.5px;
	line-height: 1.4;
	color: var(--talo-muted);
	text-align: center;
}

/* ─── Móvil ────────────────────────────────────────────────────────────── */

@media (max-width: 560px) {

	.talo { inset-block-end: 16px; }
	.talo--right { inset-inline-end: 16px; }
	.talo--left  { inset-inline-start: 16px; }

	.talo-launcher__label { display: none; }
	.talo-launcher { padding: 14px; border-radius: 50%; }

	.talo-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-height: none;
		height: 100dvh;
		border: 0;
		border-radius: 0;
	}

	.talo-log { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {

	.talo-launcher,
	.talo-panel,
	.talo-bubble,
	.talo-typing span,
	.talo-launcher::after {
		animation: none !important;
		transition: none !important;
	}
}
