/* Creditory AI Agent Widget */
#caa-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Utility ── */
.caa-hidden { display: none !important; }

/* ── Bubble button ── */
#caa-bubble {
    width: auto;
    height: 56px;
    border-radius: 28px;
    padding: 0 20px 0 16px;
    gap: 8px;
    background: #c9a24d;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 20px rgba(201,162,77,.45);
    transition: transform .2s, box-shadow .2s;
    margin-left: auto;
}
#caa-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 28px rgba(201,162,77,.55);
}
.caa-bubble-icon { display: block; flex-shrink: 0; }
.caa-bubble-label {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    letter-spacing: .03em;
    white-space: nowrap;
}
.caa-bubble-open .caa-bubble-label { display: none; }

/* ── Chat window ── */
#caa-chat-window {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(15,42,68,.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: caa-slide-up .22s ease;
}
#caa-chat-window.caa-hidden {
    display: none;
}

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

/* ── Header ── */
.caa-header {
    background: #0f2a44;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.caa-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(201,162,77,.6);
    flex-shrink: 0;
}
.caa-avatar-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #c9a24d;
    color: #0f2a44;
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.caa-header-title {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
}
.caa-close {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    flex-shrink: 0;
}
.caa-close:hover { background: rgba(255,255,255,.28); }

/* ── Messages ── */
.caa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.caa-messages::-webkit-scrollbar { width: 4px; }
.caa-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.caa-msg {
    max-width: 82%;
    font-size: 13.5px;
    line-height: 1.55;
    padding: 10px 13px;
    border-radius: 12px;
    word-break: break-word;
}
.caa-msg-bot {
    background: #f3f4f6;
    color: #111827;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.caa-msg-user {
    background: #0f2a44;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.caa-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #f3f4f6;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: 52px;
}
.caa-typing span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: caa-bounce 1.2s infinite;
}
.caa-typing span:nth-child(2) { animation-delay: .2s; }
.caa-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes caa-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ── Input ── */
.caa-input-row {
    position: relative;
    display: block;
    padding: 10px 12px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
#caa-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 10px 50px 10px 14px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
#caa-input:focus { border-color: #c9a24d; }
#caa-send {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    background: #c9a24d;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s;
}
#caa-send:hover { opacity: .85; }
#caa-send svg { width: 22px !important; height: 22px !important; display: block; }

/* ── Chat ended overlay ── */
#caa-ended {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 20px 16px;
    background: #f9fafb;
}
.caa-ended-status {
    font-size: 12px;
    color: #6b7280;
    text-align: center;
}
.caa-ended-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    text-align: center;
    margin: 0;
}
.caa-feedback-box,
.caa-new-chat-box {
    width: 100%;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
}
.caa-feedback-tag {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 0 0 4px;
}
.caa-feedback-ask {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 14px;
}
#caa-rating-btns {
    display: flex;
    gap: 10px;
}
.caa-rate-btn {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: #0f2a44;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s;
}
.caa-rate-btn:hover { opacity: .8; }
.caa-rating-thanks {
    font-size: 13px;
    color: #16a34a;
    margin: 0;
    padding: 6px 0;
}
.caa-new-chat-box {
    text-align: center;
    font-size: 13.5px;
    color: #374151;
}
.caa-new-chat-box p { margin: 0 0 6px; }
#caa-new-chat {
    background: none;
    border: none;
    color: #0f2a44;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}
#caa-new-chat:hover { color: #c9a24d; }
.caa-ended-brand {
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
}
.caa-ended-brand strong { color: #0f2a44; }

/* ── Footer brand ── */
.caa-footer-brand {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding: 6px 0 8px;
    flex-shrink: 0;
}
.caa-footer-brand strong { color: #0f2a44; }

/* ── Responsive: full-screen on mobile ── */
@media (max-width: 480px) {
    #caa-widget {
        bottom: 0;
        right: 0;
    }
    #caa-bubble {
        position: fixed;
        bottom: 18px;
        right: 18px;
    }
    #caa-chat-window {
        position: fixed !important;
        top: 0;
        bottom: 0;
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh;
        height: 100dvh;
        border-radius: 0 !important;
        z-index: 999999 !important;
    }
    /* Hide bubble when chat is open — header close button handles closing */
    #caa-chat-window:not(.caa-hidden) + #caa-bubble {
        display: none !important;
    }
}
/* ── Very small screens (≤360px) ── */
@media (max-width: 360px) {
    #caa-bubble {
        bottom: 14px;
        right: 14px;
        height: 46px;
        border-radius: 23px;
        padding: 0 14px;
    }
}
