/* =========================================
   1. VARIÁVEIS E RESET (O DNA do Design)
   ========================================= */
:root {
    /* Paleta Corporativa "Trust Blue" */
    --primary-color: #003366;       /* Azul Marinho Profundo */
    --primary-light: #004d99;       /* Azul Médio para Hover */
    --accent-color: #00a86b;        /* Verde Esmeralda (Ações de Sucesso) */
    --accent-dark: #008f5a;         /* Verde Escuro */
    --danger-color: #d32f2f;        /* Vermelho Erro */
    --warning-color: #ffa000;       /* Laranja Alerta */
    
    /* Neutros */
    --bg-body: #f4f6f9;             /* Cinza muito claro (Fundo) */
    --bg-card: #ffffff;             /* Branco (Cards) */
    --text-main: #333333;           /* Preto Suave (Texto) */
    --text-muted: #6c757d;          /* Cinza (Legendas) */
    --border-color: #dde2e6;        /* Bordas sutis */
    
    /* Sombras (Elevação) */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.08);
    
    /* Espaçamentos */
    --radius: 8px;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   2. HEADER (Navegação Superior)
   ========================================= */
.app-header {
    background-color: var(--primary-color);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-brand {
    display: flex;
    align-items: center;
}

.header-logo {
    height: 35px;
    width: auto;
    filter: brightness(0) invert(1); /* Deixa o logo branco se for png transparente */
}

.header-nav {
    display: flex;
    gap: 25px;
    height: 100%;
}

.header-link {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    height: 100%;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.header-link:hover {
    color: #fff;
}

.header-link.active {
    color: #fff;
    border-bottom-color: var(--accent-color);
}

.header-user-area {
    display: flex;
    align-items: center;
    gap: 15px;
    color: white;
}

.user-info {
    text-align: right;
    line-height: 1.2;
}

.user-name {
    display: block;
    font-size: 13px;
}

.user-role {
    display: block;
    font-size: 11px;
    opacity: 0.7;
    font-weight: bold;
}

.btn-logout-panel {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    text-transform: uppercase;
    transition: background 0.2s;
}

.btn-logout-panel:hover {
    background: rgba(255,255,255,0.2);
}

/* =========================================
   3. LAYOUT E CARDS
   ========================================= */
.main-container {
    max-width: 1100px; /* Largura contida para leitura confortável */
    margin: 30px auto;
    padding: 0 20px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
    position: relative; /* Para bordas coloridas no topo */
    overflow: hidden;
}

/* Títulos de Seção */
h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 5px;
}

h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =========================================
   4. FORMULÁRIOS (Modern Inputs)
   ========================================= */
fieldset {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    background-color: #fff;
}

legend {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    padding: 0 10px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

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

label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="email"],
select {
    height: 42px; /* Altura confortável para clique */
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-main);
    background-color: #fff;
    transition: all 0.2s ease-in-out;
    width: 100%;
}

/* Efeito de Foco (Glow Azul) */
input:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
    outline: none;
}

/* Campos somente leitura ou desabilitados */
input:disabled, select:disabled {
    background-color: #f8f9fa;
    color: #999;
    cursor: not-allowed;
}

/* Campo Especial de Total (Destaque) */
#premio_total {
    background-color: #e8f5e9;
    color: var(--accent-dark);
    font-weight: 700;
    border-color: #c8e6c9;
}

/* Upload de Arquivo Estilizado */
input[type="file"] {
    padding: 10px;
    background: #f8f9fa;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    width: 100%;
    cursor: pointer;
}
input[type="file"]:hover {
    background: #fff;
    border-color: var(--primary-color);
}

/* =========================================
   5. BOTÕES (Call to Action)
   ========================================= */
button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Botão Salvar (Principal) */
.btn-novo {
    background-color: var(--accent-color);
    color: white;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.5px;
    padding: 12px 24px;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 168, 107, 0.2);
    width: 100%;
    margin-top: 10px;
}

.btn-novo:hover {
    background-color: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(0, 168, 107, 0.3);
}

.btn-novo:active {
    transform: translateY(0);
}

/* Botão Processar PDF (Secundário) */
.btn-processar {
    background-color: var(--primary-color);
    color: white;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 4px;
    margin-top: 15px;
}

.btn-processar:hover {
    background-color: var(--primary-light);
}

/* =========================================
   6. TABELAS (Dashboard)
   ========================================= */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: white;
}

