/**
 * =============================================================================
 * CUSTOM-MASCOT.CSS — Anatomía y animaciones de "Botti"
 * ComboCreador
 * -----------------------------------------------------------------------------
 * Botti es un robot circular retro construido ÚNICAMENTE con divs y CSS
 * (sin imágenes externas). Este archivo define:
 *
 *   1. La anatomía base: cuerpo, antenas, orejas, pantalla, ojos, boca,
 *      LEDs y sombra.
 *   2. Los cuatro estados visuales, controlados por mascot.js con clases
 *      en el contenedor #botti:
 *        .state-idle        → flotación suave (bobbing) y parpadeo.
 *        .state-calculating → ojos giratorios de carga y zarandeo lateral.
 *        .state-happy       → ojos de estrella, pantalla verde y saltitos.
 *        .state-sad         → ojos en ∩, pantalla roja/ámbar e inclinación.
 *   3. La burbuja de diálogo (#botti-burbuja).
 *   4. El confeti CSS de celebración (piezas generadas por mascot.js).
 *   5. Soporte para prefers-reduced-motion.
 *
 * Los colores "emocionales" se controlan con variables CSS que cada estado
 * sobrescribe: --ojo-color, --pantalla-fondo, --pantalla-brillo, --boca-color.
 * =============================================================================
 */

/* =========================================================================
 * 1-3. NEXO — ROBOT SVG PREMIUM (estados y animaciones)
 * -------------------------------------------------------------------------
 * La mascota es ahora una ilustración SVG (plata pulida, armadura índigo,
 * detalles de oro y emblema de la doble C en el pecho) inspirada en el
 * estilo de render 3D. Este CSS controla su vida:
 *
 *   .state-idle        → levitación + parpadeo de los ojos del visor.
 *   .state-calculating → aparece el anillo de análisis giratorio.
 *   .state-happy       → expresión feliz dorada + impulso vertical.
 *   .state-sad         → expresión preocupada + inclinación abatida.
 *
 * Las tres expresiones viven dentro del propio SVG (grupos
 * .nexo-cara-svg--normal/--happy/--sad) y se alternan por estado.
 * ========================================================================= */

.botti {
	position: relative;
	width: 230px;
	height: 262px;
	margin: 0 auto;
	user-select: none;
}

.botti-flotador {
	position: relative;
	width: 100%;
	height: 100%;
	animation: nexo-flotar 4.2s ease-in-out infinite;
	transform-origin: 50% 92%;
	will-change: transform;
}

.nexo-svg {
	width: 100%;
	height: 100%;
	display: block;
	filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.45));
}

/* Sombra en el suelo (bajo la base holográfica) */
.botti-sombra {
	position: absolute;
	bottom: -4px;
	left: 50%;
	transform: translateX(-50%);
	width: 150px;
	height: 16px;
	border-radius: 50%;
	background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.5), transparent 70%);
	animation: nexo-sombra 4.2s ease-in-out infinite;
}

/* --- Expresiones: solo una visible a la vez --- */
.nexo-cara-svg--happy,
.nexo-cara-svg--sad,
.nexo-spinner-svg { display: none; }

/* Parpadeo natural en reposo */
.state-idle .nexo-ojo-svg {
	transform-origin: center;
	transform-box: fill-box;
	animation: nexo-parpadeo 6s ease-in-out infinite;
}

/* --- Analizando: ojos fuera, anillo de escaneo dentro --- */
.state-calculating .nexo-cara-svg--normal { display: none; }
.state-calculating .nexo-spinner-svg { display: block; }

.state-calculating .nexo-spinner-arco {
	transform-origin: 120px 76px;
	animation: nexo-girar 0.75s linear infinite;
}

.state-calculating .botti-flotador { animation: nexo-cabeceo 1.1s ease-in-out infinite; }

/* --- Satisfecho --- */
.state-happy .nexo-cara-svg--normal { display: none; }
.state-happy .nexo-cara-svg--happy { display: block; }
.state-happy .botti-flotador { animation: nexo-impulso 1.25s ease-in-out infinite; }

/* --- Preocupado --- */
.state-sad .nexo-cara-svg--normal { display: none; }
.state-sad .nexo-cara-svg--sad { display: block; }
.state-sad .botti-flotador { animation: nexo-lamento 3.6s ease-in-out infinite; }

/* =========================================================================
 * KEYFRAMES
 * ========================================================================= */

@keyframes nexo-flotar {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(-11px); }
}

