/* ========================================
   GOCLEAN - ASSISTENTE VIRTUAL
   CSS com Bootstrap - Vanilla JavaScript
   ======================================== */

:root {
    --goclean-primary: #1D6BE8;
    --goclean-primary-dark: #1040A0;
    --goclean-primary-light: #60A5FA;
    --goclean-secondary: #F8FAFC;
    --goclean-accent: #60A5FA;
    --goclean-bg: #f9fafb;
    --goclean-text: #1f2937;
    --goclean-text-light: #6b7280;
    --goclean-white: #ffffff;
    --goclean-border: #e5e7eb;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.18);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   BOTÃO FLUTUANTE — posição e alinhamento
   ======================================== */

.floating-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--goclean-white);
    border: none;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(29, 107, 232, 0.35), 0 2px 8px rgba(0,0,0,0.12);
    z-index: 1050; /* acima do navbar (z-index 1000) */
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    outline: none;
}

.floating-btn:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 8px 32px rgba(29, 107, 232, 0.45), 0 4px 12px rgba(0,0,0,0.15);
}

.floating-btn:active {
    transform: scale(1.03);
}

/* Avatar humano no botão flutuante */
.floating-btn .bot-avatar-img {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Fallback: ícone se não tiver foto */
.floating-btn .bot-avatar-icon {
    font-size: 1.6rem;
    color: var(--goclean-primary);
}

/* Badge verde de online no botão */
.floating-btn::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #22C55E;
    border-radius: 50%;
    border: 2.5px solid white;
    animation: pulse-online 2s ease-in-out infinite;
    z-index: 2;
}

@keyframes pulse-online {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
    50%       { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

/* Balão de chamada acima do botão */
.chat-bubble-hint {
    position: fixed;
    bottom: 102px;
    right: 30px;
    background: white;
    border-radius: 14px 14px 4px 14px;
    padding: 10px 16px;
    font-size: 0.82rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--goclean-text);
    box-shadow: var(--shadow-lg);
    z-index: 1049;
    white-space: nowrap;
    animation: hint-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    border: 1px solid rgba(29,107,232,0.1);
    cursor: pointer;
}

.chat-bubble-hint::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 22px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 3px solid transparent;
    border-top: 8px solid white;
}

.chat-bubble-hint .hint-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--goclean-primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
    margin-bottom: 2px;
}

.chat-bubble-hint.hidden {
    display: none;
}

@keyframes hint-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========================================
   SCROLL TOP — alinhado à esquerda do bot
   ======================================== */

/* O botão scroll-top do styles.css ficará posicionado
   corretamente. Aqui garantimos que não conflite. */

/* ========================================
   MODAL DO CHAT
   ======================================== */

