/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Colors */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --red-50: #fef2f2;
  --red-500: #ef4444;
  --red-600: #dc2626;

  --green-50: #f0fdf4;
  --green-500: #22c55e;
  --green-600: #16a34a;

  --yellow-50: #fffbeb;
  --yellow-500: #eab308;
  --yellow-600: #ca8a04;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Typography */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Border Radius */
  --radius-sm: 0.125rem;
  --radius: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Transitions */
  --transition: all 0.2s ease-in-out;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  color: var(--gray-900);
  background-color: var(--gray-50);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.lg-hidden {
  display: block;
}

@media (min-width: 1024px) {
  .lg-hidden {
    display: none;
  }
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--gray-200);
  border-top: 2px solid var(--primary-600);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-4);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Login Screen */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.login-container {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-icon img {
  width: 220px;
  height: 180px;
}

#header-logo {
  width: 30px;
}

@media screen and (max-width: 1125px) {
  #header-text {
    font-size: 16px;
    margin-top: 10px;
  }
  #header-logo {
    width: 20px;
  }
}

.login-header h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-2);
}

.login-header p {
  color: var(--gray-600);
  font-size: var(--text-sm);
}

/* Main Application */
.main-app {
  min-height: 100vh;
  display: flex;
  gap: 1px;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 16rem;
  background: white;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(-100%);
  transition: transform 0.3s ease-in-out;
}

.sidebar.open {
  transform: translateX(0);
}

@media (min-width: 1024px) {
  .sidebar {
    position: static;
    transform: translateX(0);
  }
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 30;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--gray-200);
  height: 4rem;
}

.sidebar-header h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--gray-900);
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--gray-500);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius);
  transition: var(--transition);
}

.sidebar-close:hover {
  background-color: var(--gray-100);
  color: var(--gray-700);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-2);
  overflow-y: auto;
  max-height: 77vh;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-1);
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--gray-700);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.nav-item:hover {
  background-color: var(--gray-100);
  color: var(--gray-900);
}

.nav-item.active {
  background-color: var(--primary-600);
  color: white;
}

.nav-item svg {
  margin-right: var(--space-3);
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--gray-200);
  padding: var(--space-4);
}

.user-info {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-3);
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background-color: var(--gray-200);
  color: var(--gray-500);
  border-radius: 50%;
  margin-right: var(--space-3);
}

.user-details {
  flex: 1;
}

.user-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-900);
  margin-bottom: var(--space-1);
}

.user-role {
  font-size: var(--text-xs);
  color: var(--gray-500);
  text-transform: capitalize;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: 0;
}

/* @media (min-width: 1024px) {
  .main-content {
    margin-left: 16rem;
  }
} */

.main-header {
  display: flex;
  align-items: center;
  height: 4rem;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 var(--space-4);
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--gray-500);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius);
  margin-right: var(--space-4);
  transition: var(--transition);
}

.sidebar-toggle:hover {
  background-color: var(--gray-100);
  color: var(--gray-700);
}

.header-content {
  flex: 1;
}

.header-content h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-900);
}

/* Content Area */
.content-area {
  flex: 1;
  padding: var(--space-6);
  margin: 0 auto;
  width: 100%;
}

/* @media (min-width: 1280px) {
  .content-area {
    max-width: 90rem;
    padding: var(--space-6) var(--space-8);
  }
} */

/* Dashboard */
.dashboard-header {
  margin-bottom: var(--space-8);
}

.dashboard-header h1 {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-2);
}

.dashboard-header p {
  color: var(--gray-600);
  font-size: var(--text-lg);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  background-color: var(--primary-100);
  color: var(--primary-600);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}

.stat-icon.alert {
  background-color: var(--red-50);
  color: var(--red-600);
}

.stat-content h3 {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: var(--space-2);
}

.stat-number {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-1);
}

.stat-number.alert {
  font-size: var(--text-3xl);
  /*font-weight: 700;*/
  color: var(--red-600);
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--gray-500);
}

/* View Header */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.view-title h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-1);
}

.view-title p {
  color: var(--gray-600);
  font-size: var(--text-sm);
}

/* View Controls */
.view-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 20rem;
}

.search-box input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  padding-right: var(--space-10);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box svg {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}

.view-actions {
  display: flex;
  gap: var(--space-2);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--gray-500);
}

.empty-state svg {
  margin: 0 auto var(--space-4);
  color: var(--gray-300);
}

.empty-state h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: var(--space-2);
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--gray-500);
}

/* Alerts */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}

.alert-error {
  background-color: var(--red-50);
  color: var(--red-800);
  border: 1px solid var(--red-200);
}

.alert-success {
  background-color: var(--green-50);
  color: var(--green-800);
  border: 1px solid var(--green-200);
}

.alert-warning {
  background-color: var(--yellow-50);
  color: var(--yellow-800);
  border: 1px solid var(--yellow-200);
}

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

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

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

.slide-in {
  animation: slideIn 0.3s ease-out;
}

.nav-link {
  text-decoration: none;
  color: inherit;
}

.text-muted {
  color: var(--gray-500);
}

