/* ============================================================
   SINERGI — Main Stylesheet
   Sistem Informasi Geografis Penanganan Kemiskinan
   Kota Pontianak
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --clr-primary:    #1a3a5c;
  --clr-primary-d:  #112845;
  --clr-primary-l:  #2a5c8e;
  --clr-accent:     #e8a020;
  --clr-accent-d:   #c87d10;
  --clr-success:    #16a34a;
  --clr-danger:     #dc2626;
  --clr-warning:    #d97706;
  --clr-info:       #0284c7;
  --clr-bg:         #f0f4f8;
  --clr-surface:    #ffffff;
  --clr-border:     #d1dce8;
  --clr-text:       #1e2d3d;
  --clr-text-muted: #5a6e82;
  --clr-sidebar-bg: #112845;
  --clr-sidebar-hover: rgba(255,255,255,0.08);
  --clr-sidebar-active: rgba(232,160,32,0.18);
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;
  --shadow-sm:      0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.14);
  --sidebar-w:      260px;
  --topbar-h:       62px;
  --font-main:      'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;
  --transition:     all 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--clr-primary-l); text-decoration: none; }
a:hover { color: var(--clr-accent); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- Layout: App Shell --- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  grid-row: 1 / -1;
  background: var(--clr-sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  transition: var(--transition);
}
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: var(--clr-accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.sidebar-brand-text h1 {
  font-size: 1.1rem; font-weight: 700; color: #fff; line-height: 1.2;
}
.sidebar-brand-text p { font-size: 0.68rem; color: rgba(255,255,255,0.5); line-height: 1.3; }

.sidebar-section { padding: 20px 12px 4px; }
.sidebar-section-title {
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  padding: 0 8px; margin-bottom: 4px;
}
.sidebar-nav { list-style: none; }
.sidebar-nav li { margin-bottom: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.78); font-size: 0.875rem; font-weight: 500;
  transition: var(--transition); cursor: pointer;
}
.sidebar-nav a:hover { background: var(--clr-sidebar-hover); color: #fff; }
.sidebar-nav a.active {
  background: var(--clr-sidebar-active);
  color: var(--clr-accent); font-weight: 600;
  border-left: 3px solid var(--clr-accent);
}
.sidebar-nav a .nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 1rem; }
.sidebar-nav a .nav-badge {
  margin-left: auto; background: var(--clr-danger);
  color: #fff; font-size: 0.65rem; font-weight: 700;
  padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}

.sidebar-footer {
  margin-top: auto; padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
}
.sidebar-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--clr-primary-l);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.68rem; color: rgba(255,255,255,0.45); }
.sidebar-logout { color: rgba(255,255,255,0.5); font-size: 1rem; cursor: pointer; transition: var(--transition); }
.sidebar-logout:hover { color: var(--clr-danger); }

/* --- Topbar --- */
.topbar {
  grid-column: 2;
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--clr-text); flex: 1; }
.topbar-breadcrumb { font-size: 0.8rem; color: var(--clr-text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-time { font-size: 0.8rem; color: var(--clr-text-muted); font-family: var(--font-mono); }

/* --- Main Content --- */
.main-content {
  grid-column: 2;
  padding: 24px 28px;
  overflow-x: hidden;
}

/* --- Cards --- */
.card {
  background: var(--clr-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--clr-border);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--clr-border);
  display: flex; align-items: center; gap: 10px;
}
.card-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--clr-text); }
.card-header .card-icon { font-size: 1.1rem; }
.card-header .card-actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--clr-surface);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  border: 1px solid var(--clr-border);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-start; gap: 14px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-card-icon.blue    { background: #dbeafe; color: #1d4ed8; }
.stat-card-icon.red     { background: #fee2e2; color: #dc2626; }
.stat-card-icon.orange  { background: #ffedd5; color: #c2410c; }
.stat-card-icon.yellow  { background: #fef9c3; color: #a16207; }
.stat-card-icon.green   { background: #dcfce7; color: #15803d; }
.stat-card-icon.purple  { background: #f3e8ff; color: #7e22ce; }
.stat-card-icon.teal    { background: #ccfbf1; color: #0f766e; }
.stat-card-icon.gray    { background: #f1f5f9; color: #475569; }
.stat-card-body { flex: 1; min-width: 0; }
.stat-card-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--clr-text); }
.stat-card-label { font-size: 0.78rem; color: var(--clr-text-muted); margin-top: 3px; }
.stat-card-sub { font-size: 0.72rem; color: var(--clr-text-muted); margin-top: 6px; }

/* --- Map Container --- */
.map-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--clr-border);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.map-container #map, .map-container .map-inner {
  width: 100%; border-radius: 0;
}

/* --- Dashboard Grid --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}
.dashboard-grid.full { grid-template-columns: 1fr; }
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  background: #f8fafc; color: var(--clr-text-muted);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 10px 14px;
  border-bottom: 1px solid var(--clr-border); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 9px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.badge-red      { background: #fee2e2; color: #dc2626; }
.badge-orange   { background: #ffedd5; color: #c2410c; }
.badge-yellow   { background: #fef9c3; color: #a16207; }
.badge-green    { background: #dcfce7; color: #15803d; }
.badge-blue     { background: #dbeafe; color: #1d4ed8; }
.badge-gray     { background: #f1f5f9; color: #475569; }
.badge-purple   { background: #f3e8ff; color: #7e22ce; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  border: none; transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--clr-primary); color: #fff; }
.btn-primary:hover { background: var(--clr-primary-l); }
.btn-accent   { background: var(--clr-accent); color: var(--clr-primary-d); }
.btn-accent:hover { background: var(--clr-accent-d); }
.btn-success  { background: var(--clr-success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger   { background: var(--clr-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost    { background: transparent; color: var(--clr-text-muted); border: 1px solid var(--clr-border); }
.btn-ghost:hover { background: var(--clr-bg); color: var(--clr-text); }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-icon { padding: 7px; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--clr-text); margin-bottom: 5px; }
.form-label .required { color: var(--clr-danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--clr-border); border-radius: var(--radius-sm);
  background: var(--clr-surface); color: var(--clr-text); font-size: 0.875rem;
  transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--clr-primary-l); box-shadow: 0 0 0 3px rgba(42,92,142,0.12); }
.form-hint { font-size: 0.75rem; color: var(--clr-text-muted); margin-top: 4px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* --- Flash Messages --- */
.flash-message {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 20px; font-size: 0.875rem; font-weight: 500;
}
.flash-success { background: #dcfce7; color: #15803d; border-left: 4px solid #16a34a; }
.flash-error   { background: #fee2e2; color: #dc2626; border-left: 4px solid #dc2626; }
.flash-warning { background: #fef9c3; color: #a16207; border-left: 4px solid #d97706; }
.flash-info    { background: #dbeafe; color: #1d4ed8; border-left: 4px solid #0284c7; }

/* --- Priority Score Bar --- */
.priority-bar { position: relative; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.priority-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.priority-bar-fill.high   { background: var(--clr-danger); }
.priority-bar-fill.medium { background: var(--clr-warning); }
.priority-bar-fill.low    { background: var(--clr-success); }

/* --- Map Legend --- */
.map-legend {
  position: absolute; bottom: 28px; left: 12px; z-index: 1000;
  background: var(--clr-surface); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: 12px 14px;
  border: 1px solid var(--clr-border); min-width: 160px;
}
.map-legend h4 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--clr-text-muted); margin-bottom: 8px; }
.map-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; margin-bottom: 5px; }
.map-legend-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.legend-dot-ekstrem  { background: #dc2626; }
.legend-dot-miskin   { background: #ea580c; }
.legend-dot-rentan   { background: #ca8a04; }
.legend-dot-ri       { background: #16a34a; }
.legend-dot-blind    { background: #7c3aed; }
.legend-dot-laporan  { background: #0284c7; }

/* --- Tabs --- */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--clr-border); margin-bottom: 20px; }
.tab-btn {
  padding: 9px 18px; font-size: 0.875rem; font-weight: 600;
  color: var(--clr-text-muted); border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition);
}
.tab-btn.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); }
.tab-btn:hover:not(.active) { color: var(--clr-text); }

/* --- Filters --- */
.filters-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 18px; padding: 14px 16px;
  background: var(--clr-surface); border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
}
.filters-bar select, .filters-bar input {
  padding: 7px 11px; border: 1px solid var(--clr-border); border-radius: var(--radius-sm);
  background: var(--clr-surface); font-size: 0.85rem; color: var(--clr-text);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.48);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--clr-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(20px); transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--clr-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--clr-text-muted); font-size: 1.3rem; border: none; background: none; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--clr-border); display: flex; justify-content: flex-end; gap: 10px; }

/* --- Empty State --- */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--clr-text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; }

/* --- Pagination --- */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 20px; }
.page-btn {
  padding: 6px 11px; border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--clr-border); background: var(--clr-surface); color: var(--clr-text-muted);
  transition: var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--clr-primary); color: #fff; border-color: var(--clr-primary); }

