/* ==========================================================================
   MateoLab — Chatbot widget (Mateo)
   Hereda los tokens de marca de styles.css (:root). Estética premium clara.
   ========================================================================== */

.mlc {
  --mlc-accent: var(--accent, #0E7490);
  --mlc-accent-ink: var(--accent-ink, #0B5A70);
  --mlc-bright: var(--accent-bright, #2EC4DE);
  --mlc-paper: #fff;
  --mlc-ink: var(--ink, #0E1726);
  --mlc-muted: var(--muted, #51606E);
  --mlc-line: var(--line, #DCE5EA);
  --mlc-bot-bg: #F1F6F8;
  --mlc-radius: 20px;
  position: fixed;
  z-index: 9000;
  font-family: var(--font-sans, system-ui, sans-serif);
}

/* --- Launcher (burbuja flotante) --- */
.mlc-launcher {
  position: fixed;
  right: 24px; bottom: 24px;
  z-index: 9001;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 0; border: none;
  height: 60px; min-width: 60px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--mlc-accent), var(--mlc-accent-ink));
  color: #fff;
  box-shadow: 0 12px 30px rgba(14, 116, 144, 0.38);
  cursor: pointer;
  transition: transform .25s var(--ease, ease), box-shadow .25s ease, opacity .2s ease;
  overflow: hidden;
}
.mlc-launcher:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 16px 40px rgba(14,116,144,.46); }
.mlc-launcher:active { transform: translateY(-1px) scale(.99); }
.mlc-launcher .mlc-l-ico { width: 60px; height: 60px; display: grid; place-items: center; flex: 0 0 auto; }
.mlc-launcher .mlc-l-ico svg { width: 28px; height: 28px; }
.mlc-launcher .mlc-l-label {
  font-size: .95rem; font-weight: 600; white-space: nowrap;
  max-width: 0; opacity: 0; padding-right: 0;
  transition: max-width .35s var(--ease, ease), opacity .25s ease, padding .35s ease;
}
.mlc-launcher:hover .mlc-l-label { max-width: 220px; opacity: 1; padding-right: 22px; }

/* puntito de notificación */
.mlc-launcher .mlc-dot {
  position: absolute; top: 12px; right: 12px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #38d39f; border: 2px solid #fff;
  animation: mlc-pulse 2s infinite;
}
@keyframes mlc-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(56,211,159,.6); }
  70%  { box-shadow: 0 0 0 9px rgba(56,211,159,0); }
  100% { box-shadow: 0 0 0 0 rgba(56,211,159,0); }
}
.mlc-launcher.is-open .mlc-dot { display: none; }

/* Subir el botón de WhatsApp para que no choque con el launcher del chat */
.wa-float { bottom: 96px !important; }

/* --- Panel del chat --- */
.mlc-panel {
  position: fixed;
  right: 24px; bottom: 96px;
  width: 384px; max-width: calc(100vw - 32px);
  height: 600px; max-height: calc(100vh - 130px);
  background: var(--mlc-paper);
  border: 1px solid var(--mlc-line);
  border-radius: var(--mlc-radius);
  box-shadow: 0 24px 70px rgba(14, 23, 38, 0.22);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0; transform: translateY(16px) scale(.96);
  pointer-events: none;
  transition: opacity .28s var(--ease, ease), transform .28s var(--ease, ease);
}
.mlc-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* Header */
.mlc-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--mlc-accent), var(--mlc-accent-ink));
  color: #fff;
}
.mlc-avatar {
  width: 42px; height: 42px; flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(255,255,255,.16);
  display: grid; place-items: center;
}
.mlc-avatar svg { width: 24px; height: 24px; }
.mlc-head-meta { flex: 1; min-width: 0; line-height: 1.25; }
.mlc-head-meta b { font-size: 1rem; font-weight: 600; font-family: var(--font-serif, serif); }
.mlc-head-meta span { display: flex; align-items: center; gap: 6px; font-size: .78rem; opacity: .9; }
.mlc-head-meta .mlc-online { width: 7px; height: 7px; border-radius: 50%; background: #38d39f; }
.mlc-close {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  cursor: pointer; transition: background .2s ease; flex: 0 0 auto;
}
.mlc-close:hover { background: rgba(255,255,255,.26); }
.mlc-close svg { width: 18px; height: 18px; }

/* Cuerpo de mensajes */
.mlc-body {
  flex: 1; overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 12px;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(46,196,222,.05), transparent 60%),
    var(--mlc-paper);
  scrollbar-width: thin; scrollbar-color: var(--mlc-line) transparent;
}
.mlc-body::-webkit-scrollbar { width: 8px; }
.mlc-body::-webkit-scrollbar-thumb { background: var(--mlc-line); border-radius: 8px; }

.mlc-msg { display: flex; max-width: 86%; animation: mlc-in .3s var(--ease, ease); }
@keyframes mlc-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.mlc-msg-bubble {
  padding: 11px 14px; border-radius: 16px;
  font-size: .92rem; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word;
}
.mlc-msg.bot { align-self: flex-start; }
.mlc-msg.bot .mlc-msg-bubble {
  background: var(--mlc-bot-bg); color: var(--mlc-ink);
  border-bottom-left-radius: 5px;
}
.mlc-msg.user { align-self: flex-end; }
.mlc-msg.user .mlc-msg-bubble {
  background: var(--mlc-accent); color: #fff;
  border-bottom-right-radius: 5px;
}
.mlc-msg-bubble a { color: var(--mlc-accent-ink); text-decoration: underline; font-weight: 600; }
.mlc-msg.user .mlc-msg-bubble a { color: #fff; }
.mlc-msg-bubble strong { font-weight: 600; }

/* indicador "escribiendo" */
.mlc-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.mlc-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--mlc-muted); opacity: .5; animation: mlc-bounce 1.3s infinite; }
.mlc-typing i:nth-child(2) { animation-delay: .18s; }
.mlc-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes mlc-bounce { 0%,60%,100% { transform: translateY(0); opacity:.45;} 30% { transform: translateY(-5px); opacity:.9;} }

