<?php include 'koneksi.php'; ?>
<!DOCTYPE html>
<html lang="en">
    <head><link rel="icon" href="upload/bn2.png" type="image/png">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Detail Prestasi | Smk Budiniah 2</title>
        <style>
            body{
                margin:0;
                font-family: 'Times New Roman', Times, serif;
            }
            .detail-container{
                padding: 5%;
                max-width: 800px;
                margin: 0 auto;
            }
            .detail-image{
                width: 100%;
                max-height: 500px;
                object-fit: cover;
                border-radius: 8px;
                margin-bottom: 20px;
            }
            .detail-title{
                font-size: 48px;
                font-weight: 700;
                margin-bottom: 10px;
            }
            .detail-kejuaraan{
                font-size: 18px;
                color: #b8860b;
                margin-bottom: 20px;
            }
            .detail-description{
                font-size: 20px;
                line-height: 1.6;
                color: #333;
            }
            .button a{
            display: inline-block;
            margin-top: 30px;
            padding: 10px 20px;
            background: linear-gradient(135deg, #0f62fe, #3f3ea5ff);
            color: white;
            text-decoration: none;
            border-radius: 5px;
            transition: all 0.3s ease;
        }
        .button:hover a{
            background: linear-gradient(135deg, #3f3ea5ff, #0f62fe);
            transform: translateY(-2px);
        }
        </style>
    </head>
    <body>
        <?php require 'navbar.php'; ?>
        <div class="detail-container">
            <?php
            if (isset($_GET['id_prestasi'])) {
                $id = intval($_GET['id_prestasi']);
                $query = "SELECT * FROM tb_prestasi WHERE id_prestasi = $id";
                $result = mysqli_query($host, $query);
                if ($result && mysqli_num_rows($result) > 0) {
                    $row = mysqli_fetch_assoc($result);
                    $kejuaraan = htmlspecialchars($row['kejuaraan_dari']);
                    $judul = htmlspecialchars($row['nama_prestasi']);
                    $deskripsi = htmlspecialchars($row['deskripsi']);
                    $imgSrc = !empty($row['gambar_prestasi']) ? "upload/" . htmlspecialchars($row['gambar_prestasi']) : "upload/default.jpg";
                    echo "<img src='" . $imgSrc . "' alt='" . $judul . "' class='detail-image'>";
                    echo "<h1 class='detail-title'>" . $judul . "</h1>";
                    echo "<p class='detail-kejuaraan'>Kejuaraan dari " . $kejuaraan . "</p>";
                    echo "<p class='detail-description'>" . $deskripsi . "</p>";
                    echo "<div class='button'>";
                    echo "<a href='prestasi.php'>Kembali ke prestasi</a>";
                    echo "</div>";
                } else {
                    echo "<p>Prestasi tidak ditemukan.</p>";
                }
            } else {
                echo "<p>ID prestasi tidak valid.</p>";
            }
            ?>
        </div>
        <?php require 'footer.php'; ?>
    </body>
</html>

