/* ==========================================================================
   GHG / CO2 Emissions Inventory Management System
   Shared stylesheet — used by every page in the prototype
   ========================================================================== */

:root {
  --primary: #0f7a4d;
  --primary-dark: #0a5c39;
  --primary-darker: #0a3d2a;
  --primary-light: #e6f5ec;
  --teal: #0e9594;
  --teal-light: #e3f6f5;
  --blue: #2563eb;
  --blue-light: #eaf1ff;
  --amber: #b45309;
  --amber-light: #fef3c7;
  --red: #b91c1c;
  --red-light: #fee2e2;
  --purple: #6d28d9;
  --purple-light: #ede9fe;

  --sidebar-w: 264px;
  --topbar-h: 66px;

  --body-bg: #f2f6f4;
  --surface: #ffffff;
  --border-color: #e4eae7;
  --text-main: #1c2a24;
  --text-muted: #667a72;
  --text-soft: #8a9a93;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-sm: 0 1px 3px rgba(15, 40, 30, 0.06), 0 1px 2px rgba(15, 40, 30, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 40, 30, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 40, 30, 0.14);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--body-bg);
  color: var(--text-main);
  font-size: 0.9375rem;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

.text-primary-em { color: var(--primary) !important; }
.text-muted-soft { color: var(--text-soft) !important; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn { border-radius: var(--radius-sm); font-weight: 500; }
.btn-sm { border-radius: 8px; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.1rem;
}
.btn-icon:hover { background: var(--body-bg); color: var(--text-main); }

/* ==========================================================================
   App shell / layout
   ========================================================================== */

.app-wrapper { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0c3d2b 0%, #082a1e 100%);
  color: #eaf3ee;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #7bd9a8;
}

.sidebar-brand .brand-title {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand .brand-subtitle {
  display: block;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.2;
  margin-top: 2px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 0.85rem;
}

.sidebar-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.35);
  padding: 0.5rem 0.65rem 0.35rem;
  margin-top: 0.5rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: rgba(234,243,238,0.72);
  padding: 0.62rem 0.75rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; color: inherit; }
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.18);
}

.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 20, 15, 0.55);
  z-index: 1035;
}
.sidebar-overlay.show { display: block; }

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-left { display: flex; align-items: center; gap: 0.9rem; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 0.6rem; }

.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-title-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e14b4b;
  border: 2px solid #fff;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.3rem 0.5rem;
}
.user-menu:hover { background: var(--body-bg); }

.avatar-circle {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-info { text-align: left; line-height: 1.2; }
.user-info .user-name { display: block; font-size: 0.83rem; font-weight: 600; color: var(--text-main); }
.user-info .user-role { display: block; font-size: 0.72rem; color: var(--text-muted); }

.page-content {
  padding: 1.5rem;
  flex: 1;
  width: 100%;
}

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .user-info { display: none; }
}

@media (max-width: 575.98px) {
  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  padding: 1rem 1.25rem;
}
.card-body { padding: 1.25rem; }

.section-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}
.section-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.15rem;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  height: 100%;
}
.stat-icon {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}
.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}
.stat-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stat-trend {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 4px;
}

.bg-soft-primary { background: var(--primary-light); color: var(--primary); }
.bg-soft-teal { background: var(--teal-light); color: var(--teal); }
.bg-soft-blue { background: var(--blue-light); color: var(--blue); }
.bg-soft-amber { background: var(--amber-light); color: var(--amber); }
.bg-soft-red { background: var(--red-light); color: var(--red); }
.bg-soft-purple { background: var(--purple-light); color: var(--purple); }

.chart-card { padding: 1.25rem; }
.chart-wrap { position: relative; width: 100%; }

/* ==========================================================================
   Badges
   ========================================================================== */

.badge { font-weight: 600; font-size: 0.72rem; padding: 0.4em 0.7em; border-radius: 999px; letter-spacing: 0.01em; }

