/* Asistente MYC: botón flotante y ventana de ayuda (ver ayuda.js) */

.ayuda-boton, .ayuda-ventana { --ay-navy: var(--navy, #151A40); --ay-navy-3: var(--navy-3, #232A55); --ay-lav: var(--lav, #9FB0FF); --ay-lav-soft: var(--lav-soft, #EEF0FF); --ay-lav-ink: var(--lav-ink, #3B4BB8); --ay-line: var(--line, #DCDFEA); --ay-ink: var(--ink, #151A40); --ay-ink-2: var(--ink-2, #4A5070); --ay-ink-3: var(--ink-3, #585E7E); }

/* ── Botón ── */
.ayuda-boton {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 1400;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px 0 6px;
  border: 0;
  border-radius: 999px;
  background: var(--ay-navy);
  color: #fff;
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 12px 30px -14px rgba(15, 18, 38, .7), 0 2px 6px rgba(15, 18, 38, .16);
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s ease, background-color .2s ease;
}
.ayuda-boton:hover { background: var(--ay-navy-3); transform: translateY(-2px); box-shadow: 0 16px 34px -14px rgba(15, 18, 38, .75), 0 2px 6px rgba(15, 18, 38, .16); }
.ayuda-boton:active { transform: scale(.96); }
.ayuda-boton:focus-visible { outline: 3px solid var(--ay-lav); outline-offset: 3px; }
.ayuda-boton[hidden] { display: none; }
.ayuda-boton-ico {
  width: 32px; height: 32px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(159, 176, 255, .16);
  color: var(--ay-lav);
}
.ayuda-boton-ico svg { width: 19px; height: 19px; }
body.ayuda-abierta .ayuda-boton { opacity: 0; pointer-events: none; transform: scale(.9); }

/* ── Ventana ── */
.ayuda-ventana {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 1450;
  width: min(400px, calc(100vw - 40px));
  height: min(600px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  background: #fff;
  color: var(--ay-ink);
  border: 1px solid rgba(21, 26, 64, .08);
  border-radius: 22px;
  box-shadow: 0 30px 70px -24px rgba(15, 18, 38, .45), 0 4px 14px rgba(15, 18, 38, .08);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .18s ease, transform .22s cubic-bezier(.2, .8, .2, 1);
}
.ayuda-ventana.abierta { opacity: 1; transform: none; }
.ayuda-ventana[hidden] { display: none; }

.ayuda-cab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 12px 14px;
  background: var(--ay-navy);
  color: #fff;
}
.ayuda-avatar {
  width: 34px; height: 34px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(159, 176, 255, .16);
  color: var(--ay-lav);
}
.ayuda-avatar svg { width: 20px; height: 20px; }
.ayuda-titulo { flex: 1; min-width: 0; line-height: 1.2; }
.ayuda-titulo b { display: block; font-size: .92rem; font-weight: 700; }
.ayuda-titulo small { display: inline-flex; align-items: center; gap: 6px; font-size: .7rem; color: var(--on-navy-2, #C4C9E4); }
.ayuda-punto { width: 6px; height: 6px; border-radius: 50%; background: #5FD39A; box-shadow: 0 0 0 3px rgba(95, 211, 154, .18); }
.ayuda-icono {
  width: 34px; height: 34px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 10px;
  background: transparent; color: #fff; cursor: pointer;
  transition: background-color .15s ease;
}
.ayuda-icono svg { width: 18px; height: 18px; }
.ayuda-icono:hover { background: rgba(255, 255, 255, .1); }
.ayuda-icono:focus-visible { outline: 2px solid var(--ay-lav); outline-offset: 1px; }

/* ── Mensajes ── */
.ayuda-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #F7F8FC;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.ayuda-msg { max-width: 90%; font-size: .875rem; line-height: 1.55; overflow-wrap: anywhere; }
.ayuda-msg p { margin: 0 0 6px; }
.ayuda-msg p:last-child { margin-bottom: 0; }
.ayuda-msg b { font-weight: 700; color: var(--ay-ink); }
.ayuda-yo {
  align-self: flex-end;
  padding: 9px 14px;
  border-radius: 18px 18px 6px 18px;
  background: var(--ay-navy);
  color: #fff;
}
.ayuda-ia {
  align-self: flex-start;
  position: relative;
  padding: 12px 14px;
  border-radius: 18px 18px 18px 6px;
  background: #fff;
  border: 1px solid rgba(21, 26, 64, .07);
  box-shadow: 0 1px 2px rgba(15, 18, 38, .04);
}
.ayuda-error { color: var(--danger, #B42318); background: var(--danger-light, #FBECEA); border-color: transparent; }

/* Pasos numerados en círculos */
.ayuda-msg ol { list-style: none; counter-reset: paso; margin: 4px 0 10px; padding: 0; }
.ayuda-msg ol li { counter-increment: paso; position: relative; padding: 2px 0 2px 32px; margin: 6px 0; }
.ayuda-msg ol li::before {
  content: counter(paso);
  position: absolute; left: 0; top: 2px;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--ay-lav-soft);
  color: var(--ay-lav-ink);
  font-size: .72rem; font-weight: 700;
}
.ayuda-msg ul { margin: 4px 0 10px; padding-left: 18px; }
.ayuda-msg ul li { margin: 4px 0; }
.ayuda-msg ul li::marker { color: var(--ay-lav-ink); }
.ayuda-cuerpo > :last-child { margin-bottom: 0; }

.ayuda-entra { opacity: 0; animation: ayudaEntra .32s ease forwards; }
@keyframes ayudaEntra { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.ayuda-copiar {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 8px; padding: 3px 8px 3px 6px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--ay-ink-3);
  font: inherit; font-size: .72rem; cursor: pointer;
  opacity: .75;
  transition: background-color .15s ease, opacity .15s ease;
}
.ayuda-copiar svg { width: 14px; height: 14px; }
.ayuda-copiar:hover, .ayuda-copiar:focus-visible { background: var(--ay-lav-soft); color: var(--ay-lav-ink); opacity: 1; }

/* Escribiendo… */
.ayuda-cargando { padding: 14px 16px; }
.ayuda-escribiendo { display: inline-flex; gap: 5px; }
.ayuda-escribiendo i { width: 7px; height: 7px; border-radius: 50%; background: var(--ay-lav-ink); opacity: .3; animation: ayudaPunto 1.1s infinite ease-in-out; }
.ayuda-escribiendo i:nth-child(2) { animation-delay: .15s; }
.ayuda-escribiendo i:nth-child(3) { animation-delay: .3s; }
@keyframes ayudaPunto { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* Bienvenida */
.ayuda-hola { margin: auto 0 4px; padding: 8px 4px 0; }
.ayuda-hola-ico {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: var(--ay-navy); color: var(--ay-lav);
  margin-bottom: 12px;
}
.ayuda-hola-ico svg { width: 24px; height: 24px; }
.ayuda-hola-tit { margin: 0 0 4px; font-size: 1.05rem; font-weight: 700; color: var(--ay-ink); }
.ayuda-hola-sub { margin: 0 0 16px; font-size: .84rem; line-height: 1.5; color: var(--ay-ink-2); }
.ayuda-hola-donde { margin: 0 0 8px; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ay-ink-3); }
.ayuda-sugerencias { display: flex; flex-wrap: wrap; gap: 6px; }
.ayuda-sugerencias button {
  padding: 7px 12px;
  border: 1px solid var(--ay-line);
  border-radius: 999px;
  background: #fff;
  color: var(--ay-ink);
  font: inherit; font-size: .8rem;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.ayuda-sugerencias button:hover, .ayuda-sugerencias button:focus-visible { border-color: var(--ay-lav); background: var(--ay-lav-soft); color: var(--ay-lav-ink); outline: none; }

/* ── Escribir ── */
.ayuda-form { padding: 10px 12px 8px; background: #fff; border-top: 1px solid rgba(21, 26, 64, .06); }
.ayuda-caja {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 5px 5px 5px 14px;
  border: 1px solid var(--ay-line);
  border-radius: 22px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ayuda-caja:focus-within { border-color: var(--ay-lav-ink); box-shadow: 0 0 0 3px var(--ay-lav-soft); }
.ayuda-caja textarea {
  flex: 1;
  resize: none;
  min-height: 34px; max-height: 120px;
  padding: 7px 0;
  border: 0; outline: none;
  background: transparent;
  font: inherit;
  font-size: 16px; /* evita el zoom automático en iPhone */
  line-height: 1.35;
  color: var(--ay-ink);
}
/* el panel pinta un anillo de foco en todos los campos: aquí lo lleva la caja */
.ayuda-caja textarea:focus, .ayuda-caja textarea:focus-visible { box-shadow: none !important; outline: none !important; border: 0 !important; }
.ayuda-caja textarea::placeholder { color: var(--ay-ink-3); }
.ayuda-enviar {
  width: 34px; height: 34px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: var(--ay-navy); color: #fff; cursor: pointer;
  transition: opacity .15s ease, transform .15s ease;
}
.ayuda-enviar svg { width: 17px; height: 17px; }
.ayuda-enviar:hover:not(:disabled) { transform: scale(1.06); }
.ayuda-enviar:disabled { opacity: .3; cursor: default; }
.ayuda-pie { margin: 6px 4px 0; font-size: .62rem; line-height: 1.35; color: var(--ay-ink-3); opacity: .8; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .ayuda-ventana, .ayuda-boton { transition: none; }
  .ayuda-escribiendo i { animation: none; opacity: .6; }
}

@media (max-width: 768px) {
  .ayuda-boton { right: 14px; bottom: calc(var(--bottom-nav-h, 64px) + 12px + env(safe-area-inset-bottom, 0px)); }
  .ayuda-ventana {
    right: 0; left: 0; bottom: 0;
    width: 100%;
    height: calc(100dvh - 56px - env(safe-area-inset-top, 0px));
    z-index: 1500; /* por encima de la barra inferior de navegación */
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    transform-origin: bottom center;
  }
  .ayuda-form { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}

@media print { .ayuda-boton, .ayuda-ventana { display: none !important; } }
