/* ═══════════════════════════════════════════
   MGIA02 — Agente IA
   Estilos del Widget de Chat (Frontend)
   Tipografía nativa del sistema (sin @import)
═══════════════════════════════════════════ */

:root {
	--mgia02-azul:        #0047AB;
	--mgia02-azul-oscuro: #003380;
	--mgia02-fondo:       #F5F7FA;
	--mgia02-texto:       #333333;
	--mgia02-radio:       16px;
	--mgia02-sombra:      0 8px 32px rgba(0, 71, 171, 0.18);
	--mgia02-font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	--mgia02-mono:        ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

/* ── Contenedor del Botón Flotante ── */
#mgia02-chat-wrapper,
.mgia02-chat-wrapper,
#mg-chat-wrapper {
	position: fixed;
	bottom: 28px;
	right: 28px;
	width: 62px;
	height: 62px;
	z-index: 9998;
}

/* ── Botón Flotante ── */
#mgia02-chat-btn,
.mgia02-chat-btn,
#mg-chat-btn {
	position: absolute;
	inset: 0;
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: #ffffff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 20px rgba(0, 71, 171, 0.25), 0 1px 4px rgba(0, 0, 0, 0.1);
	padding: 0;
	overflow: hidden;
	transition: transform 0.25s cubic-bezier(.34, 1.56, .64, 1), box-shadow 0.25s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

#mgia02-chat-btn:hover,
#mg-chat-btn:hover {
	transform: scale(1.1);
	box-shadow: 0 8px 28px rgba(0, 71, 171, 0.35);
}

#mgia02-chat-btn img,
#mg-chat-btn img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

/* Pulso animado */
#mgia02-chat-btn::before,
#mg-chat-btn::before {
	content: '';
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 2px solid rgba(0, 71, 171, 0.3);
	animation: mgia02-pulso 2.5s ease-in-out infinite;
}

@keyframes mgia02-pulso {
	0%, 100% { transform: scale(1);    opacity: 0.6; }
	50%       { transform: scale(1.12); opacity: 0;   }
}

/* ── Notificación Roja ── */
#mgia02-chat-notif,
.mgia02-chat-notif,
#mg-chat-notif {
	position: absolute;
	top: -4px;
	right: -4px;
	width: 20px;
	height: 20px;
	background: #e53935;
	border-radius: 50%;
	border: 2.5px solid #ffffff;
	font-size: 10px;
	font-weight: 700;
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--mgia02-font);
	z-index: 1;
	pointer-events: none;
}

/* ── Ventana de Chat ── */
#mgia02-chat-window,
.mgia02-chat-window,
#mg-chat-window {
	position: fixed;
	bottom: 104px;
	right: 28px;
	width: 360px;
	max-height: 520px;
	background: #ffffff;
	border-radius: var(--mgia02-radio);
	box-shadow: var(--mgia02-sombra);
	z-index: 9999;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(20px) scale(0.96);
	pointer-events: none;
	transition: opacity 0.25s ease, transform 0.25s cubic-bezier(.34, 1.56, .64, 1);
	font-family: var(--mgia02-font);
}

#mgia02-chat-window.abierto,
#mg-chat-window.abierto {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: all;
}

/* ── Encabezado ── */
#mgia02-chat-header,
.mgia02-chat-header,
#mg-chat-header {
	background: var(--mgia02-azul);
	padding: 14px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

#mgia02-chat-header img,
#mg-chat-header img {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(255, 255, 255, 0.3);
	flex-shrink: 0;
}

.mgia02-header-info {
	flex: 1;
	min-width: 0;
}

.mgia02-header-nombre {
	font-size: 0.88rem;
	font-weight: 600;
	color: #ffffff;
	line-height: 1.2;
}

.mgia02-header-estado {
	font-size: 0.72rem;
	color: rgba(255, 255, 255, 0.75);
	display: flex;
	align-items: center;
	gap: 5px;
	margin-top: 2px;
}

.mgia02-header-estado::before {
	content: '';
	width: 7px;
	height: 7px;
	background: #4cde80;
	border-radius: 50%;
	display: inline-block;
	flex-shrink: 0;
}

#mgia02-chat-cerrar,
.mgia02-chat-cerrar,
#mg-chat-cerrar {
	background: none;
	border: none;
	color: rgba(255, 255, 255, 0.7);
	cursor: pointer;
	font-size: 1.1rem;
	line-height: 1;
	padding: 4px;
	border-radius: 6px;
	transition: color 0.15s, background 0.15s;
	flex-shrink: 0;
}

#mgia02-chat-cerrar:hover,
#mg-chat-cerrar:hover {
	color: #ffffff;
	background: rgba(255, 255, 255, 0.15);
}

/* ── Área de Mensajes ── */
#mgia02-chat-mensajes,
.mgia02-chat-mensajes,
#mg-chat-mensajes {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--mgia02-fondo);
	scroll-behavior: smooth;
}

#mgia02-chat-mensajes::-webkit-scrollbar,
#mg-chat-mensajes::-webkit-scrollbar {
	width: 4px;
}