thead th {
    background-color: #f8f9fa;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    padding: 12px 15px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
}

tbody td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    color: var(--text-main);
    font-size: 13px;
}

tbody tr:hover {
    background-color: #f4f6f9; /* Destaque ao passar o mouse */
}

/* Ações da Tabela */
.action-btn {
    padding: 6px 10px;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    margin-right: 5px;
    text-decoration: none;
}
.btn-edit { background-color: #1976d2; }
.btn-delete { background-color: #d32f2f; }
.btn-pdf { background-color: #757575; }

/* =========================================
   7. RODAPÉ E CRÉDITOS
   ========================================= */
.system-credits {
    text-align: center;
    margin-top: 40px;
    font-size: 12px;
    color: #999;
    border-top: 1px solid #eee;
    padding-top: 20px;
    margin-bottom: 20px;
}

/* =========================================
   8. RESPONSIVIDADE (Mobile)
   ========================================= */
@media (max-width: 768px) {
    .header-nav { display: none; } /* Esconde menu no mobile por enquanto */
    .form-row { flex-direction: column; gap: 10px; }
    .main-container { padding: 10px; }
    h2 { font-size: 18px; }
}

/* =========================================
   9. CARDS DE ESTATÍSTICAS (DASHBOARD) - CORRIGIDO
   ========================================= */

/* Container dos Cards */
.stats-container {
    display: flex; /* Mudado de Grid para Flex para alinhar melhor */
    justify-content: space-between;
    gap: 12px; /* Espaço equilibrado */
    flex-wrap: wrap; /* Permite quebra apenas em telas muito pequenas (celular) */
    margin-bottom: 30px;
}

/* Estilo Base do Stat Card */
.stat-card {
    flex: 1; /* Ocupa espaço igual */
    min-width: 150px; /* Permite que fiquem 5 na mesma linha em telas normais */
    background: #fff;
    padding: 15px; /* Padding levemente reduzido */
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border-left: 5px solid transparent; 
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden; /* Garante que o texto não saia do card */
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

/* Área de Texto (Protegida contra quebra) */
.stat-info {
    flex: 1;
    min-width: 0; /* Truque CSS: permite encolher o texto se faltar espaço */
}

.stat-info h3 {
    margin: 0;
    font-size: 1.4em !important; /* Tamanho ideal (aprox 22px) */
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap; /* Impede quebra de linha */
    overflow: hidden;
    text-overflow: ellipsis; /* Coloca "..." se o valor for infinito */
    border: none;
    padding: 0;
}

/* AJUSTE FINO PARA O CARD DE COMISSÃO (VALORES LONGOS) */
.stat-card.money .stat-info h3 {
    font-size: 1.25em !important; /* Levemente menor para caber "R$ 10.000,00" */
    color: #28a745;
}

.stat-info p {
    margin: 0;
    font-size: 0.75em !important; /* Legenda compacta */
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Ícone */
.stat-icon {
    font-size: 2em; /* Tamanho visualmente agradável */
    opacity: 0.8;
    margin-left: 10px;
    flex-shrink: 0; /* IMPORTANTE: O ícone nunca vai ser esmagado */
}

/* Cores Específicas */
.stat-card.green { border-left: 5px solid #00a86b !important; }
.stat-card.green .stat-icon { color: #00a86b !important; }

.stat-card.blue { border-left: 5px solid #1976d2 !important; }
.stat-card.blue .stat-icon { color: #1976d2 !important; }

.stat-card.orange { border-left: 5px solid #ffa000 !important; }
.stat-card.orange .stat-icon { color: #ffa000 !important; }

.stat-card.purple { border-left: 5px solid #7b1fa2 !important; }
.stat-card.purple .stat-icon { color: #7b1fa2 !important; }

.stat-card.money { border-left: 5px solid #28a745 !important; background: #fff; }
.stat-card.money .stat-icon { color: #28a745 !important; }

/* =========================================
   10. PAGINAÇÃO (NOVO)
   ========================================= */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-top: 1px solid #eee;
    margin-top: 10px;
}

.pagination-info {
    font-size: 13px;
    color: #666;
}

.pagination-controls {
    display: flex;
    gap: 5px;
}

.page-btn {
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: bold;
}

.page-btn:disabled {
    background-color: #f4f4f4;
    color: #ccc;
    cursor: not-allowed;
}