/* ═══════════════════════════════════════════════════════════════════════════
   ATENDENTE IA (24/10/2026) — botão no hero + painel de conversa.
   Tema noite é o padrão; o tema dia (html.tema-dia) troca só as cores.
   Script: js/atendente_ia.js · servidor: atendente_ia.php
   ═══════════════════════════════════════════════════════════════════════════ */

.atd-painel {
    --atd-bg: #0b1220;
    --atd-bolha-ia: #131c2e;
    --atd-bolha-eu: #1d4ed8;
    --atd-borda: rgba(148, 163, 184, 0.18);
    --atd-texto: #e5e7eb;
    --atd-suave: #94a3b8;
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(420px, calc(100vw - 32px));
    height: min(640px, calc(100vh - 48px));
    display: none;
    flex-direction: column;
    background: var(--atd-bg);
    color: var(--atd-texto);
    border: 1px solid var(--atd-borda);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    z-index: 2147483000;            /* acima do balão do LiveChat e do VLibras */
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
}
.atd-painel.aberto { display: flex; }

html.tema-dia .atd-painel {
    --atd-bg: #ffffff;
    --atd-bolha-ia: #f1f5f9;
    --atd-bolha-eu: #2563eb;
    --atd-borda: #e2e8f0;
    --atd-texto: #1f2937;
    --atd-suave: #64748b;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.atd-topo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--atd-borda);
}
.atd-topo-ico {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-accent);
    flex: none;
}
.atd-topo h3 { margin: 0; font-size: 0.98rem; line-height: 1.2; color: var(--atd-texto); }
.atd-topo small { color: var(--atd-suave); font-size: 0.75rem; }
.atd-fechar {
    margin-left: auto;
    background: none; border: 0; cursor: pointer;
    color: var(--atd-suave);
    font-size: 1.15rem;
    width: 36px; height: 36px; border-radius: 8px;
}
.atd-fechar:hover { background: var(--atd-bolha-ia); color: var(--atd-texto); }

.atd-aviso {
    margin: 0;
    padding: 0.55rem 1rem;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--atd-suave);
    border-bottom: 1px solid var(--atd-borda);
}

.atd-lista {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.atd-msg {
    max-width: 88%;
    padding: 0.65rem 0.85rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.atd-msg p { margin: 0 0 0.5rem; }
.atd-msg p:last-child, .atd-msg ul:last-child { margin-bottom: 0; }
.atd-msg ul { margin: 0 0 0.5rem; padding-left: 1.1rem; }
.atd-msg li { margin: 0.15rem 0; }
.atd-ia { align-self: flex-start; background: var(--atd-bolha-ia); border-bottom-left-radius: 4px; }
.atd-eu { align-self: flex-end; background: var(--atd-bolha-eu); color: #fff; border-bottom-right-radius: 4px; }
.atd-erro { align-self: center; font-size: 0.8rem; color: #f59e0b; text-align: center; }

.atd-digitando { display: inline-flex; gap: 4px; }
.atd-digitando span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--atd-suave);
    animation: atd-pulo 1.2s infinite ease-in-out;
}
.atd-digitando span:nth-child(2) { animation-delay: 0.15s; }
.atd-digitando span:nth-child(3) { animation-delay: 0.3s; }
@keyframes atd-pulo { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.atd-sugestoes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.atd-sugestoes button {
    background: transparent;
    border: 1px solid var(--atd-borda);
    color: var(--atd-texto);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
}
.atd-sugestoes button:hover { border-color: var(--color-accent); color: var(--color-accent); }

.atd-whats {
    display: inline-flex; align-items: center; gap: 0.5rem;
    margin-top: 0.6rem;
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    background: #16a34a;
    color: #fff !important;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
}
.atd-whats:hover { background: #15803d; }

.atd-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--atd-borda);
}
.atd-form textarea {
    flex: 1;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--atd-borda);
    background: var(--atd-bolha-ia);
    color: var(--atd-texto);
    font: inherit;
    font-size: 0.9rem;
}
.atd-form textarea:focus { outline: 2px solid var(--color-primary); outline-offset: 0; }
.atd-enviar {
    width: 44px; height: 44px; flex: none;
    border: 0; border-radius: 10px; cursor: pointer;
    background: var(--color-primary);
    color: #fff;
    font-size: 1rem;
}
.atd-enviar:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 600px) {
    .atd-painel {
        inset: 0;
        width: auto;
        height: auto;
        border-radius: 0;
        border: 0;
    }
}

button.btn-badge-hero { cursor: pointer; }

/* com o chat aberto, o botão flutuante do VLibras não cobre a conversa */
/* (a versão atual do plugin desenha o botão em #vlibras-access-wrapper, não dentro de div[vw]) */
body.atd-aberto #vlibras-access-wrapper,
body.atd-aberto div[vw] { display: none !important; }

/* imagem da galeria dentro da resposta (fase 3) */
.atd-img { margin: 0.6rem 0 0; }
.atd-img a { display: block; border-radius: 8px; overflow: hidden; border: 1px solid var(--atd-borda); background: #fff; }
.atd-img img { display: block; width: 100%; height: auto; max-height: 360px; object-fit: cover; object-position: top; }
.atd-img figcaption { margin-top: 0.35rem; font-size: 0.72rem; color: var(--atd-suave); }
.atd-msg:has(.atd-img) { max-width: 94%; }

/* vídeo do YouTube dentro da resposta: capa com play; o player só carrega no clique */
.atd-video { margin: 0.6rem 0 0; }
.atd-video-capa, .atd-video iframe {
    display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px;
}
.atd-video-capa {
    position: relative; cursor: pointer; padding: 0;
    background: #000 center / cover no-repeat;
}
.atd-video-play {
    position: absolute; inset: 0; margin: auto;
    width: 56px; height: 40px; border-radius: 10px;
    display: grid; place-items: center;
    background: rgba(220, 38, 38, 0.92); color: #fff; font-size: 1.05rem;
}
.atd-video-capa:hover .atd-video-play { background: #dc2626; }
.atd-video figcaption { margin-top: 0.35rem; font-size: 0.72rem; color: var(--atd-suave); }
.atd-msg:has(.atd-video) { max-width: 94%; }
