/* Misión Mérito – Asesor virtual */
#mma-root {
	--mma-color: #001D2F;
	--mma-logo-bg: #001D2F;
	--mma-text: #1f2937;
	--mma-muted: #6b7280;
	--mma-bg: #ffffff;
	--mma-soft: #f3f4f6;
	--mma-line: #e5e7eb;
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--mma-text);
}
#mma-root *, #mma-root *::before, #mma-root *::after { box-sizing: border-box; }
#mma-root svg { width: 20px; height: 20px; display: block; }
#mma-root button { font: inherit; cursor: pointer; margin: 0; text-transform: none; letter-spacing: normal; box-shadow: none; }

/* Burbuja */
#mma-root .mma-bubble {
	display: flex; align-items: center; gap: 10px;
	background: var(--mma-color);
	color: #fff; border: 2px solid rgba(255,255,255,.9); border-radius: 999px;
	padding: 12px 18px 12px 14px;
	box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 6px 20px rgba(0,0,0,.28);
	transition: transform .15s ease, box-shadow .15s ease;
}
#mma-root .mma-bubble:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 10px 26px rgba(0,0,0,.32); }
#mma-root .mma-bubble svg { width: 26px; height: 26px; }
#mma-root .mma-bubble-label { font-weight: 600; font-size: 15px; white-space: nowrap; }
#mma-root.mma-is-open .mma-bubble { display: none; }

/* Panel */
#mma-root .mma-panel {
	width: 400px; height: min(640px, calc(100vh - 40px));
	background: var(--mma-bg); border-radius: 16px; overflow: hidden;
	box-shadow: 0 16px 48px rgba(0,0,0,.25);
	display: flex; flex-direction: column;
	transition: width .2s ease, height .2s ease;
}
#mma-root .mma-panel[hidden] { display: none; }
#mma-root .mma-panel.mma-wide { width: min(980px, calc(100vw - 40px)); height: calc(100vh - 40px); }

#mma-root .mma-head {
	display: flex; align-items: center; gap: 10px;
	background: var(--mma-color); color: #fff; padding: 12px 12px 12px 14px;
}
#mma-root .mma-avatar {
	width: 40px; height: 40px; border-radius: 50%; background: var(--mma-logo-bg); flex: 0 0 40px;
	display: flex; align-items: center; justify-content: center; overflow: hidden; color: #fff;
}
#mma-root .mma-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 3px; border: 0; border-radius: 0; background: transparent; max-width: none; }
#mma-root .mma-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#mma-root .mma-title strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
#mma-root .mma-title span { font-size: 12px; opacity: .85; }
#mma-root .mma-actions { display: flex; gap: 2px; }
#mma-root .mma-ic {
	display: inline-flex; align-items: center; justify-content: center;
	width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent; color: #fff; padding: 0; text-decoration: none;
}
#mma-root .mma-ic:hover { background: rgba(255,255,255,.18); }
#mma-root .mma-ic svg { width: 18px; height: 18px; }

/* Mensajes */
#mma-root .mma-msgs { flex: 1; overflow-y: auto; padding: 16px 14px; background: #fafafa; display: flex; flex-direction: column; gap: 10px; }
#mma-root .mma-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; word-wrap: break-word; }
#mma-root .mma-msg p { margin: 0 0 8px; }
#mma-root .mma-msg p:last-child { margin-bottom: 0; }
#mma-root .mma-msg ul, #mma-root .mma-msg ol { margin: 4px 0 8px 20px; padding: 0; }
#mma-root .mma-msg a { color: var(--mma-color); text-decoration: underline; font-weight: 600; }
#mma-root .mma-user { align-self: flex-end; background: var(--mma-color); color: #fff; border-bottom-right-radius: 4px; }
#mma-root .mma-bot { align-self: flex-start; background: #fff; border: 1px solid var(--mma-line); border-bottom-left-radius: 4px; }
#mma-root .mma-bot:has(.mma-rec), #mma-root .mma-bot:has(.mma-cards) { max-width: 100%; width: 100%; }
#mma-root .mma-msg > .mma-cards { margin: 10px 0 12px !important; }
#mma-root .mma-error { border-color: #fecaca; background: #fff7f7; }

#mma-root .mma-typing { display: flex; flex-direction: column; gap: 6px; }
#mma-root .mma-typing-note { font-size: 13px; color: var(--mma-muted); }
#mma-root .mma-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
#mma-root .mma-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--mma-muted); animation: mma-b 1.2s infinite ease-in-out; }
#mma-root .mma-dots i:nth-child(2) { animation-delay: .15s; }
#mma-root .mma-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes mma-b { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* Botones de contacto */
#mma-root .mma-ctas { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
#mma-root .mma-cta { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; color: #fff !important; text-decoration: none !important; font-size: 14px; }
#mma-root .mma-cta svg { width: 16px; height: 16px; }
#mma-root .mma-cta-wa { background: #25D366; }
#mma-root .mma-cta-tg { background: #229ED9; }
#mma-root .mma-support-line { font-size: 13px; color: var(--mma-muted); margin-top: 8px !important; }

