/**
 * FAQ Chat Styles
 * Version: 1.0.0
 * Author: Hueini David
 */

/* Botão Flutuante - Estilo igual aos botões sociais, mas redondo */
.chat-faq-float {
    position: fixed !important;
    bottom: 120px !important;
    right: 40px !important;
    width: 60px !important;
    height: 60px !important;
    background: var(--bg-color) !important;
    color: #fff !important;
    border-radius: 50% !important; /* Botão redondo */
    padding: 0.5rem !important; /* Padding igual aos botões sociais para borda aparecer */
    /* Borda padrão igual aos botões sociais */
    border: 1px solid var(--hover-color) !important;
    outline: 2px solid var(--bg-color) !important;
    outline-offset: 0 !important; /* Sem offset para outline aparecer */
    box-shadow: var(--neon-box-shadow) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: move !important; /* Cursor de arrastar */
    z-index: 10000 !important;
    transition: box-shadow 0.3s, border 0.3s, outline 0.3s !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    user-select: none !important; /* Prevenir seleção de texto */
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    touch-action: none !important; /* Melhor controle em touch devices */
    overflow: visible !important; /* Mudado para visible para borda aparecer */
    box-sizing: border-box !important; /* Incluir borda no cálculo do tamanho */
    margin: 0 !important; /* Remover margens que podem afetar o outline */
}

/* Imagem dentro do botão - Aumentada e ajustada para botão redondo */
.chat-faq-float img {
    width: 160% !important; /* Aumentada para 95% do tamanho do botão */
    height: 160% !important; /* Aumentada para 95% do tamanho do botão */
    max-width: 160% !important;
    max-height: 160% !important;
    object-fit: contain !important;
    border-radius: 50% !important; /* Imagem também redonda */
    transition: all 0.3s ease !important;
    display: block !important;
}

.chat-faq-float:hover {
    transform: translateY(-3px) !important; /* Igual ao botão de idiomas */
    box-shadow: 0 0 20px var(--hover-color) !important; /* Igual ao botão de idiomas */
    border-color: var(--hover-color) !important;
}

.chat-faq-float:hover img {
    filter: brightness(1.1) !important; /* Igual ao botão de idiomas */
}

.chat-faq-float:active {
    cursor: grabbing !important; /* Cursor ao arrastar */
    transform: translateY(-1px) !important; /* Pequeno movimento ao clicar */
}

/* Container do Chat */
.chat-faq-container {
    position: fixed;
    bottom: 190px;
    right: 40px;
    width: 370px;
    min-width: 300px;
    min-height: 400px;
    max-width: calc(100vw - 80px);
    max-height: calc(100vh - 80px);
    background: var(--bg-color);
    border-radius: 8px; /* Igual ao LinkedIn */
    /* Borda igual ao botão de idiomas */
    border: 1px solid var(--hover-color);
    outline: 2px solid var(--bg-color);
    box-shadow: var(--neon-box-shadow);
    z-index: 9999; /* Um pouco menor que o botão para ficar atrás */
    color: #fff;
    display: none;
    flex-direction: column;
    transition: box-shadow 0.3s, border 0.3s, outline 0.3s; /* Transição suave (sem width/height/left/top para resize suave) */
    resize: none; /* Desabilitar resize padrão do navegador */
    overflow: hidden;
}

.chat-faq-container:hover {
    box-shadow: 0 0 20px var(--hover-color);
    border-color: var(--hover-color);
}

.chat-faq-container.show {
    display: flex !important;
}

