<?php
require __DIR__ . '/../helpers/auth.php';
auth_check();
$user = auth_user();
?>
<?php
$menu  = 'site';
$title = 'Master Site';
?>

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title><?= $title ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/dashboard.css">
<style>

</style>
</head>

<body>
<div class="app">
 <!-- OVERLAY -->
    <div class="overlay" id="overlay" onclick="toggleSidebar()"></div>

<?php include '../layout/sidebar.php'; ?>

<main class="main">
<?php include '../layout/header.php'; ?>

<h2>📍 Master Site</h2>
<button onclick="openForm()">+ Tambah Site</button>

<table id="siteTable">
<thead>
<tr>
  <th>Nama</th>
  <th>Subnet</th>
  <th>Alamat</th>
  <th>Aksi</th>
</tr>
</thead>
<tbody></tbody>
</table>

</main>
</div>

<!-- MODAL -->
<div class="modal" id="modal">
  <div class="modal-content">
    <h3 id="formTitle">Tambah Site</h3>

    <input type="hidden" id="id">
    <input id="nama_site" placeholder="Nama Site">
    <input id="code_site" placeholder="Subnet (contoh: 1)">
    <input id="lat" placeholder="Latitude">
    <input id="lon" placeholder="Longitude">
    <textarea id="alamat" placeholder="Alamat"></textarea>
    <input id="email" placeholder="Email">
    <input id="no_tlp" placeholder="No Telp">

    <div style="display:flex; gap:10px; margin-top:10px;">
        <button onclick="save()">💾 Simpan</button>
        <button onclick="closeForm()" style="background:#aaa;">❌ Batal</button>
    </div>
  </div>
</div>
<!-- ===============================
     GLOBAL JS (WAJIB)
================================ -->
<script src="../assets/js/layout.js"></script>

<!-- ===============================
     DASHBOARD JS
================================ -->
<script src="../assets/js/dashboard1.js"></script>
<script src="site.js"></script>
</body>
</html>