.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 5px;
  font-size: 14px;
  color: white;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.ag-picker-field {
  display: none !important;
}

.custom-select {
  position: relative;
  display: inline-block;
  width: 100%;
}

.custom-select-selected {
  border: 1px solid #ccc;
  padding: 10px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius);
}

.custom-select-selected:focus {
  outline: none;
  border-color: #888;
}

.custom-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: none;
  border: 1px solid #ccc;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  z-index: 99999;
  overflow: hidden;
}

.custom-select-search {
  width: 100%;
  padding: 8px;
  border: none;
  border-bottom: 1px solid #ccc;
  box-sizing: border-box;
}

.custom-select-search:focus {
  outline: none;
  border-color: #888;
}

.custom-select-options {
  max-height: 200px;
  overflow-y: auto;
}

.custom-select-option {
  padding: 8px;
  cursor: pointer;
  user-select: none;
}

.custom-select-option:hover {
  background: #f0f0f0;
}


/* ====== AJUSTES GERAIS / DASHBOARD ====== */
.stat-card {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
}

.stat-card h3 { margin-bottom: var(--space-1); }
.stat-label { color: var(--gray-500); }

.stat-number { letter-spacing: 0.2px; }
.stat-number.alert { color: var(--red-600); }

.content-area { padding: var(--space-6) var(--space-6); }

/* Grid dos gráficos (opcional se quiser remover estilos inline do HTML) */
.cards-grid-2 {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
  .cards-grid-2 { grid-template-columns: 1fr 1fr; }
}

/* Cartão para gráficos */
.chart-card {
  padding: var(--space-6);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  background: white;
  box-shadow: var(--shadow);
  min-height: 360px; /* mantém altura confortável */
  display: flex;
  flex-direction: column;
}
.chart-card h3 { margin-bottom: var(--space-4); }
.chart-card canvas { flex: 1; }

/* Tabela de alerta */
.table-sm th,
.table-sm td {
  padding: 0.55rem 0.75rem;
}
.table-sm td.num { font-variant-numeric: tabular-nums; }

/* Cores auxiliares */
.text-danger { color: var(--red-600) !important; }
.text-muted  { color: var(--gray-500) !important; }
.text-right  { text-align: right !important; }

/* Barra divisória leve (se precisar em seções) */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: var(--space-4) 0;
}

/* Scrollbar mais discreta (Chrome/Edge) */
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* Focus só quando via teclado */
:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
  border-radius: 6px;
}


/* =========================================================
   OVERRIDES — Sidebar fixa/colapsável + caret do Cadastros
   (cole no FINAL do styles.css)
   ========================================================= */
:root{
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 78px;
}

/* Sidebar fixa (desktop) / off-canvas (mobile) */
#sidebar{
  position: fixed !important;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w) !important;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: width .25s ease, transform .30s ease-in-out;
}

/* conteúdo rola, sidebar não */
#sidebar .sidebar-nav{ overflow-y: auto; }

/* Itens do menu (garante alinhamento) */
#sidebar .nav-item{ display:flex; align-items:center; gap:.6rem; }
#sidebar .label{ white-space: nowrap; }

/* Botão flutuante de colapso (desktop) */
.sidebar-pin{
  position: fixed;
  top: 12px;
  left: calc(var(--sidebar-w) - 12px);
  z-index: 50;
  width: 30px; height: 30px;
  display:flex; align-items:center; justify-content:center;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
  cursor: pointer;
}
body.sidebar-collapsed .sidebar-pin{ left: calc(var(--sidebar-w-collapsed) - 12px); }
.sidebar-pin svg{ transition: transform .2s ease; }
body.sidebar-collapsed .sidebar-pin svg{ transform: rotate(180deg); }

/* Desktop: empurra conteúdo e aplica colapso */
@media (min-width: 1024px){
  .main-app{ padding-left: var(--sidebar-w) !important; transition: padding-left .25s ease; }
  body.sidebar-collapsed .main-app{ padding-left: var(--sidebar-w-collapsed) !important; }

  /* estado colapsado */
  #sidebar.collapsed{ width: var(--sidebar-w-collapsed) !important; }
  #sidebar.collapsed .label,
  #sidebar.collapsed .sidebar-footer{ display: none !important; }
  #sidebar.collapsed .nav-item{ justify-content: center; }
  #sidebar.collapsed .collapse.show{ display: none !important; }

  /* some a setinha do "Cadastros" no colapso pra alinhar ícones */
  body.sidebar-collapsed #btn-cadastros .submenu-caret{ display: none !important; }
  #btn-cadastros .submenu-caret{ margin-left: auto; display: inline-flex; }
}

/* Mobile: sidebar vira off-canvas, conteúdo sem padding-left */
@media (max-width: 1023px){
  /* off-canvas por padrão; abra adicionando .open no #sidebar (seu JS já faz) */
  #sidebar{ transform: translateX(-100%) !important; }
  #sidebar.open{ transform: translateX(0) !important; }
  .main-app{ padding-left: 0 !important; }
  .sidebar-pin{ display: none !important; } /* botão flutuante some no mobile */
}