/* Header */
.chat-faq-header {
    background: #1a1a1a;
    color: #12f7ff;
    padding: 16px 20px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    font-weight: 600;
    font-size: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-faq-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-faq-maximize,
.chat-faq-close {
    background: none;
    border: none;
    color: #12f7ff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
}

.chat-faq-maximize:hover,
.chat-faq-close:hover {
    background: rgba(18, 247, 255, 0.1);
    transform: scale(1.1);
}

.chat-faq-maximize:hover {
    color: #12f7ff;
}

.chat-faq-close:hover {
    color: #ff0056;
}

.chat-faq-maximize svg {
    width: 16px;
    height: 16px;
    transition: opacity 0.2s;
}

/* Estado maximizado */
.chat-faq-container.maximized {
    width: calc(100vw - 40px) !important;
    height: calc(100vh - 40px) !important;
    max-width: none !important;
    bottom: 20px !important;
    right: 20px !important;
    left: 20px !important;
    top: 20px !important;
    border-radius: 12px;
    position: fixed !important;
}

.chat-faq-container.maximized .chat-faq-body {
    max-height: calc(100vh - 200px) !important;
    height: auto !important;
}

.chat-faq-container.maximized .chat-faq-maximize .maximize-icon {
    display: none;
}

.chat-faq-container.maximized .chat-faq-maximize .restore-icon {
    display: block !important;
}

/* Handles de Resize */
.chat-resize-handle {
    position: absolute;
    background: transparent;
    z-index: 10001;
    pointer-events: auto; /* Permitir interação apenas quando necessário */
}

/* Quinas (diagonal resize) */
.chat-resize-handle.nw {
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    cursor: nw-resize;
}

.chat-resize-handle.ne {
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: ne-resize;
}

.chat-resize-handle.sw {
    bottom: 0;
    left: 0;
    width: 20px;
    height: 20px;
    cursor: sw-resize;
}

.chat-resize-handle.se {
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
}

/* Bordas (horizontal/vertical resize) */
.chat-resize-handle.n {
    top: 0;
    left: 20px;
    right: 20px;
    height: 10px;
    cursor: n-resize;
}

.chat-resize-handle.s {
    bottom: 0;
    left: 20px;
    right: 20px;
    height: 10px;
    cursor: s-resize;
}

.chat-resize-handle.e {
    top: 60px; /* Começar abaixo do header */
    bottom: 80px; /* Acima do footer */
    right: 0;
    width: 8px; /* Reduzido para não interferir com scroll */
    cursor: e-resize;
}

.chat-resize-handle.w {
    top: 60px; /* Começar abaixo do header */
    bottom: 80px; /* Acima do footer */
    left: 0;
    width: 8px; /* Reduzido para não interferir com scroll */
    cursor: w-resize;
}

/* Visual feedback ao passar o mouse */
.chat-resize-handle:hover {
    background: rgba(18, 247, 255, 0.2);
    z-index: 10002; /* Aumentar z-index no hover para feedback visual */
}

/* Quando não está em resize, handles laterais não devem bloquear scroll */
.chat-resize-handle.e:not(:hover):not(.active),
.chat-resize-handle.w:not(:hover):not(.active) {
    pointer-events: none; /* Desabilitar quando não está em hover ou ativo */
}

/* Reativar pointer-events quando necessário (via JavaScript durante resize) */
.chat-faq-container.resizing .chat-resize-handle {
    pointer-events: auto !important;
}

/* Desabilitar resize quando maximizado */
.chat-faq-container.maximized .chat-resize-handle {
    display: none;
}

/* Body */
.chat-faq-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden; /* Prevenir scroll horizontal */
    max-height: 400px;
    min-height: 200px;
    background: #0f0f0f;
    /* Imagem de fundo estilo WhatsApp */
    background-image: url('../img/chat/fundo.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: local; /* Fixa durante scroll */
    position: relative;
    z-index: 1; /* Garantir que fique acima dos handles quando necessário */
    pointer-events: auto; /* Permitir scroll */
}

/* Overlay escuro para melhorar legibilidade */
.chat-faq-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 15, 0.3); /* Overlay escuro semi-transparente (reduzido para mostrar mais a imagem) */
    pointer-events: none; /* Não interfere com interações */
    z-index: 0;
}

