<!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') ?> — SINERGI Verifikator</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" id="sidebar">
    <div class="sidebar-brand">
      <div class="sidebar-brand-icon">✅</div>
      <div class="sidebar-brand-text">
        <h1>SINERGI</h1>
        <p>Verifikator Kelurahan</p>
      </div>
    </div>

    <?php $u = Auth::user(); ?>
    <div style="padding:14px 16px;background:rgba(255,255,255,0.05);margin:12px;border-radius:8px;">
      <div style="font-size:0.7rem;color:rgba(255,255,255,0.45);text-transform:uppercase;letter-spacing:0.08em;margin-bottom:4px;">Wilayah Tugas</div>
      <div style="font-size:0.88rem;color:#fff;font-weight:600;"><?= e($u['kelurahan_nama'] ?? '-') ?></div>
      <div style="font-size:0.75rem;color:rgba(255,255,255,0.5);"><?= e($u['kecamatan_nama'] ?? '') ?></div>
    </div>

    <div class="sidebar-section">
      <div class="sidebar-section-title">Menu</div>
      <ul class="sidebar-nav">
        <li><a href="<?= APP_URL ?>/verifikator/dashboard"><span class="nav-icon">📊</span> Dashboard</a></li>
        <li><a href="<?= APP_URL ?>/verifikator/laporan"><span class="nav-icon">📋</span> Daftar Laporan</a></li>
        <li><a href="<?= APP_URL ?>/verifikator/warga"><span class="nav-icon">👥</span> Data Warga</a></li>
        <li><a href="<?= APP_URL ?>/verifikator/warga/tambah"><span class="nav-icon">➕</span> Tambah Warga</a></li>
      </ul>
    </div>

    <div class="sidebar-footer">
      <div class="sidebar-user">
        <div class="sidebar-user-avatar"><?= strtoupper(substr($user['nama'] ?? 'V', 0, 1)) ?></div>
        <div class="sidebar-user-info">
          <div class="sidebar-user-name"><?= e($user['nama'] ?? '') ?></div>
          <div class="sidebar-user-role">Verifikator</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://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>
