.ai-chat {
    position: fixed;
    inset-inline-end: 24px;
    bottom: 24px;
    z-index: 1000;
    font-family: inherit;
}

.ai-chat *,
.ai-chat *::before,
.ai-chat *::after {
    box-sizing: border-box;
}

.ai-chat__launcher {
    display: flex;
    width: 64px;
    height: 64px;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    background: linear-gradient(135deg, #1557a6, #0d3f78);
    color: #ffffff;
    box-shadow: 0 12px 32px rgba(13, 63, 120, 0.28);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

.ai-chat__launcher:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 36px rgba(13, 63, 120, 0.36);
}

.ai-chat__launcher svg {
    width: 31px;
    height: 31px;
}

.ai-chat__panel {
    position: absolute;
    inset-inline-end: 0;
    bottom: 78px;
    display: flex;
    width: min(390px, calc(100vw - 32px));
    height: min(570px, calc(100dvh - 120px));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #dce6f2;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 22px 65px rgba(13, 42, 78, 0.24);
}

.ai-chat__panel[hidden] {
    display: none !important;
}

.ai-chat__header {
    display: flex;
    min-height: 86px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 17px 18px;
    background: linear-gradient(115deg, #1557a6, #0d3f78);
    color: #ffffff;
}

.ai-chat__identity {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.ai-chat__avatar {
    display: flex;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, .8);
    border-radius: 50%;
    background: #f0f7ff;
    color: #ffffff;
    font-size: 19px;
    font-weight: 800;
}

.ai-chat__identity strong,
.ai-chat__identity span:not(.ai-chat__avatar) {
    display: block;
}

.ai-chat__identity strong {
    font-size: 14px;
    line-height: 1.4;
}

.ai-chat__identity div > span {
    margin-top: 3px;
    color: #dbeafe;
    font-size: 12px;
}

.ai-chat__close {
    display: flex;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .13);
    color: #ffffff;
    font-size: 25px;
    cursor: pointer;
}

.ai-chat__close:hover {
    background: rgba(255, 255, 255, .25);
}

.ai-chat__messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding: 22px 17px;
    background: #f5f8fc;
}

.ai-chat__message {
    max-width: 88%;
    padding: 13px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.ai-chat__message--assistant {
    align-self: flex-start;
    border-start-start-radius: 5px;
    background: #ffffff;
    color: #24364e;
    box-shadow: 0 2px 10px rgba(25, 60, 105, .06);
}

.ai-chat__message--user {
    align-self: flex-end;
    border-start-end-radius: 5px;
    background: #1557a6;
    color: #ffffff;
}

.ai-chat__composer {
    padding: 13px 15px 12px;
    border-top: 1px solid #e6edf5;
    background: #ffffff;
}

.ai-chat__composer form {
    display: flex;
    align-items: center;
    gap: 9px;
}

.ai-chat__composer input {
    width: 100%;
    min-width: 0;
    padding: 12px 13px;
    border: 1px solid #dce6f2;
    border-radius: 12px;
    outline: none;
    color: #24364e;
    font: inherit;
    font-size: 14px;
}

.ai-chat__composer input:focus {
    border-color: #1557a6;
    box-shadow: 0 0 0 3px rgba(21, 87, 166, .1);
}

.ai-chat__composer input:disabled {
    background: #f5f8fc;
    cursor: not-allowed;
}

.ai-chat__composer button {
    display: flex;
    width: 43px;
    height: 43px;
    flex: 0 0 43px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: #f07b28;
    color: #ffffff;
    font-size: 23px;
    cursor: pointer;
}

.ai-chat__composer button:disabled {
    background: #f07b28;
    color: #ffffff;
    opacity: 1;
    cursor: not-allowed;
}

.ai-chat__disclaimer {
    margin: 10px 0 0;
    color: #718096;
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
}

.ai-chat button:focus-visible {
    outline: 3px solid #f07b28;
    outline-offset: 3px;
}

@media (max-width: 480px) {
    .ai-chat {
        inset-inline-end: 16px;
        bottom: 20px;
    }

    .ai-chat__launcher {
        width: 58px;
        height: 58px;
    }

    .ai-chat:has(.ai-chat__panel:not([hidden])) .ai-chat__launcher {
        visibility: hidden;
        pointer-events: none;
    }

    .ai-chat__panel {
        position: fixed;
        inset-inline-start: 12px;
        inset-inline-end: 12px;
        top: 12px;
        bottom: 12px;
        width: auto;
        height: auto;
        max-height: calc(100dvh - 24px);
        border-radius: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chat__launcher {
        transition: none;
    }
}


/* LOCAL-069: acabamento mobile */
@media (max-width: 980px) {
    .ai-chat__launcher {
        bottom: 20px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
}


/* LOCAL-071: posicionamento seguro mobile */
@media (max-width: 980px) {
    .ai-chat__launcher {
        position: fixed;
        right: 12px;
        bottom: 12px;
        width: 44px;
        height: 44px;
        z-index: 1000;
    }

    .ai-chat__panel {
        max-width: calc(100vw - 24px);
        max-height: calc(100dvh - 24px);
    }
}


/* LOCAL-140: rótulo acessível sem ocupar espaço visual */
.ai-chat .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
