/**
 * COEPLUS Chatbot Bubble — Styles v1.0.0
 * Colours driven by CSS variables set from plugin settings.
 */

:root {
    --cpbub-accent:  #0f6e56;
    --cpbub-header:  #0a1628;
    --cpbub-wa:      #25D366;
    --cpbub-wa-dark: #1da851;
}

/* ── Widget wrapper ─────────────────────────────── */
.cpbub-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

/* ── Chat window ────────────────────────────────── */
.cpbub-window {
    position: absolute;
    bottom: 136px;
    right: 0;
    width: 340px;
    height: 520px;
    max-height: 80vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cpbub-slide-up 0.22s ease;
}

.cpbub-widget.no-wa .cpbub-window {
    bottom: 78px;
}

@keyframes cpbub-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ─────────────────────────────────────── */
.cpbub-header {
    background: var(--cpbub-header);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cpbub-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cpbub-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.cpbub-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    object-fit: cover;
    background: #fff;
}

.cpbub-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--cpbub-header);
}

.cpbub-agent-name   { font-weight: 600; font-size: 14px; }
.cpbub-agent-status { font-size: 11px; opacity: 0.75; margin-top: 1px; }

.cpbub-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s;
}
.cpbub-close-btn:hover { color: #fff; }

/* ── Messages ───────────────────────────────────── */
.cpbub-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f5f5f5;
}

.cpbub-msg { display: flex; }
.cpbub-msg-bot  { justify-content: flex-start; }
.cpbub-msg-user { justify-content: flex-end; }

.cpbub-bubble-msg {
    max-width: 80%;
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
}

.cpbub-msg-bot  .cpbub-bubble-msg {
    background: #fff;
    color: #1a1a1a;
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.cpbub-msg-user .cpbub-bubble-msg {
    background: var(--cpbub-accent);
    color: #fff;
    border-radius: 16px 4px 16px 16px;
}

/* Typing dots */
.cpbub-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
}

.cpbub-typing-dots span {
    width: 7px;
    height: 7px;
    background: #bbb;
    border-radius: 50%;
    animation: cpbub-dot-bounce 1.2s infinite;
}

.cpbub-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.cpbub-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cpbub-dot-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* ── Quick replies ──────────────────────────────── */
.cpbub-quick-replies {
    padding: 8px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #f5f5f5;
    border-top: 1px solid #eee;
    max-height: 130px;
    overflow-y: auto;
    flex-shrink: 0;
}

.cpbub-qr-btn {
    background: #fff;
    border: 1px solid var(--cpbub-accent);
    color: var(--cpbub-accent);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: normal;
    max-width: 100%;
    text-align: left;
    line-height: 1.4;
    font-family: inherit;
}

.cpbub-qr-btn:hover {
    background: var(--cpbub-accent);
    color: #fff;
}

/* ── Input area ─────────────────────────────────── */
.cpbub-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}

.cpbub-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
    background: #fafafa;
}

.cpbub-input:focus {
    border-color: var(--cpbub-accent);
    background: #fff;
}

.cpbub-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cpbub-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.cpbub-send-btn:hover { opacity: 0.85; }

/* ── Footer brand ───────────────────────────────── */
.cpbub-footer-brand {
    text-align: center;
    font-size: 10px;
    color: #aaa;
    padding: 5px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.cpbub-footer-brand a {
    color: var(--cpbub-accent);
    text-decoration: none;
}

/* ── Main bubble button ─────────────────────────── */
.cpbub-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cpbub-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 22px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.22);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}

.cpbub-bubble:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(0,0,0,0.28);
}

.cpbub-bubble-icon, .cpbub-icon-chat, .cpbub-icon-close {
    line-height: 1;
}

/* Pulse animation for badge notification */
@keyframes cpbub-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(15,110,86,0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(15,110,86,0); }
    100% { box-shadow: 0 0 0 0 rgba(15,110,86,0); }
}
.cpbub-pulse { animation: cpbub-pulse 2s infinite; }

/* ── Notification badge ─────────────────────────── */
.cpbub-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── WhatsApp float button ──────────────────────── */
.cpbub-wa-float {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cpbub-wa);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    text-decoration: none;
    transition: transform 0.15s;
    flex-shrink: 0;
    position: relative;
    overflow: visible;
}

.cpbub-wa-float:hover { transform: scale(1.06); }

.cpbub-wa-float-label {
    position: absolute;
    right: 64px;
    background: #222;
    color: #fff;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.cpbub-wa-float:hover .cpbub-wa-float-label { opacity: 1; }

/* ── Mobile responsive ──────────────────────────── */
@media (max-width: 400px) {
    .cpbub-window {
        width: calc(100vw - 20px);
        right: -12px;
        border-radius: 12px 12px 0 0;
        bottom: 130px;
        height: 70vh;
    }
    .cpbub-widget.no-wa .cpbub-window {
        bottom: 72px;
    }
    .cpbub-widget {
        right: 16px;
        bottom: 16px;
    }
}
