/*
 * CSS Padrão - Saúde Digital
 * Baseado na padronização visual dos projetos SIECES e upFiles
 * 
 * Versão: 1.0
 * Data: Janeiro 2025
 */

/* ============================================
   VARIÁVEIS CSS - PALETA OFICIAL
   ============================================ */
:root {
    /* Cores Principais */
    --azul-principal: #337ab7;
    --azul-botao: #478fcd;
    --cinza-fundo: #f2f2f2;
    --cinza-texto: #555;
    --preto-texto: #222;
    --branco: #ffffff;
    
    /* Cores de Status */
    --erro: #cc0000;
    --sucesso: #28a745;
    --aviso: #ffc107;
    
    /* Aliases para Compatibilidade */
    --primary: var(--azul-principal);
    --primary-hover: #2868a0;
    --secondary: var(--cinza-texto);
    --success: var(--sucesso);
    --error: var(--erro);
    --bg: var(--cinza-fundo);
    --card-bg: var(--branco);
    --border: #ddd;
    --text: var(--preto-texto);
    --text-light: var(--cinza-texto);
}

/* ============================================
   RESET E BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Open Sans', 'Segoe UI', sans-serif;
    background-color: var(--cinza-fundo);
    color: var(--preto-texto);
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    padding-top: 0;
    overflow-y: auto;
    margin: 0;
    padding: 0;
}

body:has(#searchSection:not([style*="display: none"])) {
    justify-content: center;
    overflow-y: visible;
}

body:has(#searchSection:not([style*="display: none"])) .container {
    overflow-y: visible;
}

/* ============================================
   BARRA SUPERIOR (HEADER)
   ============================================ */
.top-bar {
    background-color: var(--azul-principal);
    color: var(--branco);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 30px;
    height: 70px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
    width: 100%;
}

.logo-header {
    height: 50px;
}

.right-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.right {
    text-align: right;
}

.right div:first-child {
    font-size: 18px;
    font-weight: 700;
    color: var(--branco);
}

.right div:last-child {
    font-size: 14px;
    color: var(--branco);
    opacity: 0.9;
}

.logout {
    margin-left: 20px;
    font-size: 24px;
}

.logout a {
    color: var(--branco);
    text-decoration: none;
}

.logout a:hover {
    color: #ddd;
}

/* ============================================
   CONTAINER E LAYOUT
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 15px;
    padding-bottom: 0;
    flex: 1;
    box-sizing: border-box;
}

/* Remover overflow quando está na tela de busca */
body:has(#searchSection:not([style*="display: none"])) .container {
    overflow-y: visible;
}

/* Centralizar verticalmente quando apenas a busca estiver visível */
body.busca-visivel:not(.dados-visivel) .container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* ============================================
   CARDS E SECTIONS
   ============================================ */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 15px 0;
}

.card h1 {
    font-size: 24px;
    color: var(--azul-principal);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 600;
    text-align: center;
}

.card h2 {
    font-size: 20px;
    color: var(--azul-principal);
    margin: 30px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
}

.section {
    background: var(--branco);
    border-radius: 8px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* ============================================
   BOTÕES
   ============================================ */
button,
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    width: auto;
    min-width: fit-content;
}

.btn * {
    flex-shrink: 0;
}