#mgia02-chat-mensajes::-webkit-scrollbar-track,
#mg-chat-mensajes::-webkit-scrollbar-track {
	background: transparent;
}

#mgia02-chat-mensajes::-webkit-scrollbar-thumb,
#mg-chat-mensajes::-webkit-scrollbar-thumb {
	background: #d0d5e8;
	border-radius: 4px;
}

/* ── Burbujas ── */
.mgia02-burbuja,
.mg-burbuja {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 0.83rem;
	line-height: 1.5;
	word-wrap: break-word;
	animation: mgia02-aparecer 0.2s ease;
}

@keyframes mgia02-aparecer {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0);   }
}

.mgia02-burbuja.agente,
.mg-burbuja.agente {
	background: #ffffff;
	color: var(--mgia02-texto);
	border-bottom-left-radius: 4px;
	align-self: flex-start;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.mgia02-burbuja.usuario,
.mg-burbuja.usuario {
	background: var(--mgia02-azul);
	color: #ffffff;
	border-bottom-right-radius: 4px;
	align-self: flex-end;
}

.mgia02-burbuja.sistema,
.mg-burbuja.sistema {
	background: #eef2f9;
	color: #444444;
	font-size: 0.78rem;
	text-align: center;
	align-self: center;
	border-radius: 8px;
	padding: 6px 12px;
	max-width: 90%;
}

.mgia02-burbuja.fallback,
.mg-burbuja.fallback {
	background: #fff3e0;
	color: #b7410e;
	border-left: 3px solid #ff9800;
	border-bottom-left-radius: 4px;
	align-self: flex-start;
}

.mgia02-burbuja a,
.mg-burbuja a {
	color: inherit;
	text-decoration: underline;
	opacity: 0.95;
	font-weight: 600;
}

/* ── Typing Indicator ── */
.mgia02-typing,
.mg-typing {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 10px 14px;
	background: #ffffff;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	align-self: flex-start;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
	animation: mgia02-aparecer 0.2s ease;
}

.mgia02-typing span,
.mg-typing span {
	width: 7px;
	height: 7px;
	background: #b0b8d0;
	border-radius: 50%;
	animation: mgia02-bounce 1.2s ease-in-out infinite;
}

.mgia02-typing span:nth-child(2),
.mg-typing span:nth-child(2) {
	animation-delay: 0.2s;
}

.mgia02-typing span:nth-child(3),
.mg-typing span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes mgia02-bounce {
	0%, 60%, 100% { transform: translateY(0);   }
	30%           { transform: translateY(-5px); }
}

/* ── Input Area ── */
#mgia02-chat-input-area,
.mgia02-chat-input-area,
#mg-chat-input-area {
	padding: 12px 14px;
	background: #ffffff;
	border-top: 1px solid #eef0f7;
	display: flex;
	gap: 8px;
	align-items: flex-end;
	flex-shrink: 0;
}

#mgia02-chat-input,
.mgia02-chat-input,
#mg-chat-input {
	flex: 1;
	border: 1.5px solid #e0e4f0;
	border-radius: 12px;
	padding: 9px 13px;
	font-size: 0.82rem;
	font-family: var(--mgia02-font);
	color: var(--mgia02-texto);
	background: var(--mgia02-fondo);
	resize: none;
	outline: none;
	transition: border-color 0.2s;
	min-height: 38px;
	max-height: 100px;
	line-height: 1.4;
	box-sizing: border-box;
}

#mgia02-chat-input:focus,
#mg-chat-input:focus {
	border-color: var(--mgia02-azul);
	background: #ffffff;
}

#mgia02-chat-input::placeholder,
#mg-chat-input::placeholder {
	color: #aab0c8;
}

#mgia02-chat-enviar,
.mgia02-chat-enviar,
#mg-chat-enviar {
	width: 38px;
	height: 38px;
	border-radius: 10px;
	background: var(--mgia02-azul);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.2s, transform 0.15s;
}

#mgia02-chat-enviar:hover,
#mg-chat-enviar:hover {
	background: var(--mgia02-azul-oscuro);
}

#mgia02-chat-enviar:active,
#mg-chat-enviar:active {
	transform: scale(0.93);
}

#mgia02-chat-enviar svg,
#mg-chat-enviar svg {
	width: 16px;
	height: 16px;
	fill: #ffffff;
}

/* ── Footer ── */
#mgia02-chat-footer,
.mgia02-chat-footer,
#mg-chat-footer {
	text-align: center;
	font-size: 0.65rem;
	color: #bbbbbb;
	padding: 6px 0 8px;
	background: #ffffff;
	font-family: var(--mgia02-mono);
	flex-shrink: 0;
}

/* ── Responsive Móvil ── */
@media (max-width: 420px) {
	#mgia02-chat-window,
	#mg-chat-window {
		right: 0;
		bottom: 0;
		width: 100vw;
		max-height: 85vh;
		border-radius: var(--mgia02-radio) var(--mgia02-radio) 0 0;
	}
	#mgia02-chat-wrapper,
	#mg-chat-wrapper {
		bottom: 20px;
		right: 20px;
	}
}
