:root {
    --primary-color: #0164c3;
    /* 🔵 Azul oficial da Prefeitura */
    --primary-dark: #014fa0;
    /* Tom mais escuro para hover */
    --secondary-color: #34a853;
    --warning-color: #fbbc05;
    --danger-color: #d93025;
    --text-color: #202124;
    --text-light: #5f6368;
    --bg-light: #f1f3f4;
    --bg-white: #ffffff;
    --border-color: #dadce0;
    --hover-bg-light: #e8f0fe;
    --shadow-light: 0 1px 3px rgba(60, 64, 67, .15);
    --shadow-hover: 0 4px 12px rgba(60, 64, 67, .2);
}


/* Base */

html {
    scroll-behavior: smooth;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    background-color: var(--bg-light);
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s, background-color 0.3s;
}

a:hover {
    color: var(--primary-dark);
    opacity: 1;
    /* Remove a opacidade para um hover mais direto */
}

h1,
h2,
h3 {
    margin-bottom: 0.75em;
    /* Mais espaçamento abaixo dos títulos */
    font-weight: 500;
}


/* * ----------------------------------------------------------------------
 * LAYOUT PADRÃO (Main Content)
 * ----------------------------------------------------------------------
 */

.header {
    background-color: var(--bg-white);
    padding: 15px 20px;
    box-shadow: var(--shadow-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.header h1 a {
    color: inherit;
    text-decoration: none;
}

.user-info {
    font-size: 0.9em;
    color: var(--text-light);
    display: flex;
    align-items: center;
}

.user-info span {
    margin-right: 15px;
    font-weight: 500;
}

main {
    padding: 20px;
    max-width: 1200px;
    margin: 20px auto;
}

.card {
    background-color: var(--bg-white);
    padding: 25px;
    /* Padding ligeiramente maior */
    border-radius: 10px;
    /* Cantos mais arredondados */
    box-shadow: var(--shadow-light);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 30px 0;
}


/* * ----------------------------------------------------------------------
 * BOTÕES E FORMULÁRIOS
 * ----------------------------------------------------------------------
 */

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    /* Transição mais rápida */
    border: 1px solid transparent;
}


/* Adiciona anel de foco para acessibilidade */

.btn:focus-visible {
    outline: 3px solid rgba(26, 115, 232, 0.5);
    outline-offset: 2px;
    border-color: transparent;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--bg-white);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    color: var(--bg-white);
    opacity: 1;
}

.btn-secondary {
    background-color: var(--bg-white);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    /* Borda mais sutil */
}

.btn-secondary:hover {
    background-color: var(--hover-bg-light);
    color: var(--primary-dark);
    opacity: 1;
}

.btn-warning {
    background-color: var(--warning-color);
    color: var(--text-color);
    border-color: var(--warning-color);
}

.btn-warning:hover {
    background-color: #0164c3;
    color: var(--text-color);
    opacity: 1;
}

.btn-logout {
    background-color: var(--danger-color);
    color: var(--bg-white);
    border-color: var(--danger-color);
}

.btn-logout:hover {
    background-color: #b32a1e;
    /* Um pouco mais escuro */
    color: var(--bg-white);
    opacity: 1;
}


/* Formulários */

form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    /* Espaçamento ligeiramente maior */
}

label {
    font-weight: 500;
    margin-bottom: 5px;
    display: block;
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
input[type="file"] {
    width: 100%;
    padding: 12px;
    /* Padding ligeiramente maior */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
    color: var(--text-color);
    transition: border-color 0.3s, box-shadow 0.3s;
}


/* Foco para acessibilidade */

input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
input[type="date"]:focus-visible,
select:focus-visible {
    border-color: var(--primary-color);
    outline: 3px solid rgba(26, 115, 232, 0.4);
    outline-offset: 1px;
    box-shadow: none;
}


/* Foco padrão para clique do mouse */

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}


/* * ----------------------------------------------------------------------
 * ALERTS E MENSAGENS
 * ----------------------------------------------------------------------
 */

.alert {
    padding: 18px;
    margin-bottom: 20px;
    border-radius: 8px;
    /* Cantos mais suaves */
    font-size: 1em;
    font-weight: 500;
}

.alert-success {
    background-color: #e6f4ea;
    color: var(--secondary-color);
    /* Consistente com variável */
    border: 1px solid #c8e6c9;
}

.alert-danger {
    background-color: #fce8e6;
    color: var(--danger-color);
    /* Consistente com variável */
    border: 1px solid #f9d5d3;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.9em;
    margin-top: 5px;
}


/* * ----------------------------------------------------------------------
 * ESTILOS DE PÁGINA ESPECÍFICOS
 * ----------------------------------------------------------------------
 */


/* === Login Page === */

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--primary-color);
    min-height: 100vh;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    padding: 30px;
    border-radius: 10px;
}

.login-header {
    text-align: center;
    margin-bottom: 25px;
}

.login-logo {
    max-width: 80px;
    height: auto;
    margin-bottom: 15px;
}

