/* ==========================================================
   CONSULTORIA MEDUARDA - CHATBOT IA COM GEMINI
   Design System Editorial de Luxo para Assistente Virtual
   ========================================================== */

/* 1. Botão Flutuante do Chatbot (posicionado acima do WhatsApp) */
.chatbot-float {
    position: fixed;
    right: 1.2rem;
    bottom: 5.2rem;
    z-index: 1030;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-secondary), #1b2012);
    color: #ffffff !important;
    display: grid;
    place-items: center;
    border: 1px solid rgba(217, 197, 178, 0.4);
    box-shadow: 0 10px 28px rgba(44, 51, 29, 0.28);
    cursor: pointer;
    transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 240ms ease;
}

.chatbot-float:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 14px 34px rgba(44, 51, 29, 0.38);
    color: #ffffff;
}

.chatbot-float-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: 50%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.chatbot-float i {
    font-size: 1.4rem;
    color: var(--color-primary-soft);
}

.chatbot-float .ai-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: var(--color-accent);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 999px;
    border: 2px solid #ffffff;
    letter-spacing: 0.04em;
}

/* Ajusta o botão voltar ao topo para ficar acima do chatbot */
.back-to-top {
    bottom: 9.2rem !important;
}

/* 2. Janela do Chatbot */
.chatbot-window {
    position: fixed;
    right: 1.2rem;
    bottom: 1.2rem;
    z-index: 1060;
    width: min(390px, calc(100vw - 2rem));
    height: min(560px, calc(100vh - 3rem));
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid rgba(44, 51, 29, 0.12);
    box-shadow: 0 20px 50px rgba(22, 23, 19, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: opacity 280ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.chatbot-window.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Cabeçalho do Chat */
.chatbot-header {
    background: var(--color-secondary);
    color: #ffffff;
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chatbot-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--color-accent);
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.chatbot-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    display: block;
}

.chatbot-avatar .avatar-status {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 11px;
    height: 11px;
    background: #25d366;
    border: 2px solid var(--color-secondary);
    border-radius: 50%;
}

.chatbot-info h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.chatbot-info span {
    font-size: 0.75rem;
    color: var(--color-primary-soft);
    display: block;
}

.chatbot-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chatbot-btn-icon {
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.75);
    font-size: 1.15rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 180ms ease, color 180ms ease;
}

.chatbot-btn-icon:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

/* Banner de Aviso de Escopo */
.chatbot-notice {
    background: #fdf9f4;
    border-bottom: 1px solid rgba(137, 86, 35, 0.15);
    padding: 0.45rem 1rem;
    font-size: 0.76rem;
    color: #6d461c;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.chatbot-notice i {
    color: var(--color-accent);
    font-size: 0.85rem;
}

/* Área de Mensagens */
.chatbot-messages {
    flex: 1;
    padding: 1.1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background: #fcfbf9;
}

.chat-msg {
    max-width: 85%;
    padding: 0.8rem 1rem;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
    animation: fadeIn 220ms ease;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: #ffffff;
    color: var(--color-text);
    border: 1px solid rgba(44, 51, 29, 0.1);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-msg.assistant p:last-child {
    margin-bottom: 0;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--color-secondary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* Chips de Sugestões Rápidas */
.chatbot-chips {
    padding: 0.5rem 1rem 0.2rem;
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    background: #fcfbf9;
    scrollbar-width: none;
}
.chatbot-chips::-webkit-scrollbar {
    display: none;
}

.chat-chip {
    white-space: nowrap;
    background: #ffffff;
    border: 1px solid rgba(44, 51, 29, 0.15);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-secondary);
    cursor: pointer;
    transition: all 180ms ease;
}

.chat-chip:hover {
    background: var(--color-secondary);
    color: #ffffff;
    border-color: var(--color-secondary);
}

/* Indicador de Digitação */
.typing-indicator {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 0.6rem 0.9rem;
    background: #ffffff;
    border: 1px solid rgba(44, 51, 29, 0.1);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.typing-indicator.active {
    display: inline-flex;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent);
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-5px); opacity: 1; }
}

/* Área de Envio */
.chatbot-form {
    padding: 0.8rem 1rem;
    background: #ffffff;
    border-top: 1px solid rgba(44, 51, 29, 0.08);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chatbot-input {
    flex: 1;
    border: 1px solid rgba(44, 51, 29, 0.18);
    border-radius: 999px;
    padding: 0.6rem 1rem;
    font-size: 0.88rem;
    background: #fdfdfd;
    outline: none;
    transition: border-color 200ms ease;
}

.chatbot-input:focus {
    border-color: var(--color-secondary);
}

.chatbot-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--color-secondary);
    color: #ffffff;
    border: 0;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform 180ms ease, background 180ms ease;
    flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
    transform: scale(1.06);
    background: #1e2414;
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Rodapé do Chatbot */
.chatbot-footer-brand {
    text-align: center;
    font-size: 0.68rem;
    color: #888;
    padding-bottom: 0.4rem;
    background: #ffffff;
}

@media (max-width: 576px) {
    .chatbot-window {
        right: 0.75rem;
        left: 0.75rem;
        bottom: 0.75rem;
        width: auto;
        height: min(520px, calc(100vh - 2rem));
    }
}
