/* ==========================================================================
   1. Reset Básico, Variáveis e Tipografia Global
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f1f5f9;
    color: #1e293b;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.6;
}

/* Ocupa quase a tela inteira em monitores grandes */
.container {
    max-width: 1700px;
    width: 95%;
    margin: 0 auto;
    padding: 0 16px;
}

/* ==========================================================================
   2. Cabeçalho (Topo com Padrão Geométrico em SVG)
   ========================================================================== */
header.topo-site {
    background-color: #0f172a;
    color: #ffffff;
    padding: 18px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='hexagons' fill='%2394a3b8' fill-opacity='0.07' fill-rule='nonzero'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34L25 30.6V17.9l-11.01-6.36L3 17.9zM27.98 0l.02 3.12-6.5 3.75-6.5-3.75L15 0h12.98zM0 0h13l-6.5 3.75L0 0zm28 49l-13-7.5 6.5-3.75L28 49zm-15 0L0 41.5l6.5-3.75L13 49z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

header.topo-site .logo {
    color: #ffffff;
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* ==========================================================================
   3. Estrutura Principal (Conteúdo Ampliado + Sidebar)
   ========================================================================== */
.conteudo-principal {
    display: flex;
    flex: 1;
    max-width: 1700px;
    width: 95%;
    margin: 28px auto;
    gap: 32px;
}

.area-conteudo {
    flex: 4;
    background-color: #ffffff;
    padding: 36px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    min-width: 0; /* Essencial para que o Flexbox force a redução de elementos filhos */
    overflow: hidden; /* Garante contenção física de elementos grandes */
}

/* ==========================================================================
   4. Barra Lateral (Sidebar)
   ========================================================================== */
aside.barra-lateral {
    flex: 1.1;
    min-width: 300px;
    max-width: 380px;
    background-color: #ffffff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    height: fit-content;
    position: sticky;
    top: 84px;
}

aside.barra-lateral h3 {
    font-size: 1.1rem;
    color: #0f172a;
    margin-bottom: 14px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 6px;
}

.box-busca {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
}

.grupo-busca {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.grupo-busca input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.grupo-busca input[type="text"]:focus {
    border-color: #0284c7;
}

.grupo-busca button {
    background-color: #0284c7;
    color: #ffffff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.grupo-busca button:hover {
    background-color: #0369a1;
}

.opcao-busca-profunda {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #64748b;
    cursor: pointer;
}

.box-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.box-menu li {
    margin-bottom: 10px;
}

.box-menu a {
    color: #334155;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: color 0.2s;
}

.box-menu a:hover {
    color: #0284c7;
}

/* ==========================================================================
   5. Formatação da Matéria Completa e Conteúdo de Páginas (.corpo-texto)
   ========================================================================== */
article.materia-completa h1,
article.pagina-institucional h1 {
    font-size: 2.2rem;
    color: #0f172a;
    margin-bottom: 12px;
    line-height: 1.25;
    font-weight: 800;
}

.linha-fina {
    font-size: 1.15rem;
    color: #475569;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Meta dados (Data, Categoria e Tags) */
.meta-materia {
    font-size: 0.88rem;
    color: #64748b;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.meta-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.badge-categoria {
    display: inline-block;
    background-color: #e0f2fe;
    color: #0369a1;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 3px 10px;
    border-radius: 6px;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: background-color 0.2s;
}

.badge-categoria:hover {
    background-color: #bae6fd;
    color: #0284c7;
}

.meta-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tag-link {
    display: inline-block;
    background-color: #ffffff;
    color: #0284c7;
    border: 1px solid #cbd5e1;
    padding: 4px 10px;
    border-radius: 16px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s;
}

.tag-link:hover {
    background-color: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

/* CONTENÇÃO E FORMATAÇÃO DE CONTEÚDO HTML LIBERADO (Matérias e Páginas) */
.corpo-texto {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.corpo-texto p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #334155;
    line-height: 1.7;
}

.corpo-texto h2, 
.corpo-texto h3,
.corpo-texto h4 {
    color: #0f172a;
    margin: 28px 0 12px 0;
    line-height: 1.3;
}

/* Correção das listas para não vazarem da borda */
.corpo-texto ul, 
.corpo-texto ol {
    margin: 0 0 20px 0;
    padding-left: 28px; /* Recuo interno suficiente para o marcador */
    color: #334155;
    font-size: 1.05rem;
    list-style-position: outside; /* Garante alinhamento limpo do texto */
}

.corpo-texto li {
    margin-bottom: 8px;
    padding-left: 4px;
    line-height: 1.6;
}

.corpo-texto img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px 0;
    display: block;
}

.corpo-texto iframe {
    max-width: 100%;
    border-radius: 8px;
    margin: 20px 0;
}

.corpo-texto blockquote {
    border-left: 4px solid #0284c7;
    padding: 8px 0 8px 16px;
    margin: 20px 0;
    font-style: italic;
    color: #475569;
    background-color: #f8fafc;
    border-radius: 0 6px 6px 0;
}

.corpo-texto table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    overflow-x: auto;
    display: block;
}
.imagem-destaque {
    margin: 24px 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}
.imagem-destaque img {
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain; /* Mantém a proporção exata sem distorcer */
    border-radius: 10px;
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   6. Grade de Cards e Listagens (Home, Categorias, Tags e Busca)
   ========================================================================== */
.home-capa h1,
.categoria-header h1,
.tags-header h1 {
    font-size: 1.6rem;
    color: #0f172a;
    margin-bottom: 20px;
    border-bottom: 2px solid #0284c7;
    padding-bottom: 8px;
}

.categoria-header,
.tags-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.tag-contagem,
.badge-contagem {
    font-size: 0.85rem;
    background-color: #e0f2fe;
    color: #0369a1;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 700;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.card-materia {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-materia:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

.card-materia a.link-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-imagem-wrapper {
    width: 100%;
    height: 170px;
    background-color: #f1f5f9;
    overflow: hidden;
}

.card-imagem-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-categoria {
    font-size: 0.75rem;
    font-weight: 700;
    color: #0284c7;
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 0.05em;
}

.card-titulo {
    font-size: 1.1rem;
    color: #0f172a;
    line-height: 1.35;
    margin-bottom: 10px;
    font-weight: 700;
}

.card-descricao {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.45;
    margin-bottom: 14px;
    flex: 1;
}

.card-data {
    font-size: 0.78rem;
    color: #94a3b8;
}

.sem-conteudo {
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    padding: 24px;
    border-radius: 8px;
    color: #64748b;
}

.nuvem-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #f1f5f9;
    color: #334155;
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.tag-item:hover {
    background-color: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

.tag-item .qtd {
    font-size: 0.75rem;
    background-color: #cbd5e1;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 10px;
}

.btn-voltar {
    display: inline-block;
    margin-bottom: 16px;
    font-size: 0.88rem;
    color: #0284c7;
    text-decoration: none;
    font-weight: 600;
}

.btn-voltar:hover {
    text-decoration: underline;
}
/* ==========================================================================
   7. Painel de Publicação e Edição (publicar.php e publicar_pagina.php)
   ========================================================================== */
.container-painel {
    max-width: 100%;
    margin: 0 auto;
}

.painel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #0284c7;
}

.painel-header h1 {
    font-size: 1.6rem;
    color: #0f172a;
}

.form-publicar {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end; /* Garante alinhamento pela base dos inputs e botões */
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #334155;
}

/* Incluído input[type="number"] para o campo Ordem receber o mesmo estilo */
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
    background-color: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Botão de envio ajustado para alinhar perfeitamente na mesma linha */
.btn-submit {
    background-color: #0284c7;
    color: #ffffff;
    border: none;
    padding: 11px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
    height: 42px; /* Força a mesma altura dos campos de texto */
    white-space: nowrap;
}

.btn-submit:hover {
    background-color: #0369a1;
}

.mensagem-alerta {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 600;
}

.mensagem-alerta.sucesso {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.mensagem-alerta.erro {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Tabela de Gerenciamento */
.tabela-gerenciamento {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.tabela-gerenciamento th,
.tabela-gerenciamento td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    font-size: 0.88rem;
}

.tabela-gerenciamento th {
    background-color: #f8fafc;
    color: #0f172a;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge.publicado { background-color: #dcfce7; color: #166534; }
.status-badge.rascunho { background-color: #fef3c7; color: #92400e; }

/* Linha especial de ações (Senha + Botão Salvar) */
.form-row-acoes {
    display: flex;
    gap: 16px;
    align-items: flex-end; /* Alinha a base do input com a base do botão */
    margin-top: 10px;
}

.form-group-btn {
    display: flex;
    align-items: flex-end;
}

.btn-submit {
    background-color: #0284c7;
    color: #ffffff;
    border: none;
    padding: 0 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
    height: 42px; /* Força exatamente a mesma altura do input de senha */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.btn-submit:hover {
    background-color: #0369a1;
}


/* ==========================================================================
   8. Rodapé
   ========================================================================== */
footer.rodape-site {
    background-color: #0f172a;
    color: #94a3b8;
    text-align: center;
    padding: 20px 0;
    font-size: 0.875rem;
    margin-top: auto;
}

/* ==========================================================================
   9. Responsividade Mobile
   ========================================================================== */
@media (max-width: 768px) {
    .container,
    .conteudo-principal {
        width: 100%;
    }

    .conteudo-principal {
        flex-direction: column;
        margin: 16px auto;
        gap: 20px;
    }

    aside.barra-lateral {
        max-width: 100%;
        min-width: 0;
    }

    .area-conteudo {
        padding: 20px;
    }

    article.materia-completa h1,
    article.pagina-institucional h1 {
        font-size: 1.5rem;
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .tabela-gerenciamento {
        display: block;
        overflow-x: auto;
    }
}