.wab {
    --wab-green: #25D366; --wab-green-2: #128C7E;
    --wab-accent: #1e67b9; --wab-accent-2: #38bdf8; --wab-on-accent: #fff;
    --wab-ink: #0B1220; --wab-bottom: 24px; --wab-right: 24px;
    --wab-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --wab-ease: cubic-bezier(.16, 1, .3, 1);
    position: fixed; right: var(--wab-right); bottom: var(--wab-bottom); z-index: 4000; font-family: var(--wab-font);
}
.wab *, .wab *::before, .wab *::after { box-sizing: border-box; }
.wab svg { width: 1em; height: 1em; display: block; }

.wab-launch {
    position: relative; width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
    background: var(--wab-green);
    box-shadow: 0 18px 40px -12px rgba(18, 140, 126, .8), inset 0 1px 0 rgba(255, 255, 255, .4);
    display: grid; place-items: center; font-size: 30px;
    transform: scale(0) rotate(-90deg); transition: transform .8s var(--wab-ease), box-shadow .3s;
}
.wab.is-ready .wab-launch { transform: none; }
.wab-launch:hover { box-shadow: 0 24px 50px -12px rgba(18, 140, 126, 1), inset 0 1px 0 rgba(255, 255, 255, .5); transform: translateY(-3px) scale(1.04); }
.wab-launch:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.wab-icon { position: absolute; display: grid; place-items: center; transition: transform .5s var(--wab-ease), opacity .3s; }
.wab-icon--x { font-size: 34px; line-height: 1; opacity: 0; transform: rotate(-90deg) scale(.5); }
.wab.is-open .wab-icon--wa { opacity: 0; transform: rotate(90deg) scale(.5); }
.wab.is-open .wab-icon--x { opacity: 1; transform: none; }
.wab-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--wab-green); animation: wab-ring 2.8s var(--wab-ease) infinite; pointer-events: none; }
.wab-ring--2 { animation-delay: 1.4s; }
.wab.is-open .wab-ring { display: none; }
@keyframes wab-ring { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.75); opacity: 0; } }
.wab-badge {
    position: absolute; top: -2px; right: -2px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
    background: #ef4444; color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center;
    border: 2px solid #fff; animation: wab-pop 1s 1.8s var(--wab-ease) both;
}
@keyframes wab-pop { from { transform: scale(0); } to { transform: scale(1); } }