/* Sugerencias */
#mma-root .mma-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; background: #fafafa; }
#mma-root .mma-chips:not(:empty) { padding-bottom: 10px; }
#mma-root .mma-chip { background: #fff; border: 1px solid var(--mma-color); color: var(--mma-color); border-radius: 999px; padding: 6px 12px; font-size: 13px; text-align: left; }
#mma-root .mma-chip:hover { background: var(--mma-color); color: #fff; }

/* Entrada */
#mma-root .mma-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--mma-line); background: #fff; margin: 0; }
#mma-root .mma-form textarea {
	flex: 1; resize: none; border: 1px solid var(--mma-line); border-radius: 12px; padding: 10px 12px;
	font: inherit; font-size: 15px; line-height: 1.4; max-height: 160px; min-height: 42px; overflow-y: hidden; color: var(--mma-text); background: #fff; margin: 0; box-shadow: none; width: auto;
}
#mma-root .mma-form textarea:focus { outline: none; border-color: var(--mma-color); }
#mma-root .mma-send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--mma-color); color: #fff; display: flex; align-items: center; justify-content: center; padding: 0; flex: 0 0 42px; }
#mma-root .mma-send:disabled { opacity: .5; cursor: wait; }
#mma-root .mma-foot { display: flex; justify-content: space-between; gap: 8px; padding: 0 12px 8px; background: #fff; font-size: 11px; color: var(--mma-muted); }
#mma-root .mma-foot a { color: var(--mma-muted); }
#mma-root .mma-remaining { white-space: nowrap; font-weight: 600; }

/* Recomendaciones: resumen en tarjetas.
   Se usan !important en lo esencial porque muchos temas de WordPress
   sobrescriben estilos de títulos, listas y enlaces. */
#mma-root .mma-summary { display: flex !important; flex-direction: column !important; gap: 16px !important; }
#mma-root .mma-summary-title { font-weight: 700 !important; font-size: 15px !important; color: var(--mma-text) !important; margin: 0 !important; }
#mma-root .mma-sum-sec { display: flex !important; flex-direction: column !important; gap: 8px !important; }
#mma-root .mma-sum-title { display: flex !important; align-items: center !important; gap: 8px !important; font-size: 15px !important; font-weight: 700 !important; color: var(--mma-color) !important; margin: 0 !important; line-height: 1.3 !important; }
#mma-root .mma-sum-count { display: inline-flex !important; align-items: center !important; justify-content: center !important; min-width: 22px !important; height: 22px !important; padding: 0 6px !important; border-radius: 999px !important; background: var(--mma-color) !important; color: #fff !important; font-size: 12px !important; font-weight: 700 !important; }
#mma-root .mma-cards { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)) !important; gap: 10px !important; margin: 0 !important; padding: 0 !important; }
#mma-root .mma-card {
	display: flex !important; flex-wrap: wrap !important; align-items: center !important; justify-content: space-between !important; gap: 10px 12px !important;
	background: #fff !important; border: 1px solid var(--mma-line) !important; border-left: 4px solid #d1d5db !important; border-radius: 12px !important;
	padding: 12px 14px !important; margin: 0 !important; box-shadow: 0 1px 2px rgba(0,0,0,.05) !important; transition: box-shadow .15s ease, transform .15s ease;
}
#mma-root .mma-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.10) !important; transform: translateY(-1px); }
#mma-root .mma-card-alta { border-left-color: #22c55e !important; }
#mma-root .mma-card-media { border-left-color: #eab308 !important; }
#mma-root .mma-card-baja { border-left-color: #9ca3af !important; }
#mma-root .mma-card-info { flex: 1 1 170px !important; min-width: 0 !important; display: flex !important; flex-direction: column !important; align-items: flex-start !important; gap: 4px !important; }
#mma-root .mma-card-name { font-size: 14px !important; font-weight: 700 !important; line-height: 1.3 !important; color: var(--mma-text) !important; margin: 0 !important; }
#mma-root .mma-card-meta { font-size: 12.5px !important; color: var(--mma-muted) !important; margin: 0 !important; }
#mma-root .mma-card .mma-rel { margin: 2px 0 0 !important; }
#mma-root .mma-card-alt { font-size: 12.5px !important; color: var(--mma-muted) !important; margin: 2px 0 0 !important; line-height: 1.4 !important; }
#mma-root .mma-card-alt a { color: var(--mma-color) !important; font-weight: 700 !important; text-decoration: underline !important; white-space: nowrap !important; }
#mma-root .mma-table .mma-card-alt { margin-top: 4px !important; }
#mma-root .mma-card-btn { flex: 0 0 auto !important; }
#mma-root .mma-detail-hint { font-size: 13.5px !important; color: var(--mma-muted) !important; margin: 0 0 -8px !important; }