button[type="submit"],
button.btn {
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-primary,
button[type="submit"] {
    background: var(--azul-botao);
    color: white;
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-primary:hover,
button[type="submit"]:hover {
    background: var(--azul-principal);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(51, 122, 183, 0.3);
}

.btn-secondary {
    background: var(--cinza-texto);
    color: white;
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: var(--sucesso);
    color: white;
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.btn-warning {
    background: var(--aviso);
    color: #856404;
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.3);
}

.btn-danger {
    background: var(--erro);
    color: white;
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-danger:hover {
    background: #a00;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(204, 0, 0, 0.3);
}

.btn-large {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 20px;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Grupos de Botões */
.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* ============================================
   FORMULÁRIOS E INPUTS
   ============================================ */
.form-group {
    margin: 18px 0;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    font-size: 15px;
    text-align: left;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="file"],
select,
textarea,
.input-field {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
    box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus,
.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(51, 122, 183, 0.1);
}

input::placeholder {
    color: #999;
    font-size: 14px;
}

/* Radio Buttons e Checkboxes */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.radio-label:hover {
    background: #e0e7ff;
}

.radio-label input[type="radio"],
.radio-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.radio-label span {
    font-size: 14px;
    font-weight: 500;
}

/* ============================================
   TABELAS
   ============================================ */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.preview-table,
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.preview-table th,
table th {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.preview-table td,
table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

.preview-table tr:hover,
table tr:hover {
    background: var(--bg);
}

/* ============================================
   ALERTAS
   ============================================ */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.alert i {
    font-size: 20px;
}

.alert-success {
    background: #d4edda;
    border: 1px solid var(--sucesso);
    color: #155724;
}

.alert-success i {
    color: var(--sucesso);
}

.alert-error,
.alert-danger {
    background: #f8d7da;
    border: 1px solid var(--erro);
    color: #721c24;
}

.alert-error i,
.alert-danger i {
    color: var(--erro);
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid var(--aviso);
    color: #856404;
}

.alert-warning i {
    color: var(--aviso);
}

.mensagem-erro {
    margin-top: 15px;
    color: var(--erro);
    font-weight: bold;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-content {
    background-color: #fefefe;
    margin: 0;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    position: relative;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.modal-header {
    background-color: var(--azul-principal);
    color: white;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 20px;
    font-size: 16px;
    line-height: 1.5;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 20px;
    text-align: right;
    border-top: 1px solid #eee;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============================================
   FOOTER
   ============================================ */
footer,
/* Footer removido - copyright agora está no final da página */

/* ============================================
   PÁGINA DE LOGIN (OPCIONAL)
   ============================================ */
body.login-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    justify-content: center;
    align-items: center;
}

.login-box {
    margin: auto;
    background: var(--azul-principal);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    width: 400px;
    max-width: 90%;
    text-align: center;
}

.login-box .logo {
    width: 280px;
    max-width: 100%;
    margin-bottom: 30px;
}

.login-box input[type="text"],
.login-box input[type="password"],
.login-box input[type="email"] {
    width: 100%;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 18px;
}

.login-box button {
    margin-top: 20px;
    width: 100%;
    padding: 15px;
    font-size: 18px;
}

/* ============================================
   SCROLLBAR PERSONALIZADA
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ============================================
   UTILITÁRIOS
   ============================================ */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-30 {
    margin-top: 30px;
}

.mb-30 {
    margin-bottom: 30px;
}

/* ============================================
   RESPONSIVIDADE
   ============================================ */
@media (max-width: 768px) {
    .top-bar {
        padding: 10px 15px;
        height: auto;
        min-height: 65px;
        flex-direction: column;
        gap: 6px;
        position: relative;
        z-index: 1000;
        width: 100%;
        box-sizing: border-box;
        flex-shrink: 0;
    }
    
    .logo-header {
        height: 40px;
    }
    
    .right div:first-child {
        font-size: 13px;
    }
    
    .right div:last-child {
        font-size: 11px;
    }
    
    .container {
        padding: 10px;
        padding-bottom: 0;
        min-height: 0;
        margin-bottom: 0;
    }
    
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .card {
        padding: 20px;
        margin: 10px;
    }
    
    .card h1 {
        font-size: 24px;
    }
    
    .card h2 {
        font-size: 18px;
    }
    
    .container {
        padding: 0 10px;
    }
    
    .main-content {
        padding: 20px 10px;
    }
    
    /* Grids responsivos - vira coluna única em mobile */
    [style*="grid-template-columns"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .button-group .btn {
        width: 100%;
    }
    
    /* Botões de ação em mobile */
    #botoesAcaoTopo {
        flex-direction: column !important;
        gap: 12px !important;
        justify-content: stretch !important;
        align-items: stretch !important;
    }
    
    #botoesAcaoTopo .btn {
        width: 100% !important;
        justify-content: center !important;
        margin: 0 !important;
        padding: 14px 20px !important;
        font-size: 16px !important;
    }
    
    #botoesAcaoBaixo {
        flex-direction: column !important;
        gap: 12px !important;
        justify-content: stretch !important;
        align-items: stretch !important;
    }
    
    #botoesAcaoBaixo .btn {
        width: 100% !important;
        justify-content: center !important;
        margin: 0 !important;
        padding: 14px 20px !important;
        font-size: 16px !important;
    }
    
    /* Garantir que apenas os botões visíveis sejam mostrados */
    #botoesAcaoTopo .btn[style*="display: none"],
    #botoesAcaoBaixo .btn[style*="display: none"] {
        display: none !important;
    }
    
    /* Remover o seletor antigo que não funciona mais */
    #dadosSection > div:first-of-type {
        text-align: center;
    }
    
    .login-box {
        width: 90%;
        padding: 30px 20px;
    }
    
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        margin: 0 !important;
    }
    
    .modal-body {
        padding: 15px !important;
        font-size: 14px !important;
        max-height: calc(90vh - 120px);
        overflow-y: auto;
    }
    
    .right-group {
        flex-direction: column;
        align-items: flex-end;
    }
    
    /* Seção de telefones destacada em mobile */
    .telefones-section {
        padding: 20px !important;
    }
    
    .telefones-section h2 {
        font-size: 18px !important;
    }
    
    .telefones-section .input-field {
        font-size: 16px !important;
        padding: 12px !important;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 15px;
        margin: 5px;
    }
    
    .card h1 {
        font-size: 20px;
    }
    
    .card h2 {
        font-size: 16px;
    }
    
    .top-bar {
        padding: 10px 15px;
    }
    
    .right div:first-child {
        font-size: 16px;
    }
    
    .right div:last-child {
        font-size: 12px;
    }
    
    /* Inputs em mobile pequeno */
    .input-field {
        font-size: 16px !important; /* Evita zoom automático no iOS */
        padding: 14px !important;
    }
    
    /* Seção de telefones em mobile pequeno */
    .telefones-section {
        padding: 15px !important;
    }
    
    .telefones-section h2 {
        font-size: 16px !important;
        margin-bottom: 15px !important;
    }
    
    .telefones-section .input-field {
        font-size: 16px !important;
        padding: 14px !important;
    }
    
    .form-group label {
        font-size: 14px;
    }
    
    /* Botões em mobile pequeno */
    .btn {
        padding: 14px 20px;
        font-size: 16px;
    }
    
    .btn-large {
        padding: 16px;
        font-size: 16px;
    }
}

