/* Las variables se declaran DENTRO del widget, no en :root,
   para que el tema de la web no las pueda redefinir. */
#ichat-box, .ichat-fab{
  --ichat-green:#25D366;
  --ichat-dark:#075E54;
  --ichat-mid:#128C7E;
  --ichat-bg:#EFEAE2;
  --ichat-user-bubble:#DCF8C6;
  --ichat-bot-bubble:#FFFFFF;
  --ichat-ts:#667781;
}

/* ---------- Botón flotante ---------- */
.ichat-fab{
  position:fixed;bottom:24px;right:24px;
  width:60px !important;height:60px !important;
  min-width:60px !important;min-height:60px !important;
  max-width:60px !important;max-height:60px !important;
  border-radius:50% !important;
  -webkit-border-radius:50% !important;
  overflow:hidden;
  background:#25D366 !important;background-image:none !important;
  border:none !important;outline:none !important;cursor:pointer;
  display:flex !important;align-items:center;justify-content:center;
  box-shadow:0 4px 14px rgba(0,0,0,.25) !important;
  z-index:99998;transition:transform .2s;
  padding:0 !important;margin:0 !important;line-height:0;color:#fff !important;
  -webkit-appearance:none;appearance:none;
  text-transform:none !important;letter-spacing:normal !important;
  font-size:0;
}
.ichat-fab:hover,.ichat-fab:focus,.ichat-fab:active{
  background:#25D366 !important;border-radius:50% !important;
  border:none !important;outline:none !important;
}
.ichat-fab:hover{transform:scale(1.06)}
.ichat-fab.ichat-hidden{display:none !important}

/* El icono es de tipo TRAZO (stroke), no de relleno.
   Por eso se fuerza stroke y se deja fill en none: al revés desaparece. */
.ichat-fab svg{
  width:30px !important;
  height:30px !important;
  display:block !important;
  fill:none !important;
  stroke:#ffffff !important;
  stroke-width:2 !important;
  overflow:visible;
}
.ichat-fab svg path{
  fill:none !important;
  stroke:#ffffff !important;
}
/* El primer path es el "marco" invisible del icono: debe quedarse sin trazo. */
.ichat-fab svg path[stroke="none"]{
  stroke:none !important;
  fill:none !important;
}

/* ---------- Ventana ---------- */
#ichat-box{
  position:fixed;bottom:24px;right:24px;width:370px;max-width:calc(100vw - 32px);
  height:560px;max-height:calc(100vh - 48px);background:#EFEAE2 !important;
  border-radius:12px !important;
  overflow:hidden;display:none;flex-direction:column;box-shadow:0 12px 40px rgba(0,0,0,.3);z-index:99999;
  font-family:-apple-system,"Segoe UI",Helvetica,Arial,sans-serif;font-size:14px;
}
#ichat-box.ichat-open{display:flex}
#ichat-box *{box-sizing:border-box}

#ichat-header{background:#075E54 !important;background-image:none !important;color:#fff !important;
  padding:12px 14px;display:flex;align-items:center;gap:12px;flex-shrink:0}
