<?php
include "../koneksi.php";
include "inc/navbar.php";
$query = mysqli_query($conn, "SELECT * FROM ustadz ORDER BY id DESC");
?>

<!DOCTYPE html>
<html>
<head>
<title>Data Ustadz</title>

<style>
body{
    font-family:Arial, sans-serif;
    background:#f3f4f6;
    margin:0;
}

.container{
    max-width:1100px;
    margin:50px auto;
    background:#fff;
    padding:25px;
    border-radius:16px;
    box-shadow:0 10px 30px rgba(0,0,0,.1);
}

.header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:20px;
}

.header h2{
    margin:0;
}

.btn-add{
    background:#10b981;
    color:#fff;
    padding:10px 16px;
    border-radius:10px;
    text-decoration:none;
    font-size:14px;
}

table{
    width:100%;
    border-collapse:collapse;
}

thead{
    background:#1f2937;
    color:#fff;
}

th, td{
    padding:12px;
    text-align:center;
    border-bottom:1px solid #e5e7eb;
}

.btn-edit{
    background:#3b82f6;
    color:#fff;
    padding:6px 12px;
    border-radius:8px;
    text-decoration:none;
}

.btn-hapus{
    background:#ef4444;
    color:#fff;
    padding:6px 12px;
    border-radius:8px;
    text-decoration:none;
}
</style>
</head>

<body>

<div class="container">
    <div class="header">
        <h2>Data Ustadz</h2>
        <a href="ustadz_tambah.php" class="btn-add">+ Tambah Ustadz</a>
    </div>

    <table>
        <thead>
            <tr>
                <th>No</th>
                <th>Nama</th>
                <th>Bidang</th>
                <th>Alamat</th>
                <th>Aksi</th>
            </tr>
        </thead>
        <tbody>
        <?php $no=1; while($u = mysqli_fetch_assoc($query)): ?>
            <tr>
                <td><?= $no++; ?></td>
                <td><?= $u['nama']; ?></td>
                <td><?= $u['bidang']; ?></td>
                <td><?= $u['alamat']; ?></td>
                <td>
    <a href="ustadz_edit.php?id=<?= $u['id']; ?>" class="btn-edit">Edit</a>
    <a href="ustadz_hapus.php?id=<?= $u['id']; ?>"
       class="btn-hapus"
       onclick="return confirm('Yakin hapus data ustadz ini?')">
       Hapus
    </a>
</td>

            </tr>
        <?php endwhile; ?>
        </tbody>
    </table>
</div>

</body>
</html>