.login-header h2 {
    color: var(--text-color);
    font-size: 1.8em;
    margin-top: 0;
    font-weight: 600;
}


/* === Dashboard (admin-header-main) === */

.admin-header-main {
    /* Adicionando gradiente sutil para dar mais profundidade */
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--bg-white);
    padding: 20px 20px;
    box-shadow: var(--shadow-light);
}

.admin-header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.admin-header-main .header-title {
    font-size: 2em;
    font-weight: 700;
    color: var(--bg-white);
    margin: 0;
    flex-grow: 1;
}

.admin-header-main a {
    color: var(--bg-white);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.3s;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
}

.admin-header-main a:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.15);
}

.admin-header-main .btn-back,
.admin-header-main .btn-logout {
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--bg-white);
    font-size: 1em;
}


/* Área de Boas-vindas */

.welcome-area {
    text-align: center;
    padding: 30px;
    background-color: var(--bg-white);
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    margin-bottom: 30px;
    /* Mais margem */
    border: 1px solid var(--border-color);
}

.welcome-message {
    font-size: 1.4em;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--primary-dark);
}

.user-role-info {
    font-size: 0.9em;
    color: var(--text-light);
}


/* Grid de Estatísticas */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    /* Espaçamento maior */
    margin-bottom: 30px;
}

.stats-card {
    padding: 30px 20px;
    /* Padding ajustado */
    text-align: center;
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
}

.stats-card:hover {
    transform: translateY(-5px);
    /* Efeito de elevação maior */
    box-shadow: var(--shadow-hover);
}

.stats-card .number {
    font-size: 3em;
    /* Número maior */
    font-weight: 700;
    margin-bottom: 5px;
    display: block;
}

.stats-card h3 {
    font-size: 1.05em;
    font-weight: 600;
    color: var(--text-light);
    margin-top: 0;
}

.stats-card .stat-icon {
    font-size: 2em;
    margin-bottom: 10px;
    opacity: 0.8;
}

.stats-card .subtitle {
    font-size: 0.85em;
    color: var(--text-light);
    margin-top: 5px;
}


/* Cores das Cards de Estatísticas */

.card-publicacoes-ativas {
    background-color: #e6f4ea;
    border-left: 6px solid var(--secondary-color);
}

.card-publicacoes-ativas .number,
.card-publicacoes-ativas .stat-icon {
    color: var(--secondary-color);
}

.card-total-publicacoes {
    background-color: #f1f3f4;
    border-left: 6px solid var(--text-light);
}

.card-total-publicacoes .number,
.card-total-publicacoes .stat-icon {
    color: var(--text-light);
}

.card-downloads-mes {
    background-color: #fff7e6;
    border-left: 6px solid var(--warning-color);
}

.card-downloads-mes .number,
.card-downloads-mes .stat-icon {
    color: var(--warning-color);
}

.card-downloads-total {
    background-color: var(--hover-bg-light);
    border-left: 6px solid var(--primary-color);
}

.card-downloads-total .number,
.card-downloads-total .stat-icon {
    color: var(--primary-color);
}


/* Grid de Ações Rápidas (Ações Rápidas) */

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    /* Min-width um pouco maior */
    gap: 25px;
    margin-bottom: 30px;
}

.btn-action {
    width: 100%;
    padding: 18px 20px;
    font-size: 1.05em;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-action:hover {
    transform: translateY(-3px);
    /* Efeito de elevação maior */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}


/* Estilo para Tabela (Gerenciar Publicações / Usuários) */

.data-table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    /* Permite border-radius */
    border-spacing: 0;
    margin-top: 15px;
    min-width: 650px;
}

.data-table th,
.data-table td {
    padding: 15px 15px;
    /* Mais padding vertical */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table thead tr th:first-child {
    border-top-left-radius: 8px;
}

.data-table thead tr th:last-child {
    border-top-right-radius: 8px;
}

.data-table th {
    background-color: var(--bg-light);
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background-color: var(--bg-light);
}

.data-table td .btn {
    padding: 6px 12px;
    margin-right: 5px;
    font-size: 0.85em;
    white-space: nowrap;
}


/* Status Badges */

.status-badge {
    padding: 5px 10px;
    border-radius: 12px;
    /* Pill shape */
    font-size: 0.8em;
    font-weight: 600;
    display: inline-block;
    min-width: 80px;
    text-align: center;
}

.status-publicado {
    background-color: #e6f4ea;
    color: var(--secondary-color);
}

.status-arquivado {
    background-color: #f1f3f4;
    color: var(--text-light);
}


/* === Área Pública (index.php) === */

.public-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    /* Gradiente mais suave */
    color: var(--bg-white);
    padding: 40px 20px;
    /* Mais padding */
    text-align: center;
}

.header-content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
}

.header-logo-container {
    flex-shrink: 0;
    margin-right: 25px;
}

.public-logo {
    max-width: 90px;
    /* Logo um pouco maior */
    height: auto;
    margin: 0;
    opacity: 1 !important;
    filter: invert(100%);
}

