<?php include("config.php"); ?>
<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>MetalBoss! - Website musik cadas dan badass</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #f4f4f4;
            padding: 20px;
        }

        .navbar {
            background: #000000;
            padding: 1rem 2rem;
            position: sticky;
            top: 0;
            z-index: 1000;
            box-shadow: 0 2px 5px rgba(159, 159, 159, 0.1);
        }

        .nav-content {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            color: white;
            font-size: 1.5rem;
            font-weight: bold;
            text-decoration: none;
        }

        .nav-links {
            display: flex;
            gap: 2rem;
        }

        .nav-links a {
            color: white;
            text-decoration: none;
            font-weight: 500;
            transition: color 0.3s;
            position: relative;
        }

        .nav-links a::after {
            content: '';
            position: absolute;
            bottom: -5px;
            left: 0;
            width: 0;
            height: 2px;
            background: white;
            transition: width 0.3s;
        }

        .nav-links a:hover::after {
            width: 100%;
        }

        .dropdown {
            position: relative;
            display: inline-block;
        }

        .dropdown-menu {
            display: none;
            position: absolute;
            background: rgb(104, 104, 104);
            border-radius: 5px;
            padding: 0;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            list-style: none;
            min-width: 150px;
            top: 100%;
            left: 0;
        }

        .dropdown:hover .dropdown-menu {
            display: block;
        }

        .dropdown-item {
            padding: 12px 20px;
            color: black;
            font-weight: bold;
            text-transform: uppercase;
            transition: background 0.3s;
            display: block;
            text-decoration: none;
        }

        .dropdown-item:hover {
            background: #000000;
            color: white;
        }

        .metal-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
            background: white;
        }

        .metal-table th, .metal-table td {
            border: 1px solid black;
            padding: 10px;
            text-align: center;
        }

        .metal-table th {
            background: #000;
            color: white;
        }

        .metal-table tr:nth-child(even) {
            background: #f4f4f4;
        }

        .add-button {
            display: inline-block;
            margin-top: 20px;
            margin-bottom: 10px;
            padding: 10px 20px;
            background-color: #000;
            color: white;
            text-decoration: none;
            font-weight: bold;
            border-radius: 5px;
            transition: background 0.3s;
        }

        .add-button:hover {
            background-color: #333;
        }
    </style>
</head>
<body>
    <nav class="navbar">
        <div class="nav-content">
            <a href="#" class="logo">MetalBoss!</a>
            <div class="nav-links">
                <a href="http://localhost/khansa/index.html">Beranda</a>
                <div class="dropdown">
                    <a href="#" class="dropdown-toggle" itemprop="url"><span itemprop="name">Genre</span></a>
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" href="http://localhost/khansa/list-album.php" itemprop="http://localhost/khansa/list-album.php"><span itemprop="name">Album</span></a></li>
                        <li><a class="dropdown-item" href="#" itemprop="url"><span itemprop="name">Band</span></a></li>
                        <li><a class="dropdown-item" href="#" itemprop="url"><span itemprop="name">Musik</span></a></li>
                    </ul>
                </div>
                <div class="dropdown">
                    <a href="#" class="dropdown-toggle" itemprop="url"><span itemprop="name">Region</span></a>
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" href="#" itemprop="url"><span itemprop="name">Amerika</span></a></li>
                        <li><a class="dropdown-item" href="#" itemprop="url"><span itemprop="name">Jerman</span></a></li>
                        <li><a class="dropdown-item" href="#" itemprop="url"><span itemprop="name">Inggris</span></a></li>
                    </ul>
                </div>
                <a href="#">Konser</a>
                <a href="#">Lirik</a>
            </div>
        </div>
    </nav>

    <h2>Daftar Album Metal Terbaik</h2>

    <!-- Tombol ke form isi-album -->
    <a href="isi-album.php" class="add-button">+ Tambah Album</a>

    <table class="metal-table">
        <thead>
            <tr>
                <th>ID</th>
                <th>Band</th>
                <th>Album</th>
                <th>Tahun Rilis</th>
                <th>Aksi</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $sql = "SELECT * FROM album";
            $query = mysqli_query($db, $sql);
            while($album = mysqli_fetch_array($query)) {
                echo "<tr>";
                echo "<td>".$album['id']."</td>";
                echo "<td>".$album['band']."</td>";
                echo "<td>".$album['album']."</td>";
                echo "<td>".$album['tahun_rilis']."</td>";
                echo "<td>
                        <a href='form-edit.php?id=".$album['id']."'>Edit</a> |
                        <a href='hapus.php?id=".$album['id']."' onclick=\"return confirm('Yakin ingin menghapus album ini?');\">Hapus</a>
                    </td>";
                echo "</tr>";
            }
            ?>
        </tbody>
    </table>

    <p>Total: <?php echo mysqli_num_rows($query); ?></p>
</body>
</html>