/* ==========================================================================
   VARIÁVEIS DE CORES DINÂMICAS (MODO CLARO POR PADRÃO)
   ========================================================================== */
:root {
    --bg-global: #edf2f7;
    --bg-card: #ffffff;
    --texto-principal: #2d3748;
    --texto-secundario: #4a5568;
    --texto-mutado: #718096;
    --borda: #e2e8f0;
    --borda-input: #cbd5e0;
    --primary: #3182ce;
    --primary-hover: #2b6cb0;
    --bg-topo-chat: linear-gradient(135deg, #1a202c, #2d3748);
    --bg-cliente-chat: #ffffff;
}

/* PALETA DE CORES DO MODO ESCURO */
[data-theme="dark"] {
    --bg-global: #121620;
    --bg-card: #1a202c;
    --texto-principal: #f7fafc;
    --texto-secundario: #e2e8f0;
    --texto-dark-orange: #FC8322;
    --texto-mutado: #a0aec0;
    --borda: #2d3748;
    --borda-input: #4a5568;
    --primary: #4299e1;
    --primary-hover: #3182ce;
    --bg-topo-chat: linear-gradient(135deg, #2d3748, #4a5568);
    --bg-cliente-chat: #2d3748;
}

/* ==========================================================================
   CONFIGURAÇÕES GLOBAIS E TIPOGRAFIA
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-global);
    color: var(--texto-principal);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   BOTÃO DE MODO ESCURO APENAS ÍCONE (CIRCULAR E COMPACTO)
   ========================================================================== */
.btn-dark-toggle-icone {
    background: var(--bg-card);
    border: 1px solid var(--borda-input);
    width: 40px;
    height: 40px;
    border-radius: 50%; /* Torna o botão um círculo perfeito */
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.btn-dark-toggle-icone:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}


/* ==========================================================================
   CABEÇALHO PÚBLICO
   ========================================================================== */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--borda);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

header h1 {
    font-size: 1.5rem;
    color: var(--texto-principal);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-controles {
    display: flex;
    align-items: center;
    gap: 20px;
}

header nav a {
    color: var(--texto-secundario);
    text-decoration: none;
    font-weight: 500;
    margin: 0 10px;
    font-size: 0.95rem;
}

header nav a:hover {
    color: var(--primary);
}

/* ==========================================================================
   MENU DE CATEGORIAS E BUSCA UNIFICADOS (RESPONSIVO)
   ========================================================================== */
.menu-categorias-wrapper {
    max-width: 800px;
    margin: 20px auto 30px auto;
    padding: 0 20px;
    width: 100%;
}

.btn-categoria-toggle {
    display: none;
    width: 100%;
    background: var(--bg-card);
    color: var(--texto-secundario);
    border: 1px solid var(--borda-input);
    padding: 14px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.seta-cat {
    float: right;
    transition: transform 0.2s ease;
    font-size: 0.8rem;
}

.menu-categorias {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lista-links-cat {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.lista-links-cat a {
    color: var(--texto-secundario);
    text-decoration: none;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--borda);
    transition: all 0.2s ease;
}

.lista-links-cat a:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.form-busca-integrado {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.form-busca-integrado input[type="text"] {
    flex: 1;
    padding: 12px 18px;
    border: 1px solid var(--borda-input);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--bg-card);
    color: var(--texto-principal);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
    transition: border 0.2s;
}

.form-busca-integrado input[type="text"]:focus {
    border-color: var(--primary);
    outline: none;
}

.form-busca-integrado button {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.form-busca-integrado button:hover {
    background: var(--primary-hover);
}

.btn-limpar-filtros {
    font-size: 0.9rem;
    color: #e53e3e;
    text-decoration: none;
    white-space: nowrap;
}

/* ==========================================================================
   CONTEÚDO PRINCIPAL (FEED DE ARTIGOS)
   ========================================================================== */
main {
    max-width: 800px;
    margin: 40px auto 10px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
}

article {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;
}

article:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

article h3 a, article h1 {
    color: var(--texto-principal);
    text-decoration: none;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.3;
}

article h3 a:hover {
    color: var(--primary);
}

article small {
    display: block;
    color: var(--texto-mutado);
    margin: 8px 0 15px 0;
    font-size: 0.85rem;
}

article small strong {
    color: var(--texto-secundario);
}

article small mark {
    background: #ebf8ff;
    color: #2b6cb0;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

article p {
    color: var(--texto-secundario);
    margin-bottom: 15px;
}

article a {
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.95rem;
}

article img {
    width: 100%;
    max-height: 450px;
    object-fit: cover;
    border-radius: 8px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ==========================================================================
   BLOCO DE PAGINAÇÃO
   ========================================================================== */
.paginacao {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
}

.paginacao a {
    color: var(--texto-secundario);
    text-decoration: none;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--borda);
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.paginacao a:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ==========================================================================
   SISTEMA DE COMENTÁRIOS (PÁGINA INTERNA)
   ========================================================================== */
.secao-comentarios {
    width: 100%;
    margin: 40px 0;
    padding: 30px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.secao-comentarios h3 {
    margin-bottom: 20px;
    font-size: 1.25rem;
    color: var(--texto-principal);
}

.secao-comentarios form {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.secao-comentarios textarea {
    width: 100%;
    max-width: 100%;
    padding: 15px;
    border: 1px solid var(--borda-input);
    border-radius: 8px;
    font-size: 0.95rem;
    resize: vertical;
    background: var(--bg-card);
    color: var(--texto-principal);
}

.secao-comentarios button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    align-self: flex-start;
}

.secao-comentarios button:hover {
    background: var(--primary-hover);
}

.lista-comentarios div {
    background: var(--bg-global) !important;
    border: 1px solid var(--borda);
    border-left: 4px solid var(--primary) !important;
    border-radius: 8px;
    padding: 15px !important;
    margin-bottom: 15px;
    color: var(--texto-principal);
}

/* ==========================================================================
   WIDGET DE CHAT FLUTUANTE
   ========================================================================== */
.widget-chat {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

.chat-botao-abrir {
    background: linear-gradient(135deg, #3182ce, #2b6cb0);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(49, 130, 206, 0.35);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

/* Adicione este bloco no seu front.css */
.chat-botao-abrir:hover {
    transform: scale(1.1);            /* Mantém o leve efeito de crescer */
    background: #B6CADC !important;   /* Aplica o tom cinza-azulado exato */
    color: #2d3748 !important;       /* Muda o emoji de dentro para grafite para dar contraste */
}


.chat-janela {
    display: none;
    flex-direction: column;
    width: 360px;
    height: 480px;
    background: var(--bg-card);
    border: 1px solid var(--borda);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    right: 0;
}

.chat-topo {
    background: var(--bg-topo-chat);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-corpo {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-global);
}

.chat-linha-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    width: 100%;
}

.chat-linha-wrapper.msg-cliente { flex-direction: row; }
.chat-linha-wrapper.msg-admin { flex-direction: row-reverse; }

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.msg-cliente .chat-avatar { background: #718096; }
.msg-admin .chat-avatar { background: #dd6b20; }

.chat-balao {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.msg-cliente .chat-balao {
    background: var(--bg-cliente-chat);
    border: 1px solid var(--borda);
    color: var(--texto-principal);
    border-bottom-left-radius: 2px;
}

.msg-admin .chat-balao {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-rodape-input {
    padding: 15px;
    background: var(--bg-card);
    border-top: 1px solid var(--borda);
    display: flex;
    gap: 8px;
}

.chat-rodape-input input {
    flex: 1;
    border: 1px solid var(--borda-input);
    background: var(--bg-card);
    color: var(--texto-principal);
    padding: 10px 14px;
    border-radius: 25px;
}

/* ==========================================================================
   VOLTAR AO TOPO E RODAPÉ
   ========================================================================== */
.btn-voltar-topo {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    border: 1px solid var(--borda);
    color: var(--texto-principal);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
    z-index: 9998;
}
.btn-voltar-topo.visivel { opacity: 1; visibility: visible; }
.btn-voltar-topo:hover { background: var(--primary); color: white; border-color: var(--primary); }

footer {
    text-align: center;
    color: var(--texto-mutado);
    font-size: 0.85rem;
    background: var(--bg-card);
    border-top: 1px solid var(--borda);
    padding: 25px 0;
    width: 100%;
    margin-top: auto;
}

/* ==========================================================================
   REGRAS EXCLUSIVAS PARA CELULAR (MEDIA QUERIES COMPLETO E ANIMADO)
   ========================================================================== */
@media (max-width: 768px) {
    /* Força o cabeçalho a virar uma coluna vertical sem vazar da tela */
    header {
        display: flex;
        flex-direction: column;
        gap: 20px;
        padding: 25px 15px;
        text-align: center;
        align-items: center;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    /* Garante que a imagem do logotipo encolha proporcionalmente */
    header h1 img {
        max-width: 85%;
        height: auto;
        max-height: 70px;
        display: block;
        margin: 0 auto;
    }

    /* Organiza o bloco de controles em uma única linha horizontal centralizada abaixo do logo */
    .header-controles {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 15px;
        width: 100%;
        flex-wrap: wrap;
    }

    /* Remove margens forçadas e integra o botão na linha horizontal */
    .btn-dark-toggle-icone {
        margin: 0 !important;
        flex-shrink: 0;
    }

    /* Alinha os links de texto na horizontal, logo ao lado do botão */
    header nav {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 15px;
    }

    /* Mantém os links como texto simples, limpos e sem formato de botão */
    header nav a {
        display: inline-block;
        background: transparent !important;
        color: var(--texto-secundario) !important;
        border: none !important;
        padding: 5px 0 !important;
        width: auto !important;
        text-align: center;
        font-weight: 600;
        font-size: 0.95rem;
        box-shadow: none !important;
        text-decoration: none;
        white-space: nowrap;
    }

    header nav a:hover {
        color: var(--primary) !important;
        text-decoration: underline;
    }

    /* Exibe o botão de categorias ocupando toda a largura no mobile */
    .btn-categoria-toggle {
        display: flex;
    }

    /* CONFIGURAÇÃO COM ANIMAÇÃO SLIDE: Prepara a caixa para expandir de forma fluida */
    .menu-categorias {
        display: flex;
        flex-direction: column;
        background: var(--bg-card);
        border: 1px solid var(--borda);
        border-radius: 8px;
        padding: 0 10px; /* Começa zerado nas bordas verticais para não dar tranco */
        margin-top: 5px;
        gap: 15px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.05);
        
        /* Efeito mecânico de cortina */
        max-height: 0;        /* Totalmente encolhido por padrão */
        opacity: 0;           /* Invisível por padrão */
        overflow: hidden;     /* Trava o conteúdo para não vazar enquanto abre */
        transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out, padding 0.4s ease-in-out;
    }

    /* ESTADO EXPANDIDO: Ativado via JavaScript ao clicar no botão */
    .menu-categorias.ativo {
        max-height: 600px;    /* Altura limite máxima para comportar os links e o formulário */
        opacity: 1;           /* Esmaece revelando os itens suavemente */
        padding: 15px;        /* Restaura o respiro interno do card */
    }

    /* Transforma a lista de categorias em botões empilhados confortáveis para o toque */
    .lista-links-cat {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }

    .lista-links-cat a {
        background: var(--bg-global);
        border-radius: 6px;
        padding: 12px;
        text-align: center;
        width: 100%;
    }

    /* Força o formulário de busca e seus botões a ficarem verticais no celular */
    .form-busca-integrado {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }
    
    .form-busca-integrado input[type="text"] {
        width: 100%;
    }
    
    .form-busca-integrado button {
        padding: 12px;
        text-align: center;
        width: 100%;
    }

    .btn-limpar-filtros {
        text-align: center;
        margin-top: 5px;
    }

    /* Ajustes finos de margem do contêiner para telas de 6,5 polegadas */
    main {
        padding: 0 10px;
        margin: 20px auto;
    }

    article {
        padding: 20px;
    }

    article h3 a, article h1 {
        font-size: 1.35rem; /* Encolhe levemente a tipografia para telas pequenas */
    }

    /* Janela do chat flutuante adaptada para smartphones */
    .widget-chat {
        bottom: 20px;
        right: 20px;
    }

    .chat-janela {
        width: calc(100vw - 40px);
        right: 0;
        bottom: 75px;
    }
}
