/* ==========================================================================
 * asistente_wa.css — Mini-chat estilo WhatsApp (perfil Ultra)
 * ========================================================================== */

.erwa-root{
  --erwa-verde:#25D366;
  --erwa-verde-osc:#128C7E;
  --erwa-header:#075E54;
  --erwa-fondo:#ECE5DD;
  --erwa-in:#ffffff;
  --erwa-out:#DCF8C6;
  --erwa-txt:#111b21;
  --erwa-sombra:0 12px 40px rgba(0,0,0,.28);
  position:fixed; top:0; left:0; right:0;
  height:100vh;            /* fallback navegadores viejos */
  height:100dvh;           /* se ajusta cuando aparece el teclado */
  z-index:2147483000;
  display:none;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
}
.erwa-root.erwa-open{ display:block; }
body.erwa-lock{ overflow:hidden; }

.erwa-backdrop{
  position:absolute; inset:0; background:rgba(0,0,0,.45);
  opacity:0; transition:opacity .2s ease;
}
.erwa-open .erwa-backdrop{ opacity:1; }

.erwa-panel{
  position:absolute; background:var(--erwa-fondo);
  display:flex; flex-direction:column; overflow:hidden;
  box-shadow:var(--erwa-sombra);
}

/* ---- Móvil: bottom-sheet casi completo ---- */
@media (max-width:600px){
  .erwa-panel{
    left:0; right:0; bottom:0;
    height:72vh;            /* fallback: sheet más bajo */
    height:72dvh;          /* alto del sheet cuando hay espacio */
    max-height:100%;       /* nunca más alto que el área visible (la raíz la fija el JS) */
    border-radius:16px 16px 0 0;
    transform:translateY(100%); transition:transform .28s cubic-bezier(.2,.8,.2,1);
  }
  .erwa-open .erwa-panel{ transform:translateY(0); }
}

/* ---- PC/tablet: panel flotante esquina inferior derecha ---- */
@media (min-width:601px){
  .erwa-backdrop{ background:rgba(0,0,0,.25); }
  .erwa-panel{
    right:24px; bottom:24px; width:390px; height:min(600px,82vh);
    border-radius:16px;
    transform:translateY(16px) scale(.98); opacity:0;
    transition:transform .22s ease, opacity .22s ease;
  }
  .erwa-open .erwa-panel{ transform:translateY(0) scale(1); opacity:1; }
}

/* ---- Header ---- */
.erwa-header{
  display:flex; align-items:center; gap:10px;
  background:var(--erwa-header); color:#fff; padding:12px 14px;
  flex:0 0 auto;
}
.erwa-avatar{
  width:40px; height:40px; border-radius:50%;
  background:var(--erwa-verde); color:#053b30; font-weight:700; font-size:18px;
  display:flex; align-items:center; justify-content:center; flex:0 0 auto;
}
.erwa-headtxt{ display:flex; flex-direction:column; line-height:1.2; min-width:0; }
.erwa-nombre{ font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.erwa-sub{ font-size:12px; opacity:.85; }
.erwa-x{
  margin-left:auto; background:none; border:0; color:#fff;
  font-size:26px; line-height:1; cursor:pointer; padding:0 4px; opacity:.9;
}
.erwa-x:hover{ opacity:1; }

/* ---- Mensajes ---- */
.erwa-mensajes{
  flex:1 1 auto; overflow-y:auto; padding:14px 12px;
  background:var(--erwa-fondo);
  background-image:radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px);
  background-size:22px 22px;
  display:flex; flex-direction:column; gap:8px;
}
.erwa-msg{
  max-width:82%; padding:8px 11px; border-radius:10px; font-size:14.5px;
  line-height:1.4; color:var(--erwa-txt); white-space:pre-wrap; word-wrap:break-word;
  box-shadow:0 1px 1px rgba(0,0,0,.08);
}
.erwa-in{ background:var(--erwa-in); align-self:flex-start; border-top-left-radius:2px; }
.erwa-out{ background:var(--erwa-out); align-self:flex-end; border-top-right-radius:2px; }

/* typing */
.erwa-typing{ display:flex; gap:4px; align-items:center; }
.erwa-typing span{
  width:7px; height:7px; border-radius:50%; background:#9aa5a1;
  animation:erwa-bounce 1.1s infinite ease-in-out;
}
.erwa-typing span:nth-child(2){ animation-delay:.15s; }
.erwa-typing span:nth-child(3){ animation-delay:.3s; }
@keyframes erwa-bounce{ 0%,80%,100%{ transform:translateY(0); opacity:.5; } 40%{ transform:translateY(-4px); opacity:1; } }

/* CTA enviar por WhatsApp */
.erwa-cta-wrap{ align-self:flex-end; max-width:90%; }
.erwa-cta{
  display:inline-flex; align-items:center; gap:8px;
  background:var(--erwa-verde); color:#fff; text-decoration:none;
  font-weight:700; font-size:14.5px; padding:11px 16px; border-radius:24px;
  box-shadow:0 3px 10px rgba(37,211,102,.4);
}
.erwa-cta:hover{ background:var(--erwa-verde-osc); }

/* ---- Barra de input ---- */
.erwa-inputbar{
  flex:0 0 auto; display:flex; align-items:flex-end; gap:8px;
  padding:10px; background:#f0f2f5;
}
.erwa-input{
  flex:1 1 auto; resize:none; border:0; outline:0; border-radius:22px;
  padding:10px 14px; font-size:14.5px; line-height:1.35; max-height:110px;
  background:#fff; color:var(--erwa-txt);
  box-shadow:0 1px 2px rgba(0,0,0,.08);
}
.erwa-send{
  flex:0 0 auto; width:44px; height:44px; border:0; border-radius:50%;
  background:var(--erwa-verde); color:#fff; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.erwa-send:hover{ background:var(--erwa-verde-osc); }

/* Accesibilidad: focus visible */
.erwa-x:focus-visible,
.erwa-send:focus-visible,
.erwa-input:focus-visible,
.erwa-cta:focus-visible{ outline:3px solid #ffd34d; outline-offset:2px; }

/* Menos movimiento si el usuario lo pide */
@media (prefers-reduced-motion:reduce){
  .erwa-panel,.erwa-backdrop{ transition:none !important; }
  .erwa-typing span{ animation:none; }
}