.badge-draft { background: #e7ebe9; color: #475a52; }
.badge-submitted { background: var(--blue-light); color: var(--blue); }
.badge-district-review { background: var(--amber-light); color: var(--amber); }
.badge-qaqc-review { background: var(--purple-light); color: var(--purple); }
.badge-approved { background: var(--primary-light); color: var(--primary); }
.badge-returned { background: #ffe8d6; color: #c2410c; }
.badge-rejected { background: var(--red-light); color: var(--red); }
.badge-locked { background: #e2e8f0; color: #1e293b; }
.badge-active { background: var(--primary-light); color: var(--primary); }
.badge-pending { background: #fef9c3; color: #a16207; }
.badge-inactive { background: #eef1f0; color: #667a72; }
.badge-suspended { background: var(--red-light); color: var(--red); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-card { overflow: hidden; }
.table { margin-bottom: 0; }
.table thead th {
  background: #f7faf8;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}
.table tbody td {
  padding: 0.8rem 1rem;
  vertical-align: middle;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--border-color);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafcfb; }

.row-link { color: var(--text-main); font-weight: 600; }
.row-link:hover { color: var(--primary); }

/* ==========================================================================
   Forms / filters
   ========================================================================== */

.form-label { font-size: 0.82rem; font-weight: 600; color: var(--text-main); }
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border-color);
  font-size: 0.875rem;
  padding: 0.55rem 0.8rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(15, 122, 77, 0.14);
}
.form-text { font-size: 0.76rem; }

.form-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.form-section-title i { font-size: 1rem; }

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}

.upload-drop {
  border: 1.5px dashed #c7d6cf;
  border-radius: var(--radius-md);
  background: #fafcfb;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
}
.upload-drop i { font-size: 1.8rem; color: var(--primary); }

/* ==========================================================================
   Login page
   ========================================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
}

.login-brand-panel {
  flex: 1.1;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.10) 0, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(255,255,255,0.08) 0, transparent 40%),
    linear-gradient(155deg, #0c4630 0%, #0a3626 55%, #082a1e 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.login-brand-panel .hierarchy-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.85);
  margin: 0.2rem 0.3rem 0.2rem 0;
}

.login-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--surface);
}

.login-card { width: 100%; max-width: 400px; }

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--body-bg);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

@media (max-width: 991.98px) {
  .login-brand-panel { display: none; }
}

/* ==========================================================================
   Geography tree
   ========================================================================== */

.geo-tree { position: relative; }
.geo-node { position: relative; }
.geo-node-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
}
.geo-node-row:hover { background: var(--body-bg); }

.geo-toggle {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.geo-node-row[aria-expanded="true"] .geo-toggle i { transform: rotate(90deg); }
.geo-toggle i { transition: transform 0.15s ease; font-size: 0.8rem; }
.geo-leaf-spacer { width: 22px; min-width: 22px; }

.geo-icon { font-size: 1rem; color: var(--primary); width: 20px; text-align: center; }
.geo-name { font-weight: 600; font-size: 0.88rem; flex: 1; min-width: 0; }
.geo-level-badge {
  font-size: 0.65rem;
  padding: 0.32em 0.6em;
  background: var(--body-bg);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.geo-value {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary-dark);
  white-space: nowrap;
  min-width: 110px;
  text-align: right;
}

.geo-children {
  margin-left: 27px;
  padding-left: 18px;
  border-left: 2px dashed #d7e3dd;
}

.geo-node.d-none { display: none !important; }

/* ==========================================================================
   Workflow stepper
   ========================================================================== */

.workflow-stepper {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.25rem;
  position: relative;
  padding: 0.5rem 0.5rem 0.25rem;
}

.workflow-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  min-width: 90px;
}

.workflow-step::before {
  content: "";
  position: absolute;
  top: 21px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--border-color);
  z-index: 0;
}
.workflow-step:first-child::before { display: none; }

.workflow-step.is-complete::before { background: var(--primary); }

.workflow-step-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-color);
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  position: relative;
  z-index: 1;
  margin-bottom: 0.5rem;
}
.workflow-step.is-complete .workflow-step-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.workflow-step.is-current .workflow-step-circle {
  background: #fff;
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.workflow-step-label { font-size: 0.78rem; font-weight: 700; color: var(--text-main); }
.workflow-step-sub { font-size: 0.68rem; color: var(--text-muted); }

@media (max-width: 767.98px) {
  .workflow-stepper { flex-direction: column; align-items: stretch; gap: 1rem; }
  .workflow-step { flex-direction: row; text-align: left; gap: 0.75rem; min-width: 0; }
  .workflow-step::before { display: none; }
  .workflow-step-circle { margin-bottom: 0; }
}

/* ==========================================================================
   Timeline (review history)
   ========================================================================== */

.timeline { position: relative; padding-left: 1.75rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border-color);
}
.timeline-item { position: relative; padding-bottom: 1.25rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -1.75rem;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--primary-light);
}
.timeline-title { font-size: 0.85rem; font-weight: 700; }
.timeline-meta { font-size: 0.75rem; color: var(--text-muted); }

/* ==========================================================================
   Evidence / file list
   ========================================================================== */

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.6rem;
}
.file-item:last-child { margin-bottom: 0; }
.file-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.file-name { font-size: 0.85rem; font-weight: 600; }
.file-meta { font-size: 0.72rem; color: var(--text-muted); }

/* ==========================================================================
   GIS Map page
   ========================================================================== */

.map-shell {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
#gisMap { height: 560px; width: 100%; background: #dfeae4; }

.facility-list-panel { max-height: 560px; overflow-y: auto; }
.facility-list-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}
.facility-list-item:hover { background: var(--body-bg); }
.facility-list-item.active { background: var(--primary-light); }
.facility-dot { width: 10px; height: 10px; border-radius: 50%; min-width: 10px; }

.leaflet-popup-content-wrapper { border-radius: 10px; }

/* ==========================================================================
   Notification page
   ========================================================================== */

.notif-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--body-bg);
  padding: 2rem 1rem;
}
.notif-card {
  max-width: 480px;
  width: 100%;
  text-align: center;
  padding: 2.5rem 2rem;
}
.notif-icon-circle {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  margin: 0 auto 1.25rem;
}
.notif-reason-box {
  text-align: left;
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  font-size: 0.83rem;
  margin: 1.25rem 0;
}
.notif-demo-switch .btn { font-size: 0.72rem; }

/* ==========================================================================
   Misc utility
   ========================================================================== */

.divider-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-soft);
  font-size: 0.75rem;
  margin: 1rem 0;
}
.divider-label::before, .divider-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.kv-list dt { font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-soft); font-weight: 600; }
.kv-list dd { font-size: 0.9rem; color: var(--text-main); margin-bottom: 0.9rem; }

.breadcrumb { font-size: 0.8rem; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2rem; color: var(--text-soft); margin-bottom: 0.5rem; display: block; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9d6cf; border-radius: 999px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); }

/* ==========================================================================
   Print styles (used by reports.html "Print Report")
   ========================================================================== */

@media print {
  .sidebar, .sidebar-overlay, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}
