/* Asistente Mágico – Cartas Mágicas de Navidad */
#cmn-asistente {
	--cmn-primary: #9b1c1c;
	--cmn-accent: #d4a017;
	--cmn-bg: #fffaf3;
	--cmn-surface: #ffffff;
	--cmn-text: #2b2420;
	--cmn-muted: #7a6f66;
	--cmn-border: #eadfce;
	--cmn-radius: 18px;
	position: fixed;
	bottom: 20px;
	z-index: 2147483000;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	color: var(--cmn-text);
}
#cmn-asistente.cmn-pos-right { right: 20px; }
#cmn-asistente.cmn-pos-left { left: 20px; }
#cmn-asistente *,
#cmn-asistente *::before,
#cmn-asistente *::after { box-sizing: border-box; }
#cmn-asistente [hidden] { display: none !important; }
#cmn-asistente button { font-family: inherit; cursor: pointer; margin: 0; text-transform: none; letter-spacing: normal; }

/* Botón flotante */
#cmn-asistente .cmn-launcher {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	border: 3px solid var(--cmn-accent);
	background: var(--cmn-primary);
	color: #fff;
	box-shadow: 0 10px 28px rgba(60, 10, 10, .35);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: transform .2s ease, box-shadow .2s ease;
	position: relative;
}
#cmn-asistente .cmn-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 32px rgba(60, 10, 10, .4); }
#cmn-asistente .cmn-launcher:focus-visible { outline: 3px solid var(--cmn-accent); outline-offset: 3px; }
#cmn-asistente .cmn-launcher-open { font-size: 28px; line-height: 1; }
#cmn-asistente .cmn-launcher-close { display: none; }
#cmn-asistente.cmn-is-open .cmn-launcher-open { display: none; }
#cmn-asistente.cmn-is-open .cmn-launcher-close { display: block; }
#cmn-asistente .cmn-launcher::after {
	content: "";
	position: absolute;
	inset: -6px;
	border-radius: 50%;
	border: 2px solid var(--cmn-accent);
	opacity: 0;
	animation: cmn-pulse 2.8s ease-out 1.5s 3;
}
@keyframes cmn-pulse {
	0% { transform: scale(.9); opacity: .7; }
	100% { transform: scale(1.35); opacity: 0; }
}

/* Invitación */
#cmn-asistente .cmn-teaser {
	position: absolute;
	bottom: 74px;
	width: max-content;
	max-width: 250px;
	background: var(--cmn-surface);
	color: var(--cmn-text);
	border: 1px solid var(--cmn-border);
	border-radius: 16px;
	padding: 12px 34px 12px 14px;
	font-size: 14px;
	font-weight: 500;
	text-align: left;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
	animation: cmn-in .35s ease;
}
#cmn-asistente.cmn-pos-right .cmn-teaser { right: 0; border-bottom-right-radius: 4px; }
#cmn-asistente.cmn-pos-left .cmn-teaser { left: 0; border-bottom-left-radius: 4px; }
#cmn-asistente .cmn-teaser-x {
	position: absolute;
	top: 4px;
	right: 8px;
	font-size: 18px;
	color: var(--cmn-muted);
	line-height: 1;
	padding: 2px 4px;
}

/* Panel */
#cmn-asistente .cmn-panel {
	position: absolute;
	bottom: 78px;
	width: 380px;
	height: min(620px, calc(100vh - 120px));
	background: var(--cmn-bg);
	border-radius: var(--cmn-radius);
	box-shadow: 0 24px 60px rgba(40, 10, 10, .28);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--cmn-border);
	animation: cmn-in .25s ease;
}
#cmn-asistente.cmn-pos-right .cmn-panel { right: 0; }
#cmn-asistente.cmn-pos-left .cmn-panel { left: 0; }
@keyframes cmn-in {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: none; }
}

#cmn-asistente .cmn-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 12px 14px 16px;
	background: var(--cmn-primary);
	background-image: radial-gradient(circle at 15% 20%, rgba(255,255,255,.12) 0 2px, transparent 3px),
		radial-gradient(circle at 70% 30%, rgba(255,255,255,.10) 0 1.5px, transparent 2.5px),
		radial-gradient(circle at 40% 80%, rgba(255,255,255,.10) 0 1.5px, transparent 2.5px),
		radial-gradient(circle at 90% 75%, rgba(255,255,255,.12) 0 2px, transparent 3px);
	color: #fff;
	border-bottom: 3px solid var(--cmn-accent);
}
#cmn-asistente .cmn-avatar {
	width: 42px;
	height: 42px;
	flex: 0 0 42px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .16);
	border: 2px solid var(--cmn-accent);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
}
#cmn-asistente .cmn-titles { flex: 1; min-width: 0; }
#cmn-asistente .cmn-name { font-weight: 700; font-size: 16px; line-height: 1.2; }
#cmn-asistente .cmn-subtitle { font-size: 12.5px; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cmn-asistente .cmn-icon-btn {
	background: transparent;
	border: 0;
	color: #fff;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	opacity: .85;
}
#cmn-asistente .cmn-icon-btn:hover { background: rgba(255, 255, 255, .15); opacity: 1; }

