:root {
  --primary: #0066cc;
  --primary-dark: #0855a9;
  --secondary: #28a745;
  --accent: #ffc107;
  --danger: #dc3545;
  --dark: #343a40;
  --light: #f8f9fa;
  --radius: 8px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body {
  background: var(--light);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
}

/* ===== Header ================================================= */
.dashboard-header {
  background: linear-gradient(to right, #4f8df9, #355fbd); /* tons mais azuis */
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.gov-logo {
  height: 60px;
  width: auto;
}

/* ===== Cards ================================================== */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.card-header {
  background: #fff;
  border-bottom: 2px solid var(--primary-dark);
  font-weight: 600;
  color: var(--dark);
  /* centralizar o título */
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* ===== KPI cards ============================================= */
.kpi-card {
  background: linear-gradient(135deg, #4f8df9, #355fbd); /* tons de azul */
  color: white;
  border-radius: 10px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}
.kpi-card .card-body{padding:2rem;}
.kpi-icon{font-size:4rem;margin-bottom:1rem;opacity:.8;}
.kpi-card h3{font-size:3rem;font-weight:700;margin-bottom:.5rem;}

/* ===== AJUSTES PARA ALTURA IGUAL E ALINHAMENTO ============== */

/* 1. Para garantir que todas as rows tenham altura igual */
.equal-height-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

.equal-height-row > [class*="col-"] {
  display: flex;
  flex-direction: column;
}

.equal-height-row .card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 400px; /* Altura mínima fixa para todos os cards */
}

/* 2. Centralização vertical do KPI card */
.kpi-card .card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center; /* Centraliza verticalmente */
  align-items: center; /* Centraliza horizontalmente */
  text-align: center;
}

/* 3. Para cards com gráficos - altura fixa do card-body */
.equal-height-row .card:not(.kpi-card) .card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 340px; /* Altura fixa do conteúdo (400px total - 60px header) */
}

/* 4. Ajuste específico para gráficos de barra com scroll */
.bar-chart-wrapper {
  flex: 1;
  max-height: 320px; /* Altura máxima para ativar scroll */
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  position: relative;
}

.bar-chart-wrapper .canvas-container {
  height: auto !important;
  min-height: 100%;
  position: relative;
}

.bar-chart-wrapper canvas {
  width: 100% !important;
  display: block;
}

/* 5. Para o gráfico de pizza - altura fixa */
.chart-container {
  height: 320px !important; /* Altura fixa */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 6. Scrollbar customizada para os gráficos de barra */
.bar-chart-wrapper::-webkit-scrollbar {
  width: 6px;
}

.bar-chart-wrapper::-webkit-scrollbar-track {
  background: #f8f8f8;
  border-radius: 3px;
}

.bar-chart-wrapper::-webkit-scrollbar-thumb {
  background: rgba(183, 183, 184, 0.686);
  border-radius: 3px;
}

.bar-chart-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--dark);
}

/* 7. Ajuste do card header para altura consistente */
.equal-height-row .card-header {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ===== Filtros =============================================== */
.filter-group {
  margin-bottom: 1rem;
}

.filter-group label {
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

#filter-sidebar {
  width: 300px;
  position: fixed;
  top: 0;
  left: -300px;
  height: 100%;
  background: white;
  z-index: 1049;
  padding: 20px;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.2);
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
}

.filter-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 5px; /* para espaço do scrollbar */
}

.filter-footer {
  background: white;
  padding-top: 10px;
}

#toggle-filters {
  /* position: fixed;   <-- remova ou comente */
  top: 20px;
  left: 20px;
  z-index: 1050;
}

#toggle-filters i { font-size: 1.1rem; }
#toggle-filters { padding: .375rem .75rem; }

#toggle-filters.open {
  opacity: 0.5;
}

.form-select,
.form-control {
  border-radius: var(--radius);
  border: 1px solid #dee2e6;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-select:focus,
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
  outline: none;
}

.btn {
  border-radius: var(--radius);
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-primary:hover {
  background: #004f9f;
  border-color: #004f9f;
  transform: translateY(-1px);
}

/* ===== Loading overlay ======================================= */
.loading-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.spinner-border {
  width: 3rem;
  height: 3rem;
}

/* ===== Pagination / Controls ================================= */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* ===== Responsive tweaks ===================================== */
@media (max-width: 768px) {
  .dashboard-header h1 {
    font-size: 1.5rem;
  }
  
  .kpi-card h3 {
    font-size: 2.5rem;
  }
  
  .kpi-icon {
    font-size: 2rem;
  }
  
  .equal-height-row .card {
    min-height: 300px; /* Altura menor em mobile */
  }
  
  .equal-height-row .card:not(.kpi-card) .card-body {
    min-height: 240px;
  }
  
  .bar-chart-wrapper {
    max-height: 220px;
  }
  
  .chart-container {
    height: 220px !important;
  }
  
  #filter-sidebar {
    width: 280px;
    left: -280px;
  }
}

@media (max-width: 576px) {
  .filter-col {
    min-width: 100% !important;
  }
  
  #filter-sidebar {
    width: 100%;
    left: -100%;
  }
  
  .dashboard-header h1 {
    font-size: 1.25rem;
  }
  
  .kpi-card .card-body {
    padding: 1.5rem;
  }
  
  .kpi-card h3 {
    font-size: 1.75rem;
  }
  
  .equal-height-row .card {
    min-height: 250px; /* Altura ainda menor em mobile pequeno */
  }
  
  .equal-height-row .card:not(.kpi-card) .card-body {
    min-height: 190px;
  }
  
  .bar-chart-wrapper {
    max-height: 170px;
  }
  
  .chart-container {
    height: 170px !important;
  }
}

/* ===== Animations ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

/* ===== Overlay para sidebar em mobile ======================= */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(220, 220, 220, 0.945);
  z-index: 1048;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== Misc ================================================== */
.currency {
  font-family: 'Courier New', monospace;
  font-weight: bold;
}

.card-hover-effect:hover {
  transform: scale(1.02);
  transition: transform 0.2s ease;
}
