/* Variáveis de Cores e Estilo (Sóbrio) */
:root {
    --primary-color: #003366; /* Azul Marinho Governamental */
    --secondary-color: #f4f6f8; /* Fundo Cinza Claro */
    --text-color: #333333;
    --border-color: #e0e0e0;
    --hover-color: #00509e;
    --icon-color: #0066cc; /* Azul mais vivo para dar destaque aos ícones */
}

/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--secondary-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Garante que o rodapé fique no fundo */
}

/* Cabeçalho */
.main-header {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.header-container {
    max-width: 1200px;    /* Mesma largura limite do resto do site */
    margin: 0 auto;       /* Centraliza o bloco na tela */
    padding: 1.5rem 2rem; /* Mantém as margens laterais alinhadas */
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.logo-placeholder {
    width: 80px;
    height: 80px;
    background-color: white;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.8rem;
    text-align: center;
}

.header-titles h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.header-titles h2 {
    font-size: 1.1rem;
    font-weight: 400;
    opacity: 0.9;
}

/* Container Principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1; /* Faz o container crescer para empurrar o rodapé para baixo */
    width: 100%;
}

/* Barra de Pesquisa */
.search-section {
    margin-bottom: 2rem;
}

.search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    border-color: var(--primary-color);
}

/* Grid de Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Estilo dos Cards */
.card {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    align-items: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    min-height: 100px;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    border-color: var(--primary-color);
}

.card-icon {
    font-size: 2rem;
    color: var(--icon-color);
    margin-right: 1.2rem;
    flex-shrink: 0; /* Impede que o ícone esmague em telas pequenas */
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Mensagem de "Nenhum resultado" */
.no-results {
    display: none;
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: #666;
    font-size: 1.1rem;
}

/* Rodapé */
.main-footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 1.5rem 2rem;
    margin-top: auto;
}

.main-footer p {
    margin: 0.3rem 0;
    font-size: 0.95rem;
    opacity: 0.9;
}

/* Responsividade */
@media (max-width: 600px) {
    .main-header {
        flex-direction: column;
        text-align: center;
    }
    .container {
        padding: 1rem;
    }
    .card {
        padding: 1.2rem;
    }
}

/* --- ACESSIBILIDADE --- */
.accessibility-bar {
    background-color: #1a1a1a;
    color: #ffffff;
    font-size: 0.85rem;
    padding: 0.5rem 0;
}

.container-acc {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.acc-shortcuts a, .acc-tools button {
    color: #ffffff;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    margin-left: 0.5rem;
    font-weight: 600;
    border-radius: 4px;
}

.acc-shortcuts a:focus, .acc-tools button:focus {
    outline: 2px solid #ffcc00; /* Destaque visual claro para navegação por teclado */
    background-color: #333;
}

.acc-tools button:hover {
    background-color: #333;
}

/* Foco global para navegação por teclado */
*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* --- MODO ALTO CONTRASTE --- */
body.high-contrast {
    --primary-color: #000000;
    --secondary-color: #121212;
    --text-color: #ffffff;
    --border-color: #ffff00;
    --hover-color: #000000;
    --icon-color: #ffff00;
}

body.high-contrast .card {
    background-color: #000000;
    border: 2px solid #ffff00;
}

body.high-contrast .search-input {
    background-color: #000000;
    color: #ffffff;
    border-color: #ffff00;
}

body.high-contrast .search-input::placeholder {
    color: #cccccc;
}

body.high-contrast .logo-placeholder {
    background-color: #000000;
    border: 1px solid #ffff00;
    color: #ffff00;
}
/* --- PÁGINA INTERNA E DATATABLES --- */
.page-title {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.8rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    color: var(--icon-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.back-link i {
    margin-right: 0.5rem;
}

/* Badges de Status */
.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background-color: #e6f4ea;
    color: #1e8e3e;
    border: 1px solid #ceead6;
}

.badge-warning {
    background-color: #fef7e0;
    color: #b06000;
    border: 1px solid #feefc3;
}

/* Ajustes no DataTables para bater com nosso tema */
table.dataTable thead th {
    background-color: var(--primary-color);
    color: white;
    border-bottom: none !important;
}

table.dataTable.no-footer {
    border-bottom: 2px solid var(--border-color);
}
/* Espaçamento entre os controles do topo e a tabela DataTables */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 10px;
}

/* Espaçamento entre a tabela e os controles de paginação no rodapé */
table.dataTable {
    margin-bottom: 15px !important;
}

/* Estilo do Botão de Imprimir */
.btn-imprimir {
    background-color: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 0.5rem 1rem !important;
    font-weight: 600 !important;
    margin-left: 15px !important;
    transition: background-color 0.2s;
}

.btn-imprimir:hover {
    background-color: var(--hover-color) !important;
}

/* Alinhamento dos controles no topo (Quantidade, Botão, Pesquisa) */
.dt-controles {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

/* --- REGRAS DE IMPRESSÃO (Oculta o que não deve ir para o papel) --- */
@media print {
    .accessibility-bar, 
    .back-link, 
    .main-footer,
    .dataTables_filter,
    .dataTables_length,
    .dt-buttons {
        display: none !important;
    }
    
    body {
        background-color: white;
    }

    .main-header {
        box-shadow: none;
        border-bottom: 2px solid var(--primary-color);
        color: black;
    }
}

/* Novas cores para Badges de Exames e Cirurgias */
.badge-danger {
    background-color: #fce8e6;
    color: #c5221f;
    border: 1px solid #fad2cf;
}

.badge-info {
    background-color: #e8f0fe;
    color: #1a73e8;
    border: 1px solid #d2e3fc;
}

/* --- ACESSO RÁPIDO (Escala e Endereços) --- */
.quick-access {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.quick-btn {
    flex: 1;
    min-width: 280px;
    background-color: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    text-align: center;
}

.quick-btn i {
    font-size: 1.3rem;
    margin-right: 0.8rem;
}

.quick-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Regra para o Alto Contraste */
body.high-contrast .quick-btn {
    background-color: #000000;
    border-color: #ffff00;
    color: #ffff00;
}

body.high-contrast .quick-btn:hover {
    background-color: #ffff00;
    color: #000000;
}

/* Destaque sutil de linhas de tabela com base no status */
.row-highlight-info {
    background-color: #f0f7ff !important;
}
.row-highlight-info:hover {
    background-color: #e0efff !important;
}

.row-highlight-danger {
    background-color: #fff5f5 !important;
}
.row-highlight-danger:hover {
    background-color: #ffebeb !important;
}

.row-highlight-success {
    background-color: #f6fdf9 !important;
}
.row-highlight-success:hover {
    background-color: #edfaf1 !important;
}

/* Layout de duas colunas para pesquisa */
.search-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.search-col {
    display: flex;
    flex-direction: column;
}
.search-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sus-search-wrapper {
    display: flex;
    gap: 0.5rem;
}
.sus-search-wrapper .search-input {
    flex: 1;
}
.search-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.search-btn:hover {
    background-color: var(--hover-color);
}

/* Resultados do SUS */
.sus-results-block {
    background-color: white;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    animation: fadeInSUS 0.3s ease-out;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.sus-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}
.sus-results-header h3 {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-close-sus {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-close-sus:hover {
    color: #ef4444;
}
.sus-table-container {
    width: 100%;
    overflow-x: auto;
}
.sus-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}
.sus-table th, .sus-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}
.sus-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
}
.sus-table td {
    font-size: 0.95rem;
    color: #334155;
}

@keyframes fadeInSUS {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .search-grid {
        grid-template-columns: 1fr;
    }
}