/* Quick replies / acciones */
.mlc-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 10px; }
.mlc-quick button {
  border: 1px solid var(--mlc-line); background: #fff; color: var(--mlc-accent-ink);
  font-size: .82rem; font-weight: 500; padding: 8px 13px; border-radius: 999px;
  cursor: pointer; transition: all .18s ease; line-height: 1.2;
}
.mlc-quick button:hover { border-color: var(--mlc-accent); background: var(--accent-soft, #DEF2F6); }

/* CTAs de conversión */
.mlc-cta-row { display: flex; gap: 8px; padding: 0 16px 8px; }
.mlc-cta {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: .84rem; font-weight: 600; padding: 10px; border-radius: 12px;
  cursor: pointer; border: 1px solid var(--mlc-line); background: #fff; color: var(--mlc-ink);
  transition: all .18s ease; text-align: center;
}
.mlc-cta svg { width: 16px; height: 16px; }
.mlc-cta.primary { background: var(--mlc-accent); border-color: var(--mlc-accent); color: #fff; }
.mlc-cta.primary:hover { background: var(--mlc-accent-ink); }
.mlc-cta.ghost:hover { border-color: var(--mlc-accent); color: var(--mlc-accent-ink); }

/* Input */
.mlc-input {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--mlc-line); background: #fff;
}
.mlc-input textarea {
  flex: 1; resize: none; border: 1px solid var(--mlc-line); border-radius: 13px;
  padding: 11px 13px; font-family: inherit; font-size: .9rem; line-height: 1.4;
  max-height: 110px; color: var(--mlc-ink); background: var(--paper, #FBFCFD);
  transition: border-color .18s ease;
}
.mlc-input textarea:focus { outline: none; border-color: var(--mlc-accent); }
.mlc-send {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; border: none;
  background: var(--mlc-accent); color: #fff; display: grid; place-items: center; cursor: pointer;
  transition: background .18s ease, transform .12s ease;
}
.mlc-send:hover:not(:disabled) { background: var(--mlc-accent-ink); }
.mlc-send:active:not(:disabled) { transform: scale(.92); }
.mlc-send:disabled { opacity: .45; cursor: not-allowed; }
.mlc-send svg { width: 20px; height: 20px; }

.mlc-foot { text-align: center; font-size: .68rem; color: var(--mlc-muted); padding: 0 0 8px; background:#fff; }
.mlc-foot b { color: var(--mlc-accent-ink); font-weight: 600; }

/* Mini-formulario de lead */
.mlc-lead {
  margin: 0 16px 12px; padding: 14px; border: 1px solid var(--mlc-line);
  border-radius: 14px; background: var(--accent-soft, #DEF2F6);
  animation: mlc-in .3s var(--ease, ease);
}
.mlc-lead h4 { margin: 0 0 4px; font-size: .92rem; font-family: var(--font-serif, serif); color: var(--mlc-ink); }
.mlc-lead p { margin: 0 0 10px; font-size: .8rem; color: var(--mlc-muted); line-height: 1.4; }
.mlc-lead input {
  width: 100%; margin-bottom: 8px; border: 1px solid var(--mlc-line); border-radius: 10px;
  padding: 10px 12px; font-family: inherit; font-size: .86rem; background: #fff; color: var(--mlc-ink);
}
.mlc-lead input:focus { outline: none; border-color: var(--mlc-accent); }
.mlc-lead-actions { display: flex; gap: 8px; }
.mlc-lead-actions button {
  flex: 1; padding: 9px; border-radius: 10px; font-size: .84rem; font-weight: 600; cursor: pointer; border: 1px solid var(--mlc-line); background:#fff; color: var(--mlc-muted);
}
.mlc-lead-actions .mlc-lead-send { background: var(--mlc-accent); border-color: var(--mlc-accent); color: #fff; }
.mlc-lead-actions .mlc-lead-send:hover { background: var(--mlc-accent-ink); }
.mlc-lead-ok { font-size: .86rem; color: var(--mlc-accent-ink); font-weight: 600; text-align:center; padding: 6px 0; }

/* Responsive: ocupa casi toda la pantalla en móvil */
@media (max-width: 480px) {
  .mlc-panel {
    right: 0; bottom: 0; left: 0;
    width: 100%; max-width: 100%;
    height: 88vh; max-height: 88vh;
    border-radius: 18px 18px 0 0;
  }
  .mlc-launcher { right: 16px; bottom: 16px; }
  .mlc-launcher:hover .mlc-l-label { max-width: 0; opacity: 0; padding-right: 0; }
  .wa-float { bottom: 86px !important; right: 16px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .mlc-launcher, .mlc-panel, .mlc-msg, .mlc-lead { transition: none; animation: none; }
  .mlc-launcher .mlc-dot { animation: none; }
}
