/* Chat del sitio */
/* Prefijo propio (.sa-chat / --sa-chat-) para no chocar con el tema. Sin blur, sin bordes decorativos. */
.sa-chat, .sa-chat-p {
	--sa-chat-ink: #060E1C;
	--sa-chat-acento: #004A90;
	--sa-chat-acento-d: #2249C9;
	--sa-chat-live: #0D7A4F;
	--sa-chat-bubble: #F3F5F8;
	--sa-chat-muted: #5A6A80;
	--sa-chat-line: #E3E8F0;
	--sa-chat-error: #D3264B;
	--sa-chat-ease: cubic-bezier(.16, 1, .3, 1);
	--sa-chat-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
	font-family: var(--sa-chat-font);
	-webkit-font-smoothing: antialiased;
}
.sa-chat *, .sa-chat-p *, .sa-chat-p *::before, .sa-chat-p *::after { box-sizing: border-box; }
.sa-chat-p button, .sa-chat-p input, .sa-chat-p textarea, .sa-chat button { font: inherit; letter-spacing: normal; text-transform: none; }

/* ------------------------------------------------------------------ Lanzador */
.sa-chat {
	position: fixed;
	z-index: 110;
	right: max(18px, env(safe-area-inset-right));
	bottom: calc(18px + env(safe-area-inset-bottom) + var(--sa-chat-lift, 0px));
	transition: bottom .4s var(--sa-chat-ease);
}
.sa-chat__launcher {
	position: relative;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--sa-chat-acento);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 10px 30px rgba(6, 14, 28, .14);
	transition: transform .3s var(--sa-chat-ease), background-color .2s;
	-webkit-tap-highlight-color: transparent;
}
.sa-chat__launcher:hover { background: var(--sa-chat-acento-d); transform: scale(1.04); box-shadow: 0 14px 34px rgba(6, 14, 28, .18); }
.sa-chat__launcher:active { transform: scale(.97); }
.sa-chat.is-away { opacity: 0; pointer-events: none; transform: scale(.8); }
.sa-chat { transition: bottom .4s var(--sa-chat-ease), opacity .3s var(--sa-chat-ease), transform .3s var(--sa-chat-ease); }
.sa-chat__i { position: absolute; top: 50%; left: 50%; margin: -12px 0 0 -12px; transition: transform .3s var(--sa-chat-ease), opacity .2s; }
.sa-chat__i--down { opacity: 0; transform: rotate(-90deg) scale(.6); }
.sa-chat[data-state="open"] .sa-chat__i--chat { opacity: 0; transform: rotate(90deg) scale(.4); }
.sa-chat[data-state="open"] .sa-chat__i--down { opacity: 1; transform: none; }
.sa-chat[data-state="open"] .sa-chat__dot { display: none; }
.sa-chat__launcher:focus-visible { outline: 2px solid var(--sa-chat-acento); outline-offset: 3px; }
.sa-chat__launcher svg { width: 24px; height: 24px; }
.sa-chat__dot {
	position: absolute;
	top: 3px;
	right: 3px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--sa-chat-live);
	box-shadow: 0 0 0 2px #fff;
	opacity: 0;
	transform: scale(.5);
	transition: opacity .3s, transform .3s var(--sa-chat-ease);
}
.sa-chat__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--sa-chat-live);
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	line-height: 20px;
	text-align: center;
	box-shadow: 0 0 0 2px #fff;
}

