/* ── Reset e base ─────────────────────────────── */
#chatbot-root * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Botão flutuante ──────────────────────────── */
#cb-btn-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 24px;
    z-index: 99998;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, box-shadow .2s ease;
}
#cb-btn-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,.3);
}

/* ── Caixa principal ──────────────────────────── */
#cb-box {
    position: fixed;
    bottom: 94px;
    right: 24px;
    width: 360px;
    height: 520px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: none;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
    animation: cb-slide-in .25s ease;
}
@keyframes cb-slide-in {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

/* ── Cabeçalho ────────────────────────────────── */
#cb-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#cb-header-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
#cb-header-title::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(74,222,128,.3);
}
#cb-btn-fechar {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    transition: color .15s;
}
#cb-btn-fechar:hover { color: #fff; }

/* ── Área de mensagens ────────────────────────── */
#cb-mensagens {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f8fc;
    scroll-behavior: smooth;
}
#cb-mensagens::-webkit-scrollbar { width: 4px; }
#cb-mensagens::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* ── Balões de mensagem ───────────────────────── */
.cb-msg {
    max-width: 82%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}
.cb-msg-bot {
    align-self: flex-start;
    background: #ffffff;
    color: #222;
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.cb-msg-user {
    align-self: flex-end;
    color: #ffffff;
    border-radius: 16px 4px 16px 16px;
}

/* ── Indicador "digitando..." ─────────────────── */
#cb-typing {
    align-self: flex-start;
    background: #fff;
    border-radius: 4px 16px 16px 16px;
    padding: 10px 14px;
    display: none;
    gap: 5px;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
#cb-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aaa;
    animation: cb-bounce .9s infinite;
}
#cb-typing span:nth-child(2) { animation-delay: .15s; }
#cb-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes cb-bounce {
    0%, 80%, 100% { transform: translateY(0);   opacity: .5; }
    40%            { transform: translateY(-6px); opacity: 1;  }
}

/* ── Área de entrada ──────────────────────────── */
#cb-footer {
    padding: 12px 14px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}
#cb-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
    resize: none;
}
#cb-input:focus { border-color: #1a4d8f; }
#cb-btn-enviar {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    white-space: nowrap;
}
#cb-btn-enviar:hover   { opacity: .9; }
#cb-btn-enviar:active  { transform: scale(.96); }
#cb-btn-enviar:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Responsivo mobile ────────────────────────── */
@media (max-width: 420px) {
    #cb-box {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        height: 70vh;
    }
}