/* ===================================================
   Sistema de Diárias - Araci/BA
   Estilos principais — Responsivo, acessível
   =================================================== */

:root {
  --blue-700: #185FA5;
  --blue-800: #0C447C;
  --blue-100: #B5D4F4;
  --blue-50:  #E6F1FB;
  --green-700:#3B6D11;
  --green-100:#C0DD97;
  --green-50: #EAF3DE;
  --amber-700:#854F0B;
  --amber-100:#FAC775;
  --amber-50: #FAEEDA;
  --red-700:  #A32D2D;
  --red-50:   #FCEBEB;
  --gray-900: #2C2C2A;
  --gray-700: #5F5E5A;
  --gray-400: #888780;
  --gray-200: #D3D1C7;
  --gray-100: #F1EFE8;
  --white:    #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 2px 8px rgba(0,0,0,.10);
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --transition: .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  color: var(--gray-900);
  background: var(--gray-100);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ===================================================
   LAYOUT PRINCIPAL
   =================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===================================================
   SIDEBAR
   =================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-brand {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}
.sidebar-brand .brand-name {
  font-size: .85rem;
  font-weight: 700;
  color: var(--blue-700);
  line-height: 1.3;
}
.sidebar-brand .brand-sub {
  font-size: .72rem;
  color: var(--gray-400);
  margin-top: 2px;
}
.sidebar-entity {
  padding: 8px 20px;
  background: var(--blue-50);
  border-bottom: 1px solid var(--blue-100);
}
.sidebar-entity select {
  width: 100%;
  border: none;
  background: transparent;
  font-size: .78rem;
  color: var(--blue-800);
  font-weight: 600;
  cursor: pointer;
}
.nav-group { padding: 8px 0; }
.nav-group-label {
  font-size: .65rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .7px;
  padding: 6px 20px 2px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: .82rem;
  color: var(--gray-700);
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-900); text-decoration: none; }
.nav-link.active { background: var(--blue-50); color: var(--blue-700); border-left-color: var(--blue-700); font-weight: 600; }
.nav-link .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red-700);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--blue-50);
  color: var(--blue-700);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}
.avatar.green  { background: var(--green-50);  color: var(--green-700); }
.avatar.amber  { background: var(--amber-50);  color: var(--amber-700); }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: .78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .68rem; color: var(--gray-400); }
.sidebar-logout { background: none; border: none; cursor: pointer; color: var(--gray-400); font-size: 1rem; padding: 4px; }
.sidebar-logout:hover { color: var(--red-700); }

/* ===================================================
   CONTEÚDO PRINCIPAL
   =================================================== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  height: var(--topbar-h);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.topbar-menu-btn {
  display: none;
  background: none; border: none;
  font-size: 1.3rem; cursor: pointer;
  color: var(--gray-700);
}
.topbar-title { font-size: 1rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-content { padding: 24px; flex: 1; max-width: 1400px; }

/* ===================================================
   CARDS
   =================================================== */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.card-title { font-size: .88rem; font-weight: 600; }
.card-body { padding: 20px; }

/* ===================================================
   STAT CARDS
   =================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: 10px;
}
.stat-card .stat-label { font-size: .73rem; color: var(--gray-700); font-weight: 500; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-card .stat-sub   { font-size: .72rem; color: var(--gray-400); margin-top: 4px; }
.stat-blue  .stat-icon  { background: var(--blue-50);  color: var(--blue-700); }
.stat-blue  .stat-value { color: var(--blue-700); }
.stat-green .stat-icon  { background: var(--green-50); color: var(--green-700); }
.stat-green .stat-value { color: var(--green-700); }
.stat-amber .stat-icon  { background: var(--amber-50); color: var(--amber-700); }
.stat-amber .stat-value { color: var(--amber-700); }
.stat-red   .stat-icon  { background: var(--red-50);   color: var(--red-700); }
.stat-red   .stat-value { color: var(--red-700); }

/* ===================================================
   TABELAS
   =================================================== */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.data-table th {
  padding: 10px 14px; font-size: .72rem; font-weight: 700;
  color: var(--gray-400); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--gray-200); text-align: left; white-space: nowrap;
}
table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}
table.data-table tbody tr:hover td { background: var(--gray-100); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ===================================================
   BADGES
   =================================================== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: .7rem; font-weight: 700;
  white-space: nowrap;
}
.badge-pendente   { background: var(--amber-50);  color: var(--amber-700); }
.badge-aprovado   { background: var(--green-50);  color: var(--green-700); }
.badge-rejeitado  { background: var(--red-50);    color: var(--red-700); }
.badge-pago       { background: var(--blue-50);   color: var(--blue-700); }
.badge-comprovado { background: #E1F5EE;           color: #04342C; }
.badge-arquivado  { background: var(--gray-100);  color: var(--gray-700); }
.badge-prefeitura { background: var(--blue-50);   color: var(--blue-800); }
.badge-saae       { background: var(--green-50);  color: var(--green-700); }
.badge-camara     { background: var(--amber-50);  color: var(--amber-700); }

/* ===================================================
   FORMULÁRIOS
   =================================================== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 5px; color: var(--gray-700); }
.form-label.required::after { content: ' *'; color: var(--red-700); }
.form-control {
  display: block; width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .85rem; color: var(--gray-900);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--blue-700);
  box-shadow: 0 0 0 3px rgba(24,95,165,.12);
}
.form-control:read-only { background: var(--gray-100); color: var(--gray-700); }
.form-control.is-invalid { border-color: var(--red-700); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-text { font-size: .75rem; color: var(--gray-400); margin-top: 3px; }
.invalid-feedback { color: var(--red-700); font-size: .75rem; margin-top: 3px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--blue-700); }

/* ===================================================
   BOTÕES
   =================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: .83rem; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent;
  transition: background var(--transition), transform .1s;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary  { background: var(--blue-700);  color: #fff; border-color: var(--blue-700); }
.btn-primary:hover  { background: var(--blue-800); color: #fff; text-decoration: none; }
.btn-success  { background: var(--green-700); color: #fff; border-color: var(--green-700); }
.btn-success:hover  { background: #27500A; color: #fff; text-decoration: none; }
.btn-danger   { background: var(--red-700);   color: #fff; border-color: var(--red-700); }
.btn-danger:hover   { background: #791F1F; color: #fff; text-decoration: none; }
.btn-warning  { background: var(--amber-700); color: #fff; border-color: var(--amber-700); }
.btn-outline  { background: transparent; color: var(--gray-700); border-color: var(--gray-200); }
.btn-outline:hover  { background: var(--gray-100); text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: .75rem; }
.btn-lg { padding: 11px 22px; font-size: .93rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===================================================
   ALERTAS
   =================================================== */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .82rem; margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
  border-left: 4px solid transparent;
}
.alert-info    { background: var(--blue-50);  color: var(--blue-800);  border-left-color: var(--blue-700); }
.alert-success { background: var(--green-50); color: var(--green-700); border-left-color: var(--green-700); }
.alert-warning { background: var(--amber-50); color: var(--amber-700); border-left-color: var(--amber-700); }
.alert-danger  { background: var(--red-50);   color: var(--red-700);   border-left-color: var(--red-700); }

