#leyenda-ai-root{
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:999999;
  font-family:inherit;
}
#leyenda-ai-toggle{
  border:0;
  border-radius:999px;
  padding:13px 18px;
  background:#8325E3;
  color:#fff;
  font-weight:700;
  box-shadow:0 10px 30px rgba(0,0,0,.20);
  cursor:pointer;
}
#leyenda-ai-toggle span{
  display:inline-block;
  width:9px;
  height:9px;
  border-radius:50%;
  background:#fff;
  margin-right:8px;
}
#leyenda-ai-panel{
  position:absolute;
  right:0;
  bottom:60px;
  width:min(410px,calc(100vw - 28px));
  height:min(620px,calc(100vh - 120px));
  background:#fff;
  border:1px solid rgba(0,0,0,.08);
  border-radius:18px;
  overflow:hidden;
  box-shadow:0 18px 55px rgba(0,0,0,.24);
}
#leyenda-ai-panel[hidden]{display:none!important}
#leyenda-ai-panel header{
  height:64px;
  box-sizing:border-box;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px 10px 16px;
  background:#8325E3;
  color:#fff;
}
#leyenda-ai-panel header b,
#leyenda-ai-panel header small{display:block}
#leyenda-ai-panel header small{opacity:.82;margin-top:2px}
#leyenda-ai-close{
  width:44px;
  height:44px;
  min-width:44px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:0;
  border-radius:50%;
  background:rgba(255,255,255,.12);
  color:#fff;
  font-size:28px;
  line-height:1;
  cursor:pointer;
  touch-action:manipulation;
}
#leyenda-ai-close:hover{background:rgba(255,255,255,.20)}
#leyenda-ai-messages{
  height:calc(100% - 128px);
  overflow:auto;
  padding:14px;
  background:#fafafa;
  box-sizing:border-box;
}
.lai-msg{
  max-width:88%;
  width:max-content;
  padding:10px 12px;
  border-radius:14px;
  margin-bottom:10px;
  background:#fff;
  border:1px solid rgba(0,0,0,.07);
  white-space:pre-wrap;
  line-height:1.42;
  color:#222;
}
.lai-msg.user{
  margin-left:auto;
  background:#8325E3;
  color:#fff;
  border-color:#8325E3;
}
#leyenda-ai-form{
  height:64px;
  box-sizing:border-box;
  display:flex;
  gap:8px;
  padding:11px;
  background:#fff;
  border-top:1px solid rgba(0,0,0,.08);
}
#leyenda-ai-input{
  flex:1;
  min-width:0;
  border:1px solid #ddd;
  border-radius:10px;
  padding:10px;
}
#leyenda-ai-form button{
  border:0;
  border-radius:10px;
  background:#8325E3;
  color:#fff;
  font-weight:700;
  padding:0 14px;
  cursor:pointer;
}

@media(max-width:520px){
  #leyenda-ai-root{
    right:12px;
    bottom:12px;
  }
  #leyenda-ai-toggle{
    padding:12px 16px;
  }
  #leyenda-ai-panel{
    position:fixed;
    left:14px;
    right:14px;
    bottom:76px;
    top:auto;
    width:auto;
    height:min(72vh,560px);
    max-height:calc(100vh - 110px);
    border-radius:18px;
  }
  #leyenda-ai-panel header{
    height:62px;
    padding-left:14px;
  }
  #leyenda-ai-close{
    width:46px;
    height:46px;
    min-width:46px;
    font-size:30px;
  }
  #leyenda-ai-messages{
    height:calc(100% - 124px);
  }
}

/* En pantallas muy bajas deja todavía más sitio visible detrás del chat */
@media(max-width:520px) and (max-height:700px){
  #leyenda-ai-panel{
    height:66vh;
    bottom:72px;
  }
}

.lai-msg.loading{opacity:.65;font-style:italic}


