/* ── Variaveis ─────────────────────────────────────────────────────────────── */
:root {
  --sidebar-w:     220px;
  --sidebar-bg:    #0f2744;
  --sidebar-hover: #1a3a5c;
  --sidebar-active:#2471a3;
  --accent:        #2471a3;
  --accent-light:  #ebf5fb;
  --page-bg:       #f0f3f7;
  --card-bg:       #ffffff;
  --text-main:     #1a2a3a;
  --text-muted:    #7f8c8d;
  --border:        #e1e8ed;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0,0,0,.07);
}

/* ── Reset / Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--page-bg); color: var(--text-main); }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .25s ease;
  overflow: hidden;
}

/* ── Botão toggle da sidebar ───────────────────────────────────────────────── */
.sidebar-toggle {
  position: absolute;
  right: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: var(--sidebar-active);
  border: 2px solid var(--page-bg);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  z-index: 200;
  transition: background .15s, box-shadow .15s;
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
  padding: 0;
}
.sidebar-toggle:hover {
  background: #1a5276;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}

/* ── Sidebar recolhida ─────────────────────────────────────────────────────── */
.sidebar.collapsed { width: 54px; }
.sidebar.collapsed .brand-name,
.sidebar.collapsed .brand-sub,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-label { display: none !important; }
.sidebar.collapsed .sidebar-brand {
  padding: 20px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
.sidebar.collapsed .brand-icon { display: flex !important; }
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
}
.sidebar.collapsed .nav-item i { font-size: 1.15rem; margin: 0; }
.sidebar.collapsed .user-chip  { justify-content: center; }
.sidebar.collapsed .user-avatar { margin: 0; }
.sidebar.collapsed .btn-logout { justify-content: center; padding: 8px 0; }

/* Ícone da brand (recolhida) */
.brand-icon { display: none; color: #fff; font-size: 1.3rem; }

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-name {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
}
.brand-sub {
  display: block;
  font-size: .7rem;
  color: rgba(255,255,255,.4);
  margin-top: 3px;
  line-height: 1.3;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .875rem;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item i { font-size: 1rem; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }

.sidebar-footer {
  padding: 14px 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { font-size: .82rem; color: #fff; font-weight: 600; }
.user-role { font-size: .7rem; color: rgba(255,255,255,.45); text-transform: uppercase; letter-spacing: .5px; }
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 7px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .8rem;
  transition: all .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ── Main content ──────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 28px 30px;
  overflow-x: hidden;
  min-width: 0;
}

.flash-bar { margin-bottom: 20px; }

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; color: var(--text-main); }
.page-sub   { font-size: .8rem; color: var(--text-muted); }

/* ── Stat cards ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.bg-primary-soft { background: #ebf5fb; }
.bg-success-soft { background: #eafaf1; }
.bg-warning-soft { background: #fef9e7; }
.bg-danger-soft  { background: #fdedec; }

.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ── Charts ────────────────────────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.chart-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 16px;
}
.chart-wrap { height: 220px; }

/* ── Section card ──────────────────────────────────────────────────────────── */
.section-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.section-header {
  padding: 14px 20px;
  font-size: .875rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-head th {
  background: #f8fafc;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border) !important;
  padding: 10px 16px;
}
.table td { padding: 11px 16px; vertical-align: middle; }
.table tbody tr { border-bottom: 1px solid #f0f3f6; }
.table tbody tr:last-child { border-bottom: none; }

/* Row status colors - subtle left border */
.doc-row.status-danger  { border-left: 3px solid #e74c3c; }
.doc-row.status-warning { border-left: 3px solid #f39c12; }
.doc-row.status-success { border-left: 3px solid #27ae60; }

.badge.bg-tipo { background: #34495e !important; font-weight: 500; }

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.filter-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-field {
  position: relative;
  flex: 1;
  min-width: 180px;
}
.filter-field i {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.filter-field input { padding-left: 32px; }
.filter-select { max-width: 170px; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 12px; display: block; }
.empty-state p { font-size: .95rem; margin-bottom: 16px; }

/* ── Auth pages ────────────────────────────────────────────────────────────── */
.auth-body {
  background: linear-gradient(135deg, #0f2744 0%, #1a5276 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-container { width: 100%; max-width: 400px; padding: 20px; }
.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo {
  width: 60px; height: 60px;
  background: var(--accent);
  border-radius: 16px;
  color: #fff;
  font-size: 1.3rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.auth-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: .85rem; }
.input-with-icon { position: relative; }
.input-with-icon i {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.input-with-icon input { padding-left: 36px; }
.btn-auth { padding: 10px; font-weight: 600; }
.auth-divider {
  text-align: center;
  margin: 20px 0 12px;
  position: relative;
  color: var(--text-muted);
  font-size: .8rem;
}
.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: var(--border);
}
.auth-divider span {
  position: relative;
  background: #fff;
  padding: 0 12px;
}
.auth-version {
  text-align: center;
  margin-top: 16px;
  font-size: .75rem;
  color: rgba(255,255,255,.4);
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 20px; }
.modal-content { border-radius: 12px; border: none; box-shadow: 0 20px 60px rgba(0,0,0,.2); }

/* ── Botao primario ────────────────────────────────────────────────────────── */
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #1a5276; border-color: #1a5276; }

/* ── Responsivo ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .charts-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