/* --- Chart Container --- */
.chart-wrap { position: relative; height: 240px; }

/* --- Sidebar list panel --- */
.sidebar-panel {
  height: 100%; overflow-y: auto;
  border-left: 1px solid var(--clr-border);
  background: var(--clr-surface);
}
.sidebar-panel-header {
  padding: 16px 20px; border-bottom: 1px solid var(--clr-border);
  position: sticky; top: 0; background: var(--clr-surface); z-index: 10;
}
.sidebar-panel-item {
  padding: 12px 20px; border-bottom: 1px solid #f1f5f9; cursor: pointer;
  transition: var(--transition);
}
.sidebar-panel-item:hover { background: #f8fafc; }
.sidebar-panel-item.active { background: #eff6ff; border-left: 3px solid var(--clr-primary); }
.sidebar-panel-item h4 { font-size: 0.85rem; font-weight: 600; }
.sidebar-panel-item p { font-size: 0.75rem; color: var(--clr-text-muted); margin-top: 2px; }

/* --- Public layout --- */
.public-nav {
  position: sticky; top: 0; z-index: 200;
  background: var(--clr-primary-d); box-shadow: var(--shadow-md);
  padding: 0 32px; height: 64px;
  display: flex; align-items: center; gap: 24px;
}
.public-nav-brand {
  display: flex; align-items: center; gap: 10px; color: #fff;
  font-weight: 800; font-size: 1.15rem; text-decoration: none;
}
.public-nav-brand span { color: var(--clr-accent); }
.public-nav-links { display: flex; gap: 4px; margin-left: auto; }
.public-nav-links a {
  color: rgba(255,255,255,0.78); padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500; transition: var(--transition);
}
.public-nav-links a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.public-nav-links a.btn-login {
  background: var(--clr-accent); color: var(--clr-primary-d);
  font-weight: 700; padding: 7px 18px;
}
.public-footer {
  background: var(--clr-primary-d); color: rgba(255,255,255,0.55);
  padding: 32px; text-align: center; font-size: 0.82rem; margin-top: 60px;
}

/* --- Login Page --- */
.login-page {
  min-height: 100vh; display: flex;
  background: linear-gradient(135deg, var(--clr-primary-d) 0%, var(--clr-primary) 60%, var(--clr-primary-l) 100%);
}
.login-left {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 48px;
  color: #fff; display: none;
}
@media (min-width: 900px) { .login-left { display: flex; } }
.login-right {
  width: 100%; max-width: 440px; background: #fff;
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px; box-shadow: var(--shadow-lg);
}
.login-logo { font-size: 3rem; font-weight: 900; letter-spacing: -0.02em; }
.login-logo span { color: var(--clr-accent); }
.login-tagline { font-size: 0.875rem; color: rgba(255,255,255,0.65); margin-top: 8px; max-width: 360px; text-align: center; line-height: 1.5; }
.login-form-title { font-size: 1.5rem; font-weight: 800; color: var(--clr-text); margin-bottom: 6px; }
.login-form-sub { font-size: 0.85rem; color: var(--clr-text-muted); margin-bottom: 28px; }

/* --- Misc --- */
.text-muted { color: var(--clr-text-muted); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-auto { margin-top: auto; }
.w-full { width: 100%; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--clr-text); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.divider { border: none; border-top: 1px solid var(--clr-border); margin: 20px 0; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- Responsive --- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar, .main-content { grid-column: 1; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .main-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
}