/* ------------------------------------------------------------------ Ventana */
.sa-chat-p {
	position: fixed;
	z-index: 120;
	right: max(18px, env(safe-area-inset-right));
	bottom: calc(18px + 56px + 12px + env(safe-area-inset-bottom));
	width: 380px;
	height: min(600px, calc(100vh - 120px));
	display: flex;
	flex-direction: column;
	background: #fff;
	color: var(--sa-chat-ink);
	border-radius: 24px;
	overflow: hidden;
	box-shadow: 0 24px 60px -12px rgba(6, 14, 28, .22), 0 2px 8px rgba(6, 14, 28, .06);
	transform-origin: calc(100% - 28px) calc(100% + 40px);
	opacity: 0;
	transform: translateY(12px) scale(.9);
	transition: opacity .22s ease-in, transform .22s ease-in;
	will-change: transform, opacity;
	font-size: 15px;
	line-height: 1.45;
}
.sa-chat-p.is-in { opacity: 1; transform: none; transition: opacity .38s var(--sa-chat-ease), transform .38s var(--sa-chat-ease); }
/* Contenido escalonado al abrir */
.sa-chat-p > * { opacity: 0; transform: translateY(6px); transition: opacity .3s var(--sa-chat-ease), transform .3s var(--sa-chat-ease); }
.sa-chat-p.is-in > * { opacity: 1; transform: none; }
.sa-chat-p.is-in > :nth-child(1) { transition-delay: .06s; }
.sa-chat-p.is-in > :nth-child(2) { transition-delay: .1s; }
.sa-chat-p.is-in > :nth-child(3) { transition-delay: .14s; }
.sa-chat-p.is-in > :nth-child(4) { transition-delay: .18s; }
.sa-chat-p.is-out > * { transition-duration: .15s; }
.sa-chat-p[hidden] { display: none; }

.sa-chat-p__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 12px 16px 18px;
	border-bottom: 1px solid var(--sa-chat-line);
	background: #fff;
}
.sa-chat-p__avw { position: relative; flex: none; }
.sa-chat-p__av { display: block; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--sa-chat-bubble); }
 .sa-chat-row__av--txt { display: grid; place-items: center; background: var(--sa-chat-ink); color: #fff; font-weight: 600; }
.sa-chat-dot {
	position: absolute;
	right: 0;
	bottom: 0;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: #A9B4C4;
	box-shadow: 0 0 0 2px #fff;
}
.sa-chat-p.is-online .sa-chat-dot { background: var(--sa-chat-live); }
.sa-chat-p__who { min-width: 0; flex: 1; line-height: 1.3; }
.sa-chat-p__who b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-chat-p__who small { display: block; color: var(--sa-chat-muted); font-size: 13px; }
.sa-chat-p__x {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--sa-chat-ink);
	cursor: pointer;
	transition: background-color .2s;
}
.sa-chat-p__x:hover { background: var(--sa-chat-bubble); }
.sa-chat-p__x svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ Conversación */
.sa-chat-p__log {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 20px 16px 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #fff;
}
.sa-chat-p__log > .is-first:not(:first-child), .sa-chat-p__log > .sa-chat-chips { margin-top: 8px; } /* 8px + 8px = 16px entre emisores */
.sa-chat-row { display: flex; align-items: flex-end; gap: 8px; max-width: 88%; }
.sa-chat-row__av { flex: none; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; font-size: 12px; }
.sa-chat-row__av--gap { visibility: hidden; }
.sa-chat-row.is-first .sa-chat-row__av { align-self: flex-start; }
.sa-chat-msg {
	max-width: 86%;
	padding: 10px 14px;
	border-radius: 18px;
	background: var(--sa-chat-bubble);
	color: var(--sa-chat-ink);
	font-size: 15px;
	line-height: 1.45;
	overflow-wrap: anywhere;
	animation: sa-chat-up .3s var(--sa-chat-ease) both;
}
.sa-chat-row .sa-chat-msg { max-width: none; }
@keyframes sa-chat-up { from { opacity: 0; transform: translateY(6px); } }
.sa-chat-msg p { margin: 0; white-space: pre-line; }
.sa-chat-msg a { color: var(--sa-chat-acento); font-weight: 500; text-underline-offset: 2px; }
.sa-chat-msg img { display: block; max-width: 100%; max-height: 200px; border-radius: 12px; }
.sa-chat-msg time { display: block; margin-top: 4px; font-size: 11px; color: var(--sa-chat-muted); }
.sa-chat-msg__who { display: block; font-size: 12px; font-weight: 600; color: var(--sa-chat-muted); margin-bottom: 2px; }
.sa-chat-msg--visitor { align-self: flex-end; background: var(--sa-chat-acento); color: #fff; }
.sa-chat-msg--visitor a { color: #fff; }
.sa-chat-msg--visitor time { color: rgba(255, 255, 255, .75); text-align: right; }
.sa-chat-msg--visitor.is-pending { opacity: .6; }
.sa-chat-msg--visitor.is-failed { background: var(--sa-chat-error); cursor: pointer; }
.sa-chat-msg--system {
	align-self: center;
	max-width: 92%;
	padding: 2px 8px;
	background: none;
	color: var(--sa-chat-muted);
	font-size: 12px;
	line-height: 1.4;
	text-align: center;
}
.sa-chat-typing {
	display: inline-flex;
	gap: 4px;
	align-self: flex-start;
	margin-left: 36px;
	padding: 13px 14px;
	border-radius: 18px;
	background: var(--sa-chat-bubble);
}
.sa-chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--sa-chat-muted); animation: sa-chat-dot 1s infinite; }
.sa-chat-typing i:nth-child(2) { animation-delay: .15s; }
.sa-chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes sa-chat-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }

.sa-chat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 36px; }
.sa-chat-chips__label { flex-basis: 100%; color: var(--sa-chat-muted); font-size: 13px; margin-bottom: 2px; }
.sa-chat-chip {
	min-height: 36px;
	padding: 7px 14px;
	border: 0;
	border-radius: 999px;
	background: #EEF3FE;
	color: var(--sa-chat-acento);
	font-size: 14px;
	font-weight: 500;
	line-height: 1.3;
	text-align: left;
	cursor: pointer;
	transition: background-color .2s, color .2s;
}
.sa-chat-chip:hover { background: #E0E9FD; }
.sa-chat-chip--solid { background: var(--sa-chat-acento); color: #fff; }
.sa-chat-chip--solid:hover { background: var(--sa-chat-acento-d); }

/* Formulario «hablar con un asesor» */
.sa-chat-form {
	display: grid;
	gap: 8px;
	margin: 8px 0 0;
	padding: 16px;
	border-radius: 18px;
	background: var(--sa-chat-bubble);
	animation: sa-chat-up .3s var(--sa-chat-ease) both;
}
.sa-chat-form p { margin: 0 0 4px; font-size: 14px; color: var(--sa-chat-muted); }
.sa-chat-input {
	width: 100%;
	min-height: 44px;
	padding: 10px 14px;
	border: 1px solid var(--sa-chat-line);
	border-radius: 12px;
	background: #fff;
	color: var(--sa-chat-ink);
	font-size: 16px;
	-webkit-appearance: none;
	appearance: none;
}
.sa-chat-input:focus { outline: none; border-color: var(--sa-chat-acento); }
.sa-chat-tel { display: flex; }
.sa-chat-tel > span {
	display: grid;
	place-items: center;
	padding: 0 10px;
	border: 1px solid var(--sa-chat-line);
	border-right: 0;
	border-radius: 12px 0 0 12px;
	background: #fff;
	color: var(--sa-chat-muted);
	font-size: 14px;
}
.sa-chat-tel .sa-chat-input { border-radius: 0 12px 12px 0; }
.sa-chat-check { display: flex; gap: 8px; align-items: flex-start; margin: 2px 0; font-size: 13px; line-height: 1.4; cursor: pointer; }
.sa-chat-check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--sa-chat-acento); flex: none; }
.sa-chat-check a { color: var(--sa-chat-acento); }
.sa-chat-err { margin: 0; color: var(--sa-chat-error); font-size: 13px; font-weight: 500; }
.sa-chat-form button[type="submit"] {
	min-height: 44px;
	border: 0;
	border-radius: 999px;
	background: var(--sa-chat-acento);
	color: #fff;
	font-weight: 500;
	cursor: pointer;
}
.sa-chat-form button[disabled] { opacity: .5; }