/* ===================================================
   MODAIS
   =================================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  opacity: 0; visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 620px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(12px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0;
  background: var(--white); z-index: 1;
}
.modal-title { font-size: .95rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray-400); }
.modal-close:hover { color: var(--gray-900); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ===================================================
   TABS
   =================================================== */
.tab-nav { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 18px; overflow-x: auto; }
.tab-btn {
  padding: 10px 18px; font-size: .82rem; font-weight: 600; cursor: pointer;
  color: var(--gray-400); border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: color var(--transition);
}
.tab-btn:hover { color: var(--gray-900); }
.tab-btn.active { color: var(--blue-700); border-bottom-color: var(--blue-700); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===================================================
   TIMELINE
   =================================================== */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--gray-200); }
.timeline-item { position: relative; padding-bottom: 16px; padding-left: 16px; }
.timeline-dot {
  position: absolute; left: -14px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--gray-200); border: 2px solid var(--white);
}
.timeline-dot.green { background: var(--green-700); }
.timeline-dot.amber { background: var(--amber-700); }
.timeline-dot.blue  { background: var(--blue-700); }
.timeline-dot.red   { background: var(--red-700); }
.timeline-action { font-size: .82rem; font-weight: 600; }
.timeline-meta { font-size: .75rem; color: var(--gray-400); margin-top: 2px; }
.timeline-parecer { font-size: .78rem; color: var(--gray-700); margin-top: 4px; font-style: italic; }

/* ===================================================
   PAGINAÇÃO
   =================================================== */
.pagination { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.page-btn {
  padding: 6px 11px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: .78rem; font-weight: 600;
  background: var(--white); cursor: pointer; color: var(--gray-700);
  transition: background var(--transition);
}
.page-btn:hover { background: var(--gray-100); }
.page-btn.active { background: var(--blue-700); color: #fff; border-color: var(--blue-700); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===================================================
   UPLOAD ZONE
   =================================================== */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-size: .82rem; color: var(--gray-400);
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--blue-700); background: var(--blue-50); color: var(--blue-700); }
.upload-zone input[type="file"] { display: none; }

/* ===================================================
   LOGIN
   =================================================== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--blue-700) 0%, var(--blue-800) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%; max-width: 400px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-circle {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--blue-50); color: var(--blue-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin: 0 auto 12px;
}
.login-logo h1 { font-size: 1.1rem; font-weight: 700; margin-bottom: 2px; }
.login-logo p  { font-size: .8rem; color: var(--gray-400); }

/* ===================================================
   GRÁFICOS (canvas)
   =================================================== */
.chart-container { position: relative; width: 100%; }

/* ===================================================
   RESPONSIVIDADE
   =================================================== */
@media (max-width: 1024px) {
  .form-grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-240px);
    width: 240px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .topbar-menu-btn { display: flex; }
  .form-grid.cols-2, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .page-content { padding: 14px; }
  .topbar { padding: 0 14px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 24px 18px; }
  .topbar-actions .btn-lg { padding: 8px 12px; font-size: .78rem; }
}

/* ===================================================
   UTILITÁRIOS
   =================================================== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-400); }
.text-sm { font-size: .78rem; }
.fw-600 { font-weight: 600; }
.mt-0  { margin-top: 0; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.d-none { display: none; }
.spinner {
  width: 20px; height: 20px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue-700);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Overlay para mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 190;
}
.sidebar-overlay.open { display: block; }
