/* Motion Master AI Chat - Widget flotante estilo burbuja.
   Reescrito desde cero. Prefijo .mmw- para aislarlo del tema.
   El widget se monta como hijo directo de <body>, por lo que ningun
   contenedor con transform (Divi) puede romper su posicion fija. */

.mmw-root {
	position: fixed !important;
	z-index: 2147483000;
	bottom: var(--mmw-offset-y, 24px);
	right: var(--mmw-offset-x, 24px);
	left: auto;
	top: auto;
	width: auto;
	height: auto;
	margin: 0;
	padding: 0;
	font-family: var(--mmw-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif);
	font-size: 15px;
	line-height: 1.5;
	color: var(--mmw-text);
	direction: ltr;
	text-align: left;
	pointer-events: none;
}

.mmw-root.mmw-left {
	right: auto;
	left: var(--mmw-offset-x, 24px);
}

.mmw-root * {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font-family: inherit;
}

.mmw-root button,
.mmw-root input,
.mmw-root textarea {
	font-family: inherit;
	font-size: inherit;
	color: inherit;
	border: 0;
	background: none;
	outline: none;
}

/* ============ Lanzador (burbuja) ============ */
.mmw-launcher {
	pointer-events: auto;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--mmw-bubble, 60px);
	height: var(--mmw-bubble, 60px);
	border-radius: 50%;
	background: var(--mmw-primary);
	color: var(--mmw-on-primary);
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
	cursor: pointer;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
	margin-left: auto;
	overflow: hidden;
}

.mmw-root.mmw-left .mmw-launcher {
	margin-left: 0;
	margin-right: auto;
}

.mmw-launcher:hover {
	transform: scale(1.06);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
}

.mmw-launcher:active {
	transform: scale(0.97);
}

.mmw-launcher svg {
	width: 46%;
	height: 46%;
	display: block;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.mmw-launcher-avatar {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.mmw-badge {
	position: absolute;
	top: 2px;
	right: 2px;
	min-width: 18px;
	height: 18px;
	border-radius: 9px;
	background: #E5484D;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 0 5px;
	border: 2px solid var(--mmw-primary);
}

.mmw-root.mmw-unread .mmw-badge {
	display: flex;
}

/* ============ Aviso emergente (teaser) ============ */
.mmw-teaser {
	pointer-events: auto;
	position: relative;
	display: none;
	align-items: flex-start;
	gap: 10px;
	max-width: 260px;
	margin: 0 0 12px auto;
	padding: 12px 34px 12px 14px;
	background: var(--mmw-surface);
	color: var(--mmw-text);
	border: 1px solid var(--mmw-border);
	border-radius: 14px;
	box-shadow: 0 8px 26px rgba(0, 0, 0, 0.18);
	font-size: 14px;
	cursor: pointer;
	animation: mmw-pop 0.28s ease;
}

.mmw-root.mmw-left .mmw-teaser {
	margin-left: 0;
	margin-right: auto;
}

.mmw-root.mmw-teaser-on .mmw-teaser {
	display: flex;
}

.mmw-teaser-close {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	opacity: 0.55;
}

.mmw-teaser-close:hover {
	opacity: 1;
	background: var(--mmw-hover);
}

.mmw-teaser-close svg {
	width: 12px;
	height: 12px;
	stroke: currentColor;
	stroke-width: 2.4;
	fill: none;
	stroke-linecap: round;
}

@keyframes mmw-pop {
	from { opacity: 0; transform: translateY(8px) scale(0.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ Panel de chat ============ */
.mmw-panel {
	pointer-events: auto;
	display: none;
	flex-direction: column;
	position: absolute;
	bottom: calc(var(--mmw-bubble, 60px) + 14px);
	right: 0;
	left: auto;
	width: var(--mmw-panel-w, 372px);
	max-width: calc(100vw - 32px);
	height: var(--mmw-panel-h, 560px);
	max-height: calc(100dvh - var(--mmw-offset-y, 24px) - var(--mmw-bubble, 60px) - 32px);
	background: var(--mmw-surface);
	border: 1px solid var(--mmw-border);
	border-radius: var(--mmw-radius, 16px);
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.30);
	overflow: hidden;
	transform-origin: bottom right;
}

.mmw-root.mmw-left .mmw-panel {
	right: auto;
	left: 0;
	transform-origin: bottom left;
}

.mmw-root.mmw-open .mmw-panel {
	display: flex;
	animation: mmw-open 0.22s ease;
}

.mmw-root.mmw-open .mmw-launcher {
	display: none;
}

.mmw-root.mmw-open .mmw-teaser {
	display: none;
}

@keyframes mmw-open {
	from { opacity: 0; transform: translateY(12px) scale(0.97); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Cabecera ---- */
.mmw-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 14px;
	background: var(--mmw-primary);
	color: var(--mmw-on-primary);
	flex-shrink: 0;
}

.mmw-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	flex-shrink: 0;
	font-weight: 700;
	font-size: 15px;
}

.mmw-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.mmw-head-text {
	flex: 1;
	min-width: 0;
}

.mmw-title {
	font-size: 15px;
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mmw-status {
	font-size: 12px;
	opacity: 0.85;
	display: flex;
	align-items: center;
	gap: 5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mmw-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #3DDC84;
	flex-shrink: 0;
}

.mmw-head-btn {
	width: 30px;
	height: 30px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: inherit;
	opacity: 0.85;
	flex-shrink: 0;
}

.mmw-head-btn:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.16);
}

.mmw-head-btn svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ---- Mensajes ---- */
.mmw-body {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--mmw-bg);
	-webkit-overflow-scrolling: touch;
}

.mmw-body::-webkit-scrollbar { width: 6px; }
.mmw-body::-webkit-scrollbar-thumb { background: var(--mmw-border); border-radius: 3px; }

.mmw-msg {
	max-width: 84%;
	padding: 10px 13px;
	border-radius: 14px;
	font-size: 14.5px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	animation: mmw-in 0.2s ease;
}

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

.mmw-msg-bot {
	align-self: flex-start;
	background: var(--mmw-bot-bubble);
	color: var(--mmw-text);
	border-bottom-left-radius: 5px;
}

.mmw-msg-user {
	align-self: flex-end;
	background: var(--mmw-primary);
	color: var(--mmw-on-primary);
	border-bottom-right-radius: 5px;
}

/* Escribiendo */
.mmw-typing {
	align-self: flex-start;
	background: var(--mmw-bot-bubble);
	padding: 12px 14px;
	border-radius: 14px;
	border-bottom-left-radius: 5px;
	display: flex;
	gap: 4px;
}

.mmw-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--mmw-muted);
	animation: mmw-blink 1.3s infinite;
}

