/* Chatbot Audiencia Segura — widget flotante */

.cas-root {
	--cas-brand: #12356b;
	--cas-brand-ink: #ffffff;
	--cas-accent: #e0692f;
	--cas-bg: #ffffff;
	--cas-ink: #1c2530;
	--cas-muted: #667085;
	--cas-line: #e4e8ef;
	--cas-bubble-user: #12356b;
	--cas-bubble-bot: #f2f4f8;
	--cas-radius: 16px;
	--cas-shadow: 0 18px 48px rgba(16, 32, 62, 0.22);

	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}

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

/* --- Botón lanzador --- */

.cas-launcher {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	margin-left: auto;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--cas-brand);
	color: var(--cas-brand-ink);
	cursor: pointer;
	box-shadow: var(--cas-shadow);
	transition: transform 0.18s ease, background 0.18s ease;
}

.cas-launcher:hover {
	transform: translateY(-2px);
	background: #0e2a55;
}

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

.cas-launcher svg {
	width: 27px;
	height: 27px;
	fill: currentColor;
	pointer-events: none;
}

.cas-launcher__badge {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 13px;
	height: 13px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--cas-accent);
}

.cas-launcher {
	position: relative;
}

.cas-root.is-open .cas-launcher__badge {
	display: none;
}

/* --- Panel --- */

.cas-panel {
	display: none;
	flex-direction: column;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 120px);
	margin-bottom: 14px;
	overflow: hidden;
	border-radius: var(--cas-radius);
	background: var(--cas-bg);
	box-shadow: var(--cas-shadow);
}

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

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

@media (prefers-reduced-motion: reduce) {
	.cas-root.is-open .cas-panel,
	.cas-launcher,
	.cas-root .cas-chip,
	.cas-root .cas-msg__cta {
		animation: none;
		transition: none;
	}
}

/* --- Cabecera --- */

.cas-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 15px 16px;
	background: var(--cas-brand);
	color: var(--cas-brand-ink);
}

.cas-header__avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 38px;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
	font-weight: 700;
	font-size: 15px;
}

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

.cas-header__title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cas-header__status {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12.5px;
	opacity: 0.82;
}

.cas-header__dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #3ddc84;
}

.cas-header__actions {
	display: flex;
	gap: 2px;
}

.cas-iconbtn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	cursor: pointer;
	opacity: 0.85;
}

.cas-iconbtn:hover {
	background: rgba(255, 255, 255, 0.14);
	opacity: 1;
}

.cas-iconbtn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 1px;
}

.cas-iconbtn svg {
	width: 17px;
	height: 17px;
	fill: currentColor;
}

/* --- Mensajes --- */

.cas-log {
	flex: 1 1 auto;
	padding: 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: #fbfcfe;
}

.cas-msg {
	display: flex;
	margin-bottom: 10px;
}

.cas-msg--user {
	justify-content: flex-end;
}

.cas-msg__bubble {
	max-width: 84%;
	padding: 10px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.cas-msg--bot .cas-msg__bubble {
	border-bottom-left-radius: 4px;
	background: var(--cas-bubble-bot);
	color: var(--cas-ink);
}

.cas-msg--user .cas-msg__bubble {
	border-bottom-right-radius: 4px;
	background: var(--cas-bubble-user);
	color: #fff;
}

.cas-msg--error .cas-msg__bubble {
	background: #fdecec;
	color: #8a1f1f;
}

.cas-msg__bubble a {
	color: inherit;
	text-decoration: underline;
}

/* Enlaces escritos por el asistente en formato Markdown: se muestran con su
   texto legible, nunca con la URL completa. */
.cas-root .cas-msg__cta {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	margin-top: 6px;
	padding: 8px 14px;
	border-radius: 999px;
	background: var(--cas-brand);
	color: var(--cas-brand-ink);
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	transition: background 0.15s ease;
}

.cas-root .cas-msg__cta:hover,
.cas-root .cas-msg__cta:focus-visible {
	background: #0e2a55;
	color: var(--cas-brand-ink);
	text-decoration: none;
}

.cas-root .cas-msg__cta:focus-visible {
	outline: 3px solid var(--cas-accent);
	outline-offset: 2px;
}

/* Variante WhatsApp: verde de marca con texto blanco (contraste 4.6:1). */
.cas-root .cas-msg__cta--wa {
	background: #128c7e;
}

.cas-root .cas-msg__cta--wa:hover,
.cas-root .cas-msg__cta--wa:focus-visible {
	background: #0d6d62;
}

.cas-root .cas-msg__cta svg {
	width: 16px;
	height: 16px;
	fill: currentColor;
	flex: 0 0 16px;
}

/* --- Indicador de escritura --- */

.cas-typing {
	display: flex;
	gap: 4px;
	align-items: center;
	padding: 13px;
}

.cas-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9aa4b5;
	animation: cas-bounce 1.2s infinite ease-in-out;
}

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

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

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

/* --- Sugerencias --- */

.cas-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 0 16px 12px;
}

/* Los selectores van prefijados con .cas-root para ganar en especificidad a
   los estilos de botón del tema activo, que son la causa habitual de que el
   texto quede del mismo color que el fondo al pasar el ratón. */
.cas-root .cas-chip {
	padding: 7px 12px;
	border: 1px solid var(--cas-line);
	border-radius: 999px;
	background: #fff;
	color: var(--cas-brand);
	font: inherit;
	font-size: 13px;
	line-height: 1.35;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* Hover/focus: fondo azul de marca con texto blanco (contraste 11.4:1). */
.cas-root .cas-chip:hover,
.cas-root .cas-chip:focus-visible {
	border-color: var(--cas-brand);
	background: var(--cas-brand);
	color: var(--cas-brand-ink);
}

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

.cas-root .cas-chip:active {
	border-color: #0e2a55;
	background: #0e2a55;
	color: var(--cas-brand-ink);
}

.cas-root .cas-chip[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

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

.cas-footer {
	border-top: 1px solid var(--cas-line);
	background: #fff;
}

.cas-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
}

.cas-input {
	flex: 1 1 auto;
	max-height: 110px;
	min-height: 42px;
	padding: 10px 12px;
	border: 1px solid var(--cas-line);
	border-radius: 12px;
	background: #fff;
	color: var(--cas-ink);
	font: inherit;
	line-height: 1.4;
	resize: none;
}

.cas-input:focus {
	outline: none;
	border-color: var(--cas-brand);
	box-shadow: 0 0 0 3px rgba(18, 53, 107, 0.12);
}

.cas-send {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 42px;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: var(--cas-brand);
	color: #fff;
	cursor: pointer;
}

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

.cas-send svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

.cas-legal {
	padding: 0 14px 10px;
	color: var(--cas-muted);
	font-size: 11.5px;
	text-align: center;
}

.cas-legal a {
	color: var(--cas-brand);
}

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

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

	.cas-panel {
		width: calc(100vw - 28px);
		height: calc(100vh - 110px);
	}
}
