/* =============================================
   WhatsApp Vibe — style.css
   ============================================= */

/* ── Font Import ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ── CSS Custom Properties ── */
:root {
    --wav-green:        #25D366;
    --wav-green-dark:   #1ebe5d;
    --wav-green-deep:   #128C7E;
    --wav-teal:         #075E54;
    --wav-white:        #ffffff;
    --wav-bg-chat:      #ece5dd;
    --wav-shadow-sm:    0 2px 8px rgba(0,0,0,0.10);
    --wav-shadow-md:    0 4px 12px rgba(0,0,0,0.15);
    --wav-shadow-lg:    0 8px 32px rgba(0,0,0,0.18);
    --wav-radius-sm:    10px;
    --wav-radius-md:    16px;
    --wav-radius-lg:    20px;
    --wav-font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --wav-z:            9999;
    --wav-size:         60px;
    --wav-bottom:       24px;
    --wav-side:         24px;
}

/* ── Widget Container ── */
.wav-widget {
    position: fixed;
    bottom: var(--wav-bottom);
    z-index: var(--wav-z);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: var(--wav-font);
}

.wav-widget.wav-right {
    right: var(--wav-side);
    align-items: flex-end;
}

.wav-widget.wav-left {
    left: var(--wav-side);
    align-items: flex-start;
}

/* ── Floating Trigger Button ── */
.wav-trigger {
    position: relative;
    width: var(--wav-size);
    height: var(--wav-size);
    border-radius: 50%;
    background: var(--wav-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--wav-shadow-md);
    transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.wav-trigger:hover {
    background: var(--wav-green-dark);
    transform: scale(1.08);
    box-shadow: var(--wav-shadow-lg);
}

.wav-trigger:active {
    transform: scale(0.96);
}

.wav-trigger:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.45), var(--wav-shadow-md);
}

/* SVG icons inside trigger */
.wav-trigger svg {
    width: 28px;
    height: 28px;
    transition: opacity 0.2s ease, transform 0.25s ease;
    position: absolute;
}

.wav-icon-x {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}

.wav-icon-wa {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Open state icon swap */
.wav-widget.wav-open .wav-icon-wa {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}

.wav-widget.wav-open .wav-icon-x {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ── Notification Badge ── */
.wav-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--wav-font);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 2;
}

.wav-badge.wav-badge-hidden {
    transform: scale(0) !important;
    opacity: 0 !important;
}

/* ── Chat Bubble Popup ── */
.wav-bubble {
    width: 320px;
    background: var(--wav-white);
    border-radius: var(--wav-radius-lg);
    box-shadow: var(--wav-shadow-lg);
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.85) translateY(12px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity   0.25s ease;
    pointer-events: none;
}

.wav-widget.wav-left .wav-bubble {
    transform-origin: bottom left;
}

.wav-bubble:not([hidden]) {
    display: block;
}

.wav-bubble.wav-bubble-visible {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Bubble Header ── */
.wav-bubble-header {
    background: var(--wav-teal);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.wav-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--wav-green);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.wav-avatar svg {
    width: 22px;
    height: 22px;
}

.wav-agent-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wav-agent-name {
    color: var(--wav-white);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.wav-agent-status {
    color: rgba(255,255,255,0.75);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.wav-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--wav-green);
    box-shadow: 0 0 0 2px rgba(37,211,102,0.25);
    animation: wav-pulse 2s infinite;
    display: inline-block;
}

/* Offline status overrides */
.wav-status-offline .wav-status-dot {
    background: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245,158,11,0.2);
    animation: none;
}

.wav-agent-status.wav-status-offline {
    color: rgba(255,255,255,0.65);
}

.wav-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
    border-radius: 50%;
    flex-shrink: 0;
}

.wav-close-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

.wav-close-btn svg {
    width: 18px;
    height: 18px;
}

/* ── Bubble Body ── */
.wav-bubble-body {
    background: var(--wav-bg-chat);
    padding: 18px 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='%23c8b8a2' fill-opacity='0.12'%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");
}

.wav-message-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.wav-message-bubble {
    background: var(--wav-white);
    border-radius: 0 var(--wav-radius-md) var(--wav-radius-md) var(--wav-radius-md);
    padding: 12px 14px;
    box-shadow: var(--wav-shadow-sm);
    max-width: 90%;
    position: relative;
}