.chat-modal {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 360px;
    max-height: 80vh;
    height: 500px;
    background: var(--goclean-white);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 20px rgba(29,107,232,0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1100; /* acima de tudo, inclusive navbar */
    border: 1px solid rgba(29, 107, 232, 0.08);
}

.chat-modal.active {
    display: flex;
    animation: slideUpEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-modal.closing {
    animation: slideDownExit 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

@keyframes slideUpEnter {
    from { opacity: 0; transform: translateY(24px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideDownExit {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(24px) scale(0.95); }
}

/* ========================================
   HEADER DO CHAT — visual humanizado
   ======================================== */

.chat-header {
    background: linear-gradient(135deg, #1D6BE8 0%, #0D306B 100%);
    color: var(--goclean-white);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

/* Avatar com foto humana */
.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,0.4);
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    flex-shrink: 0;
    overflow: hidden;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Fallback icon se não houver imagem */
.chat-avatar i {
    font-size: 1.5rem;
    color: rgba(255,255,255,0.9);
}

/* Badge online dentro do avatar */
.chat-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    background: #22C55E;
    border-radius: 50%;
    border: 2px solid white;
}

.chat-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chat-title {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: white;
}

.chat-status {
    font-size: 0.72rem;
    opacity: 0.88;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255,255,255,0.85);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #75fdae;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

.btn-close-chat {
    background: rgba(255,255,255,0.12);
    border: none;
    color: var(--goclean-white);
    font-size: 1.1rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.btn-close-chat:hover {
    background: rgba(255,255,255,0.25);
    transform: rotate(90deg);
}

/* ========================================
   ÁREA DE MENSAGENS
   ======================================== */

.chat-messages {
    flex: 1;
    padding: 18px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background-color: #F4F6F8;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(29,107,232,0.25); border-radius: 4px; }

/* Mensagens */
.message {
    max-width: 85%;
    padding: 11px 15px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.6;
    position: relative;
    animation: messageSlideIn 0.28s ease-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-family: 'Poppins', sans-serif;
}

@keyframes messageSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #1D6BE8 0%, #1040A0 100%);
    color: var(--goclean-white);
    border-bottom-right-radius: 4px;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(29,107,232,0.3);
}

/* ========================================
   INDICADOR DE DIGITAÇÃO
   ======================================== */

.typing-indicator {
    display: none;
    align-self: flex-start;
    background: var(--goclean-white);
    padding: 12px 16px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    gap: 5px;
    align-items: center;
    border: 1px solid rgba(0,0,0,0.06);
}

.typing-indicator span {
    height: 7px;
    width: 7px;
    background: #93C5FD;
    display: inline-block;
    border-radius: 50%;
    animation: typingBounce 1.3s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.18s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-7px); opacity: 1; }
}

/* ========================================
   INPUT DO CHAT
   ======================================== */

.chat-input-container {
    display: flex;
    gap: 8px;
    padding: 14px 16px;
    background: var(--goclean-white);
    border-top: 1px solid rgba(0,0,0,0.07);
    flex-shrink: 0;
}

.chat-input-container[style*="display: none"] { display: none !important; }

.chat-input {
    flex: 1;
    padding: 11px 14px;
    border: 1.5px solid #E2E8F0;
    border-radius: 10px;
    font-size: 0.875rem;
    font-family: 'Poppins', sans-serif;
    transition: var(--transition-fast);
    outline: none;
    color: var(--goclean-text);
    background: #F8FAFC;
}

.chat-input:focus {
    border-color: var(--goclean-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(29,107,232,0.1);
}

.chat-input::placeholder {
    color: #94A3B8;
}

.chat-textarea {
    resize: none;
    min-height: 56px;
    max-height: 110px;
    line-height: 1.5;
}

.btn-send {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #1D6BE8 0%, #1040A0 100%);
    border: none;
    border-radius: 10px;
    color: var(--goclean-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition-fast);
    box-shadow: 0 2px 8px rgba(29,107,232,0.3);
    outline: none;
    flex-shrink: 0;
    align-self: flex-end;
}

.btn-send:hover { transform: scale(1.06); box-shadow: 0 4px 14px rgba(29,107,232,0.4); }
.btn-send:active { transform: scale(0.95); }

/* ========================================
   BOTÕES DE AÇÃO (Quick Replies)
   ======================================== */

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 6px;
    align-self: flex-start;
    width: 90%;
}

.action-btn {
    background: var(--goclean-white);
    border: 1.5px solid #BFDBFE;
    color: #1D6BE8;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 0.84rem;
    cursor: pointer;
    transition: all 0.22s ease;
    font-weight: 600;
    text-align: left;
    width: 100%;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.action-btn:hover {
    background: #1D6BE8;
    color: white;
    border-color: #1D6BE8;
    transform: translateX(4px);
    box-shadow: 0 3px 12px rgba(29,107,232,0.28);
}

.action-btn:active { transform: translateX(2px); }

/* ========================================
   RESPONSIVIDADE
   ======================================== */

@media (max-width: 768px) {
    .chat-modal {
        width: calc(100% - 32px);
        max-width: 370px;
        right: 16px;
        bottom: 96px;
        height: 500px;
        max-height: 72vh;
        border-radius: 16px;
    }

    .floating-btn {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .floating-btn .bot-avatar-img { width: 56px; height: 56px; }

    .chat-bubble-hint {
        bottom: 86px;
        right: 20px;
        font-size: 0.78rem;
    }

    .message { max-width: 90%; }
}

@media (max-width: 425px) {
    .chat-modal {
        width: calc(100% - 24px);
        right: 12px;
        bottom: 88px;
        height: 470px;
        max-height: 68vh;
    }

    .floating-btn {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .floating-btn .bot-avatar-img { width: 52px; height: 52px; }

    .chat-bubble-hint { right: 16px; bottom: 80px; }

    .message { max-width: 92%; font-size: 0.84rem; }
    .chat-title { font-size: 0.85rem; }
    .chat-status { font-size: 0.68rem; }
    .chat-avatar { width: 42px; height: 42px; }
    .action-btn { padding: 10px 12px; font-size: 0.8rem; }
    .chat-input-container { padding: 10px 12px; }
    .chat-input { padding: 9px 12px; font-size: 0.83rem; }
    .btn-send { width: 36px; height: 36px; font-size: 1rem; }
}

/* ========================================
   ACESSIBILIDADE
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   UTILITÁRIOS
   ======================================== */
.hidden  { display: none !important; }
.visible { display: block !important; }