#foaic-chatbot,
#foaic-chatbot * {
    box-sizing: border-box;
}

#foaic-chatbot {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: #172033;
}

#foaic-toggle {
    border: 0;
    width: 60px;
    min-width: 60px;
    height: 60px;
    border-radius: 999px;
    padding: 0;
    background: linear-gradient(135deg, #283646 0%, #1f2b39 100%);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 12px 30px rgba(31, 43, 57, 0.35);
    transition: transform 160ms ease, box-shadow 160ms ease, width 180ms ease, padding 180ms ease;
}

#foaic-toggle:hover,
#foaic-toggle:focus {
    width: auto;
    min-width: 158px;
    padding: 0 18px;
    transform: translateY(-2px);
    box-shadow: 0 16px 38px rgba(31, 43, 57, 0.42);
    outline: none;
}

#foaic-toggle .foaic-icon {
    font-size: 25px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

#foaic-toggle .foaic-button-text {
    display: inline-block;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 180ms ease, opacity 180ms ease;
}

#foaic-toggle:hover .foaic-button-text,
#foaic-toggle:focus .foaic-button-text {
    max-width: 220px;
    opacity: 1;
}

#foaic-window {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 500px;
    max-height: calc(100vh - 112px);
    background: #ffffff;
    border: 1px solid rgba(39, 52, 68, 0.12);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 22px 60px rgba(31, 43, 57, 0.28);
    transform-origin: bottom right;
}

#foaic-window.foaic-open {
    animation: foaic-pop 170ms ease-out;
}

@keyframes foaic-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#foaic-header {
    height: 58px;
    padding: 0 14px 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #2c3747;
    color: #ffffff;
    border-bottom: 3px solid #2a9ad1;
}

#foaic-header .foaic-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.01em;
}

#foaic-close {
    border: 0;
    background: transparent;
    color: #ffffff;
    width: 36px;
    height: 36px;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: 8px;
}

#foaic-close:hover,
#foaic-close:focus {
    background: rgba(255,255,255,0.14);
    outline: none;
}

#foaic-messages {
    height: calc(100% - 158px);
    overflow-y: auto;
    padding: 16px;
    background: #f4f7fb;
    font-size: 14px;
    line-height: 1.45;
}

.foaic-message {
    max-width: 88%;
    margin: 0 0 12px;
    padding: 11px 13px;
    border-radius: 14px;
    word-wrap: break-word;
}

.foaic-message-bot {
    background: #ffffff;
    border: 1px solid #dce5ee;
    color: #172033;
    border-bottom-left-radius: 5px;
}

.foaic-message-user {
    margin-left: auto;
    background: #2c3747;
    color: #ffffff;
    border-bottom-right-radius: 5px;
}

.foaic-message-loading {
    opacity: 0.72;
}

#foaic-privacy {
    margin: 0;
    padding: 8px 14px;
    font-size: 11px;
    color: #687587;
    background: #ffffff;
    border-top: 1px solid #dce5ee;
}

#foaic-form {
    height: 54px;
    display: flex;
    align-items: stretch;
    background: #ffffff;
    border-top: 1px solid #dce5ee;
}

#foaic-question {
    flex: 1;
    border: 0;
    padding: 0 14px;
    font-size: 14px;
    min-width: 0;
    outline: none;
    background: #ffffff;
    color: #172033;
}

#foaic-question::placeholder {
    color: #8290a3;
}

#foaic-send {
    width: 56px;
    border: 0;
    background: #2a9ad1;
    color: #ffffff;
    cursor: pointer;
    font-size: 20px;
    font-weight: 800;
}

#foaic-send:hover,
#foaic-send:focus {
    background: #238ac0;
    outline: none;
}

#foaic-send:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

@media (max-width: 640px) {
    #foaic-chatbot {
        right: 14px;
        bottom: 14px;
    }

    #foaic-toggle,
    #foaic-toggle:hover,
    #foaic-toggle:focus {
        width: 56px;
        min-width: 56px;
        height: 56px;
        padding: 0;
    }

    #foaic-toggle .foaic-button-text {
        display: none;
    }

    #foaic-window {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 82px;
        width: auto;
        max-width: none;
        height: min(72vh, 520px);
        max-height: 72vh;
        border-radius: 18px;
        transform-origin: bottom center;
    }

    #foaic-window.foaic-open {
        animation: foaic-sheet 180ms ease-out;
    }

    #foaic-header {
        height: 54px;
    }

    #foaic-header .foaic-title {
        font-size: 15px;
    }

    #foaic-messages {
        height: calc(100% - 154px);
        padding: 14px;
        font-size: 14px;
    }

    .foaic-message {
        max-width: 92%;
    }
}

@media (max-width: 380px) {
    #foaic-window {
        left: 8px;
        right: 8px;
        bottom: 78px;
        height: 68vh;
        max-height: 68vh;
    }

    #foaic-messages {
        font-size: 13px;
    }

    #foaic-question {
        font-size: 13px;
    }
}

@keyframes foaic-sheet {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
