/* Billy: chat de dúvidas da Sala de Miaula */
.prof-root {
    --prof-laranja: #f29400;
    --prof-laranja-escuro: #d97f00;
    --prof-marrom: #3e2723;
    --prof-marrom-claro: #795548;
    --prof-fundo: #fcf9f2;
    --prof-fundo-chat: #f6efe3;
    --prof-bolha-bot: #ffffff;
    --prof-bolha-eu: #f29400;
    --prof-bolha-eu-texto: #ffffff;
    --prof-borda: #e8dccb;
    --prof-sombra: 0 18px 50px rgba(62, 39, 35, 0.28), 0 4px 14px rgba(62, 39, 35, 0.14);
    --prof-wpp: #25d366;
    --prof-wpp-escuro: #1da851;
    font-family: 'Nunito', system-ui, sans-serif;
}
[data-theme="dark"] .prof-root {
    --prof-marrom: #f3e6d6;
    --prof-marrom-claro: #c9b49d;
    --prof-fundo: #1f1915;
    --prof-fundo-chat: #17120f;
    --prof-bolha-bot: #2b231d;
    --prof-borda: #3a3029;
    --prof-sombra: 0 18px 50px rgba(0, 0, 0, 0.55), 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* ---------- botão flutuante ---------- */
.prof-launcher {
    position: fixed;
    right: 16px;
    bottom: calc(var(--bottom-nav-height, 78px) + 22px + env(safe-area-inset-bottom, 0px));
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    padding: 0;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
body.nav-recolhida .prof-launcher { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
.prof-launcher-avatar {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: #ffe8c4;
    box-shadow: 0 8px 24px rgba(62, 39, 35, 0.3), 0 0 0 3px var(--prof-laranja);
    display: grid;
    place-items: center;
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.4);
    position: relative;
}
@media (hover: hover) { .prof-launcher:hover .prof-launcher-avatar { transform: scale(1.06); } }
.prof-launcher-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 50%; }
/* bolinha de online: do lado de fora do círculo, no canto de cima */
.prof-launcher-ponto {
    position: absolute;
    right: -6px;
    top: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2ecc71;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(62, 39, 35, 0.25);
}
.prof-launcher-balao {
    order: -1;
    background: #fff;
    color: #3e2723;
    font-weight: 800;
    font-size: 14px;
    line-height: 1.25;
    padding: 10px 14px;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 8px 22px rgba(62, 39, 35, 0.2);
    max-width: 190px;
    text-align: left;
    animation: prof-balao-in 0.5s 1.2s both cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.prof-launcher-balao small { display: block; font-weight: 600; color: #795548; font-size: 12px; margin-top: 2px; }
.prof-launcher.sem-balao .prof-launcher-balao { display: none; }
@keyframes prof-balao-in { from { opacity: 0; transform: translateX(14px) scale(0.9); } to { opacity: 1; transform: none; } }
.prof-root.aberto .prof-launcher { display: none; }

/* ---------- janela ---------- */
.prof-janela {
    position: fixed;
    z-index: 1300;
    right: 18px;
    bottom: 18px;
    width: 400px;
    height: min(680px, calc(100vh - 36px));
    height: min(680px, calc(100dvh - 36px));
    display: flex;
    flex-direction: column;
    background: var(--prof-fundo);
    border-radius: 22px;
    box-shadow: var(--prof-sombra);
    overflow: hidden;
    transform-origin: bottom right;
    animation: prof-abre 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.prof-root:not(.aberto) .prof-janela { display: none; }
.prof-root.fechando .prof-janela { animation: prof-fecha 0.2s cubic-bezier(0.4, 0, 1, 1) forwards; pointer-events: none; }
@keyframes prof-abre { from { opacity: 0; transform: translateY(18px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes prof-fecha { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(18px) scale(0.94); } }
@media (max-width: 600px) {
    .prof-janela {
        inset: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        animation-name: prof-abre-mobile;
    }
    @keyframes prof-abre-mobile { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
    .prof-root.fechando .prof-janela { animation-name: prof-fecha-mobile; animation-duration: 0.22s; }
    @keyframes prof-fecha-mobile { from { transform: none; opacity: 1; } to { transform: translateY(40px); opacity: 0; } }
}
body.prof-travado { overflow: hidden; }

/* cabeçalho */
.prof-topo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    background: linear-gradient(135deg, #f7a21b 0%, #f29400 55%, #e07f00 100%);
    color: #fff;
    flex-shrink: 0;
}
.prof-topo-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #ffe8c4;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 0 0 2.5px rgba(255, 255, 255, 0.7);
}
.prof-topo-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.prof-topo-info { flex: 1; min-width: 0; }
.prof-topo-nome { font-weight: 900; font-size: 17px; line-height: 1.15; }
.prof-topo-status { font-size: 12.5px; font-weight: 600; opacity: 0.95; display: flex; align-items: center; gap: 6px; }
.prof-topo-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #b9ffcf; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35); }
.prof-topo-status.digitando::before { background: #fff; animation: prof-pisca 1s infinite; }
.prof-btn-icone {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 0;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.prof-btn-icone:hover { background: rgba(255, 255, 255, 0.3); }

/* mensagens */
.prof-msgs {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 14px 10px;
    background-color: var(--prof-fundo-chat);
    background-image: radial-gradient(rgba(242, 148, 0, 0.09) 1.2px, transparent 1.2px);
    background-size: 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(121, 85, 72, 0.28) transparent;
}
/* barra de rolagem fininha, sem setas, só aparece o "trilho" quando passa o mouse */
.prof-msgs::-webkit-scrollbar { width: 6px; }
.prof-msgs::-webkit-scrollbar-track { background: transparent; }
.prof-msgs::-webkit-scrollbar-thumb { background: rgba(121, 85, 72, 0.25); border-radius: 999px; }
.prof-msgs:hover::-webkit-scrollbar-thumb { background: rgba(121, 85, 72, 0.45); }
.prof-msgs::-webkit-scrollbar-button { display: none; height: 0; }
.prof-dia {
    align-self: center;
    font-size: 11.5px;
    font-weight: 800;
    color: var(--prof-marrom-claro);
    background: var(--prof-bolha-bot);
    padding: 4px 12px;
    border-radius: 999px;
    margin: 2px 0 10px;
    box-shadow: 0 1px 2px rgba(62, 39, 35, 0.08);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.prof-linha { display: flex; align-items: flex-end; gap: 8px; animation: prof-msg-in 0.25s ease-out; }
.prof-linha.eu { justify-content: flex-end; }
.prof-linha + .prof-linha.eu, .prof-linha.eu + .prof-linha:not(.eu) { margin-top: 8px; }
@keyframes prof-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.prof-mini {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ffe8c4;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(62, 39, 35, 0.18);
}
.prof-mini img { width: 100%; height: 100%; display: block; object-fit: cover; }
.prof-mini.oculto { visibility: hidden; }
.prof-bolha {
    max-width: 82%;
    padding: 10px 13px 8px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.45;
    color: var(--prof-marrom);
    background: var(--prof-bolha-bot);
    box-shadow: 0 1px 2px rgba(62, 39, 35, 0.1);
    border-bottom-left-radius: 6px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.prof-linha.eu .prof-bolha {
    background: var(--prof-bolha-eu);
    color: var(--prof-bolha-eu-texto);
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 6px;
}
.prof-bolha strong { font-weight: 800; }
.prof-hora { display: block; text-align: right; font-size: 10.5px; opacity: 0.6; margin-top: 3px; font-weight: 600; }
.prof-audio-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; opacity: 0.85; margin-bottom: 3px; }

/* fontes */
.prof-fontes { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; white-space: normal; }
.prof-fonte {
    display: block;
    text-decoration: none;
    border-left: 3px solid var(--prof-laranja);
    background: rgba(242, 148, 0, 0.08);
    border-radius: 4px 10px 10px 4px;
    padding: 6px 9px;
    color: var(--prof-marrom);
    font-size: 12.5px;
    line-height: 1.35;
    transition: background 0.15s;
}
.prof-fonte:hover { background: rgba(242, 148, 0, 0.16); }
.prof-fonte-titulo { font-weight: 800; font-size: 11.5px; color: var(--prof-laranja-escuro); display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
[data-theme="dark"] .prof-fonte-titulo { color: #ffb547; }
.prof-fonte-trecho { font-style: italic; opacity: 0.88; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* WhatsApp */
.prof-wpp {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--prof-wpp);
    color: #fff;
    text-decoration: none;
    font-weight: 900;
    font-size: 14.5px;
    padding: 11px 14px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
    transition: background 0.15s, transform 0.15s;
    white-space: normal;
}
.prof-wpp:hover { background: var(--prof-wpp-escuro); transform: translateY(-1px); }
.prof-wpp svg { flex-shrink: 0; }

/* digitando */
.prof-digitando { display: inline-flex; align-items: center; gap: 4px; padding: 4px 2px; }
.prof-digitando i { width: 7px; height: 7px; border-radius: 50%; background: var(--prof-marrom-claro); opacity: 0.5; animation: prof-pula 1.2s infinite; }
.prof-digitando i:nth-child(2) { animation-delay: 0.15s; }
.prof-digitando i:nth-child(3) { animation-delay: 0.3s; }
.prof-digitando-texto { font-size: 12.5px; color: var(--prof-marrom-claro); font-weight: 700; margin-left: 6px; font-style: italic; }
@keyframes prof-pula { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes prof-pisca { 50% { opacity: 0.3; } }

/* sugestões */
.prof-sugestoes { display: flex; flex-wrap: wrap; gap: 7px; padding: 6px 0 4px 38px; }
.prof-sugestao {
    border: 1.5px solid var(--prof-laranja);
    background: var(--prof-bolha-bot);
    color: var(--prof-laranja-escuro);
    font: inherit;
    font-weight: 800;
    font-size: 13px;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-align: left;
}
[data-theme="dark"] .prof-sugestao { color: #ffb547; }
.prof-sugestao:hover { background: var(--prof-laranja); color: #fff; }

/* rodapé de envio */
.prof-envio {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 10px 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--prof-fundo);
    border-top: 1px solid var(--prof-borda);
}
.prof-campo-wrap {
    flex: 1;
    min-width: 0;
    background: var(--prof-bolha-bot);
    border: 1.5px solid var(--prof-borda);
    border-radius: 22px;
    display: flex;
    align-items: flex-end;
    padding: 2px 6px; /* respiro pro texto não encostar nas curvas */
    transition: border-color 0.15s, box-shadow 0.15s;
}
.prof-campo-wrap:focus-within { border-color: var(--prof-laranja); box-shadow: 0 0 0 3px rgba(242, 148, 0, 0.15); }
.prof-campo {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    resize: none;
    font: inherit;
    font-size: 16px; /* 16px evita o zoom automático no iPhone */
    line-height: 1.35;
    color: var(--prof-marrom);
    padding: 9px 8px;
    max-height: 132px;
    overflow-y: auto;
    scrollbar-width: none; /* sem barra no campo: rola com a roda do mouse ou o dedo */
}
.prof-campo::-webkit-scrollbar { display: none; }
/* texto longo: a linha de cima some num esmaecido em vez de aparecer cortada */
.prof-campo.rolando {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, transparent 9px, #000 30px);
    mask-image: linear-gradient(to bottom, transparent 0, transparent 9px, #000 30px);
}
.prof-campo::placeholder { color: var(--prof-marrom-claro); opacity: 0.75; }
.prof-btn-redondo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 0;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: #fff;
    background: var(--prof-laranja);
    box-shadow: 0 4px 12px rgba(242, 148, 0, 0.35);
    transition: transform 0.15s, background 0.15s, opacity 0.15s;
}
.prof-btn-redondo:hover { transform: scale(1.05); }
.prof-btn-redondo:disabled { opacity: 0.45; cursor: default; transform: none; }
.prof-btn-mic { background: var(--prof-marrom-claro); box-shadow: 0 4px 12px rgba(62, 39, 35, 0.2); }
[data-theme="dark"] .prof-btn-mic { background: #5d4a3f; }
.prof-btn-mic.gravando { background: #e53935; animation: prof-grava 1.3s infinite; }
@keyframes prof-grava { 0% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.55); } 70% { box-shadow: 0 0 0 14px rgba(229, 57, 53, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0); } }
.prof-gravando-aviso {
    display: none;
    font-size: 12.5px;
    font-weight: 800;
    color: #e53935;
    text-align: center;
    padding: 6px 0 0;
    background: var(--prof-fundo);
}
.prof-root.gravando .prof-gravando-aviso { display: block; }
.prof-rodape-nota { font-size: 11px; text-align: center; color: var(--prof-marrom-claro); padding: 0 12px 6px; background: var(--prof-fundo); opacity: 0.8; }

@media (prefers-reduced-motion: reduce) {
    .prof-btn-mic.gravando, .prof-launcher-balao, .prof-janela, .prof-linha { animation: none !important; }
}