/* Recomendaciones: detalle desplegable */
#mma-root details.mma-sec { border: 1px solid var(--mma-line); border-radius: 10px; background: #fff; }
#mma-root details.mma-sec > summary { cursor: pointer; list-style: none; padding: 10px 12px; font-weight: 600; font-size: 14px; color: var(--mma-color); display: flex; justify-content: space-between; align-items: center; margin: 0; }
#mma-root details.mma-sec > summary::-webkit-details-marker { display: none; }
#mma-root details.mma-sec > summary::after { content: "+"; font-size: 18px; line-height: 1; }
#mma-root details.mma-sec[open] > summary::after { content: "−"; }
#mma-root .mma-sec-body { padding: 0 12px 12px; font-size: 14px; }

/* Recomendaciones */
#mma-root .mma-rec { display: flex; flex-direction: column; gap: 14px; }
#mma-root .mma-sec-title { margin: 4px 0 6px; font-size: 16px; color: var(--mma-color); }
#mma-root .mma-table-wrap { overflow-x: auto; margin-top: 8px; border: 1px solid var(--mma-line); border-radius: 10px; }
#mma-root .mma-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 0; }
#mma-root .mma-table th { background: var(--mma-color); color: #fff; text-align: left; padding: 8px 10px; font-weight: 600; white-space: nowrap; border: 0; }
#mma-root .mma-table td { padding: 9px 10px; border-top: 1px solid var(--mma-line); vertical-align: top; border-left: 0; border-right: 0; border-bottom: 0; background: #fff; }
#mma-root .mma-table tr:nth-child(even) td { background: #f9fafb; }
#mma-root .mma-rel { display: inline-block !important; font-size: 12px !important; font-weight: 700 !important; line-height: 1.5 !important; padding: 2px 9px !important; border-radius: 999px !important; margin-bottom: 3px; }
#mma-root .mma-rel-alta { background: #dcfce7; color: #166534; }
#mma-root .mma-rel-media { background: #fef9c3; color: #854d0e; }
#mma-root .mma-rel-baja { background: #f3f4f6; color: #374151; }
#mma-root .mma-btn-link { display: inline-block !important; white-space: nowrap !important; background: var(--mma-color) !important; color: #fff !important; text-decoration: none !important; padding: 8px 14px !important; border-radius: 8px !important; font-size: 13px !important; font-weight: 600 !important; line-height: 1.2 !important; border: 0 !important; }
#mma-root .mma-btn-link:hover { filter: brightness(1.25); }
#mma-root .mma-special, #mma-root .mma-note { background: #eff6ff; border-left: 3px solid var(--mma-color); padding: 8px 10px; border-radius: 6px; font-size: 13.5px; margin-top: 8px; }
#mma-root .mma-disclaimer { font-size: 12.5px; color: var(--mma-muted); border-top: 1px dashed var(--mma-line); padding-top: 10px; }

/* Panel angosto: las tablas se muestran como tarjetas */
#mma-root .mma-panel:not(.mma-wide) .mma-table thead { display: none; }
#mma-root .mma-panel:not(.mma-wide) .mma-table, #mma-root .mma-panel:not(.mma-wide) .mma-table tbody,
#mma-root .mma-panel:not(.mma-wide) .mma-table tr, #mma-root .mma-panel:not(.mma-wide) .mma-table td { display: block; width: 100%; }
#mma-root .mma-panel:not(.mma-wide) .mma-table tr { border-top: 1px solid var(--mma-line); padding: 6px 0; }
#mma-root .mma-panel:not(.mma-wide) .mma-table tr:first-child { border-top: 0; }
#mma-root .mma-panel:not(.mma-wide) .mma-table td { border: 0; padding: 3px 10px; background: transparent !important; }
#mma-root .mma-panel:not(.mma-wide) .mma-table td::before { content: attr(data-label) ": "; font-weight: 600; color: var(--mma-muted); font-size: 12px; }
#mma-root .mma-panel:not(.mma-wide) .mma-table td:last-child::before { content: none; }
#mma-root .mma-panel:not(.mma-wide) .mma-table td:empty { display: none; }
#mma-root .mma-panel:not(.mma-wide) .mma-table-wrap { overflow: visible; }

/* Móvil: pantalla completa */
@media (max-width: 700px) {
	#mma-root { right: 12px; bottom: 12px; }
	#mma-root.mma-is-open { right: 0; bottom: 0; left: 0; top: 0; }
	#mma-root .mma-panel, #mma-root .mma-panel.mma-wide { width: 100vw; height: 100%; height: 100dvh; border-radius: 0; }
	#mma-root .mma-expand { display: none; }
	#mma-root .mma-bubble-label { display: none; }
	#mma-root .mma-bubble { padding: 14px; }
	#mma-root .mma-panel.mma-wide .mma-table thead { display: none; }
	#mma-root .mma-panel.mma-wide .mma-table, #mma-root .mma-panel.mma-wide .mma-table tbody,
	#mma-root .mma-panel.mma-wide .mma-table tr, #mma-root .mma-panel.mma-wide .mma-table td { display: block; width: 100%; }
	#mma-root .mma-panel.mma-wide .mma-table td::before { content: attr(data-label) ": "; font-weight: 600; color: var(--mma-muted); font-size: 12px; }
	#mma-root .mma-panel.mma-wide .mma-table td:last-child::before { content: none; }
}

@media print { #mma-root { display: none; } }