#cmn-asistente .cmn-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px 8px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	overscroll-behavior: contain;
}
#cmn-asistente .cmn-row { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
#cmn-asistente .cmn-user { justify-content: flex-end; }
#cmn-asistente .cmn-mini-avatar {
	width: 26px;
	height: 26px;
	flex: 0 0 26px;
	border-radius: 50%;
	background: var(--cmn-surface);
	border: 1px solid var(--cmn-border);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
}
#cmn-asistente .cmn-bubble {
	max-width: 82%;
	padding: 10px 13px;
	border-radius: 16px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
#cmn-asistente .cmn-bot .cmn-bubble {
	background: var(--cmn-surface);
	border: 1px solid var(--cmn-border);
	border-bottom-left-radius: 5px;
}
#cmn-asistente .cmn-user .cmn-bubble {
	background: var(--cmn-primary);
	color: #fff;
	border-bottom-right-radius: 5px;
	white-space: pre-wrap;
}
#cmn-asistente .cmn-bubble p { margin: 0 0 6px; padding: 0; font-size: inherit; line-height: inherit; color: inherit; }
#cmn-asistente .cmn-bubble p:last-child { margin-bottom: 0; }
#cmn-asistente .cmn-bubble ul { margin: 4px 0 6px; padding-left: 18px; list-style: disc; }
#cmn-asistente .cmn-bubble li { margin: 2px 0; padding: 0; }
#cmn-asistente .cmn-bubble a { color: var(--cmn-primary); text-decoration: underline; font-weight: 600; }
#cmn-asistente .cmn-bubble strong { font-weight: 700; }
#cmn-asistente .cmn-bubble.cmn-error { background: #fff4f0; border-color: #f0c9bc; }

#cmn-asistente .cmn-typing { display: flex; gap: 4px; padding: 13px 14px; }
#cmn-asistente .cmn-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--cmn-accent);
	animation: cmn-dot 1.2s infinite ease-in-out;
}
#cmn-asistente .cmn-typing span:nth-child(2) { animation-delay: .15s; }
#cmn-asistente .cmn-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cmn-dot {
	0%, 80%, 100% { transform: translateY(0); opacity: .4; }
	40% { transform: translateY(-5px); opacity: 1; }
}

#cmn-asistente .cmn-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 4px 14px 10px;
}
#cmn-asistente .cmn-chip {
	background: var(--cmn-surface);
	color: var(--cmn-primary);
	border: 1.5px solid var(--cmn-primary);
	border-radius: 999px;
	padding: 6px 12px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.25;
	text-align: left;
	transition: background .15s ease, color .15s ease;
}
#cmn-asistente .cmn-chip:hover { background: var(--cmn-primary); color: #fff; }

#cmn-asistente .cmn-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	background: var(--cmn-surface);
	border-top: 1px solid var(--cmn-border);
	margin: 0;
}
#cmn-asistente .cmn-input {
	flex: 1;
	resize: none;
	border: 1px solid var(--cmn-border);
	border-radius: 14px;
	padding: 10px 12px;
	font-family: inherit;
	font-size: 16px; /* evita zoom en iOS */
	line-height: 1.35;
	max-height: 120px;
	min-height: 42px;
	background: #fff;
	color: var(--cmn-text);
	box-shadow: none;
	margin: 0;
	width: auto;
}
#cmn-asistente .cmn-input:focus { outline: none; border-color: var(--cmn-accent); box-shadow: 0 0 0 3px rgba(212, 160, 23, .2); }
#cmn-asistente .cmn-send {
	width: 42px;
	height: 42px;
	flex: 0 0 42px;
	border-radius: 50%;
	border: 0;
	background: var(--cmn-primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}
#cmn-asistente .cmn-send:disabled { opacity: .5; cursor: default; }
#cmn-asistente .cmn-foot {
	font-size: 11px;
	color: var(--cmn-muted);
	text-align: center;
	padding: 0 14px 8px;
	background: var(--cmn-surface);
	line-height: 1.3;
}

/* Móvil: pantalla completa */
@media (max-width: 520px) {
	#cmn-asistente { bottom: 14px; }
	#cmn-asistente.cmn-pos-right { right: 14px; }
	#cmn-asistente.cmn-pos-left { left: 14px; }
	#cmn-asistente .cmn-launcher { width: 56px; height: 56px; }
	#cmn-asistente .cmn-teaser { bottom: 68px; max-width: calc(100vw - 28px); }
	#cmn-asistente .cmn-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		height: 100dvh;
		border-radius: 0;
		border: 0;
		bottom: 0;
	}
	#cmn-asistente.cmn-is-open .cmn-launcher { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	#cmn-asistente * { animation: none !important; transition: none !important; }
}

/* Botón de acción dentro de una respuesta */
#cmn-asistente .cmn-bubble p.cmn-cta-row { margin: 10px 0 4px; }
#cmn-asistente .cmn-bubble a.cmn-cta {
	display: inline-block;
	background: var(--cmn-primary);
	color: #fff;
	text-decoration: none;
	font-weight: 700;
	padding: 9px 16px;
	border-radius: 999px;
	box-shadow: 0 4px 12px rgba(60, 10, 10, .22);
	transition: transform .15s ease, box-shadow .15s ease;
}
#cmn-asistente .cmn-bubble a.cmn-cta:hover,
#cmn-asistente .cmn-bubble a.cmn-cta:focus-visible { color: #fff; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(60, 10, 10, .3); }
#cmn-asistente .cmn-bubble a.cmn-cta:focus-visible { outline: 3px solid var(--cmn-accent); outline-offset: 2px; }
