/* WP Agent Bridge – Chat Widget */

:root {
    --wpab-color:       #6366f1;
    --wpab-color-dark:  #4f46e5;
    --wpab-radius:      16px;
    --wpab-shadow:      0 8px 32px rgba(0,0,0,.18);
    --wpab-font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --wpab-z:           999999;
}

/* ── Launcher Button ───────────────────────────────────────────────────────── */
#wpab-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--wpab-z);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--wpab-color);
    border: none;
    cursor: pointer;
    box-shadow: var(--wpab-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, background .2s;
    outline: none;
}

#wpab-launcher.wpab-pos-bottom-left { right: auto; left: 24px; }

#wpab-launcher:hover  { transform: scale(1.08); background: var(--wpab-color-dark); }
#wpab-launcher:active { transform: scale(.96); }

#wpab-launcher svg { width: 26px; height: 26px; fill: #fff; transition: opacity .2s; }
#wpab-launcher .wpab-icon-close { display: none; }
#wpab-launcher.wpab-open .wpab-icon-chat  { display: none; }
#wpab-launcher.wpab-open .wpab-icon-close { display: block; }

/* Notification dot */
#wpab-launcher::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    display: none;
}
#wpab-launcher.wpab-has-notif::after { display: block; }

/* ── Widget Container ──────────────────────────────────────────────────────── */
#wpab-widget {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: var(--wpab-z);
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 110px);
    background: #fff;
    border-radius: var(--wpab-radius);
    box-shadow: var(--wpab-shadow);
    display: flex;
    flex-direction: column;
    font-family: var(--wpab-font);
    font-size: 14px;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(.9) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
    border: 1px solid rgba(0,0,0,.08);
}

#wpab-widget.wpab-pos-bottom-left {
    right: auto;
    left: 24px;
    transform-origin: bottom left;
}

#wpab-widget.wpab-visible {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
#wpab-header {
    background: var(--wpab-color);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#wpab-header .wpab-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

#wpab-header .wpab-title {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#wpab-header .wpab-status {
    font-size: 11px;
    opacity: .8;
    margin-top: 2px;
}

/* ── Messages Area ─────────────────────────────────────────────────────────── */
#wpab-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: #f8f9ff;
}

#wpab-messages::-webkit-scrollbar { width: 4px; }
#wpab-messages::-webkit-scrollbar-track { background: transparent; }
#wpab-messages::-webkit-scrollbar-thumb { background: #d0d5f7; border-radius: 2px; }

/* Message bubbles */
.wpab-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.5;
    word-break: break-word;
    animation: wpab-pop .18s ease;
}

@keyframes wpab-pop {
    from { transform: scale(.94); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.wpab-msg-user {
    background: var(--wpab-color);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.wpab-msg-bot {
    background: #fff;
    color: #1a1a2e;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* Typing indicator */
.wpab-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.wpab-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--wpab-color);
    opacity: .4;
    animation: wpab-bounce 1.2s infinite;
}

.wpab-typing span:nth-child(2) { animation-delay: .2s; }
.wpab-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes wpab-bounce {
    0%, 60%, 100% { transform: translateY(0);    opacity: .4; }
    30%            { transform: translateY(-5px); opacity: 1;  }
}

/* Error message */
.wpab-msg-error {
    background: #fee2e2;
    color: #991b1b;
}

/* ── Input Area ────────────────────────────────────────────────────────────── */
#wpab-footer {
    padding: 12px 14px;
    border-top: 1px solid #e8eaf0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}

#wpab-input {
    flex: 1;
    border: 1px solid #d1d5f9;
    border-radius: 10px;
    padding: 9px 13px;
    font-size: 14px;
    font-family: var(--wpab-font);
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 40px;
    overflow-y: auto;
    line-height: 1.5;
    color: #1a1a2e;
    transition: border-color .15s;
    background: #fff;
}

#wpab-input::placeholder { color: #aab0d8; }
#wpab-input:focus { border-color: var(--wpab-color); }

#wpab-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--wpab-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .1s;
    flex-shrink: 0;
    outline: none;
}

#wpab-send:hover  { background: var(--wpab-color-dark); }
#wpab-send:active { transform: scale(.93); }
#wpab-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }
#wpab-send svg { width: 18px; height: 18px; fill: #fff; }

/* Powered-by footer */
#wpab-powered {
    text-align: center;
    font-size: 10px;
    color: #b0b8d8;
    padding: 4px 0 6px;
    background: #fff;
    flex-shrink: 0;
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #wpab-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 70vh;
        border-radius: var(--wpab-radius) var(--wpab-radius) 0 0;
    }
    #wpab-widget.wpab-pos-bottom-left { left: 0; right: 0; }
    #wpab-launcher { bottom: 20px; right: 16px; }
    #wpab-launcher.wpab-pos-bottom-left { left: 16px; right: auto; }
}
