/* SACCO WhatsApp Chat Widget */
:root {
    --swa-green:     #25d366;
    --swa-green-dk:  #128c7e;
    --swa-green-hdr: #075e54;
    --swa-teal:      #00bfa5;
    --swa-white:     #ffffff;
    --swa-bg:        #ece5dd;
    --swa-shadow:    0 12px 40px rgba(0,0,0,.22), 0 4px 12px rgba(0,0,0,.1);
    --swa-radius:    16px;
    --swa-w:         340px;
}

#swa-root {
    position: fixed;
    bottom: 24px;
    z-index: 999990;
    font-family: -apple-system, 'Segoe UI', sans-serif;
}

#swa-root * { box-sizing: border-box; margin: 0; padding: 0; }

.swa-pos-right { right: 24px; }
.swa-pos-left  { left:  24px; }

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

.swa-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(37,211,102,.65);
}

.swa-fab:focus-visible {
    box-shadow: 0 0 0 3px rgba(37,211,102,.5);
}

.swa-fab__icon { transition: opacity .2s, transform .2s; }

/* Pulse ring */
.swa-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 3px solid rgba(37,211,102,.5);
    animation: swa-ping 2s cubic-bezier(0,0,.2,1) infinite;
}

@keyframes swa-ping {
    75%, 100% { transform: scale(1.4); opacity: 0; }
}

/* ── Popup teaser ── */
.swa-popup {
    position: absolute;
    bottom: 70px;
    background: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 6px 24px rgba(0,0,0,.15);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 260px;
    animation: swa-fadein .3s ease;
}

.swa-pos-right .swa-popup { right: 0; }
.swa-pos-left  .swa-popup { left: 0; }

.swa-popup__close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #64748b;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.swa-popup__avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--swa-green-hdr);
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.swa-popup__avatar img { width: 100%; height: 100%; object-fit: cover; }
.swa-popup__avatar-initial { font-size: 18px; font-weight: 700; color: #fff; }

.swa-popup__text {
    font-size: 13px;
    line-height: 1.4;
    color: #374151;
}

/* ── Chat window ── */
.swa-window {
    position: absolute;
    bottom: 74px;
    width: var(--swa-w);
    border-radius: var(--swa-radius);
    box-shadow: var(--swa-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: swa-fadein .25s ease;
    max-height: 480px;
}

.swa-pos-right .swa-window { right: 0; }
.swa-pos-left  .swa-window { left: 0; }

@keyframes swa-fadein {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
.swa-header {
    background: var(--swa-green-hdr);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.swa-header__info { flex: 1; }
.swa-header__info strong { display: block; color: #fff; font-size: 15px; font-weight: 600; }
.swa-header__info span   { font-size: 12px; color: rgba(255,255,255,.8); }

.swa-header__close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background .15s;
}
.swa-header__close:hover { background: rgba(255,255,255,.15); }

/* ── Body / chat bg ── */
.swa-body {
    flex: 1;
    overflow-y: auto;
    background: var(--swa-bg);
}

/* WhatsApp wallpaper pattern */
.swa-chat-bg {
    min-height: 100%;
    padding: 16px 12px;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c5b8ae' fill-opacity='0.2'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Offline banner */
.swa-offline-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,.07);
    border-radius: 8px;
    padding: 9px 12px;
    margin-bottom: 14px;
    font-size: 12px;
    color: #555;
    line-height: 1.4;
}

/* ── Single agent greeting bubble ── */
.swa-bubble-wrap {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 14px;
}

.swa-agent-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--swa-green-hdr);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.swa-agent-avatar img { width: 100%; height: 100%; object-fit: cover; }

.swa-avatar-initial {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

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

.swa-bubble-group { flex: 1; }

.swa-agent-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--swa-green-dk);
    margin-bottom: 5px;
}
.swa-agent-name span { font-weight: 400; color: #64748b; margin-left: 4px; }

.swa-bubble {
    background: #fff;
    border-radius: 0 10px 10px 10px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.55;
    color: #111;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    position: relative;
    max-width: 85%;
}

.swa-bubble-time {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    text-align: right;
    margin-top: 5px;
}

/* Start chat button */
.swa-start-wrap {
    display: flex;
    justify-content: center;
    margin-top: 6px;
}

.swa-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--swa-green);
    color: #fff;
    padding: 12px 22px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(37,211,102,.4);
    transition: background .15s, transform .15s;
}
.swa-start-btn:hover {
    background: var(--swa-green-dk);
    transform: translateY(-2px);
    text-decoration: none;
    color: #fff;
}

/* ── Multiple agents list ── */
.swa-agents-header {
    margin-bottom: 10px;
}
.swa-agents-header p {
    font-size: 13px;
    color: #555;
    background: rgba(255,255,255,.7);
    padding: 8px 10px;
    border-radius: 8px;
    text-align: center;
}

.swa-agents-list { display: flex; flex-direction: column; gap: 8px; }

.swa-agent-card {
    background: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
}
.swa-agent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    text-decoration: none;
}

.swa-agent-card__avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--swa-green-hdr);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.swa-agent-card__avatar img { width: 100%; height: 100%; object-fit: cover; }

.swa-agent-card__info { flex: 1; }
.swa-agent-card__info strong { display: block; font-size: 14px; color: #111; font-weight: 700; }
.swa-agent-card__info span   { font-size: 12px; color: #64748b; }

.swa-agent-card__wa { color: var(--swa-green); flex-shrink: 0; }

/* ── Footer ── */
.swa-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px;
    background: #f0f0f0;
    font-size: 11px;
    color: #888;
    flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 380px) {
    :root { --swa-w: calc(100vw - 24px); }
    #swa-root { right: 12px; bottom: 16px; }
    .swa-pos-right .swa-window { right: 0; }
    .swa-pos-left  .swa-window { left: 0; }
}