.mmw-typing span:nth-child(2) { animation-delay: 0.18s; }
.mmw-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes mmw-blink {
	0%, 60%, 100% { opacity: 0.25; }
	30% { opacity: 1; }
}

/* CTA y acciones */
.mmw-cta {
	align-self: flex-start;
	display: inline-block;
	padding: 9px 15px;
	border-radius: 10px;
	background: var(--mmw-primary);
	color: var(--mmw-on-primary);
	font-size: 13.5px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

.mmw-cta:hover { filter: brightness(1.08); }

.mmw-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding-top: 2px;
}

.mmw-chip {
	padding: 7px 13px;
	border-radius: 999px;
	border: 1px solid var(--mmw-border);
	background: var(--mmw-surface);
	color: var(--mmw-text);
	font-size: 13px;
	cursor: pointer;
	transition: background 0.15s ease;
}

.mmw-chip:hover {
	background: var(--mmw-hover);
}

.mmw-handoff {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.mmw-handoff a {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 8px 13px;
	border-radius: 10px;
	border: 1px solid var(--mmw-border);
	background: var(--mmw-surface);
	color: var(--mmw-text);
	font-size: 13.5px;
	font-weight: 600;
	text-decoration: none;
}

.mmw-handoff a:hover { background: var(--mmw-hover); }
.mmw-handoff svg { width: 16px; height: 16px; }

/* ---- Barra de entrada ---- */
.mmw-foot {
	flex-shrink: 0;
	border-top: 1px solid var(--mmw-border);
	background: var(--mmw-surface);
	padding: 10px 12px;
}

.mmw-inputrow {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.mmw-input {
	flex: 1;
	resize: none;
	max-height: 96px;
	min-height: 40px;
	padding: 10px 13px;
	border-radius: 20px;
	border: 1px solid var(--mmw-border) !important;
	background: var(--mmw-bg);
	color: var(--mmw-text);
	font-size: 14.5px;
	line-height: 1.4;
}

.mmw-input::placeholder { color: var(--mmw-muted); }
.mmw-input:focus { border-color: var(--mmw-primary) !important; }

.mmw-send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--mmw-primary);
	color: var(--mmw-on-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: filter 0.15s ease;
}

.mmw-send:hover { filter: brightness(1.1); }
.mmw-send:disabled { opacity: 0.45; cursor: default; }
.mmw-send svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.mmw-langs {
	display: flex;
	justify-content: center;
	gap: 9px;
	padding-top: 8px;
}

.mmw-lang {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.4px;
	color: var(--mmw-muted);
	cursor: pointer;
	padding: 2px 3px;
	border-radius: 4px;
}

.mmw-lang:hover { color: var(--mmw-text); }
.mmw-lang.mmw-lang-on { color: var(--mmw-primary); }

/* ---- Formulario de contacto ---- */
.mmw-form {
	align-self: stretch;
	border: 1px solid var(--mmw-border);
	border-radius: 12px;
	padding: 12px;
	background: var(--mmw-surface);
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mmw-form input,
.mmw-form textarea {
	width: 100%;
	padding: 9px 11px;
	border-radius: 9px;
	border: 1px solid var(--mmw-border) !important;
	background: var(--mmw-bg);
	color: var(--mmw-text);
	font-size: 14px;
}

.mmw-form label {
	display: flex;
	align-items: flex-start;
	gap: 7px;
	font-size: 12.5px;
	color: var(--mmw-muted);
}

.mmw-form-actions { display: flex; gap: 8px; }

.mmw-btn {
	padding: 9px 14px;
	border-radius: 9px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	background: var(--mmw-primary);
	color: var(--mmw-on-primary);
}

.mmw-btn-ghost {
	background: transparent;
	color: var(--mmw-muted);
	border: 1px solid var(--mmw-border) !important;
}

.mmw-hp { position: absolute; left: -9999px; opacity: 0; }

/* ============ Movil: hoja inferior ============ */
@media (max-width: 520px) {
	.mmw-panel {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100vw;
		max-width: 100vw;
		height: var(--mmw-mobile-h, 65dvh);
		max-height: var(--mmw-mobile-h, 65dvh);
		border-radius: 18px 18px 0 0;
		border-left: 0;
		border-right: 0;
		border-bottom: 0;
	}
	.mmw-teaser { max-width: 210px; }
}

/* ============ Accesibilidad ============ */
@media (prefers-reduced-motion: reduce) {
	.mmw-root *, .mmw-root *::before, .mmw-root *::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}

/* Contenedores heredados: el widget vive en <body>, cualquier marcador
   antiguo dejado en el contenido de la pagina se oculta para que no
   aparezca como bloque suelto. */
[data-motionmaster-chatbot] {
	display: none !important;
}
