/* MEGAFOTO — Widget de chat (MVP v0 · look WhatsApp) */
:root {
  --mf-accent: #25D366;        /* Verde WhatsApp (FAB, botón enviar) */
  --mf-accent-dark: #128C7E;   /* Verde oscuro (hover) */
  --mf-header: #075E54;        /* Verde teal oscuro clásico del header WA */
  --mf-user-bubble: #DCF8C6;   /* Verde claro tipo mensaje enviado WA */
  --mf-bg: #fff;
  --mf-fg: #1a1a1a;
  --mf-muted: #6b7280;
  --mf-border: #e5e7eb;
  --mf-chat-bg: #ECE5DD;       /* Fondo tipo WhatsApp beige-gris */
}

.mf-chat-btn {
  position: fixed; right: 20px; bottom: 20px; z-index: 9998;
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--mf-accent); color: #fff; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, background .18s ease;
}
.mf-chat-btn:hover { background: var(--mf-accent-dark); transform: translateY(-2px); }
.mf-chat-btn svg { width: 28px; height: 28px; }

.mf-chat-panel {
  position: fixed; right: 20px; bottom: 90px; z-index: 9999;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  background: var(--mf-bg); color: var(--mf-fg);
  border-radius: 16px; box-shadow: 0 24px 48px rgba(0,0,0,.22);
  display: none; flex-direction: column; overflow: hidden;
  font-family: 'Montserrat', -apple-system, system-ui, sans-serif;
}
.mf-chat-panel.open { display: flex; }

.mf-chat-head {
  padding: 14px 16px; background: var(--mf-header); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
}
.mf-chat-head-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.mf-chat-head-sub { font-size: 11px; opacity: .9; margin-top: 2px; }
.mf-chat-close {
  background: transparent; border: 0; color: #fff; cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  font-size: 20px; line-height: 1;
}
.mf-chat-close:hover { background: rgba(255,255,255,.15); }

.mf-chat-body {
  flex: 1; overflow-y: auto; padding: 14px; background: var(--mf-chat-bg);
  display: flex; flex-direction: column; gap: 8px;
}
.mf-msg { max-width: 85%; padding: 8px 11px 6px; border-radius: 8px; font-size: 14px; line-height: 1.42; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 0.5px rgba(0,0,0,.13); }
.mf-msg-user { background: var(--mf-user-bubble); color: var(--mf-fg); align-self: flex-end; border-top-right-radius: 2px; }
.mf-msg-bot { background: #fff; color: var(--mf-fg); align-self: flex-start; border-top-left-radius: 2px; }
.mf-msg-user a { color: var(--mf-accent-dark); text-decoration: underline; }
.mf-msg-bot a { color: var(--mf-accent-dark); text-decoration: underline; }
.mf-msg-bot a:hover, .mf-msg-user a:hover { color: var(--mf-header); }
.mf-msg-err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; align-self: stretch; text-align: center; font-size: 13px; }

.mf-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #fff; border-radius: 8px; border-top-left-radius: 2px; box-shadow: 0 1px 0.5px rgba(0,0,0,.13); }
.mf-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--mf-muted); animation: mf-blink 1.2s infinite; }
.mf-typing span:nth-child(2) { animation-delay: .2s; }
.mf-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes mf-blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.mf-chat-foot { padding: 10px; background: #fff; border-top: 1px solid var(--mf-border); display: flex; gap: 8px; }
.mf-chat-input {
  flex: 1; border: 1px solid var(--mf-border); border-radius: 22px;
  padding: 10px 14px; font-size: 14px; font-family: inherit;
  outline: none; resize: none; max-height: 100px;
}
.mf-chat-input:focus { border-color: var(--mf-accent); }
.mf-chat-send {
  border: 0; background: var(--mf-accent); color: #fff; cursor: pointer;
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; transition: background .18s;
}
.mf-chat-send:hover:not(:disabled) { background: var(--mf-accent-dark); }
.mf-chat-send:disabled { background: #ccc; cursor: not-allowed; }
.mf-chat-send svg { width: 18px; height: 18px; }

/* Micrófono para dictar. Va oculto (atributo hidden) salvo que el navegador
   soporte reconocimiento de voz; el JS lo revela. */
.mf-chat-mic {
  border: 1px solid var(--mf-border); background: #fff; color: #6E6357; cursor: pointer;
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center; transition: background .18s, color .18s, border-color .18s;
}
.mf-chat-mic[hidden] { display: none; }
.mf-chat-mic:hover { border-color: var(--mf-accent); color: var(--mf-accent); }
.mf-chat-mic svg { width: 19px; height: 19px; }
/* Escuchando: rojo con pulso, para que se note que el micrófono está abierto. */
.mf-chat-mic.oyendo { background: #dc2626; border-color: #dc2626; color: #fff; animation: mfMicPulso 1.4s infinite; }
@keyframes mfMicPulso {
  0%   { box-shadow: 0 0 0 0 rgba(220,38,38,.55); }
  70%  { box-shadow: 0 0 0 9px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}
@media (prefers-reduced-motion: reduce) { .mf-chat-mic.oyendo { animation: none; } }

.mf-chat-legal { text-align: center; font-size: 10px; color: var(--mf-muted); padding: 6px 10px 8px; background: #fff; }

/* ============ Invitación proactiva (nudge) ============ */
.mf-nudge {
  position: fixed; right: 20px; bottom: 90px; z-index: 9997;
  max-width: 258px; background: #fff; color: var(--mf-fg);
  border-radius: 16px; border-bottom-right-radius: 5px;
  box-shadow: 0 14px 36px rgba(0,0,0,.20);
  padding: 13px 15px; font-family: 'Montserrat', -apple-system, system-ui, sans-serif;
  font-size: 13.5px; line-height: 1.45;
  opacity: 0; transform: translateY(10px) scale(.95);
  transition: opacity .28s ease, transform .28s ease;
  pointer-events: none; cursor: pointer;
}
.mf-nudge.show { opacity: 1; transform: none; pointer-events: auto; }
.mf-nudge b { color: var(--mf-header); }
.mf-nudge-close {
  position: absolute; top: -9px; right: -9px; width: 23px; height: 23px;
  border-radius: 50%; border: 0; background: #fff; color: var(--mf-muted);
  box-shadow: 0 2px 8px rgba(0,0,0,.20); cursor: pointer;
  font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.mf-nudge-close:hover { color: #111; }

/* Pulso de atención en el botón hasta la primera interacción */
.mf-chat-btn.mf-pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(37,211,102,.55);
  animation: mf-attn 2.4s cubic-bezier(.16,1,.3,1) infinite;
}
@keyframes mf-attn {
  0%   { box-shadow: 0 0 0 0 rgba(37,211,102,.5); }
  70%  { box-shadow: 0 0 0 15px rgba(37,211,102,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); }
}
@media (prefers-reduced-motion: reduce) {
  .mf-chat-btn.mf-pulse::after { animation: none; }
  .mf-nudge { transition: opacity .01s; }
}

/* En móvil: subir el botón/panel por encima de la barra .mobile-cta (72px) del home */
@media (max-width: 640px) {
  .mf-chat-btn { bottom: 84px; }
  .mf-nudge { bottom: 152px; }
  .mf-chat-panel { bottom: 152px; height: min(560px, calc(100vh - 176px)); }
}
