@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* =========================================
   1. CONFIGURAÇÕES GLOBAIS
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', Arial, sans-serif;
}

body {
    background-color: #0f172a;
    color: #f1f5f9;
    font-size: 13px;
}

body:not(:has(.app-layout)) {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 15px;
}

h2, h3 { color: #f8fafc; margin-bottom: 12px; }
h2 { text-align: center; font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }

/* =========================================
   2. INPUTS E FORMULÁRIOS
   ========================================= */
input[type="text"],
input[type="password"],
input[type="file"],
select {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 13px;
    color: #f8fafc;
    background-color: #1e293b;
    transition: all 0.3s ease;
}

input:focus, select:focus {
    border-color: #fbbf24;
    outline: none;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.form-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.form-row .input-group { flex: 1; min-width: 180px; }
.form-row label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 12px; color: #94a3b8; }

/* =========================================
   3. BOTÕES (ALTO CONTRASTE RESTAURADO)
   ========================================= */
button {
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease-in-out;
    display: inline-block;
    text-align: center;
}

/* Primário (Amarelo/Dourado Neon) */
.btn-primary { background-color: #fbbf24; color: #0f172a; width: 100%; }
.btn-primary:hover { background-color: #f59e0b; box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3); }

/* Secundário (Verde Brilhante) */
.btn-secondary { background-color: #10b981; color: #ffffff; width: 100%; margin-top: 10px; }
.btn-secondary:hover { background-color: #059669; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }

/* Danger/Excluir (Vermelho) */
.btn-danger { background-color: #ef4444; color: #ffffff; width: auto; }
.btn-danger:hover { background-color: #dc2626; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3); }

/* Warning/Reset (Laranja) */
.btn-warning { background-color: #f97316; color: #ffffff; width: auto; }
.btn-warning:hover { background-color: #ea580c; }

/* Botões da Tabela (Sem flex:1 para não esticarem, bordas laterais justas) */
.btn-small { 
    padding: 5px 6px; 
    font-size: 10px; 
    margin: 0; 
    white-space: nowrap; 
}

/* =========================================
   4. TELA DE LOGIN
   ========================================= */
.login-container {
    background: #1e293b;
    padding: 35px 25px;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    width: 100%;
    max-width: 360px;
    border: 1px solid #334155;
}

.login-icon { display: flex; justify-content: center; margin-bottom: 20px; }
.login-icon svg { width: 45px; height: 45px; color: #fbbf24; }
.erro { color: #f87171; font-size: 12px; font-weight: 600; text-align: center; margin-top: 15px; display: none; }

/* =========================================
   5. ESTRUTURA PRINCIPAL E MENU
   ========================================= */
.app-layout { display: flex; height: 100vh; width: 100vw; overflow: hidden; background-color: #0f172a; }

.sidebar { width: 240px; background-color: #020617; color: white; display: flex; flex-direction: column; flex-shrink: 0; border-right: 1px solid #1e293b; z-index: 10; }
.sidebar-header { padding: 25px 15px; text-align: center; border-bottom: 1px solid #1e293b; }
.sidebar-header h3 { color: #f8fafc; font-size: 1.05rem; letter-spacing: 1px; margin-bottom: 8px;}

.user-badge { font-size: 0.75rem; font-weight: 600; background: #1e293b; color: #fbbf24; padding: 5px 10px; border-radius: 20px; display: inline-block; border: 1px solid #334155; }

.sidebar-menu { list-style: none; margin: 0; padding: 15px 0; flex-grow: 1; overflow-y: auto; }
.sidebar-menu li a { display: block; padding: 12px 20px; color: #94a3b8; text-decoration: none; font-weight: 500; font-size: 13px; border-left: 3px solid transparent; transition: all 0.2s ease; }
.sidebar-menu li a:hover { background-color: #1e293b; color: #f8fafc; border-left-color: #475569; }
.sidebar-menu li a.active { background-color: #1e293b; color: #fbbf24; border-left-color: #fbbf24; }

.sidebar-footer { padding: 15px; border-top: 1px solid #1e293b; }
.main-content { flex-grow: 1; padding: 25px; overflow-y: auto; }

/* =========================================
   6. CARDS E CONTAINERS INTERNOS
   ========================================= */
.dashboard-container { width: 100%; margin: 0 auto; }

.card-action { margin-bottom: 20px; padding: 20px; background: #1e293b; border: 1px solid #334155; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.card-action p { margin-bottom: 15px; font-size: 13px; color: #94a3b8; line-height: 1.4; }
.divisor { margin: 25px 0; border: 0; border-top: 1px solid #334155; }
#uploadStatus, #statusFormulario { margin-top: 12px; font-size: 13px; color: #fbbf24; }

/* =========================================
   7. TABELAS DE DADOS (ALTAMENTE COMPACTADAS)
   ========================================= */
.table-container { width: 100%; overflow-x: auto; background: #1e293b; border-radius: 8px; border: 1px solid #334155; }

.table-data { width: 100%; border-collapse: collapse; text-align: left; font-size: 11px; } 
.table-data th, .table-data td { padding: 8px 6px; border-bottom: 1px solid #334155; } 

.table-data th { background-color: #0f172a; color: #cbd5e1; font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; } 
.table-data tr:last-child td { border-bottom: none; }
.table-data tr:hover { background-color: #334155; }

/* RE e Posto (Colunas 1 e 2): Impede quebra de linha e enxuga largura */
.table-data td:nth-child(1),
.table-data th:nth-child(1),
.table-data td:nth-child(2),
.table-data th:nth-child(2) {
    white-space: nowrap;
    width: 1%;
}

/* Coluna de Ações: Mantém os botões juntos e não estica a coluna */
.table-data td:last-child, 
.table-data th:last-child {
    white-space: nowrap;
    width: 1%;
}

/* Agrupamento de botões na tabela (nowrap garante que fiquem na mesma linha) */
.acoes-container { display: flex; gap: 4px; flex-wrap: nowrap; align-items: center; }

/* =========================================
   8. BADGES (STATUS E CIAS)
   ========================================= */
.badge { padding: 3px 6px; border-radius: 12px; font-size: 10px; font-weight: 700; border: 1px solid transparent; display: inline-block; white-space: nowrap; }

/* Status: Ativo (Ciano) e Inativo (Cinza) */
.badge-ativo { background: #083344; color: #22d3ee; border-color: #06b6d4; }
.badge-inativo { background: #1f2937; color: #9ca3af; border-color: #4b5563; }

/* Companhias */
.badge-cia-1 { background: #422006; color: #fde047; border-color: #eab308; } /* Amarelo */
.badge-cia-2 { background: #052e16; color: #86efac; border-color: #22c55e; } /* Verde */
.badge-cia-3 { background: #172554; color: #93c5fd; border-color: #3b82f6; } /* Azul */
.badge-cia-4 { background: #450a0a; color: #fca5a5; border-color: #ef4444; } /* Vermelho */
.badge-cia-none { background: #27272a; color: #d4d4d8; border-color: #52525b; } /* Cinza */

.hidden { display: none !important; }

.menu-toggle-btn {
    display: none;
    background: transparent;
    border: 1px solid #334155;
    color: #fbbf24;
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    text-transform: none;
}

@media (max-width: 992px) {
    .app-layout { flex-direction: column; }
    .sidebar { 
        width: 100%; 
        height: auto; 
        flex-direction: column; 
        align-items: stretch; 
        padding: 10px 15px; 
        border-right: none; 
        border-bottom: 1px solid #1e293b; 
    }
    .sidebar-header { 
        padding: 0; 
        border: none; 
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        width: 100%; 
    }
    .sidebar-header .header-text {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .menu-toggle-btn {
        display: block;
    }
    .sidebar-menu { 
        display: none; 
        padding: 10px 0; 
    }
    .sidebar-footer { 
        display: none; 
        padding: 10px 0; 
        border-top: 1px solid #1e293b; 
    }
    
    .sidebar.menu-open .sidebar-menu {
        display: block;
    }
    .sidebar.menu-open .sidebar-footer {
        display: block;
    }
    
    .main-content { padding: 15px; }

    /* Desativa sticky da barra de filtros no mobile para economizar tela */
    .filter-bar {
        position: relative !important;
        top: auto !important;
        box-shadow: none !important;
        gap: 10px !important;
        padding: 12px 15px !important;
    }
    
    .filter-bar select, 
    .filter-bar input, 
    .filter-bar .autocomplete-container, 
    .filter-bar button {
        flex: 1 1 100% !important;
        width: 100% !important;
        min-width: 100% !important;
    }

    .charts-grid {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================
   10. PAINEL DE ESTATÍSTICAS E ANALYTICS
   ========================================= */
.filter-bar {
    display: flex;
    gap: 15px;
    background: #1e293b;
    padding: 15px 20px;
    border-radius: 8px;
    border: 1px solid #334155;
    margin-bottom: 25px;
    align-items: center;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.filter-bar select, .filter-bar input {
    margin-bottom: 0;
    width: auto;
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.kpi-card {
    background: #1e293b;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #334155;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.kpi-title {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: #f8fafc;
}

.kpi-subtext {
    font-size: 11px;
    margin-top: 5px;
    font-weight: 500;
}

.text-success { color: #10b981; }
.text-danger { color: #ef4444; }
.text-warning { color: #fbbf24; }

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.chart-container {
    background: #1e293b;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #334155;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.chart-header {
    font-size: 14px;
    color: #f8fafc;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Esconde painéis dependendo da visualização (Macro vs Dossiê) */
.view-hidden { display: none !important; }

/* Autocomplete Dropdown */
.autocomplete-container { position: relative; flex: 2; min-width: 200px; margin: 0; }
.autocomplete-list { 
    position: absolute; top: 100%; left: 0; right: 0; 
    background: #1e293b; border: 1px solid #334155; border-radius: 6px; 
    max-height: 250px; overflow-y: auto; z-index: 1000; 
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5); display: none; margin-top: 4px;
}
.autocomplete-item { 
    padding: 10px 15px; cursor: pointer; color: #f8fafc; font-size: 13px; border-bottom: 1px solid #334155; 
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #334155; color: #fbbf24; }

/* Switch Toggle (Slide Selector) */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #f8fafc;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #10b981;
}

input:focus + .slider {
  box-shadow: 0 0 1px #10b981;
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.table-data thead th {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}
.table-data thead th[style*="cursor: default"],
.table-data thead th[style*="cursor:default"] {
  cursor: default;
}
.table-data thead th:hover {
  background-color: #334155;
}

/* Tooltip fixo de sanção — injetado via JS no <body>, position: fixed */
#sancao-tooltip {
    transition: opacity 0.12s ease;
}