/* MECAL Chat Plugin Styles */

.mecal-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Botão flutuante */
#mecal-chat-button {
    background-color: #004d99;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 77, 153, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#mecal-chat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 77, 153, 0.5);
}

/* Caixa do chat */
#mecal-chat-box {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

#mecal-chat-box.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

@keyframes chat-slide-up {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Cabeçalho */
.mecal-chat-header {
    background: linear-gradient(135deg, #004d99, #0066cc);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.mecal-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mecal-chat-header-info img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
    padding: 2px;
}

.mecal-chat-header-info span {
    font-weight: 600;
    font-size: 15px;
}

#mecal-chat-close {
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    opacity: 0.85;
    transition: opacity 0.15s;
}

#mecal-chat-close:hover {
    opacity: 1;
}

/* Área de mensagens */
.mecal-chat-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    background: #f4f6f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mecal-chat-body::-webkit-scrollbar { width: 4px; }
.mecal-chat-body::-webkit-scrollbar-track { background: transparent; }
.mecal-chat-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* Mensagens */
.mecal-chat-message {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.mecal-chat-message.user {
    background: #004d99;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.mecal-chat-message.ia {
    background: #fff;
    color: #222;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Conteúdo formatado dentro da mensagem da IA */
.mecal-chat-message.ia p { margin: 0 0 6px; }
.mecal-chat-message.ia p:last-child { margin-bottom: 0; }
.mecal-chat-message.ia ul,
.mecal-chat-message.ia ol { margin: 4px 0 4px 18px; padding: 0; }
.mecal-chat-message.ia li { margin-bottom: 2px; }
.mecal-chat-message.ia h4,
.mecal-chat-message.ia h5,
.mecal-chat-message.ia h6 { margin: 6px 0 4px; font-size: 14px; }
.mecal-chat-message.ia code {
    background: #f0f0f0;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
}
.mecal-chat-message.ia strong { font-weight: 600; }
.mecal-chat-message.ia a { color: #004d99; text-decoration: underline; }
.mecal-chat-message.ia hr { border: none; border-top: 1px solid #ddd; margin: 6px 0; }
.chat-br { height: 4px; }

/* Indicador de digitação */
.ia-typing {
    align-self: flex-start;
    background: #fff;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    gap: 4px;
    align-items: center;
}

.ia-typing span {
    width: 7px;
    height: 7px;
    background: #888;
    border-radius: 50%;
    animation: chat-bounce 1.2s infinite;
}

.ia-typing span:nth-child(2) { animation-delay: 0.2s; }
.ia-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* Rodapé / input */
.mecal-chat-footer {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #e8e8e8;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}

#mecal-chat-input {
    flex: 1;
    padding: 9px 14px;
    border: 1.5px solid #ddd;
    border-radius: 22px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #f9f9f9;
}

#mecal-chat-input:focus {
    border-color: #004d99;
    background: #fff;
}

#mecal-chat-send {
    background: #004d99;
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

#mecal-chat-send:hover  { background: #003a75; transform: scale(1.05); }
#mecal-chat-send:active { transform: scale(0.96); }
#mecal-chat-send:disabled { background: #aaa; cursor: not-allowed; transform: none; }

/* Responsivo mobile */
@media (max-width: 480px) {
    .mecal-chat-container { bottom: 16px; right: 16px; }

    #mecal-chat-box {
        width: calc(100vw - 32px);
        height: 70vh;
        bottom: 68px;
        right: 0;
    }

    #mecal-chat-button { width: 52px; height: 52px; }
}