.wav-message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 10px 0;
    border-color: transparent var(--wav-white) transparent transparent;
}

.wav-msg-title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
    color: #111b21;
    line-height: 1.3;
}

.wav-msg-text {
    margin: 0;
    font-size: 13.5px;
    color: #3b4a54;
    line-height: 1.5;
}

.wav-time {
    font-size: 11px;
    color: #8696a0;
    padding-left: 4px;
}

/* ── Bubble Footer ── */
.wav-bubble-footer {
    padding: 14px 16px 16px;
    background: var(--wav-white);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.wav-start-btn {
    background: var(--wav-green);
    color: var(--wav-white);
    border: none;
    padding: 13px 20px;
    border-radius: var(--wav-radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--wav-font);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(37,211,102,0.35);
    letter-spacing: 0.01em;
}

.wav-start-btn:hover {
    background: var(--wav-green-dark);
    box-shadow: 0 4px 14px rgba(37,211,102,0.45);
    transform: translateY(-1px);
}

.wav-start-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(37,211,102,0.3);
}

.wav-start-btn:focus-visible {
    outline: 3px solid rgba(37,211,102,0.5);
    outline-offset: 2px;
}

.wav-powered {
    margin: 0;
    text-align: center;
    font-size: 11px;
    color: #adb5bd;
    font-family: var(--wav-font);
}

/* ── Keyframe Animations ── */

/* Initial bounce-in for the trigger button */
@keyframes wav-bounce-in {
    0%   { opacity: 0; transform: scale(0) translateY(20px); }
    60%  { opacity: 1; transform: scale(1.12) translateY(-4px); }
    80%  { transform: scale(0.95) translateY(2px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Pulse for online dot */
@keyframes wav-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(37,211,102,0.5); }
    70%  { box-shadow: 0 0 0 6px rgba(37,211,102,0); }
    100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); }
}

/* Badge pop */
@keyframes wav-badge-pop {
    0%   { transform: scale(0); }
    70%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Apply bounce on load */
.wav-trigger {
    opacity: 0;
    animation: wav-bounce-in 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.8s forwards;
}

.wav-badge {
    animation: wav-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 1.4s both;
}


/* ── Multiple Contacts List ── */
.wav-contacts-list {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

.wav-contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--wav-white);
    border-radius: var(--wav-radius-sm);
    text-decoration: none;
    box-shadow: var(--wav-shadow-sm);
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(0,0,0,0.03);
}

.wav-contact-item:hover {
    background: #fdfdfd;
    transform: translateY(-1.5px);
    box-shadow: var(--wav-shadow-md);
    border-color: rgba(37,211,102,0.25);
}

.wav-contact-item:active {
    transform: translateY(0);
    box-shadow: var(--wav-shadow-sm);
}

/* Avatar for contact (using initial) */
.wav-contact-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wav-green-deep);
    color: var(--wav-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
    letter-spacing: 0.05em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.wav-contact-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.wav-contact-label {
    font-size: 13.5px;
    font-weight: 600;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.wav-contact-role {
    font-size: 11.5px;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.wav-contact-chevron {
    color: #8696a0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s ease;
}

.wav-contact-item:hover .wav-contact-chevron {
    color: var(--wav-green);
    transform: translateX(2px);
}

.wav-contact-chevron svg {
    width: 16px;
    height: 16px;
}

/* ── Responsive — Mobile ── */
@media (max-width: 480px) {
    :root {
        --wav-bottom: 16px;
        --wav-side:   16px;
        --wav-size:   54px;
    }

    .wav-bubble {
        width: calc(100vw - 32px);
        max-width: 320px;
    }

    /* On mobile, always anchor to whichever side is set */
    .wav-widget.wav-right {
        right: var(--wav-side);
    }

    .wav-widget.wav-left {
        left: var(--wav-side);
    }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    .wav-trigger {
        animation: none;
        opacity: 1;
    }
    .wav-badge {
        animation: none;
    }
    .wav-bubble {
        transition: opacity 0.15s ease;
    }
    .wav-status-dot {
        animation: none;
    }
}
