/* ============================================================
   Metrix — Agente WhatsApp simulado (landing)
   Look & feel WhatsApp dark, acentos de marca en el avatar.
   Autocontenido: no depende de site.css (solo de los tokens
   globales si están, con fallbacks inline).
============================================================ */

.mtx-wa-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 6px 20px rgba(124, 58, 237, 0.45));
  transition: transform 0.2s ease, filter 0.2s ease;
}
.mtx-wa-launcher.is-visible {
  display: flex;
  animation: mtxWaPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mtx-wa-launcher:hover {
  transform: scale(1.08);
  filter: drop-shadow(0 8px 26px rgba(124, 58, 237, 0.6));
}
.mtx-wa-launcher svg {
  width: 64px;
  height: 64px;
}
/* ---- Meti viva: micro-animaciones orgánicas, lentas y sutiles ----
   Flotación tipo respiración + parpadeo + mirada que pasea + antena
   que se mece. Continuas pero de amplitud mínima: cálida, no invasiva. */
.mtx-wa-launcher.is-idle .mtx-meti {
  animation: mtxMetiFloat 3.8s ease-in-out infinite;
}
@keyframes mtxMetiFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2.5px); }
}

.mtx-meti .mtx-meti-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: mtxMetiBlink 4.6s infinite;
}
@keyframes mtxMetiBlink {
  0%, 91%, 96%, 100% { transform: scaleY(1); }
  93% { transform: scaleY(0.08); }
}

.mtx-meti .mtx-meti-pupils {
  animation: mtxMetiLook 9s ease-in-out infinite;
}
@keyframes mtxMetiLook {
  0%, 34%, 100% { transform: translate(0, 0); }
  38%, 52% { transform: translate(1.6px, -0.4px); }
  56%, 60% { transform: translate(0, 0); }
  74%, 86% { transform: translate(-1.6px, 0.3px); }
}

.mtx-meti .mtx-meti-antenna {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: mtxMetiSway 3.8s ease-in-out infinite;
}
@keyframes mtxMetiSway {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.mtx-meti .mtx-meti-ball {
  transform-box: fill-box;
  transform-origin: center;
  animation: mtxMetiGlow 3.8s ease-in-out infinite;
}
@keyframes mtxMetiGlow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.18); opacity: 0.85; }
}

/* Al pasar el mouse, Meti se entusiasma apenas. */
.mtx-wa-launcher:hover .mtx-meti .mtx-meti-pupils {
  animation: none;
  transform: translate(0, -0.5px);
}
.mtx-wa-launcher .mtx-wa-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font: 700 11px/20px var(--font-body, "Inter", system-ui, sans-serif);
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

@keyframes mtxWaPop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- Panel ---- */
.mtx-wa-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 10001;
  display: none;
  flex-direction: column;
  width: 372px;
  max-width: calc(100vw - 24px);
  height: min(560px, calc(100vh - 120px));
  overflow: hidden;
  border-radius: 16px;
  background: #0b141a;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.4);
  font-family: var(--font-body, "Inter", system-ui, sans-serif);
}
.mtx-wa-panel.is-open {
  display: flex;
  animation: mtxWaSlideUp 0.32s cubic-bezier(0.21, 1.02, 0.73, 1);
}
@keyframes mtxWaSlideUp {
  0% { transform: translateY(18px) scale(0.97); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* ---- Header ---- */
.mtx-wa-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #1f2c34;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.mtx-wa-avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mtx-wa-avatar svg {
  width: 40px;
  height: 40px;
}
.mtx-wa-avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #25d366;
  border: 2px solid #1f2c34;
}
.mtx-wa-header-info {
  flex: 1;
  min-width: 0;
}
.mtx-wa-header-name {
  margin: 0;
  color: #e9edef;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.2;
}
.mtx-wa-header-status {
  margin: 2px 0 0;
  color: #8696a0;
  font-size: 12px;
  line-height: 1;
}
.mtx-wa-header-status.is-typing {
  color: #25d366;
}
.mtx-wa-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #8696a0;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.mtx-wa-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e9edef;
}

/* ---- Body ---- */
.mtx-wa-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 10px;
  background-color: #0b141a;
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1.2px);
  background-size: 22px 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.mtx-wa-date {
  margin: 0 auto 12px;
  width: max-content;
  padding: 4px 12px;
  border-radius: 8px;
  background: #1f2c34;
  color: #8696a0;
  font-size: 11px;
  font-weight: 500;
}

