/* --- Lançador (Ícone Flutuante) --- */
#chat-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(to top right, var(--elevus-dark-blue, #AA12EA), var(--elevus-teal, #F4207B));
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: all 0.3s ease-in-out;
}

#chat-launcher:hover { transform: scale(1.1); }
#chat-launcher img { 
    width: 60px; 
    height: 60px; 
    border-radius: 50%; 
    object-fit: cover;
}
#chat-launcher.launcher-hidden { transform: scale(0); opacity: 0; pointer-events: none; }

/* --- Janela Principal do Chat --- */
#meu-chat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 370px;
    z-index: 9999;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    font-family: sans-serif;
}
#meu-chat.chat-hidden { opacity: 0; transform: translateY(20px) scale(0.95); pointer-events: none; }
#meu-chat.chat-visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* --- Cabeçalho --- */
#chat-header {
    background: linear-gradient(to right, var(--elevus-dark-blue, #AA12EA), var(--elevus-teal, #F4207B));
    color: #fff;
    font-weight: bold;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 15px 15px 0 0;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    flex-shrink: 0; 
}
#chat-close-btn { background: none; border: none; color: white; font-size: 24px; line-height: 1; cursor: pointer; padding: 0 5px; opacity: 0.8; transition: opacity 0.2s; }
#chat-close-btn:hover { opacity: 1; }

/* --- Corpo (Mensagens) --- */
#chat-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: rgba(244, 247, 249, 0.8) !important; 
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    flex-grow: 1; 
    height: 450px;
}

.chat-message { display: flex; max-width: 90%; margin-bottom: 15px; }
.chat-message.bot { align-self: flex-start; align-items: flex-end; }
.chat-message.user { align-self: flex-end; justify-content: flex-end; padding-left: 40px; }

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 10px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.message-content {
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    font-size: 14px;
}

/* Balão do BOT */
.chat-message.bot .message-content { 
    background: var(--bot-bg-color, #ffffff); 
    color: var(--bot-text-color, #000000); 
    border-bottom-left-radius: 4px; 
}

/* Balão do USUÁRIO */
.chat-message.user .message-content { 
    background: var(--user-bg-color, var(--elevus-dark-blue, #AA12EA)); 
    color: var(--user-text-color, #ffffff); 
    border-bottom-right-radius: 4px; 
}
#meu-chat .message-content span { background: transparent !important; padding: 0 !important; }

/* --- Rodapé (Input) --- */
#chat-footer {
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border-radius: 0 0 15px 15px;
    flex-shrink: 0; 
}
#chat-form { display: flex; align-items: center; position: relative; }
#chat-input {
    border: 1px solid #ddd;
    background-color: #fff;
    padding: 12px 110px 12px 20px !important;
    flex-grow: 1;
    border-radius: 22px;
    width: 100%;
    color: #333;
}
#chat-input:focus { outline: none; border-color: var(--elevus-teal, #F4207B); }

#chat-form button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(to right, var(--elevus-dark-blue, #AA12EA), var(--elevus-teal, #F4207B)) !important;
    background-size: 200% auto;
    background-position: left center;
    border: none;
    border-radius: 22px; 
    cursor: pointer;
    color: white;
    font-weight: bold;
    font-size: 13px;
    text-transform: uppercase;
    padding: 8px 20px; 
    transition: all 0.4s ease-in-out;
}
#chat-form button::before { content: 'Enviar'; }
#chat-form button:hover { background-position: right center !important; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }

/* Indicador de Digitação */
.typing-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #aaa;
    margin: 0 2px;
    animation: typing-blink 1.4s infinite both;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-blink { 0% { opacity: 0.2; } 20% { opacity: 1; } 100% { opacity: 0.2; } }

/* --- Menu Lateral Flutuante (Add-on) --- */
#meu-chat.has-sidebar {
    right: 90px; 
}
.chat-sidebar-menu {
    position: fixed;
    top: 50%;
    right: 0; 
    transform: translateY(-50%);
    width: 70px;
    background: #fff;
    border-radius: 15px 0 0 15px; 
    box-shadow: -4px 0 15px rgba(0,0,0,0.1); 
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 0;
    gap: 20px;
    z-index: 9998;
    border: 1px solid #f0f0f1;
    border-right: none;
}

.sidebar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #646970;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    position: relative;
}

.sidebar-item::after {
    content: '';
    position: absolute;
    bottom: -10px;
    width: 30px;
    height: 1px;
    background: #eee;
}
.sidebar-item:last-child::after {
    display: none;
}

.sidebar-item:hover, .sidebar-item.active {
    color: var(--elevus-teal, #F4207B);
}

.sidebar-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 5px;
}

.sidebar-item small {
    font-size: 10px;
    font-weight: 600;
}

/* =========================================================
   Botões de Resposta Rápida (Chips Blindados contra o Tema)
   ========================================================= */
#meu-chat .chat-options-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start !important; 
    gap: 8px !important; 
    margin-left: 60px !important; 
    margin-bottom: 20px !important;
}

#meu-chat .chat-option-chip {
    background-color: transparent !important;
    border: 1px solid #333 !important;
    border-radius: 20px !important;
    padding: 8px 15px !important;
    color: #333 !important;
    font-size: 13px !important;
    font-weight: normal !important; 
    font-style: normal !important; 
    text-transform: none !important; 
    cursor: pointer !important;
    text-align: left !important;
    width: max-content !important; 
    max-width: 90% !important; 
    white-space: normal !important; 
    line-height: 1.3 !important;
    transition: all 0.2s ease-in-out !important;
}

#meu-chat .chat-option-chip:hover {
    background-color: var(--elevus-teal, #F4207B) !important;
    color: #fff !important;
    border-color: var(--elevus-teal, #F4207B) !important;
}

#meu-chat .chat-options-hidden {
    display: none !important;
}

/* --- Responsividade: Transforma em menu horizontal no rodapé em telas pequenas --- */
@media (max-width: 768px) {
    #meu-chat.has-sidebar { 
        right: 15px; 
        left: 15px; 
        bottom: 90px; 
    }
    .chat-sidebar-menu { 
        top: auto; 
        transform: none; 
        flex-direction: row; 
        width: auto; 
        height: 60px; 
        bottom: 15px; 
        right: 15px; 
        left: 15px; 
        padding: 0 20px; 
        justify-content: space-around; 
        border-radius: 15px; 
        border-right: 1px solid #f0f0f1;
        box-shadow: 0 5px 20px rgba(0,0,0,0.15); 
    }
    .sidebar-item::after { display: none; }
}