/* ------------------------------------------------------------------ Escribir */
.sa-chat-p__form { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--sa-chat-line); background: #fff; }
.sa-chat-p__form textarea {
	flex: 1;
	min-width: 0;
	min-height: 44px;
	max-height: 128px;
	margin: 0;
	resize: none;
	padding: 11px 16px;
	border: 0;
	border-radius: 22px;
	background: var(--sa-chat-bubble);
	color: var(--sa-chat-ink);
	font-size: 16px;
	line-height: 1.35;
	box-shadow: none;
}
.sa-chat-p__form textarea:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--sa-chat-acento); background: #fff; }
.sa-chat-p__form textarea::placeholder { color: #8A96A8; }
.sa-chat-p__send {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--sa-chat-acento);
	color: #fff;
	flex: none;
	cursor: pointer;
	transition: opacity .2s, background-color .2s;
}
.sa-chat-p__send:hover { background: var(--sa-chat-acento-d); }
.sa-chat-p__send:disabled { opacity: .35; cursor: default; }
.sa-chat-p__send svg { width: 20px; height: 20px; }
.sa-chat-p__clip { display: grid; place-items: center; width: 40px; height: 44px; color: var(--sa-chat-muted); cursor: pointer; flex: none; }
.sa-chat-p__clip[hidden] { display: none; }
.sa-chat-p__clip svg { width: 20px; height: 20px; }
.sa-chat-p__foot { display: flex; justify-content: center; padding: 0 12px 12px; background: #fff; }
.sa-chat-p__foot[hidden] { display: none; }
.sa-chat-p__foot button {
	border: 0;
	background: none;
	color: var(--sa-chat-muted);
	font-size: 13px;
	font-weight: 500;
	text-decoration: underline;
	text-underline-offset: 3px;
	padding: 4px;
	cursor: pointer;
}
.sa-chat-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ------------------------------------------------------------------ Móvil: pantalla completa */
@media (max-width: 599px) {
	/* 28 px: pegado a 16 px del borde, Safari 26 lo toma como barra inferior y pinta un recuadro de color detrás. */
	.sa-chat { right: max(16px, env(safe-area-inset-right)); bottom: calc(28px + env(safe-area-inset-bottom) + var(--sa-chat-lift, 0px)); }
	.sa-chat-p {
		inset: 0;
		width: auto;
		height: var(--vvh, 100dvh);
		border-radius: 0;
		padding-top: env(safe-area-inset-top);
		transform: translateY(40px);
	}
	.sa-chat-p.is-in { transform: none; }
	.sa-chat-p__form { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
	html.sa-chat-open, html.sa-chat-open body { overflow: hidden; }
	.sa-chat[data-state="open"] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	.sa-chat-msg, .sa-chat-form { animation: none; }
	.sa-chat-p, .sa-chat-p.is-in, .sa-chat-p > *, .sa-chat__i {
		transform: none !important;
		transition: opacity .15s linear !important;
		transition-delay: 0s !important;
	}
}
/* Dejar un mensaje */
.sa-chat-form textarea.sa-chat-input { min-height: 84px; resize: vertical; line-height: 1.4; }
.sa-chat-pref { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0; padding: 0; border: 0; }
.sa-chat-pref legend { width: 100%; margin-bottom: 6px; padding: 0; font-size: 13px; color: var(--sa-chat-muted); }
.sa-chat-pref label { position: relative; cursor: pointer; }
.sa-chat-pref input { position: absolute; opacity: 0; }
.sa-chat-pref span {
	display: inline-block;
	padding: 8px 16px;
	border-radius: 999px;
	background: #fff;
	color: var(--sa-chat-ink);
	font-size: 14px;
	font-weight: 500;
}
.sa-chat-pref input:checked + span { background: var(--sa-chat-acento); color: #fff; }
.sa-chat-pref input:focus-visible + span { outline: 2px solid var(--sa-chat-acento); outline-offset: 2px; }
.sa-chat-form [hidden] { display: none !important; }
@media print { .sa-chat, .sa-chat-p { display: none !important; } }

/* Zonas táctiles de 44 px sin cambiar el aspecto */
.sa-chat-p__x, .sa-chat-p__clip, .sa-chat-chip { position: relative; }
.sa-chat-p__x::after { content: ""; position: absolute; inset: -2px; }
.sa-chat-p__clip::after { content: ""; position: absolute; top: 0; bottom: 0; left: -2px; right: -2px; }
.sa-chat-chip::after { content: ""; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px; }