/* Garantir que mensagens fiquem acima do overlay */
.chat-faq-body > * {
    position: relative;
    z-index: 1;
}

.chat-faq-body::-webkit-scrollbar {
    width: 8px;
}

.chat-faq-body::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.chat-faq-body::-webkit-scrollbar-thumb {
    background: #12f7ff;
    border-radius: 4px;
}

.chat-faq-body::-webkit-scrollbar-thumb:hover {
    background: #0ea8b0;
}

/* Mensagens */
.chat-message {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: 8px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    z-index: 2; /* Garantir que fique acima do overlay */
    backdrop-filter: blur(1px); /* Efeito de vidro fosco sutil */
}

.chat-message.user {
    background: rgba(26, 26, 26, 0.85); /* Semi-transparente para mostrar fundo */
    color: #fff;
    margin-left: 20%;
    text-align: right;
    backdrop-filter: blur(2px); /* Efeito de vidro fosco */
}

.chat-message.bot {
    background: rgba(18, 247, 255, 0.15); /* Mais visível sobre o fundo */
    color: #12f7ff;
    margin-right: 20%;
    border: 1px solid rgba(18, 247, 255, 0.3);
    backdrop-filter: blur(2px); /* Efeito de vidro fosco */
}

.chat-message.error {
    background: rgba(255, 0, 86, 0.2); /* Mais visível sobre o fundo */
    color: #ff0056;
    margin-right: 20%;
    border: 1px solid rgba(255, 0, 86, 0.3);
    backdrop-filter: blur(2px); /* Efeito de vidro fosco */
}

.chat-message strong {
    color: #12f7ff;
    font-weight: 600;
}

.chat-message.error strong {
    color: #ff0056;
}

/* Efeito de digitação */
.typing-text {
    display: inline;
}

.typing-cursor {
    display: inline-block;
    animation: blink 1s infinite;
    color: #12f7ff;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Footer */
.chat-faq-footer {
    background: #1a1a1a;
    padding: 16px 20px;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    display: flex;
    gap: 12px;
    border-top: 1px solid rgba(18, 247, 255, 0.2);
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0; /* Não encolher */
    align-items: center; /* Alinhar verticalmente */
}

.chat-faq-footer input {
    flex: 1 1 auto; /* Crescer e encolher conforme necessário */
    min-width: 0; /* Permitir que encolha abaixo do tamanho do conteúdo */
    width: 100%; /* Ocupar toda largura disponível */
    max-width: 100%; /* Não ultrapassar o container */
    background: #0f0f0f;
    border: 1px solid rgba(18, 247, 255, 0.3);
    border-radius: 6px;
    padding: 12px 16px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box; /* Incluir padding e border no cálculo da largura */
}

.chat-faq-footer input:focus {
    border-color: #12f7ff;
    box-shadow: 0 0 8px rgba(18, 247, 255, 0.3);
}

.chat-faq-footer input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.chat-faq-footer button {
    background: #12f7ff;
    color: #000;
    border: none;
    border-radius: 6px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0; /* Não encolher o botão */
    white-space: nowrap; /* Não quebrar texto do botão */
    min-width: fit-content; /* Largura mínima baseada no conteúdo */
}

.chat-faq-footer button:hover:not(:disabled) {
    background: #0ea8b0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(18, 247, 255, 0.4);
}

.chat-faq-footer button:disabled {
    background: rgba(18, 247, 255, 0.3);
    color: rgba(0, 0, 0, 0.5);
    cursor: not-allowed;
}

/* Mobile */
@media (max-width: 768px) {
    .chat-faq-container {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        bottom: 100px !important;
        right: 10px !important;
        left: 10px !important;
    }
    
    .chat-faq-float {
        bottom: 100px !important; /* Subido para ficar acima do botão do menu */
        right: 20px !important;
    }
    
    .chat-message.user {
        margin-left: 10%;
    }
    
    .chat-message.bot {
        margin-right: 10%;
    }
}
