@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Colors */
  --brand-primary: #2d6a4f; /* Deep Forest Green (Print Style) */
  --brand-primary-hover: #1b4332;
  --brand-secondary: #0f172a;
  --bg-color: #f1f5f9;
  --surface-color: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  
  /* Status Colors */
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;

  /* Shadows & Radius */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition: all 0.2s ease-in-out;

  /* Sidebar */
  --sidebar-w: 210px;
  --sidebar-collapsed-w: 60px;
}

[data-theme="dark"] {
  --bg-color: #0f172a;
  --surface-color: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --brand-secondary: #f8fafc;
}

/* Reset Componentes */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
a { text-decoration: none; color: var(--brand-primary); transition: var(--transition); }
a:hover { color: var(--brand-primary-hover); }

/* Typography */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--text-main); line-height: 1.2; margin-bottom: 1rem; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
p { margin-bottom: 1rem; }

/* Layout & Grid */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.col-12 { grid-column: 1 / -1; }

@media (max-width: 768px) {
  .grid { grid-template-columns: 1fr; }
}

/* Flex Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

/* Cards */
.card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; }
.card-title { font-size: 1.125rem; font-weight: 600; margin: 0; }

/* Forms */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}
input, select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--surface-color);
  color: var(--text-main);
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}
.form-group { margin-bottom: 1.25rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: normal;
}
.btn-primary {
  background-color: var(--brand-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  color: #fff;
  transform: translateY(-1px);
}
.btn-secondary {
  background-color: var(--surface-color);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--bg-color);
  color: var(--brand-secondary);
}
.btn-danger {
  background-color: var(--danger-bg);
  color: var(--danger);
}
.btn-danger:hover {
  background-color: var(--danger);
  color: #fff;
}
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }

/* Tables */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  background: var(--surface-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
thead th {
  background-color: var(--bg-color);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}
tbody td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: rgba(0,0,0,0.02); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}
.badge-success { background-color: var(--success-bg); color: var(--success); }
.badge-warning { background-color: var(--warning-bg); color: var(--warning); }
.badge-danger { background-color: var(--danger-bg); color: var(--danger); }
.badge-info { background-color: var(--info-bg); color: var(--info); }

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }

/* Alerts / Flash Messages */
.alert {
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.alert-success { background-color: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-danger { background-color: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }

/* Layout Geral (Dashboard) */
nav.top-nav {
  background: var(--brand-primary);
  padding: .6rem 1.2rem;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
nav.top-nav a { color: #fff; text-decoration: none; font-size: .9rem; font-weight: 500;}
nav.top-nav .brand { font-weight: 700; font-size: 1.1rem; margin-right: auto; color: #fff; display: flex; align-items: center; gap: 0.5rem;}
nav.top-nav a:hover { opacity: .8; }

.sidebar {
  width: var(--sidebar-w);
  height: calc(100vh - 48px);
  background: var(--surface-color);
  border-right: 1px solid var(--border-color);
  padding: 1rem 0 4rem 0; /* Extra bottom padding so last items aren't flush with viewport edge */
  position: fixed;
  top: 48px;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease;
  z-index: 90;
}
.sidebar.collapsed {
  width: var(--sidebar-collapsed-w);
}

/* Scrollbar sutil (visível apenas ao passar o mouse) */
.sidebar {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.3s ease;
}
.sidebar:hover {
  scrollbar-color: rgba(100, 116, 139, 0.3) transparent;
}
.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 10px;
  transition: background 0.3s ease;
}
.sidebar:hover::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
}
.sidebar:hover::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.5);
}

/* Links */
.sidebar a {
  display: flex;
  padding: .6rem 1.2rem;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-main);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar a:hover, .sidebar a.active {
  background: var(--bg-color);
  border-left-color: var(--brand-primary);
  color: var(--brand-primary);
}
.sidebar a i {
  min-width: 16px;
  text-align: center;
  flex-shrink: 0;
}

/* Label de seção */
.sidebar .section-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 1.5rem 1.2rem .5rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}
.sidebar.collapsed .section-label {
  opacity: 0;
  pointer-events: none;
  padding-top: 0.75rem;
  padding-bottom: 0;
  height: 0;
}

/* Texto dos links some ao recolher */
.sidebar .nav-label {
  transition: opacity 0.2s;
  white-space: nowrap;
}
.sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

/* Botão toggle */
.sidebar-toggle {
  position: fixed;
  top: calc(48px + 0.65rem);
  left: calc(var(--sidebar-w) - 14px);
  z-index: 95;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: left 0.25s ease;
  color: var(--text-muted);
  font-size: 0.7rem;
}
.sidebar-toggle:hover { color: var(--brand-primary); border-color: var(--brand-primary); }
.sidebar-toggle.collapsed { left: calc(var(--sidebar-collapsed-w) - 14px); }

/* Backdrop mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 85;
}
.sidebar-backdrop.visible { display: block; }

/* Main content */
main.content {
  margin-left: var(--sidebar-w);
  padding: 2rem;
  min-height: calc(100vh - 48px);
  width: calc(100% - var(--sidebar-w));
  transition: margin-left 0.25s ease, width 0.25s ease;
}
main.content.expanded {
  margin-left: var(--sidebar-collapsed-w);
  width: calc(100% - var(--sidebar-collapsed-w));
}

/* ── Mobile ──────────────────────────────────────────── */
@media(max-width: 768px) {
  :root {
    --sidebar-w: 210px;
    --sidebar-collapsed-w: 60px;
  }
  .sidebar {
    width: var(--sidebar-w) !important;
    left: calc(-1 * var(--sidebar-w));
    transition: left 0.25s ease, width 0.25s ease;
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .sidebar-toggle {
    left: 0.5rem !important;
    top: calc(48px + 0.65rem);
  }
  .sidebar-toggle.mobile-open {
    left: calc(var(--sidebar-w) - 14px) !important;
  }
  main.content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 1rem;
  }
}

/* Base KPI Cards and Progress */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.kpi-card { background: var(--surface-color); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.25rem; text-align: center; box-shadow: var(--shadow-sm); }
.kpi-card .value { font-size: 2rem; font-weight: 800; color: var(--brand-primary); margin-bottom: 0.25rem; line-height: 1; }
.kpi-card .label { font-size: .875rem; color: var(--text-muted); font-weight: 500; }
.progress-bar { background: var(--border-color); border-radius: 20px; height: 8px; overflow: hidden; width: 100%; }
.progress-bar-fill { height: 100%; background: var(--brand-primary); border-radius: 20px; transition: width .4s ease; }
