/* ============================================================
   FCIAA AI Chatbot – Front-end Widget Styles
   ============================================================ */

:root {
    --fciaa-primary:   #1a4f7a;
    --fciaa-primary-dark: #123a5c;
    --fciaa-accent:    #e8f4fd;
    --fciaa-white:     #ffffff;
    --fciaa-gray-100:  #f4f6f8;
    --fciaa-gray-200:  #e2e8ef;
    --fciaa-gray-700:  #4a5568;
    --fciaa-text:      #1a202c;
    --fciaa-radius:    12px;
    --fciaa-shadow:    0 8px 32px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.10);
    --fciaa-widget-w:  360px;
    --fciaa-widget-h:  520px;
}

/* ----- Launcher button ----- */
#fciaa-chatbot-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background-color: var(--fciaa-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, background-color .2s ease, box-shadow .2s ease;
    outline: none;
}

#fciaa-chatbot-launcher:hover {
    transform: scale(1.08);
    background-color: var(--fciaa-primary-dark);
    box-shadow: 0 6px 20px rgba(0,0,0,.30);
}

#fciaa-chatbot-launcher:focus-visible {
    outline: 3px solid var(--fciaa-accent);
    outline-offset: 2px;
}

#fciaa-chatbot-launcher svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity .15s;
}

#fciaa-chatbot-launcher .icon-close {
    display: none;
}

#fciaa-chatbot-launcher.is-open .icon-chat {
    display: none;
}

#fciaa-chatbot-launcher.is-open .icon-close {
    display: block;
}

/* Unread badge */
#fciaa-chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #e53e3e;
    border-radius: 50%;
    border: 2px solid #fff;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

/* ----- Chat window ----- */
#fciaa-chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: var(--fciaa-widget-w);
    height: var(--fciaa-widget-h);
    background: var(--fciaa-white);
    border-radius: var(--fciaa-radius);
    box-shadow: var(--fciaa-shadow);
    z-index: 9997;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(16px) scale(.97);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
}

#fciaa-chatbot-window.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* Header */
#fciaa-chatbot-header {
    background-color: var(--fciaa-primary);
    color: var(--fciaa-white);
    padding: 14px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.fciaa-bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fciaa-bot-avatar svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #fff;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fciaa-header-info {
    flex: 1;
    min-width: 0;
}

.fciaa-bot-name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fciaa-bot-status {
    font-size: 11px;
    opacity: .8;
    margin-top: 1px;
}

/* Messages area */
#fciaa-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--fciaa-gray-100);
    scroll-behavior: smooth;
}

#fciaa-chatbot-messages::-webkit-scrollbar { width: 4px; }
#fciaa-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#fciaa-chatbot-messages::-webkit-scrollbar-thumb { background: var(--fciaa-gray-200); border-radius: 2px; }

.fciaa-message {
    display: flex;
    gap: 8px;
    max-width: 100%;
    animation: fciaa-msg-in .2s ease forwards;
}

@keyframes fciaa-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fciaa-message.bot  { align-self: flex-start; }
.fciaa-message.user { align-self: flex-end; flex-direction: row-reverse; }

.fciaa-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    color: var(--fciaa-text);
}

.fciaa-message.bot  .fciaa-bubble {
    background: var(--fciaa-white);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.fciaa-message.user .fciaa-bubble {
    background: var(--fciaa-primary);
    color: var(--fciaa-white);
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.fciaa-typing .fciaa-bubble {
    padding: 12px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.fciaa-dot {
    width: 7px;
    height: 7px;
    background: var(--fciaa-gray-200);
    border-radius: 50%;
    animation: fciaa-bounce .9s infinite ease-in-out;
}

.fciaa-dot:nth-child(2) { animation-delay: .15s; }
.fciaa-dot:nth-child(3) { animation-delay: .30s; }

@keyframes fciaa-bounce {
    0%, 60%, 100% { transform: translateY(0);   background: var(--fciaa-gray-200); }
    30%           { transform: translateY(-6px); background: var(--fciaa-primary); }
}

/* Input area */
#fciaa-chatbot-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--fciaa-gray-200);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--fciaa-white);
    flex-shrink: 0;
}

#fciaa-chatbot-input {
    flex: 1;
    border: 1.5px solid var(--fciaa-gray-200);
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 100px;
    min-height: 38px;
    outline: none;
    font-family: inherit;
    background: var(--fciaa-gray-100);
    transition: border-color .15s;
    overflow-y: auto;
}

#fciaa-chatbot-input:focus {
    border-color: var(--fciaa-primary);
    background: var(--fciaa-white);
}

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

#fciaa-chatbot-send:hover:not(:disabled) {
    background-color: var(--fciaa-primary-dark);
    transform: scale(1.05);
}

#fciaa-chatbot-send:disabled {
    opacity: .5;
    cursor: not-allowed;
}

#fciaa-chatbot-send svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: #fff;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Powered-by footer */
#fciaa-chatbot-footer {
    text-align: center;
    font-size: 10px;
    color: #999;
    padding: 4px 0 8px;
    background: var(--fciaa-white);
    flex-shrink: 0;
    letter-spacing: .02em;
}

/* Mobile */
@media (max-width: 440px) {
    :root {
        --fciaa-widget-w: calc(100vw - 16px);
        --fciaa-widget-h: calc(100dvh - 110px);
    }

    #fciaa-chatbot-window {
        right: 8px;
        bottom: 90px;
    }

    #fciaa-chatbot-launcher {
        right: 14px;
        bottom: 14px;
    }
}
