/* ─────────────────────────────────────────────────────────────────────────────
   HOA Risk Insights — Chat Widget v2.0
   Brand colors: Navy #012342 | Teal #2FA4A9 | Button teal #00B5AD
   ───────────────────────────────────────────────────────────────────────────── */

/* ── BUBBLE ────────────────────────────────────────────────────────────────── */
#hoa-chat-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #012342;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(1, 35, 66, 0.35);
    display: none;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#hoa-chat-bubble.hoa-bubble-visible {
    display: flex;
}

#hoa-chat-bubble:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 22px rgba(1, 35, 66, 0.45);
}

#hoa-chat-bubble svg {
    width: 26px;
    height: 26px;
    fill: #2FA4A9;
}

/* ── WINDOW ────────────────────────────────────────────────────────────────── */
#hoa-chat-window {
    position: fixed;
    bottom: 108px;
    right: 28px;
    z-index: 9998;
    width: 360px;
    max-height: 520px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 8px 32px rgba(1, 35, 66, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: Arial, sans-serif;
    transition: opacity 0.2s ease, transform 0.2s ease;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
}

#hoa-chat-window.hoa-chat-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

/* ── HEADER ────────────────────────────────────────────────────────────────── */
#hoa-chat-header {
    background: #012342;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#hoa-chat-header-text {
    display: flex;
    flex-direction: column;
}

#hoa-chat-header-title {
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

#hoa-chat-header-sub {
    color: #2FA4A9;
    font-size: 11px;
    margin-top: 2px;
    line-height: 1.2;
}

#hoa-chat-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #7a9bb5;
    font-size: 18px;
    line-height: 1;
    transition: color 0.15s;
}

#hoa-chat-close:hover {
    color: #ffffff;
}

/* ── MESSAGES ──────────────────────────────────────────────────────────────── */
#hoa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f9fb;
    scroll-behavior: smooth;
}

#hoa-chat-messages::-webkit-scrollbar { width: 4px; }
#hoa-chat-messages::-webkit-scrollbar-track { background: transparent; }
#hoa-chat-messages::-webkit-scrollbar-thumb { background: #c5d4df; border-radius: 4px; }

/* ── MESSAGE BUBBLES ───────────────────────────────────────────────────────── */
.hoa-msg {
    max-width: 86%;
    font-size: 13px;
    line-height: 1.5;
    padding: 9px 12px;
    border-radius: 10px;
    word-wrap: break-word;
}

.hoa-msg-assistant {
    background: #ffffff;
    color: #283636;
    border: 1px solid #e0eaf0;
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}

.hoa-msg-user {
    background: #012342;
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}

/* ── TYPING INDICATOR ──────────────────────────────────────────────────────── */
.hoa-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid #e0eaf0;
    border-radius: 10px;
    border-bottom-left-radius: 3px;
    align-self: flex-start;
    width: fit-content;
}

.hoa-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2FA4A9;
    animation: hoa-bounce 1.2s infinite ease-in-out;
}

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

@keyframes hoa-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%            { transform: translateY(-5px); opacity: 1; }
}

/* ── ERROR MESSAGE ─────────────────────────────────────────────────────────── */
.hoa-msg-error {
    background: #fff3f0;
    color: #c0392b;
    border: 1px solid #f5c6c6;
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}

/* ── INPUT AREA ────────────────────────────────────────────────────────────── */
#hoa-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e0eaf0;
    background: #ffffff;
    flex-shrink: 0;
}

#hoa-chat-input {
    flex: 1;
    border: 1px solid #c5d4df;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: Arial, sans-serif;
    color: #283636;
    background: #f7f9fb;
    outline: none;
    resize: none;
    transition: border-color 0.15s;
    line-height: 1.4;
    max-height: 90px;
    overflow-y: auto;
}

#hoa-chat-input:focus {
    border-color: #2FA4A9;
    background: #ffffff;
}

#hoa-chat-input::placeholder {
    color: #9ab0be;
}

#hoa-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #2FA4A9;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}

#hoa-chat-send:hover {
    background: #00B5AD;
    transform: scale(1.05);
}

#hoa-chat-send:disabled {
    background: #c5d4df;
    cursor: not-allowed;
    transform: none;
}

#hoa-chat-send svg {
    width: 16px;
    height: 16px;
    fill: #ffffff;
}

/* ── FOOTER ────────────────────────────────────────────────────────────────── */
#hoa-chat-footer {
    text-align: center;
    padding: 5px 12px 8px;
    font-size: 10px;
    color: #9ab0be;
    background: #ffffff;
    border-top: 1px solid #f0f4f7;
    flex-shrink: 0;
}

/* ── MOBILE ────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #hoa-chat-window {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 88px;
        max-height: 70vh;
    }
    #hoa-chat-bubble {
        right: 16px;
        bottom: 20px;
    }
}
