/* 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: 60px;
    height: 60px;
    border-radius: 50%;
    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.08);
    box-shadow: 0 6px 28px rgba(201,162,77,.55);
}
.caa-bubble-icon { display: block; }

/* ── 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: transparent;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color .15s;
}
.caa-close:hover { color: #fff; }

/* ── 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 {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
#caa-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
#caa-input:focus { border-color: #c9a24d; }
#caa-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #c9a24d;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s;
}
#caa-send:hover { opacity: .85; }
#caa-send svg { width: 22px; height: 22px; }

/* ── 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;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}
