<!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') ?></title>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&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') ?>">
  <style>
    body { background: #f8fafc; }
    .public-hero {
      background: linear-gradient(135deg, var(--clr-primary-d) 0%, var(--clr-primary) 100%);
      color: #fff; padding: 80px 32px; text-align: center;
    }
    .public-hero h1 { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 900; }
    .public-hero p { font-size: 1rem; color: rgba(255,255,255,0.75); max-width: 600px; margin: 12px auto 0; }
    .public-container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
  </style>
  <?php if (isset($extraCss)) echo $extraCss; ?>
</head>
<body>

<nav class="public-nav">
  <a href="<?= APP_URL ?>/" class="public-nav-brand">
    <span style="background:var(--clr-accent);width:32px;height:32px;border-radius:6px;display:flex;align-items:center;justify-content:center;font-size:16px;">🗺</span>
    <span>SINER<span>GI</span></span>
  </a>
  <div class="public-nav-links">
    <a href="<?= APP_URL ?>/">Beranda</a>
    <a href="<?= APP_URL ?>/tentang">Tentang</a>
    <a href="<?= APP_URL ?>/kontak">Kontak</a>
    <a href="<?= APP_URL ?>/lapor" style="background:rgba(255,255,255,0.1);padding:7px 14px;border-radius:6px;">📝 Lapor</a>
    <a href="<?= APP_URL ?>/cek-laporan">🔍 Cek Status</a>
    <a href="<?= APP_URL ?>/login" class="btn-login" style="background:var(--clr-accent);color:var(--clr-primary-d);padding:7px 18px;border-radius:6px;font-weight:700;">Login</a>
  </div>
</nav>

<?php
// Expose kode_laporan dari flash ke GLOBALS sebelum flashMessage() mengonsumsinya
// flashMessage() memanggil getFlash() yang menghapus session — jadi kita ambil dulu
if (isset($_SESSION['flash']['kode_laporan'])) {
    $GLOBALS['_flash_kode_laporan'] = $_SESSION['flash']['kode_laporan'];
}
?>
<?= flashMessage() ?>
<?= $content ?>

<footer class="public-footer">
  <div style="margin-bottom:8px;">
    <strong style="color:rgba(255,255,255,0.8);">SINERGI</strong> — Sistem Informasi Geografis Penanganan Kemiskinan<br>
    Berbasis Kolaborasi Rumah Ibadah, Masyarakat, dan Pemerintah Kota Pontianak
  </div>
  <div>© <?= date('Y') ?> Pemerintah Kota Pontianak — Dinas Sosial</div>
</footer>

<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="<?= asset('js/app.js') ?>"></script>
<?php if (isset($extraJs)) echo $extraJs; ?>
</body>
</html>