/* Mendialyx AI — asistente calificador de leads (widget flotante) */

.mdx-chat {
  position: fixed;
  right: 24px;
  bottom: 22px;
  z-index: 60;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--sans);
  pointer-events: none;
}
.mdx-chat > * { pointer-events: auto; }
.mdx-launcher-short { display: none; }

/* El botón de WhatsApp del sitio se sube para no encimarse con el asistente. */
.floating-wa { bottom: 82px; }

/* --- Launcher --------------------------------------------------- */

.mdx-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 20px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid transparent;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .35);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  transition: transform .25s ease, box-shadow .25s ease;
}
.mdx-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(0, 0, 0, .4); }

.mdx-launcher-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-ink);
  animation: mdxPulse 2.4s ease-in-out infinite;
}
@keyframes mdxPulse { 50% { opacity: .35; transform: scale(.72); } }

.mdx-chat.is-open .mdx-launcher-text { display: none; }
.mdx-chat.is-open .mdx-launcher { padding: 0 16px; }
.mdx-chat.is-open .mdx-launcher-dot {
  width: 14px; height: 14px; border-radius: 2px; background: transparent; animation: none;
  border-top: 2px solid var(--accent-ink); border-right: 2px solid var(--accent-ink);
  transform: rotate(135deg); margin-top: -4px;
}

/* --- Panel ------------------------------------------------------ */

.mdx-panel {
  width: min(370px, calc(100vw - 40px));
  height: min(560px, calc(100vh - 150px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  background: rgba(13, 21, 30, .97);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  animation: mdxIn .28s cubic-bezier(.2, .7, .2, 1);
}
.mdx-panel[hidden] { display: none; }

@keyframes mdxIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.mdx-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 27, 37, .9);
}
.mdx-avatar {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(33, 215, 243, .12);
  border: 1px solid rgba(65, 210, 255, .3);
}
.mdx-avatar img { width: 22px; height: 22px; object-fit: contain; }
.mdx-head-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.mdx-head-text strong { font-size: 13px; letter-spacing: .02em; color: var(--text); }
.mdx-head-text small { font-size: 11px; color: var(--cyan); }

.mdx-close {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  font-size: 20px;
  line-height: 1;
  transition: color .2s ease, border-color .2s ease;
}
.mdx-close:hover { color: var(--text); border-color: var(--line); }

/* --- Mensajes --------------------------------------------------- */

.mdx-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 200, 255, .28) transparent;
}
.mdx-log::-webkit-scrollbar { width: 6px; }
.mdx-log::-webkit-scrollbar-thumb { background: rgba(120, 200, 255, .28); border-radius: 999px; }

.mdx-msg {
  max-width: 84%;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 16px;
  animation: mdxMsg .3s ease;
  overflow-wrap: anywhere;
}
@keyframes mdxMsg { from { opacity: 0; transform: translateY(8px); } }

.mdx-msg-bot {
  align-self: flex-start;
  color: #e6f1fb;
  background: rgba(22, 34, 46, .95);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.mdx-msg-me {
  align-self: flex-end;
  color: var(--accent-ink);
  font-weight: 500;
  background: var(--accent);
  border-bottom-right-radius: 5px;
}

.mdx-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 13px 15px;
  border-radius: 16px;
  border-bottom-left-radius: 5px;
  background: rgba(22, 34, 46, .95);
  border: 1px solid var(--line);
}
.mdx-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan-soft);
  animation: mdxDot 1.1s ease-in-out infinite;
}
.mdx-typing i:nth-child(2) { animation-delay: .16s; }
.mdx-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes mdxDot { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; transform: translateY(-3px); } }

/* --- Resumen final ---------------------------------------------- */

.mdx-summary {
  align-self: stretch;
  padding: 14px;
  border-radius: 14px;
  background: rgba(33, 215, 243, .07);
  border: 1px solid var(--line-strong);
  animation: mdxMsg .3s ease;
}
.mdx-summary strong { display: block; font-size: 12px; color: var(--cyan); margin-bottom: 10px; }
.mdx-summary dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.mdx-summary dt {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); padding-top: 2px;
}
.mdx-summary dd { margin: 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }

/* --- Acciones (opciones e input) -------------------------------- */

.mdx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: rgba(11, 18, 25, .7);
}
.mdx-actions:empty { display: none; }

.mdx-chip {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  color: #dce8f6;
  background: rgba(17, 27, 37, .7);
  border: 1px solid var(--line-strong);
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.mdx-chip:hover { background: rgba(33, 215, 243, .14); border-color: var(--cyan); transform: translateY(-1px); }
.mdx-chip-soft { color: var(--muted); border-color: var(--line); }
.mdx-chip-wa {
  flex: 1;
  text-align: center;
  color: var(--accent-ink);
  font-weight: 600;
  background: var(--accent);
  border-color: transparent;
}
.mdx-chip-wa:hover { color: var(--accent-ink); background: var(--accent-soft); }

.mdx-form { display: flex; gap: 8px; width: 100%; }
.mdx-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(8, 14, 20, .8);
  border: 1px solid var(--line);
  font-size: 14px;
  outline: none;
  transition: border-color .2s ease;
}
.mdx-input::placeholder { color: #6b8099; }
.mdx-input:focus { border-color: var(--cyan); }

.mdx-send {
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 13px;
  background: var(--accent);
  border: none;
}

.mdx-chat :focus-visible { outline: 2px solid var(--cyan-soft); outline-offset: 2px; }

/* --- Responsive -------------------------------------------------- */

@media (max-width: 760px) {
  .floating-wa { bottom: 16px; }
  .mdx-chat { right: 16px; bottom: 16px; left: 16px; align-items: flex-end; }
  .mdx-panel { width: 100%; height: min(72vh, calc(100svh - 110px)); }
  .mdx-launcher-text { display: none; }
  .mdx-launcher-short { display: inline; }
  .mdx-launcher { height: 52px; padding: 0 18px; }
  .mdx-chat.is-open .mdx-launcher-short { display: none; }
  .mdx-chat.is-open .mdx-launcher { width: 52px; padding: 0; justify-content: center; }
  .mdx-msg, .mdx-input { font-size: 15px; }
  .mdx-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .mdx-panel, .mdx-msg, .mdx-summary { animation: none; }
  .mdx-launcher-dot, .mdx-typing i { animation: none; }
  .mdx-launcher:hover, .mdx-chip:hover { transform: none; }
}

body.menu-open .mdx-chat, body.menu-open .floating-wa { visibility: hidden; }