.lai-actions{
  display:flex;
  gap:8px;
  align-items:stretch;
}
#leyenda-ai-form{
  height:auto;
  min-height:64px;
  align-items:stretch;
}
#leyenda-ai-form .lai-send{
  min-height:42px;
}
.lai-whatsapp{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:42px;
  padding:0 12px;
  border-radius:10px;
  background:#f3f3f3;
  color:#222;
  text-decoration:none;
  font-weight:700;
  white-space:nowrap;
  border:1px solid rgba(0,0,0,.10);
}
.lai-whatsapp:hover{
  color:#111;
  background:#eaeaea;
}
.lai-guest{
  height:calc(100% - 124px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
  background:#fafafa;
  box-sizing:border-box;
}
.lai-guest-card{
  max-width:330px;
  background:#fff;
  padding:22px;
  border:1px solid rgba(0,0,0,.08);
  border-radius:16px;
  text-align:center;
}
.lai-guest-card h3{
  margin:0 0 10px;
  font-size:19px;
  color:#222;
}
.lai-guest-card p{
  margin:0 0 16px;
  line-height:1.45;
  color:#555;
}
.lai-account{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:11px 16px;
  border-radius:10px;
  background:#8325E3;
  color:#fff!important;
  text-decoration:none!important;
  font-weight:700;
}
.lai-guest-footer{
  min-height:60px;
  display:flex;
  justify-content:center;
  align-items:center;
  padding:8px 12px;
  box-sizing:border-box;
  border-top:1px solid rgba(0,0,0,.08);
  background:#fff;
}
.lai-whatsapp.guest{
  width:100%;
  max-width:300px;
}

@media(max-width:520px){
  #leyenda-ai-form{
    flex-direction:column;
    height:auto;
    min-height:112px;
  }
  .lai-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
  }
  #leyenda-ai-messages{
    height:calc(100% - 176px);
  }
  .lai-guest{
    height:calc(100% - 122px);
  }
}


/* ===== v0.3.8: compositor de chat ===== */

#leyenda-ai-form{
  display:flex !important;
  flex-direction:column !important;
  gap:9px !important;
  height:auto !important;
  min-height:108px !important;
  padding:10px 12px !important;
}

#leyenda-ai-input{
  display:block !important;
  width:100% !important;
  max-width:none !important;
  min-height:44px !important;
  box-sizing:border-box !important;
  flex:none !important;
}

#leyenda-ai-form .lai-actions{
  display:grid !important;
  grid-template-columns:minmax(0,1.2fr) minmax(0,1.1fr) auto !important;
  gap:8px !important;
  align-items:stretch !important;
  width:100% !important;
}

#leyenda-ai-form .lai-mailbox,
#leyenda-ai-form .lai-whatsapp,
#leyenda-ai-form .lai-send{
  min-height:40px !important;
  height:40px !important;
  box-sizing:border-box !important;
  border-radius:9px !important;
  padding:0 10px !important;
  font-size:12px !important;
  font-weight:700 !important;
  line-height:1.15 !important;
  text-align:center !important;
  justify-content:center !important;
  align-items:center !important;
}

#leyenda-ai-form .lai-mailbox{
  display:flex;
  border:1px solid rgba(0,0,0,.13);
  background:#fff;
  color:#333;
  cursor:pointer;
}

#leyenda-ai-form .lai-whatsapp{
  display:flex;
  background:#f4f4f4;
  color:#222;
  border:1px solid rgba(0,0,0,.11);
  text-decoration:none;
}

#leyenda-ai-form .lai-send{
  display:flex;
  border:0;
  background:#8325E3;
  color:#fff;
  cursor:pointer;
  padding-left:16px !important;
  padding-right:16px !important;
}

#leyenda-ai-messages{
  height:calc(100% - 172px) !important;
}

@media(max-width:520px){
  #leyenda-ai-form{
    min-height:118px !important;
  }

  #leyenda-ai-form .lai-actions{
    grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto !important;
    gap:6px !important;
  }

  #leyenda-ai-form .lai-mailbox,
  #leyenda-ai-form .lai-whatsapp{
    font-size:11px !important;
    padding-left:6px !important;
    padding-right:6px !important;
  }

  #leyenda-ai-form .lai-send{
    font-size:12px !important;
    padding-left:12px !important;
    padding-right:12px !important;
  }

  #leyenda-ai-messages{
    height:calc(100% - 182px) !important;
  }
}

@media(max-width:380px){
  #leyenda-ai-form .lai-actions{
    grid-template-columns:1fr 1fr !important;
  }

  #leyenda-ai-form .lai-send{
    grid-column:1 / -1 !important;
    width:100% !important;
  }

  #leyenda-ai-form{
    min-height:164px !important;
  }

  #leyenda-ai-messages{
    height:calc(100% - 226px) !important;
  }
}


/* v0.4.0 - traspaso a ventas */
#leyenda-ai-form .lai-whatsapp{
  font-weight:700 !important;
}
#leyenda-ai-form .lai-whatsapp[aria-disabled="true"]{
  opacity:.65;
  pointer-events:none;
}