@keyframes nexo-sombra {
	0%, 100% { transform: translateX(-50%) scale(1);   opacity: 0.8; }
	50%      { transform: translateX(-50%) scale(0.8); opacity: 0.45; }
}

@keyframes nexo-parpadeo {
	0%, 43%, 47%, 93%, 97%, 100% { transform: scaleY(1); }
	45%, 95%                      { transform: scaleY(0.08); }
}

@keyframes nexo-girar {
	from { transform: rotate(0deg); }
	to   { transform: rotate(360deg); }
}

@keyframes nexo-cabeceo {
	0%, 100% { transform: rotate(0deg); }
	35%      { transform: rotate(-3deg); }
	70%      { transform: rotate(3deg); }
}

@keyframes nexo-impulso {
	0%, 100% { transform: translateY(0); }
	45%      { transform: translateY(-18px); }
	70%      { transform: translateY(-4px); }
}

@keyframes nexo-lamento {
	0%, 100% { transform: rotate(0deg)  translateY(0); }
	45%      { transform: rotate(-4deg) translateY(4px); }
}

/* =========================================================================
 * 4. BURBUJA DE DIÁLOGO
 * ========================================================================= */

/* La burbuja vive DENTRO del panel de chat flotante: mensaje de Botti. */
.botti-burbuja {
	position: relative;
	width: 100%;
	padding: 12px 14px;
	background: #060A12;
	border: 1px solid #1D2838;
	border-radius: 12px 12px 12px 4px; /* Esquina "de bocadillo" abajo-izq. */
	color: #E2E8F0;
	font-size: 0.95rem;
	line-height: 1.5;
	text-align: left;
	box-shadow: inset 0 0 14px rgba(126, 166, 255, 0.05);
	opacity: 0;
	transform: translateY(4px) scale(0.98);
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.botti-burbuja.visible {
	opacity: 1;
	transform: translateY(0) scale(1);
}

/* =========================================================================
 * 4.b WIDGET FLOTANTE: LANZADOR Y PANEL DE CHAT
 * -------------------------------------------------------------------------
 * El contenedor #botti-flotante (posicionado con Tailwind: fixed bottom-6
 * right-6 z-50) agrupa el panel de chat y el lanzador. La propia mascota
 * es el botón que abre y cierra el chat.
 * ========================================================================= */

/* --- Lanzador: botón transparente que envuelve a Botti, a escala 0.57 --- */
.botti-lanzador {
	appearance: none;
	background: transparent;
	border: 0;
	padding: 0;
	margin: 0;
	cursor: pointer;
	width: 132px;   /* 230px × 0.57 */
	height: 143px;  /* 250px × 0.57 */
	transition: transform 0.25s ease;
}

.botti-lanzador:hover { transform: scale(1.06); }
.botti-lanzador:focus-visible {
	outline: 2px solid #7EA6FF;
	outline-offset: 4px;
	border-radius: 20px;
}

.botti-lanzador .botti {
	transform: scale(0.5);
	transform-origin: top left;
	pointer-events: none; /* El clic siempre lo recibe el botón. */
}

/* En el lanzador flotante, la base con el nombre sobra: solo el robot. */
.botti-lanzador .nexo-base { display: none; }

/* --- Panel de chat: anclado en absoluto sobre la mascota para que,
 *     mientras está oculto, no reserve ni un píxel de espacio --- */
.botti-panel {
	position: absolute;
	bottom: calc(100% + 12px);
	right: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: min(340px, calc(100vw - 3rem));
	padding: 14px;
	background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(14, 21, 38, 0.72));
	-webkit-backdrop-filter: blur(22px) saturate(160%);
	backdrop-filter: blur(22px) saturate(160%);
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 18px 18px 4px 18px; /* Esquina recortada hacia Botti. */
	box-shadow:
		0 18px 44px rgba(0, 0, 0, 0.5),
		0 0 0 1px rgba(77, 124, 254, 0.08),
		0 0 30px rgba(126, 166, 255, 0.08);
	opacity: 0;
	transform: translateY(10px) scale(0.97);
	transform-origin: bottom right;
	pointer-events: none;
	transition: opacity 0.28s ease, transform 0.28s ease;
}

