/* =========================================================
   Chat com IA — painel deslizante (2026-09-17)
   ========================================================= */

#chat-ia-botao {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1045;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1.4rem;
    box-shadow: 0 6px 20px rgba(108, 99, 255, 0.45);
    transition: transform 0.15s ease, background 0.15s ease;
}

#chat-ia-botao:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
}

#chat-ia-painel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1050;
    width: 460px;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

#chat-ia-painel.aberto {
    transform: translateX(0);
}

.chat-ia-header {
    background: var(--sidebar-bg);
    color: #fff;
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.chat-ia-header .titulo {
    font-weight: 600;
    flex: 1;
}

.chat-ia-header .escopo {
    font-size: 0.72rem;
    color: var(--text-muted-sidebar);
    display: block;
    font-weight: 400;
}

.chat-ia-header button {
    background: transparent;
    border: none;
    color: var(--text-muted-sidebar);
    font-size: 1.1rem;
    padding: 0 0.3rem;
}

.chat-ia-header button:hover { color: #fff; }

#chat-ia-mensagens {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-body);
}

.chat-ia-msg {
    margin-bottom: 0.9rem;
    display: flex;
}

.chat-ia-msg .balao {
    padding: 0.6rem 0.85rem;
    border-radius: 12px;
    max-width: 88%;
    font-size: 0.86rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.chat-ia-msg.usuario { justify-content: flex-end; }

.chat-ia-msg.usuario .balao {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 3px;
}

.chat-ia-msg.ia .balao {
    background: #fff;
    color: #24243a;
    border: 1px solid #e5e6ef;
    border-bottom-left-radius: 3px;
}

.chat-ia-msg.ia .balao table {
    width: 100%;
    font-size: 0.8rem;
    margin: 0.5rem 0;
    border-collapse: collapse;
}

.chat-ia-msg.ia .balao th,
.chat-ia-msg.ia .balao td {
    border: 1px solid #e5e6ef;
    padding: 0.28rem 0.45rem;
    text-align: left;
}

.chat-ia-msg.ia .balao th { background: #f0f0f7; font-weight: 600; }
.chat-ia-msg.ia .balao p:last-child { margin-bottom: 0; }
.chat-ia-msg.ia .balao ul,
.chat-ia-msg.ia .balao ol { padding-left: 1.1rem; margin-bottom: 0.4rem; }
.chat-ia-msg.ia .balao code {
    background: #f0f0f7;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.chat-ia-msg.erro .balao {
    background: #fdeaea;
    border: 1px solid #f5c2c2;
    color: #8f2a2a;
}

.chat-ia-status {
    font-size: 0.76rem;
    color: #7a7a95;
    font-style: italic;
    margin-bottom: 0.7rem;
    padding-left: 0.2rem;
}

.chat-ia-vazio {
    color: #8a8aa3;
    font-size: 0.83rem;
    text-align: center;
    padding: 2rem 1rem;
}

.chat-ia-exemplo {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid #e5e6ef;
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    margin-bottom: 0.45rem;
    font-size: 0.8rem;
    color: #45456a;
}

.chat-ia-exemplo:hover { border-color: var(--accent); color: var(--accent); }

.chat-ia-rodape {
    border-top: 1px solid #e5e6ef;
    padding: 0.7rem;
    background: #fff;
}

.chat-ia-rodape textarea {
    resize: none;
    font-size: 0.86rem;
    border-radius: 8px;
}

.chat-ia-aviso {
    font-size: 0.7rem;
    color: #9a9ab0;
    margin-top: 0.35rem;
    text-align: center;
}

@media (max-width: 576px) {
    #chat-ia-painel { width: 100vw; }
}

/* ---------------------------------------------------------------
   Cartão de viabilidade + mapa
   O painel do chat é estreito demais para um mapa útil, então aqui
   fica só o resumo clicável; o mapa abre em modal, do tamanho da
   tela, igual ao da consulta em lote do sistema de transportes.
   --------------------------------------------------------------- */
.chat-ia-mapa-cartao {
    border: 1px solid #e5e6ef;
    border-radius: 10px;
    padding: 0.6rem 0.7rem;
    background: #fff;
    font-size: 0.8rem;
    line-height: 1.35;
}

.chat-ia-mapa-cartao .endereco {
    color: #5a5a72;
    display: block;
    margin-bottom: 0.45rem;
    word-break: break-word;
}

.chat-ia-mapa-cartao button {
    font-size: 0.78rem;
    padding: 0.25rem 0.6rem;
}

#chat-ia-mapa-tela { height: 60vh; min-height: 320px; }

/* O painel do chat sobe acima do backdrop do Bootstrap; sem isto o
   modal do mapa abriria ATRÁS do próprio chat que o pediu. */
#chat-ia-mapa-modal { z-index: 20000; }
#chat-ia-mapa-modal + .modal-backdrop,
.modal-backdrop.chat-ia-backdrop { z-index: 19990; }