/* ---- Burbujas ---- */
.mtx-wa-msg {
  position: relative;
  max-width: 84%;
  margin-bottom: 6px;
  padding: 8px 10px 6px;
  border-radius: 10px;
  color: #e9edef;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: mtxWaMsgIn 0.22s ease;
}
@keyframes mtxWaMsgIn {
  0% { transform: translateY(6px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.mtx-wa-msg--agent {
  background: #1f2c34;
  border-top-left-radius: 2px;
  margin-right: auto;
}
.mtx-wa-msg--user {
  background: #005c4b;
  border-top-right-radius: 2px;
  margin-left: auto;
}
.mtx-wa-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 3px;
  color: #8696a0;
  font-size: 10.5px;
  line-height: 1;
}
.mtx-wa-msg--user .mtx-wa-msg-meta {
  color: rgba(233, 237, 239, 0.6);
}
.mtx-wa-checks {
  color: #53bdeb;
  font-size: 11px;
  letter-spacing: -2px;
}

/* ---- Typing ---- */
.mtx-wa-typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
}
.mtx-wa-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8696a0;
  animation: mtxWaTyping 1.1s infinite ease-in-out;
}
.mtx-wa-typing span:nth-child(2) { animation-delay: 0.15s; }
.mtx-wa-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes mtxWaTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Opciones (quick replies) ---- */
.mtx-wa-options {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin: 10px 0 8px;
}
.mtx-wa-option {
  max-width: 90%;
  padding: 8px 14px;
  border: 1.5px solid #25d366;
  border-radius: 999px;
  background: rgba(37, 211, 102, 0.06);
  color: #25d366;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  animation: mtxWaMsgIn 0.25s ease backwards;
}
.mtx-wa-option:nth-child(2) { animation-delay: 0.06s; }
.mtx-wa-option:nth-child(3) { animation-delay: 0.12s; }
.mtx-wa-option:nth-child(4) { animation-delay: 0.18s; }
.mtx-wa-option:hover {
  background: rgba(37, 211, 102, 0.16);
  transform: translateX(-2px);
}

/* ---- CTA card ---- */
.mtx-wa-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.mtx-wa-cta-primary,
.mtx-wa-cta-secondary {
  display: block;
  width: 100%;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.mtx-wa-cta-primary {
  border: none;
  background: #25d366;
  color: #0b141a;
}
.mtx-wa-cta-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
.mtx-wa-cta-secondary {
  border: 1.5px solid rgba(233, 237, 239, 0.25);
  background: transparent;
  color: #e9edef;
  font-weight: 500;
}
.mtx-wa-cta-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* ---- Lead form ---- */
.mtx-wa-lead {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 88%;
  margin: 10px 0 8px auto;
  animation: mtxWaMsgIn 0.25s ease;
}
.mtx-wa-lead input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: #2a3942;
  color: #e9edef;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}
.mtx-wa-lead input::placeholder {
  color: #8696a0;
}
.mtx-wa-lead input:focus {
  border-color: var(--purple, #7c3aed);
}
.mtx-wa-lead input.is-invalid {
  border-color: #ef4444;
}
.mtx-wa-lead-error {
  margin: -2px 2px 0;
  color: #f87171;
  font-size: 11.5px;
  display: none;
}
.mtx-wa-lead-error.is-visible {
  display: block;
}
.mtx-wa-lead-submit {
  border: none;
  padding: 11px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--purple, #7c3aed), var(--pink-strong, #e891a8));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.mtx-wa-lead-submit:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
.mtx-wa-lead-skip {
  border: none;
  background: transparent;
  color: #8696a0;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.mtx-wa-lead-skip:hover {
  color: #e9edef;
}

/* ---- Footer (input simulado) ---- */
.mtx-wa-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #1f2c34;
}
.mtx-wa-input {
  flex: 1;
  padding: 9px 14px;
  border-radius: 999px;
  background: #2a3942;
  color: #8696a0;
  font-size: 13px;
  user-select: none;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
  .mtx-wa-panel {
    right: 12px;
    left: 12px;
    bottom: 86px;
    width: auto;
    height: min(540px, calc(100dvh - 110px));
  }
  .mtx-wa-launcher {
    right: 16px;
    bottom: 16px;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .mtx-wa-launcher.is-visible,
  .mtx-wa-launcher.is-idle .mtx-meti,
  .mtx-meti .mtx-meti-eyes,
  .mtx-meti .mtx-meti-pupils,
  .mtx-meti .mtx-meti-antenna,
  .mtx-meti .mtx-meti-ball,
  .mtx-wa-panel.is-open,
  .mtx-wa-msg,
  .mtx-wa-option,
  .mtx-wa-lead {
    animation: none;
  }
  .mtx-wa-typing span {
    animation: none;
    opacity: 0.7;
  }
}
:root[data-a11y-motion="reduced"] .mtx-wa-launcher.is-visible,
:root[data-a11y-motion="reduced"] .mtx-wa-launcher.is-idle .mtx-meti,
:root[data-a11y-motion="reduced"] .mtx-meti .mtx-meti-eyes,
:root[data-a11y-motion="reduced"] .mtx-meti .mtx-meti-pupils,
:root[data-a11y-motion="reduced"] .mtx-meti .mtx-meti-antenna,
:root[data-a11y-motion="reduced"] .mtx-meti .mtx-meti-ball,
:root[data-a11y-motion="reduced"] .mtx-wa-panel.is-open,
:root[data-a11y-motion="reduced"] .mtx-wa-msg,
:root[data-a11y-motion="reduced"] .mtx-wa-option,
:root[data-a11y-motion="reduced"] .mtx-wa-lead {
  animation: none;
}
