/* ========================================
   CLÍNICA KARINA - ASSISTENTE VIRTUAL
   ESTILOS MODERNOS, PROFISSIONAIS E RESPONSIVOS
   ======================================== */

:root {
    --color-primary: #25d366;
    --color-secondary: #1a1a1a;
    --color-bg-light: #f0f2f5;
    --color-white: #ffffff;
    --color-text-dark: #1c1e21;
    --color-text-muted: #65676b;
    --color-online: #4cd137;
    --color-shadow: rgba(0, 0, 0, 0.15);
    --radius-full: 50%;
    --radius-bubble: 18px;
    --radius-chat: 16px;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --z-assistant: 1000;
    --z-chat: 1001;
    
    /* Variáveis de Alinhamento */
    --fab-right: 30px;
    --fab-bottom: 30px;
    --fab-size: 60px;
    --st-btn-size: 50px;
    --st-btn-bottom: 105px;
}

@media (max-width: 576px) {
    :root {
        --fab-right: 20px;
        --fab-bottom: 20px;
        --fab-size: 55px;
        --st-btn-size: 45px;
        --st-btn-bottom: 85px;
    }
}

/* ========================================
   WIDGET DO ASSISTENTE
   ======================================== */
.assistant-widget {
    position: fixed;
    bottom: var(--fab-bottom);
    right: var(--fab-right);
    z-index: var(--z-assistant);
    display: flex;
    flex-direction: row; /* Alterado para row para a nuvem ficar à esquerda */
    align-items: flex-end;
    gap: 15px;
}

.floating-btn-wrapper {
    display: flex;
    flex-direction: row; /* Alterado para row para a nuvem ficar à esquerda */
    align-items: flex-end;
    gap: 15px;
}

.bot-floating-btn {
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: var(--radius-full);
    background-color: var(--color-white);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--color-shadow);
    position: relative;
    padding: 0;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    order: 2; /* Garante que o botão fique à direita da nuvem */
}

.bot-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.fab-avatar {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
    display: block;
}

.bot-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background-color: var(--color-online);
    border: 2px solid var(--color-white);
    border-radius: var(--radius-full);
}

/* Bolha de Boas-vindas (Agora à ESQUERDA do robô) */
.fab-bubble {
    background: var(--color-white);
    padding: 12px 18px;
    border-radius: var(--radius-bubble) var(--radius-bubble) 0 var(--radius-bubble);
    box-shadow: 0 4px 15px var(--color-shadow);
    position: relative;
    max-width: 240px;
    animation: fadeInRight 0.5s ease forwards;
    margin-bottom: 5px;
    order: 1; /* Fica antes do botão no flex row */
}

.fab-bubble-name {
    display: block;
    font-weight: 700;
    font-size: 14px;
    color: var(--color-secondary);
    margin-bottom: 2px;
}

.fab-bubble-text {
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.4;
    white-space: nowrap;
}

.fab-bubble-close {
    position: absolute;
    top: -10px;
    right: -10px; /* Invertido para o lado direito da bolha */
    background: #f0f0f0;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.fab-bubble-close:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========================================
   CONTAINER DO CHAT
   ======================================== */
.bot-chat-container {
    position: fixed;
    bottom: var(--st-btn-bottom);
    right: var(--fab-right);
    width: 360px;
    max-width: calc(100vw - 60px);
    height: 550px;
    max-height: calc(100vh - 160px);
    background: var(--color-white);
    border-radius: var(--radius-chat);
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: var(--z-chat);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: var(--transition-normal);
}

.bot-chat-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.bot-chat-header {
    background: var(--color-secondary);
    color: var(--color-white);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    border: 2px solid rgba(255,255,255,0.15);
    object-fit: cover;
}

.header-name {
    display: block;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.3px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    opacity: 0.85;
}

.header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--color-online);
    border-radius: 50%;
}

.bot-header-actions {
    display: flex;
    gap: 10px;
}

.bot-back-btn, .bot-close-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--color-white);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.bot-back-btn:hover, .bot-close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.bot-messages-list {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: var(--color-bg-light);
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.bot-messages-list::-webkit-scrollbar {
    width: 5px;
}

.bot-messages-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

/* Estilo das Mensagens */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message.bot {
    align-self: flex-start;
    background: var(--color-white);
    color: var(--color-text-dark);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.message.user {
    align-self: flex-end;
    background: var(--color-primary);
    color: var(--color-white);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.2);
}

/* Botões de Ação */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 5px;
    width: 100%;
}

.action-btn {
    background: var(--color-white);
    border: 1px solid #e0e0e0;
    color: var(--color-text-dark);
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    text-align: left;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.action-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: #fafffa;
    transform: translateX(5px);
}

/* Input de Nome / Texto */
.name-input-container {
    padding: 15px 20px;
    background: var(--color-white);
    border-top: 1px solid #eee;
    display: flex;
    gap: 12px;
    align-items: center;
}

.name-input-container input {
    flex: 1;
    border: 1px solid #e4e6eb;
    padding: 12px 18px;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    background: #f0f2f5;
    transition: 0.2s;
}

.name-input-container input:focus {
    background: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.name-input-container button {
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}

.name-input-container button:hover {
    transform: scale(1.05);
    filter: brightness(1.05);
}

/* Indicador de Digitação */
.typing-indicator {
    padding: 10px 15px;
    display: flex;
    gap: 5px;
    background: var(--color-white);
    width: fit-content;
    border-radius: 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #bcc0c4;
    border-radius: var(--radius-full);
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* ========================================
   RESPONSIVIDADE (MOBILE)
   ======================================== */
@media (max-width: 576px) {
    .assistant-widget {
        bottom: var(--fab-bottom);
        right: var(--fab-right);
        gap: 10px;
    }

    .bot-chat-container {
        bottom: var(--st-btn-bottom);
        right: var(--fab-right);
        width: calc(100vw - 40px);
        height: 480px;
        max-height: calc(100vh - 120px);
        border-radius: 16px;
    }

    .fab-bubble {
        max-width: 180px;
        padding: 10px 14px;
    }

    .fab-bubble-text {
        font-size: 13px;
    }
}

/* ========================================
   BOTÃO VOLTAR AO TOPO (#stBtn)
   ======================================== */
#stBtn {
    position: fixed;
    bottom: var(--st-btn-bottom);
    right: var(--fab-right);
    width: var(--st-btn-size);
    height: var(--st-btn-size);
    background: var(--color-white);
    color: var(--color-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--color-shadow);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
    z-index: 999;
    border: none;
    margin-right: calc((var(--fab-size) - var(--st-btn-size)) / 2);
}

#stBtn.on {
    opacity: 1;
    visibility: visible;
}

#stBtn:hover {
    background: var(--color-secondary);
    color: var(--color-white);
    transform: translateY(-5px);
}

#stBtn::before {
    content: '\f106';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 20px;
}
