/* ==========================================================================
   Asistente de ventas con IA — widget estilo WhatsApp (sympatia) + corporativo
   ========================================================================== */
.ipt-chat { position: fixed; right: 20px; bottom: 20px; z-index: 99998; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; animation: iptChatFade .3s ease both; }
.ipt-chat[hidden] { display: none; }
@keyframes iptChatFade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Lanzador estilo WhatsApp (usa el botón provisto: círculo blanco + ícono verde + punto rojo) */
.ipt-chat__fab { display: block; width: 66px; height: 66px; padding: 0; border: 0; background: transparent; cursor: pointer; position: relative; transition: transform .18s ease; }
.ipt-chat__fab:hover { transform: scale(1.06); }
.ipt-chat__fab.is-open { display: none; }
.ipt-chat__fabimg { width: 100%; height: 100%; object-fit: contain; display: block; }
.ipt-chat__fab::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; box-shadow: 0 0 0 0 rgba(37,211,102,.5); animation: iptWaPulse 2.4s ease-out infinite; }
@keyframes iptWaPulse { 0% { box-shadow: 0 0 0 0 rgba(37,211,102,.45); } 70%,100% { box-shadow: 0 0 0 16px rgba(37,211,102,0); } }

/* Burbuja de saludo */
.ipt-chat__greet { position: absolute; right: 2px; bottom: 80px; max-width: 230px; background: #fff; color: #241827; padding: 13px 30px 13px 15px; border-radius: 16px 16px 4px 16px; box-shadow: 0 16px 40px -14px rgba(24,12,20,.5); font-size: 14px; font-weight: 600; line-height: 1.35; cursor: pointer; animation: iptGreetIn .3s cubic-bezier(.2,.7,.3,1) both; }
.ipt-chat__greet[hidden] { display: none; }
@keyframes iptGreetIn { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
.ipt-chat__greetx { position: absolute; top: 6px; right: 8px; border: 0; background: transparent; color: #a595a1; font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }

/* Panel */
.ipt-chat__panel { position: absolute; right: 0; bottom: 0; width: min(348px, calc(100vw - 28px)); height: min(520px, calc(100vh - 104px)); display: flex; flex-direction: column; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 28px 74px -22px rgba(24,12,20,.62); border: 1px solid rgba(0,0,0,.06); animation: iptChatIn .24s cubic-bezier(.2,.7,.3,1) both; }
.ipt-chat__panel[hidden] { display: none; }
@keyframes iptChatIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

/* Cabecera corporativa (plum → magenta) con logo + nombre del asistente */
.ipt-chat__head { display: flex; align-items: center; gap: 10px; padding: 13px 14px; background: linear-gradient(120deg, var(--pt-plum, #2a1522), var(--pt-brand, #e5305f)); color: #fff; }
.ipt-chat__logo { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; background: #fff; display: grid; place-items: center; overflow: hidden; box-shadow: 0 3px 8px rgba(0,0,0,.25); }
.ipt-chat__logo img { width: 27px; height: 27px; object-fit: contain; }
.ipt-chat__headtxt { flex: 1 1 auto; min-width: 0; line-height: 1.2; }
.ipt-chat__headtxt b { display: block; font-size: 14.5px; }
.ipt-chat__headtxt span { font-size: 11px; opacity: .85; display: inline-flex; align-items: center; gap: 6px; }
.ipt-chat__headtxt span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #37d67a; box-shadow: 0 0 0 3px rgba(55,214,122,.3); }
.ipt-chat__x { flex: 0 0 auto; border: 0; background: rgba(255,255,255,.16); color: #fff; width: 28px; height: 28px; border-radius: 50%; font-size: 19px; line-height: 1; cursor: pointer; }
.ipt-chat__x:hover { background: rgba(255,255,255,.28); }

/* Captura de datos */
.ipt-chat__lead { padding: 16px; overflow-y: auto; }
.ipt-chat__hi { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; }
.ipt-chat__hiav { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; background: var(--pt-bg-soft, #faf5f8); display: grid; place-items: center; overflow: hidden; border: 1px solid var(--pt-line, #efe5ec); }
.ipt-chat__hiav img { width: 28px; height: 28px; object-fit: contain; }
.ipt-chat__hi p { margin: 0; font-size: 14px; line-height: 1.45; color: #4a3f49; background: var(--pt-bg-soft, #faf5f8); padding: 10px 13px; border-radius: 4px 15px 15px 15px; }
.ipt-chat__form { display: flex; flex-direction: column; gap: 9px; }
.ipt-chat__form input { font: inherit; font-size: 14px; padding: 11px 13px; border: 1.5px solid #e6dbe2; border-radius: 11px; color: #241827; }
.ipt-chat__form input:focus { outline: none; border-color: var(--pt-brand, #e5305f); box-shadow: 0 0 0 3px var(--pt-brand-50, #fdeef3); }
.ipt-chat__hp { position: absolute; left: -9999px; }
.ipt-chat__start { margin-top: 3px; border: 0; cursor: pointer; padding: 13px; border-radius: 11px; background: var(--pt-brand, #e5305f); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 10px 22px -10px rgba(229,48,95,.7); transition: background .16s; }
.ipt-chat__start:hover { background: var(--pt-brand-600, #c21f4c); }
.ipt-chat__priv { margin: 4px 0 0; font-size: 11.5px; color: var(--pt-ink-soft, #6b5f6b); text-align: center; }
.ipt-chat__err { margin: 2px 0 0; font-size: 12px; color: var(--pt-brand-600, #c21f4c); }

/* Mensajes */
.ipt-chat__body { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 9px; background: var(--pt-bg-soft, #faf5f8); }
.ipt-chat__msg { max-width: 85%; padding: 9px 12px; border-radius: 15px; font-size: 13.5px; line-height: 1.42; white-space: pre-wrap; word-wrap: break-word; }
.ipt-chat__msg--user { align-self: flex-end; background: var(--pt-brand, #e5305f); color: #fff; border-bottom-right-radius: 4px; }
.ipt-chat__msg--bot { align-self: flex-start; background: #fff; color: #241827; border: 1px solid #efe5ec; border-bottom-left-radius: 4px; }
.ipt-chat__a { color: var(--pt-brand-600, #c21f4c) !important; font-weight: 700; text-decoration: underline; word-break: break-all; }
.ipt-chat__a:hover { color: var(--pt-brand, #e5305f) !important; }
.ipt-chat__msg--handoff { border-color: var(--pt-teal, #22a8a8); background: var(--pt-teal-50, #e6f6f6); }
.ipt-chat__typing { display: inline-flex; gap: 4px; align-items: center; }
.ipt-chat__typing span { width: 6px; height: 6px; border-radius: 50%; background: #c9bcc6; animation: iptChatDot 1s infinite ease-in-out; }
.ipt-chat__typing span:nth-child(2) { animation-delay: .15s; } .ipt-chat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes iptChatDot { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Entrada */
.ipt-chat__input { display: flex; gap: 7px; padding: 10px; border-top: 1px solid #efe5ec; background: #fff; }
.ipt-chat__input input { flex: 1 1 auto; font: inherit; font-size: 14px; padding: 10px 14px; border: 1.5px solid #e6dbe2; border-radius: 999px; color: #241827; }
.ipt-chat__input input:focus { outline: none; border-color: var(--pt-brand, #e5305f); }
.ipt-chat__input input:disabled { opacity: .6; }
.ipt-chat__input button { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; background: var(--pt-brand, #e5305f); color: #fff; display: grid; place-items: center; transition: background .16s; }
.ipt-chat__input button:hover { background: var(--pt-brand-600, #c21f4c); }
.ipt-chat__input button svg { width: 18px; height: 18px; }
.ipt-chat__brand { padding: 6px; text-align: center; font-size: 10.5px; color: var(--pt-ink-3, #a595a1); background: #fff; }
.ipt-chat__brand b { color: var(--pt-ink-soft, #6b5f6b); }

/* En móvil el FAB no debe tapar la barra fija de "agregar al carro" del producto */
body:has(.pt-stickybuy.is-on) .ipt-chat { bottom: 94px; }

@media (max-width: 782px) {
	.ipt-chat { right: 14px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
	body:has(.pt-stickybuy.is-on) .ipt-chat { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
	.ipt-chat__fab { width: 60px; height: 60px; }
}
@media (max-width: 520px) {
	/* En celular el chat ocupa ~la mitad inferior de la pantalla (no toda). */
	.ipt-chat__panel { width: calc(100vw - 20px); height: 58vh; height: 58dvh; max-height: 560px; border-radius: 18px; }
	.ipt-chat__greet { max-width: 190px; }
	.ipt-chat__body { padding: 12px; gap: 8px; }
	.ipt-chat__msg { max-width: 88%; font-size: 14px; }
	.ipt-chat__input input { font-size: 16px; } /* evita zoom de iOS */
}