.wab-teaser {
    position: absolute; right: 0; bottom: 80px; width: 280px; display: flex; gap: 12px; align-items: center;
    padding: 14px 16px; border-radius: 4px; cursor: pointer;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); color: #0f172a;
    box-shadow: 0 24px 50px -20px rgba(11, 18, 32, .45), 0 0 0 1px rgba(11, 18, 32, .06);
    opacity: 0; transform: translateY(14px) scale(.96); transform-origin: bottom right; transition: opacity .45s, transform .6s var(--wab-ease);
}
.wab-teaser.is-in { opacity: 1; transform: none; }
.wab-teaser img { width: 42px; height: 42px; border-radius: 4px; object-fit: contain; background: #f1f5f9; padding: 4px; flex-shrink: 0; }
.wab-teaser strong { display: block; font-size: .9rem; }
.wab-teaser span { display: block; font-size: .82rem; color: #475569; line-height: 1.4; }
.wab-teaser-x { position: absolute; top: -9px; left: -9px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: #0f172a; color: #fff; font-size: 15px; line-height: 1; cursor: pointer; }

.wab-panel {
    position: absolute; right: 0; bottom: 82px; width: 380px; height: min(600px, calc(100vh - 140px));
    display: flex; flex-direction: column; overflow: hidden; border-radius: 4px;
    background: #f5f7fb; box-shadow: 0 50px 100px -30px rgba(11, 18, 32, .55), 0 0 0 1px rgba(11, 18, 32, .08);
    opacity: 0; transform: translateY(20px) scale(.94); transform-origin: bottom right; pointer-events: none;
    transition: opacity .35s, transform .55s var(--wab-ease);
}
.wab.is-open .wab-panel { opacity: 1; transform: none; pointer-events: auto; }
.wab-head {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 18px 16px 18px 18px; color: #fff; overflow: hidden;
    background: var(--wab-ink);
}
.wab-head::after { content: ""; position: absolute; width: 220px; height: 220px; right: -80px; top: -120px; border-radius: 50%; display: none; opacity: .45; pointer-events: none; }
.wab-avatar { position: relative; width: 46px; height: 46px; flex-shrink: 0; border-radius: 4px; background: rgba(255, 255, 255, .95); padding: 5px; }
.wab-avatar img { width: 100%; height: 100%; object-fit: contain; }
.wab-status { position: absolute; right: -3px; bottom: -3px; width: 14px; height: 14px; border-radius: 50%; background: var(--wab-green); border: 2px solid var(--wab-ink); }
.wab.is-away .wab-status { background: #f59e0b; }
.wab-who { flex: 1; min-width: 0; position: relative; z-index: 1; }
.wab-who strong { display: block; font-size: 1.02rem; }
.wab-sub { display: block; font-size: .76rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wab-close, .wab-reset { position: relative; z-index: 1; width: 34px; height: 34px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; transition: background .2s; }
.wab-reset { font-size: 16px; }
.wab-close:hover, .wab-reset:hover { background: rgba(255, 255, 255, .24); }

.wab-body {
    flex: 1; overflow-y: auto; padding: 18px 14px 8px; display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth;
    background-color: #eef2f7;
    background-image: none;
    background-size: 18px 18px;
}
.wab-msg { max-width: 84%; padding: 10px 14px; border-radius: 16px; font-size: .9rem; line-height: 1.5; word-wrap: break-word; box-shadow: 0 2px 6px -3px rgba(11, 18, 32, .25); }
.wab-msg--bot { align-self: flex-start; background: #fff; color: #0f172a; border-bottom-left-radius: 5px; }
.wab-msg--user { align-self: flex-end; color: var(--wab-on-accent); border-bottom-right-radius: 5px; background: var(--wab-accent); }
.wab-msg.is-new, .wab-chips.is-new { animation: wab-in .5s var(--wab-ease) both; }
@keyframes wab-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.wab-typing { display: inline-flex; gap: 4px; padding: 3px 0; }
.wab-typing i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: wab-dot 1.2s infinite; }
.wab-typing i:nth-child(2) { animation-delay: .15s; } .wab-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes wab-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.wab-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 2px 0 6px; }
.wab-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 999px; cursor: pointer; text-decoration: none;
    border: 1px solid color-mix(in srgb, var(--wab-accent) 35%, transparent); background: #fff; color: var(--wab-accent);
    font: inherit; font-size: .82rem; font-weight: 600; transition: all .25s var(--wab-ease);
}
.wab-chip:hover { background: var(--wab-accent); color: var(--wab-on-accent); border-color: var(--wab-accent); transform: translateY(-1px); }
.wab-chip--link span::after { content: " \2192"; }
.wab-chip--wa { background: var(--wab-green); border-color: var(--wab-green); color: #fff; }
.wab-chip--wa:hover { background: var(--wab-green-2); border-color: var(--wab-green-2); }
.wab-chip svg { font-size: 15px; }

.wab-input { display: flex; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid #e2e8f0; }
.wab-input input { flex: 1; min-width: 0; border: 1px solid #e2e8f0; border-radius: 999px; padding: 10px 16px; font: inherit; font-size: .9rem; outline: none; background: #f8fafc; color: #0f172a; transition: border-color .2s, box-shadow .2s; }
.wab-input input:focus { border-color: var(--wab-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--wab-accent) 18%, transparent); background: #fff; }
.wab-input button { width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; border: 0; cursor: pointer; color: var(--wab-on-accent); font-size: 16px; background: var(--wab-accent); transition: transform .25s var(--wab-ease); }
.wab-input button:hover { transform: scale(1.08) rotate(-8deg); }
.wab-cta {
    display: flex; align-items: center; justify-content: center; gap: 9px; padding: 13px; text-decoration: none;
    background: var(--wab-green); color: #fff; font-weight: 600; font-size: .92rem;
    position: relative; overflow: hidden;
}
.wab-cta svg { font-size: 19px; }
.wab-cta::after { content: ""; position: absolute; inset: 0; background: none; transform: translateX(-120%); animation: wab-sheen 3.5s 2s infinite; }
@keyframes wab-sheen { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }

/* Any back-to-top button steps aside while the chat is open. */
body:has(.wab.is-open) .bx-top { opacity: 0 !important; pointer-events: none !important; }

@media (max-width: 480px) {
    .wab { --wab-right: 16px; --wab-bottom: 16px; }
    .wab-panel { position: fixed; right: 10px; left: 10px; bottom: 90px; width: auto; height: min(560px, calc(100dvh - 120px)); }
    .wab-teaser { width: min(280px, calc(100vw - 110px)); }
}
@media (prefers-reduced-motion: reduce) {
    .wab-ring, .wab-cta::after { animation: none; display: none; }
    .wab-launch, .wab-panel, .wab-teaser { transition: none; }
}
