/* ==========================================
   AGENTE FLUTUANTE - ESTILOS
========================================== */

/* Botão flutuante */
.agente-flutuante {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a56db, #0f3b8a);
    color: white;
    cursor: pointer;
    font-size: 26px;
    box-shadow: 0 10px 35px rgba(26, 86, 219, 0.4);
    z-index: 9999;
    transition: all 0.3s ease;
    animation: agentePulse 2.5s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agente-flutuante:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 15px 45px rgba(26, 86, 219, 0.5);
}

.agente-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: agenteBadge 1.5s infinite;
}

@keyframes agentePulse {
    0%, 100% { box-shadow: 0 10px 35px rgba(26, 86, 219, 0.4); }
    50% { box-shadow: 0 10px 35px rgba(26, 86, 219, 0.15); }
}

@keyframes agenteBadge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Modal */
.agente-modal {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 25px;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    z-index: 10000;
    animation: agenteFadeIn 0.25s ease;
}

@keyframes agenteFadeIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.agente-modal-conteudo {
    width: 440px;
    height: 650px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    border: 1px solid #e2e8f0;
}

/* Cabeçalho */
.agente-header {
    height: 72px;
    background: linear-gradient(135deg, #1a56db, #0f3b8a);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    flex-shrink: 0;
}

.agente-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agente-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

.agente-info h2 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 1px;
}

.agente-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.agente-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: agenteOnline 1.5s infinite;
}

.agente-status .status-dot.offline {
    background: #ef4444;
    animation: none;
}

@keyframes agenteOnline {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.agente-fechar {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agente-fechar:hover {
    background: white;
    color: #1a56db;
}

/* Mensagens */
.agente-mensagens {
    flex: 1;
    padding: 18px 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.agente-mensagens::-webkit-scrollbar {
    width: 5px;
}

.agente-mensagens::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.agente-mensagens::-webkit-scrollbar-track {
    background: transparent;
}

.msg-bot, .msg-user {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: agenteMsg 0.3s ease;
}

@keyframes agenteMsg {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-user {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #1a56db;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 15px;
    flex-shrink: 0;
}

.msg-user .msg-avatar {
    background: #64748b;
}

.msg-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    background: white;
    line-height: 1.6;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.msg-user .msg-bubble {
    background: #1a56db;
    color: white;
}

.msg-bubble strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}

.msg-bubble p {
    margin: 4px 0;
}

.msg-bubble p:last-child {
    margin-bottom: 0;
}

/* Sugestões dentro da mensagem */
.agente-sugestoes {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.agente-sugestao {
    padding: 5px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #475569;
}

.agente-sugestao:hover {
    background: #1a56db;
    color: white;
    border-color: #1a56db;
}

/* Sugestões rápidas na área de input */
.agente-sugestoes-rapidas {
    padding: 8px 20px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    background: #fafbfc;
    flex-shrink: 0;
}

.agente-sugestoes-rapidas span {
    font-size: 11px;
    color: #94a3b8;
    margin-right: 4px;
}

.agente-sugestao-rapida {
    padding: 4px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    color: #475569;
    white-space: nowrap;
}

.agente-sugestao-rapida:hover {
    background: #e8f0fe;
    border-color: #1a56db;
    color: #1a56db;
}

/* Categorias de sugestões */
.agente-categorias {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.agente-categoria {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: white;
    cursor: default;
}

.agente-categoria.adm { background: #1a56db; }
.agente-categoria.pro { background: #059669; }
.agente-categoria.geral { background: #7c3aed; }
.agente-categoria.ajuda { background: #d97706; }

/* Typing */
.agente-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border-radius: 14px;
    width: 56px;
}

.agente-typing span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: agenteTyping 1.4s infinite;
}

.agente-typing span:nth-child(2) { animation-delay: 0.2s; }
.agente-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes agenteTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Input */
.agente-input-area {
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    background: white;
    flex-shrink: 0;
}

.agente-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    background: #f8fafc;
}

.agente-input:focus {
    outline: none;
    border-color: #1a56db;
    background: white;
    box-shadow: 0 0 0 4px rgba(26, 86, 219, 0.08);
}

.agente-enviar {
    padding: 10px 18px;
    background: #1a56db;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agente-enviar:hover {
    background: #0f3b8a;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(26, 86, 219, 0.25);
}

.agente-enviar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mensagem de erro */
.msg-error .msg-bubble {
    background: #fee2e2;
    color: #991b1b;
}

.msg-error .msg-bubble code {
    background: #fecaca;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Tema escuro do assistente flutuante, carregado depois dos estilos globais. */
body.dark-theme .agente-modal {
    background: rgba(2, 6, 23, 0.62);
}

body.dark-theme .agente-modal-conteudo {
    background: #0f172a;
    border-color: rgba(71, 85, 105, 0.88);
    box-shadow: 0 22px 64px rgba(0, 0, 0, 0.42);
    color: #e5edf7;
}

body.dark-theme .agente-mensagens,
body.dark-theme .agente-sugestoes-rapidas,
body.dark-theme .agente-input-area {
    background: #111827;
    border-color: rgba(71, 85, 105, 0.78);
}

body.dark-theme .msg-bubble,
body.dark-theme .agente-typing,
body.dark-theme .agente-sugestao,
body.dark-theme .agente-sugestao-rapida {
    background: rgba(15, 23, 42, 0.96);
    border-color: rgba(71, 85, 105, 0.88);
    color: #e5edf7;
    box-shadow: none;
}

body.dark-theme .msg-bubble :where(strong, p),
body.dark-theme .agente-info :where(h2, span) {
    color: inherit;
}

body.dark-theme .msg-user .msg-bubble {
    background: #1a56db;
    color: #ffffff;
}

body.dark-theme .agente-sugestoes-rapidas span {
    color: #94a3b8;
}

body.dark-theme .agente-sugestao:hover,
body.dark-theme .agente-sugestao-rapida:hover {
    background: rgba(37, 99, 235, 0.24);
    border-color: rgba(96, 165, 250, 0.58);
    color: #bfdbfe;
}

body.dark-theme .agente-input {
    background: rgba(2, 6, 23, 0.76);
    border-color: rgba(71, 85, 105, 0.92);
    color: #f8fafc;
    color-scheme: dark;
}

body.dark-theme .agente-input::placeholder {
    color: #74839a;
}

body.dark-theme .agente-input:focus {
    background: rgba(2, 6, 23, 0.9);
    border-color: rgba(96, 165, 250, 0.58);
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.14);
}

body.dark-theme .agente-mensagens::-webkit-scrollbar-thumb {
    background: #475569;
}

body.dark-theme .msg-error .msg-bubble {
    background: rgba(127, 29, 29, 0.26);
    color: #fecaca;
}

body.dark-theme .msg-error .msg-bubble code {
    background: rgba(127, 29, 29, 0.44);
}

/* Responsividade */
@media (max-width: 600px) {
    .agente-modal {
        padding: 0;
        align-items: flex-end;
    }

    .agente-modal-conteudo {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .agente-flutuante {
        right: 18px;
        bottom: 18px;
        width: 56px;
        height: 56px;
        font-size: 22px;
    }

    .agente-sugestoes-rapidas {
        padding: 6px 12px;
    }
    
    .agente-sugestao-rapida {
        font-size: 10px;
        padding: 3px 10px;
    }
}