.botti-panel.abierto {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* --- Cabecera del panel --- */
.botti-panel-cabecera {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding-bottom: 10px;
	border-bottom: 1px solid #1D2838;
}

.botti-panel-titulo {
	font-family: 'Chakra Petch', sans-serif;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	background: linear-gradient(90deg, #7EA6FF, #4D7CFE);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

.botti-panel-cerrar {
	appearance: none;
	background: transparent;
	border: 1px solid #1D2838;
	border-radius: 8px;
	width: 28px;
	height: 28px;
	color: #94A3B8;
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
	transition: color 0.2s ease, border-color 0.2s ease;
}

.botti-panel-cerrar:hover { color: #F87171; border-color: #F87171; }

/* --- Botón "✨ ¡Botti, arregla mi PC!" --- */
.botti-btn-arreglar {
	appearance: none;
	border: 0;
	border-radius: 12px;
	padding: 12px 16px;
	font-family: 'Chakra Petch', sans-serif;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #060A12;
	background: linear-gradient(90deg, #FBBF24, #4D7CFE);
	box-shadow: 0 0 18px rgba(251, 191, 36, 0.35);
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	animation: botti-pulso 1.8s ease-in-out infinite;
}

.botti-btn-arreglar:hover {
	transform: scale(1.03);
	box-shadow: 0 0 26px rgba(251, 191, 36, 0.55);
}

/* Ocultación total (la gestiona mascot.js). */
.oculto { display: none !important; }

/* --- FAQ interactivo: chips de preguntas rápidas --- */
.botti-acciones {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.botti-chip {
	appearance: none;
	background: #060A12;
	border: 1px solid #1D2838;
	border-radius: 999px;
	padding: 7px 12px;
	color: #CBD5E1;
	font-family: 'Manrope', sans-serif;
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
	transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.botti-chip:hover {
	border-color: #7EA6FF;
	color: #7EA6FF;
	transform: translateY(-1px);
}

/* Pulso de atención del botón de reparación. */
@keyframes botti-pulso {
	0%, 100% { box-shadow: 0 0 14px rgba(251, 191, 36, 0.3); }
	50%      { box-shadow: 0 0 26px rgba(77, 124, 254, 0.55); }
}

/* =========================================================================
 * 5. CONFETI DE CELEBRACIÓN
 * -------------------------------------------------------------------------
 * mascot.js inyecta <span class="confeti"> con variables aleatorias:
 *   --dur    → duración de la caída.
 *   --deriva → desplazamiento horizontal acumulado.
 *   --giro   → rotación total durante la caída.
 * ========================================================================= */

#confeti-contenedor {
	position: fixed;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 60;
}

.confeti {
	position: absolute;
	top: -24px;
	width: 10px;
	height: 15px;
	border-radius: 2px;
	opacity: 0.95;
	animation: confeti-caer var(--dur, 3s) linear forwards;
	will-change: transform;
}

/* Piezas alternas más pequeñas y redondas para variar la lluvia. */
.confeti:nth-child(2n) {
	width: 7px;
	height: 7px;
	border-radius: 50%;
}

/* =========================================================================
 * 6. KEYFRAMES
 * ========================================================================= */

/* Flotación vertical suave (bobbing) del estado de reposo. */
@keyframes botti-flotar {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(-14px); }
}

/* La sombra se encoge cuando Botti sube, para dar sensación de altura. */
@keyframes botti-sombra {
	0%, 100% { transform: translateX(-50%) scale(1);    opacity: 0.8; }
	50%      { transform: translateX(-50%) scale(0.78); opacity: 0.45; }
}

/* Parpadeo ocasional: los ojos se cierran (scaleY) dos veces por ciclo. */
@keyframes botti-parpadeo {
	0%, 41%, 45%, 91%, 95%, 100% { transform: scaleY(1); }
	43%, 93%                      { transform: scaleY(0.08); }
}

/* Giro continuo del anillo de carga (estado pensando). */
@keyframes botti-girar {
	from { transform: rotate(0deg); }
	to   { transform: rotate(360deg); }
}

/* Zarandeo lateral rápido mientras "piensa". */
@keyframes botti-zarandeo {
	0%, 100% { transform: translateX(0)     rotate(0deg); }
	25%      { transform: translateX(-10px) rotate(-2deg); }
	75%      { transform: translateX(10px)  rotate(2deg); }
}

/* La boca pulsa de ancho como una barra de progreso. */
@keyframes botti-boca-carga {
	0%, 100% { width: 16px; opacity: 0.6; }
	50%      { width: 42px; opacity: 1; }
}

/* Saltitos de alegría (estado feliz). */
@keyframes botti-salto {
	0%, 100% { transform: translateY(0)     scale(1, 1); }
	30%      { transform: translateY(2px)   scale(1.04, 0.94); } /* Se agacha. */
	55%      { transform: translateY(-26px) scale(0.97, 1.05); } /* Salta.     */
	80%      { transform: translateY(0)     scale(1.02, 0.97); } /* Aterriza.  */
}

/* Inclinación lateral lenta, como si estuviera agotado (estado triste). */
@keyframes botti-lamento {
	0%, 100% { transform: rotate(0deg)  translateY(0); }
	40%      { transform: rotate(-8deg) translateY(4px); }
	70%      { transform: rotate(-6deg) translateY(2px); }
}

/* Pulso luminoso de las bolas de las antenas. */
@keyframes botti-destello {
	0%, 100% { transform: translateX(-50%) scale(1);   opacity: 1; }
	50%      { transform: translateX(-50%) scale(1.3); opacity: 0.55; }
}

/* Encendido secuencial de los LEDs. */
@keyframes botti-led {
	0%, 100% { opacity: 0.25; }
	50%      { opacity: 1; }
}

/* Caída del confeti: desciende, deriva lateralmente y gira. */
@keyframes confeti-caer {
	0% {
		transform: translate3d(0, 0, 0) rotate(0deg);
		opacity: 1;
	}
	100% {
		transform: translate3d(var(--deriva, 0vw), 110vh, 0) rotate(var(--giro, 540deg));
		opacity: 0.7;
	}
}

/* =========================================================================
 * 7. ACCESIBILIDAD: MOVIMIENTO REDUCIDO
 * -------------------------------------------------------------------------
 * Si el usuario prefiere menos movimiento, se desactivan todas las
 * animaciones de la mascota y del confeti; los estados siguen siendo
 * distinguibles por los colores de pantalla, ojos y boca.
 * ========================================================================= */
@media (prefers-reduced-motion: reduce) {
	.botti-flotador,
	.botti-sombra,
	.nexo-ojo-svg,
	.nexo-spinner-arco,
	.confeti {
		animation: none !important;
	}
}

/* =========================================================================
 * 8. CHAT CONVERSACIONAL DE BOTTI
 * ========================================================================= */

/* Historial con scroll propio */
.botti-chat {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 240px;
	overflow-y: auto;
	padding-right: 4px;
	scroll-behavior: smooth;
}

.botti-chat::-webkit-scrollbar { width: 5px; }
.botti-chat::-webkit-scrollbar-thumb { background: #1D2838; border-radius: 999px; }

/* Mensajes: burbujas de Botti (izquierda) y del usuario (derecha) */
.botti-msg {
	max-width: 88%;
	padding: 10px 13px;
	font-size: 0.9rem;
	line-height: 1.5;
	white-space: pre-line; /* Respeta los saltos de línea de las builds. */
	animation: botti-msg-entrar 0.25s ease;
}

.botti-msg--botti {
	align-self: flex-start;
	background: #060A12;
	border: 1px solid #1D2838;
	border-radius: 12px 12px 12px 4px;
	color: #E2E8F0;
	box-shadow: inset 0 0 14px rgba(126, 166, 255, 0.05);
}

.botti-msg--usuario {
	align-self: flex-end;
	background: linear-gradient(135deg, rgba(126, 166, 255, 0.18), rgba(77, 124, 254, 0.22));
	border: 1px solid rgba(77, 124, 254, 0.45);
	border-radius: 12px 12px 4px 12px;
	color: #F1F5F9;
}

@keyframes botti-msg-entrar {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}

/* Fila de entrada: campo + botón de enviar */
.botti-form {
	display: flex;
	gap: 8px;
}

.botti-input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 10px 14px;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.12);
	color: #F1F5F9;
	font-family: 'Manrope', sans-serif;
	font-size: 0.9rem;
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.botti-input::placeholder { color: #64748B; }

.botti-input:focus {
	border-color: #7EA6FF;
	box-shadow: 0 0 0 1px #7EA6FF, 0 0 14px rgba(126, 166, 255, 0.35);
}

.botti-enviar {
	appearance: none;
	border: 0;
	border-radius: 12px;
	width: 44px;
	flex-shrink: 0;
	background: linear-gradient(135deg, #7EA6FF, #4D7CFE);
	color: #060A12;
	font-size: 1rem;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.botti-enviar:hover {
	transform: scale(1.06);
	box-shadow: 0 0 16px rgba(126, 166, 255, 0.5);
}

@media (prefers-reduced-motion: reduce) {
	.botti-msg { animation: none; }
	.botti-chat { scroll-behavior: auto; }
}

/* Botones de respuesta rápida del asistente de mejora */
.botti-opciones {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 2px 0 4px;
	animation: botti-msg-entrar 0.25s ease;
}

