/* ── WhatsApp Chat Bubble ───────────────────────────────────────────────── */

:root {
    --wacb-green:      #25D366;
    --wacb-green-dark: #1ebe5d;
    --wacb-white:      #ffffff;
    --wacb-text:       #111b21;
    --wacb-sub:        #667781;
    --wacb-bg:         #f0f2f5;
    --wacb-card-w:     340px;
    --wacb-radius:     16px;
    --wacb-shadow:     0 8px 40px rgba(0,0,0,.18);
    --wacb-z:          99999;
}

/* ── Root container ── */
#wacb-root {
    position: fixed;
    bottom: 24px;
    z-index: var(--wacb-z);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#wacb-root.wacb--right { right: 24px; align-items: flex-end; }
#wacb-root.wacb--left  { left: 24px;  align-items: flex-start; }

/* ── Notification badge ── */
.wacb-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: #ff3b30;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    pointer-events: none;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .2s;
    transform-origin: center;
}

.wacb-badge.wacb-badge--hidden {
    transform: scale(0);
    opacity: 0;
}

/* ── FAB button ── */
.wacb-fab {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wacb-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 20px rgba(37,211,102,.45);
    transition: background .2s, transform .2s, box-shadow .2s;
    outline: none;
    flex-shrink: 0;
}

.wacb-fab:hover {
    background: var(--wacb-green-dark);
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(37,211,102,.55);
}

.wacb-fab:focus-visible {
    outline: 3px solid var(--wacb-green);
    outline-offset: 3px;
}

/* Pulse ring */
.wacb-fab__pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 3px solid var(--wacb-green);
    opacity: 0;
    pointer-events: none;
    animation: wacb-pulse 2.5s ease-out infinite;
}

@keyframes wacb-pulse {
    0%   { transform: scale(1);    opacity: .6; }
    70%  { transform: scale(1.4);  opacity: 0;  }
    100% { transform: scale(1.4);  opacity: 0;  }
}

/* Icon swap */
.wacb-fab__icon {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .2s, transform .2s;
}

.wacb-fab__icon--wa    { opacity: 1; transform: scale(1) rotate(0deg); }
.wacb-fab__icon--close { opacity: 0; transform: scale(.6) rotate(-90deg); }

#wacb-root.wacb--open .wacb-fab__icon--wa    { opacity: 0; transform: scale(.6) rotate(90deg); }
#wacb-root.wacb--open .wacb-fab__icon--close { opacity: 1; transform: scale(1) rotate(0deg); }
#wacb-root.wacb--open .wacb-fab__pulse       { animation: none; opacity: 0; }

/* ── Popup card ── */
.wacb-card {
    width: var(--wacb-card-w);
    max-width: calc(100vw - 48px);
    background: var(--wacb-white);
    border-radius: var(--wacb-radius);
    box-shadow: var(--wacb-shadow);
    overflow: hidden;
    transform-origin: bottom right;

    /* Hidden state */
    opacity: 0;
    transform: scale(.92) translateY(12px);
    pointer-events: none;
    transition: opacity .22s ease, transform .22s cubic-bezier(.34,1.56,.64,1);
}

#wacb-root.wacb--left .wacb-card { transform-origin: bottom left; }

#wacb-root.wacb--open .wacb-card {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Card header */
.wacb-card__head {
    background: var(--wacb-green);
    padding: 16px 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

/* Decorative wave at bottom of header */
.wacb-card__head::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 20px;
    background: var(--wacb-bg);
    clip-path: ellipse(52% 100% at 50% 100%);
}

/* Agent */
.wacb-agent {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wacb-agent__avatar {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,.6);
}

.wacb-agent__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wacb-agent__initials {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: .02em;
}

.wacb-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    background: #44ff88;
    border-radius: 50%;
    border: 2px solid var(--wacb-green);
}

.wacb-agent__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wacb-agent__info strong {
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
}

.wacb-agent__info span {
    color: rgba(255,255,255,.8);
    font-size: .72rem;
}

/* Close button */
.wacb-close {
    background: rgba(255,255,255,.18);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
    outline: none;
}

.wacb-close:hover { background: rgba(255,255,255,.32); }

/* Card body */
.wacb-card__body {
    background: var(--wacb-bg);
    padding: 18px 14px 14px;
}

/* Chat bubble */
.wacb-bubble {
    background: #fff;
    border-radius: 0 12px 12px 12px;
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    position: relative;
    max-width: 85%;
    margin-bottom: 16px;
    animation: wacb-pop-in .35s cubic-bezier(.34,1.56,.64,1) both;
}

.wacb-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -7px;
    border-width: 0 8px 8px 0;
    border-style: solid;
    border-color: transparent #fff transparent transparent;
}

.wacb-bubble__text {
    font-size: .875rem;
    color: var(--wacb-text);
    line-height: 1.5;
}

@keyframes wacb-pop-in {
    from { opacity: 0; transform: scale(.85) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Topics */
.wacb-topics__label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--wacb-sub);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: 0 0 8px 2px;
}

.wacb-topics {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wacb-topic {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--wacb-text);
    font-size: .84rem;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: background .15s, transform .15s, box-shadow .15s;
    border: 1px solid transparent;
}

.wacb-topic:hover {
    background: #e8fdf0;
    border-color: var(--wacb-green);
    transform: translateX(2px);
    box-shadow: 0 2px 10px rgba(37,211,102,.15);
    color: var(--wacb-text);
    text-decoration: none;
}

.wacb-topic__icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    line-height: 1;
}

.wacb-topic__label { flex: 1; }

.wacb-topic__arrow {
    color: var(--wacb-sub);
    opacity: .5;
    transition: opacity .15s, transform .15s;
    flex-shrink: 0;
}

.wacb-topic:hover .wacb-topic__arrow {
    opacity: 1;
    color: var(--wacb-green);
    transform: translateX(2px);
}

/* Card footer */
.wacb-card__foot {
    background: #fff;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    color: var(--wacb-sub);
    border-top: 1px solid #f0f0f0;
}

/* ── Entrance animation for whole widget ── */
#wacb-root {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .4s ease, transform .4s cubic-bezier(.34,1.56,.64,1);
}

#wacb-root.wacb--visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .wacb-fab__pulse { animation: none; }
    .wacb-card, .wacb-fab, .wacb-topic { transition: none; }
    .wacb-bubble { animation: none; }
}

/* ── Mobile ── */
@media (max-width: 480px) {
    #wacb-root.wacb--right { right: 16px; bottom: 16px; }
    #wacb-root.wacb--left  { left: 16px;  bottom: 16px; }
    .wacb-card { max-width: calc(100vw - 32px); }
}