.header-text-center {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    flex-grow: 1;
    padding-right: 115px;
    /* Para centralizar o texto com o logo no canto */
}

.public-header h1 {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--bg-white);
}

.public-header p {
    font-size: 1.1em;
    opacity: 0.9;
}


/* Barra de Busca */

.search-form {
    display: flex;
    max-width: 600px;
    margin: 30px auto 40px auto;
    /* Mais espaçamento */
    background-color: var(--bg-white);
    border-radius: 10px;
    box-shadow: var(--shadow-hover);
    /* Sombra mais destacada */
    border: 1px solid var(--border-color);
}

.search-input {
    flex-grow: 1;
    border: none !important;
    padding: 15px 20px;
    border-radius: 10px 0 0 10px;
    font-size: 1.1em;
}

.search-input:focus-visible {
    box-shadow: none;
    outline: none;
}

.search-btn {
    padding: 15px 25px;
    border: none;
    border-radius: 0 10px 10px 0;
    font-size: 1.1em;
    background-color: var(--primary-color);
    color: var(--bg-white);
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: 500;
}

.search-btn:hover {
    background-color: var(--primary-dark);
}


/* Lista de Publicações */

.publication-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.publication-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    background-color: var(--bg-white);
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.publication-item:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.pub-details {
    flex-grow: 1;
    margin-right: 30px;
}

.pub-edition {
    display: block;
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.pub-title {
    font-size: 1.35em;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.pub-date {
    display: block;
    font-size: 0.9em;
    color: var(--text-light);
    margin-top: 8px;
}

.pub-download-btn {
    padding: 14px 24px;
    /* antes: 12px 20px */
    font-size: 1.05em;
}

.no-results {
    text-align: center;
    padding: 40px;
    font-size: 1.2em;
    background-color: var(--bg-white);
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    margin-top: 20px;
    color: var(--text-light);
}


/* Rodapé Público */

.public-footer {
    text-align: center;
    padding: 25px;
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
    font-size: 0.9em;
    color: var(--text-light);
}


/* * ----------------------------------------------------------------------
 * RESPONSIVIDADE (MOBILE FIRST)
 * ----------------------------------------------------------------------
 */

@media (max-width: 768px) {
    main {
        padding: 15px;
        margin: 15px auto;
    }
    /* Ajustes para o novo Header Admin em Mobile */
    .admin-header-main {
        padding: 15px 10px;
    }
    .admin-header-content {
        display: grid;
        grid-template-areas: "back title logout";
        grid-template-columns: auto 1fr auto;
        /* Ajuste para ter mais espaço para o título */
        gap: 10px;
        align-items: center;
    }
    .logo-area {
        grid-area: back;
    }
    .admin-header-main .header-title {
        grid-area: title;
        font-size: 1.25em;
        text-align: center;
    }
    .user-area {
        grid-area: logout;
        justify-self: end;
    }
    /* Esconde o texto dos links em telas muito pequenas, deixando apenas o ícone */
    .admin-header-main .btn-back span,
    .admin-header-main .btn-logout span {
        display: none;
    }
    .admin-header-main .btn-back,
    .admin-header-main .btn-logout {
        font-size: 1.2em;
        padding: 5px;
    }
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 10px;
    }
    .header-content-wrapper {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
    }
    .header-logo-container {
        margin-right: 0;
    }
    .header-text-center {
        margin: 0;
        padding: 0;
        flex-grow: 1;
    }
    .public-logo {
        max-width: 80px;
    }
    .public-header h1 {
        font-size: 2em;
    }
    .public-header p {
        font-size: 1em;
    }
    .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        font-size: 0.85em;
    }
    .user-info span {
        margin-right: 0;
    }
    /* Dashboard */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .actions-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .stats-card {
        padding: 20px;
    }
    /* Área Pública */
    .publication-item {
        padding: 28px 30px;
        /* antes: 20px 25px */
        min-height: 120px;
        /* garante altura visual maior */
        align-items: center;
    }
    .pub-details {
        margin-right: 40px;
    }
    .pub-title {
        font-size: 1.35em;
        /* antes: 1.3em */
        margin-bottom: 6px;
    }
    .pub-download-btn {
        width: 100%;
        text-align: center;
        padding: 10px 18px;
    }
    /* Formulário de Busca */
    .search-form {
        flex-direction: column;
        box-shadow: none;
        border: none;
    }
    .search-input {
        border-radius: 8px !important;
        margin-bottom: 10px;
        box-shadow: var(--shadow-light);
    }
    .search-btn {
        border-radius: 8px;
        width: 100%;
        padding: 12px 20px;
    }
}


/* ===============================
   CORREÇÃO BOTÕES HEADER ADMIN
   =============================== */

.admin-header-main .btn-back,
.admin-header-main .btn-logout {
    background-color: rgba(255, 255, 255, 0.18) !important;
    color: #fff !important;
    padding: 8px 14px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.admin-header-main .btn-back:hover,
.admin-header-main .btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.32) !important;
}