/* =============================================
   WhatsApp Bubble Plugin — Frontend Styles
   ============================================= */

:root {
    --wab-color: #25D366;
    --wab-dark:  #128C7E;
    --wab-white: #ffffff;
    --wab-radius: 18px;
    --wab-shadow: 0 8px 32px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.12);
    --wab-popup-w: 320px;
    --wab-size: 60px;
}

/* ── Wrapper ── */
#wab-wrapper {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}
#wab-wrapper.wab-right { right: 24px; align-items: flex-end; }
#wab-wrapper.wab-left  { left: 24px;  align-items: flex-start; }

/* ── Tooltip ── */
#wab-tooltip {
    pointer-events: none;
    background: #1f2937;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    padding: 6px 13px;
    border-radius: 20px;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s, transform .25s;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
#wab-wrapper:not(.wab-open) #wab-bubble:hover ~ #wab-tooltip,
#wab-wrapper:not(.wab-open) #wab-tooltip.wab-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Main Bubble ── */
#wab-bubble {
    pointer-events: all;
    width: var(--wab-size);
    height: var(--wab-size);
    border-radius: 50%;
    background: var(--wab-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--wab-shadow);
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}
#wab-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
#wab-bubble:active { transform: scale(.95); }

/* Icon swap */
#wab-bubble .wab-icon-wa,
#wab-bubble .wab-icon-close {
    position: absolute;
    transition: opacity .25s, transform .3s cubic-bezier(.34,1.56,.64,1);
}
#wab-bubble .wab-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(.6);
}
#wab-wrapper.wab-open #wab-bubble .wab-icon-wa {
    opacity: 0;
    transform: rotate(90deg) scale(.6);
}
#wab-wrapper.wab-open #wab-bubble .wab-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Pulse rings */
#wab-bubble.wab-pulse::before,
#wab-bubble.wab-pulse::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--wab-color);
    opacity: .4;
    animation: wab-ring 2.4s cubic-bezier(.36,.11,.89,.32) infinite;
    z-index: -1;
}
#wab-bubble.wab-pulse::after {
    animation-delay: .8s;
    opacity: .25;
}
@keyframes wab-ring {
    0%   { transform: scale(1);   opacity: .45; }
    100% { transform: scale(2);   opacity: 0;   }
}

/* Notification badge */
#wab-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: wab-badge-pop .4s cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes wab-badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── Popup Card ── */
#wab-popup {
    pointer-events: all;
    width: var(--wab-popup-w);
    background: #fff;
    border-radius: var(--wab-radius);
    box-shadow: var(--wab-shadow);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transform-origin: bottom right;
    transform: scale(.85) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
}
#wab-wrapper.wab-left #wab-popup {
    transform-origin: bottom left;
}
#wab-wrapper.wab-open #wab-popup {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Header stripe */
.wab-popup-header {
    background: linear-gradient(135deg, var(--wab-color) 0%, var(--wab-dark) 100%);
    padding: 18px 18px 22px;
    position: relative;
    color: #fff;
}
.wab-popup-header::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 0; right: 0;
    height: 24px;
    background: inherit;
    clip-path: ellipse(60% 100% at 50% 0%);
    pointer-events: none;
}

.wab-agent-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.wab-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.5);
    background: rgba(255,255,255,.2);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wab-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.wab-agent-info { flex: 1; }
.wab-agent-name {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}
.wab-agent-status {
    font-size: 12px;
    opacity: .85;
    margin-top: 2px;
}
.wab-status-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #fff;
    margin-right: 4px;
    vertical-align: middle;
}
.wab-status-dot.online  { background: #a7f3d0; }
.wab-status-dot.away    { background: #fde68a; }
.wab-status-dot.offline { background: #9ca3af; }

/* Body */
.wab-popup-body {
    padding: 28px 18px 18px;
    background: #f0f2f5;
}

/* Chat bubble */
.wab-chat-bubble {
    background: #fff;
    border-radius: 0 12px 12px 12px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.55;
    color: #111827;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    position: relative;
    max-width: 90%;
    animation: wab-bubble-in .4s cubic-bezier(.34,1.56,.64,1) .15s both;
}
.wab-chat-bubble::before {
    content: '';
    position: absolute;
    top: 0; left: -8px;
    width: 0; height: 0;
    border-top: 8px solid #fff;
    border-left: 8px solid transparent;
}
.wab-chat-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 5px;
    text-align: right;
}
@keyframes wab-bubble-in {
    from { transform: scale(.85) translateY(8px); opacity: 0; }
    to   { transform: scale(1)   translateY(0);   opacity: 1; }
}

/* Response time */
.wab-response-time {
    font-size: 12px;
    color: #6b7280;
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* CTA Button */
.wab-cta-btn {
    display: block;
    width: 100%;
    margin-top: 14px;
    background: var(--wab-color);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    text-align: center;
    padding: 13px 16px;
    border-radius: 12px;
    box-sizing: border-box;
    transition: background .2s, transform .15s, box-shadow .2s;
    box-shadow: 0 4px 14px rgba(37,211,102,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.wab-cta-btn:hover {
    background: var(--wab-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37,211,102,.45);
    color: #fff;
    text-decoration: none;
}
.wab-cta-btn:active { transform: translateY(0); }

/* Privacy note */
.wab-privacy {
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
    margin-top: 10px;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    :root { --wab-popup-w: calc(100vw - 48px); }
    #wab-wrapper.wab-right { right: 16px; }
    #wab-wrapper.wab-left  { left: 16px; }
}