.ichat-avatar{
  width:40px !important;height:40px !important;
  min-width:40px !important;min-height:40px !important;
  border-radius:50% !important;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  background:linear-gradient(135deg,#075E54,#128C7E) !important;
  color:#fff !important;font-weight:700;font-size:17px;overflow:hidden;
}
.ichat-avatar img{width:100%;height:100%;object-fit:cover;border-radius:50% !important}
.ichat-header-name{font-weight:600;font-size:15px;color:#fff !important}
.ichat-header-status{font-size:12px;color:#A8C7A0 !important;margin-top:1px}

/* Selector de idioma en la cabecera */
#ichat-lang-select{
  -webkit-appearance:none;appearance:none;
  width:auto !important;min-width:0 !important;max-width:58px !important;
  height:auto !important;min-height:0 !important;
  background:rgba(255,255,255,.15) !important;
  border:1px solid rgba(255,255,255,.3) !important;
  color:#fff !important;
  border-radius:6px !important;padding:3px 6px !important;margin:0 !important;
  font-size:11px;font-weight:700;font-family:inherit;line-height:1.2;
  cursor:pointer;flex:0 0 auto !important;outline:none;box-shadow:none !important;
  text-align:center;text-transform:uppercase;
}
#ichat-lang-select option{color:#111;background:#fff}

/* El bloque del nombre no debe colapsar cuando hay selector al lado. */
.ichat-header-info{flex:1 1 auto;min-width:0}
.ichat-header-name,.ichat-header-status{
  display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}

#ichat-close{background:transparent !important;border:none !important;color:#fff !important;opacity:.85;
  cursor:pointer;padding:6px;border-radius:50% !important;display:flex;line-height:0}
#ichat-close:hover{background:rgba(255,255,255,.15) !important}
#ichat-close svg{width:20px !important;height:20px !important;display:block !important}
#ichat-close svg path{fill:#ffffff !important;stroke:none !important}

/* ---------- Mensajes ---------- */
#ichat-messages{flex:1;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:8px;background:#EFEAE2 !important}

.ichat-row{display:flex;gap:6px;align-items:flex-end}
.ichat-row.ichat-user-row{justify-content:flex-end}
.ichat-msg{max-width:80%;padding:8px 11px;border-radius:8px !important;line-height:1.4;
  box-shadow:0 1px 1px rgba(0,0,0,.08);color:#111 !important}
.ichat-msg.ichat-bot{background:#FFFFFF !important;border-bottom-left-radius:2px !important}
.ichat-msg.ichat-user{background:#DCF8C6 !important;border-bottom-right-radius:2px !important}
.ichat-msg p{margin:0 0 6px;color:#111 !important}
.ichat-msg p:last-child{margin-bottom:0}
.ichat-msg a{color:#128C7E !important;text-decoration:underline}
.ichat-msg strong{font-weight:700}
.ichat-time{display:block;font-size:10.5px;color:#667781 !important;text-align:right;margin-top:3px}

.ichat-typing{display:inline-flex;gap:4px;padding:10px 12px;background:#FFFFFF !important;
  border-radius:8px !important;border-bottom-left-radius:2px !important;box-shadow:0 1px 1px rgba(0,0,0,.08)}
.ichat-typing span{width:6px;height:6px;border-radius:50% !important;background:#667781;
  animation:ichat-dot 1.3s infinite ease-in-out both}
.ichat-typing span:nth-child(2){animation-delay:.18s}
.ichat-typing span:nth-child(3){animation-delay:.36s}
@keyframes ichat-dot{0%,60%,100%{transform:translateY(0);opacity:.4}30%{transform:translateY(-4px);opacity:1}}

/* ---------- Preguntas fijadas arriba ---------- */
.ichat-quick-replies{
  position:sticky;top:-14px;z-index:2;
  display:flex;flex-direction:column;gap:8px;
  background:#EFEAE2 !important;
  padding:8px 0 10px;margin-top:2px;
  border-bottom:1px solid rgba(0,0,0,.07);
}
.ichat-quick-btn{
  background:#fff !important;background-image:none !important;
  border:1.5px solid #128C7E !important;border-radius:10px !important;
  padding:9px 12px !important;
  font-size:14px !important;
  line-height:1.4 !important;
  color:#075E54 !important;cursor:pointer;text-align:left;
  transition:background .15s,color .15s;font-family:inherit;
  text-transform:none !important;letter-spacing:normal !important;
  box-shadow:none !important;width:100%;
  white-space:normal !important;
  word-break:break-word;overflow-wrap:break-word;
  height:auto !important;min-height:0 !important;max-height:none !important;
  overflow:visible !important;text-overflow:clip !important;
  display:block !important;
}
.ichat-quick-btn:hover{background:#128C7E !important;color:#fff !important}
.ichat-quick-btn:disabled{opacity:.45;cursor:default;background:#fff !important;color:#075E54 !important}

.ichat-wa-cta{
  display:block;text-align:center;margin-top:2px;
  background:#25D366 !important;background-image:none !important;
  color:#fff !important;text-decoration:none !important;
  padding:10px !important;border-radius:20px !important;font-size:12.5px;font-weight:700;
  text-transform:none !important;letter-spacing:normal !important;border:none !important;
}
.ichat-wa-cta:hover{background:#128C7E !important;color:#fff !important}

#ichat-footer{text-align:center;padding:6px;font-size:10.5px;color:#8a8a8a !important;background:#fff !important;flex-shrink:0}

/* ---------- Barra de escritura ---------- */
#ichat-input-area{display:flex;align-items:center;gap:6px;padding:8px 10px;background:#f0f0f0 !important;flex-shrink:0;
  padding-bottom:calc(8px + env(safe-area-inset-bottom));}
#ichat-input{flex:1;border:none !important;border-radius:20px !important;padding:10px 14px !important;
  font-size:16px;outline:none;font-family:inherit;
  -webkit-appearance:none;appearance:none;background:#fff !important;color:#111 !important;
  min-width:0;box-shadow:none !important;}

/* Flecha de enviar: color literal y currentColor, para que ninguna regla
   del tema la deje invisible. */
#ichat-send{
  width:40px !important;height:40px !important;
  min-width:40px !important;min-height:40px !important;
  border-radius:50% !important;border:none !important;background:transparent !important;
  display:flex !important;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;
  transition:background .15s;padding:0 !important;line-height:0;
  color:#075E54 !important;visibility:visible !important;opacity:1 !important;box-shadow:none !important;}
#ichat-send:hover,#ichat-send:active{background:rgba(0,0,0,.08) !important;border-radius:50% !important}
#ichat-send svg{width:22px !important;height:22px !important;display:block !important;
  fill:currentColor !important;stroke:none !important;visibility:visible !important;opacity:1 !important;}
#ichat-send svg path{fill:currentColor !important;stroke:none !important;}

/* ---------- Móvil ---------- */
@media (max-width:768px){
  #ichat-box{
    top:0;bottom:0;right:0;left:0;
    width:100% !important;max-width:100% !important;
    height:100vh;height:100dvh;
    max-height:100vh;max-height:100dvh;
    border-radius:0 !important;
  }
  .ichat-fab{
    bottom:16px;right:16px;
    width:56px !important;height:56px !important;
    min-width:56px !important;min-height:56px !important;
    max-width:56px !important;max-height:56px !important;
    border-radius:50% !important;
  }
  .ichat-fab svg{width:28px !important;height:28px !important}
}

/* ---------- Blindaje final ----------
   Selectores más específicos que los del tema, por si alguno insiste en
   cuadrar los elementos redondos. */
body .ichat-fab,
html body .ichat-fab,
body button.ichat-fab{border-radius:50% !important}
body .ichat-avatar,
body .ichat-avatar img{border-radius:50% !important;overflow:hidden}
body #ichat-send{border-radius:50% !important}
body #ichat-close{border-radius:50% !important}