<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="app-url" content="<?= APP_URL ?>">
  <meta name="csrf-token" content="<?= $_SESSION['csrf_token'] ?? '' ?>">
  <title><?= e($title ?? 'SINERGI') ?> — Dinas Sosial</title>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
  <link rel="stylesheet" href="<?= asset('css/app.css') ?>">
  <?php if (isset($extraCss)) echo $extraCss; ?>
</head>
<body>
<div class="app-shell">
  <aside class="sidebar">
    <div class="sidebar-brand">
      <div class="sidebar-brand-icon" style="background:#0284c7">📈</div>
      <div class="sidebar-brand-text">
        <h1>SINERGI</h1>
        <p>Dinas Sosial</p>
      </div>
    </div>

    <div class="sidebar-section">
      <div class="sidebar-section-title">Monitoring</div>
      <ul class="sidebar-nav">
        <li><a href="<?= APP_URL ?>/dinsos/dashboard"><span class="nav-icon">📊</span> Dashboard</a></li>
        <li><a href="<?= APP_URL ?>/dinsos/kemiskinan"><span class="nav-icon">🗺</span> Peta Kemiskinan</a></li>
        <li><a href="<?= APP_URL ?>/dinsos/bantuan"><span class="nav-icon">📦</span> Monitoring Bantuan</a></li>
        <li><a href="<?= APP_URL ?>/dinsos/blind-spot"><span class="nav-icon">⚠️</span> Blind Spot</a></li>
        <li><a href="<?= APP_URL ?>/dinsos/kinerja"><span class="nav-icon">🏆</span> Kinerja Rumah Ibadah</a></li>
        <li><a href="<?= APP_URL ?>/dinsos/laporan"><span class="nav-icon">📄</span> Laporan Tahunan</a></li>
      </ul>
    </div>

    <div class="sidebar-footer">
      <div class="sidebar-user">
        <div class="sidebar-user-avatar" style="background:#0284c7"><?= strtoupper(substr($user['nama'] ?? 'D', 0, 1)) ?></div>
        <div class="sidebar-user-info">
          <div class="sidebar-user-name"><?= e($user['nama'] ?? '') ?></div>
          <div class="sidebar-user-role">Dinas Sosial</div>
        </div>
        <a href="<?= APP_URL ?>/logout" class="sidebar-logout" title="Logout">⏻</a>
      </div>
    </div>
  </aside>

  <header class="topbar">
    <div class="topbar-title"><?= e($title ?? '') ?></div>
    <div class="topbar-actions">
      <span class="topbar-time" id="live-clock"></span>
    </div>
  </header>

  <main class="main-content">
    <?= flashMessage() ?>
    <?= $content ?>
  </main>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet.heat@0.2.0/dist/leaflet-heat.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
<script src="<?= asset('js/app.js') ?>"></script>
<?php if (isset($extraJs)) echo $extraJs; ?>
</body>
</html>
