<?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>Pengumuman | Smk Budiniah 2</title>
    <style>
        body{
            margin:0;
            font-family: 'Times New Roman', Times, serif;
        }
        body a{
            cursor: pointer;
        }
        .hero-caption{
            display: flex;
            flex-direction: column;
            align-items: left;
            justify-content: left;
            text-align: left;
            margin-top: 10%;
            margin-bottom: 5%;
            padding-left: 5%;
            padding-right: 5%;
        }
        .hero-caption h1{
            margin: 0 0 20px 0;
            font-size: 60px; 
            font-weight: 700;
        }
        .hero-caption p{
            margin: 0 0 20px 0;
            max-width: 500px;
            line-height: 1.6;
            font-weight: 500;
        }
        .hero-caption li{
            margin-bottom: 10px;
        }
        .cart-pengumuman{
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: center;
            align-items: center;
            gap:20px;
            padding: 20px 0;
        }
        .pengumuman-card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            padding: 20px;
            max-width: 500px;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin: 10px;
        }
        .card-content {
            text-align: left;
        }
        .card-image {
            position: relative;
            margin-bottom: 15px;
            overflow: hidden;
        }
        .pengumuman-card img {
            border-radius: 10px;
            margin-bottom: 15px;
            transition: transform 0.3s ease;
        }
        .card-image:hover img {
            transform: scale(1.05);
        }
        .overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-size: 18px;
            font-weight: bold;
            opacity: 0;
            transition: opacity 0.3s ease;
            pointer-events: none;
        }
        .card-image:hover .overlay {
            opacity: 1;
        }
        .pengumuman-card h3 {
            color: #131a33;
            margin-bottom: 10px;
        }
        .pengumuman-card p {
            color: #666;
            line-height: 1.5;
        }
        .card-content a{
            margin-top: 5% ;
            text-decoration: none;
            text-align: center;
            color: #ffffff;
            padding: 10px 20px;
            border: none;
            border-radius: 25px;
            background: linear-gradient(135deg, #3426ffff, #5b8cffff);
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
            transition: all 0.3s ease;
            display: inline-block;
            font-weight: bold;
        }
        .card-content a:hover {
            box-shadow: 0 6px 12px rgba(0,0,0,0.3);
            transform: translateY(-2px);
        }

        /* Responsive Design */
        @media (max-width: 768px) {
            .hero-caption h1 {
                font-size: 40px;
                margin-top: 15%;
            }
            .hero-caption p {
                font-size: 14px;
                max-width: 100%;
            }
            .cart-pengumuman {
                padding: 10px 5%;
                gap: 15px;
            }
            .pengumuman-card {
                max-width: 100%;
                padding: 15px;
                margin: 5px;
            }
            .pengumuman-card img {
                width: 100%;
                height: auto;
                max-height: 200px;
            }
            .pengumuman-card h3 {
                font-size: 16px;
            }
            .pengumuman-card p {
                font-size: 13px;
            }
            .overlay {
                font-size: 14px;
            }
        }

        @media (max-width: 480px) {
            .hero-caption h1 {
                font-size: 30px;
                margin-top: 20%;
            }
            .hero-caption p {
                font-size: 12px;
            }
            .cart-pengumuman {
                padding: 10px 2%;
                gap: 10px;
            }
            .pengumuman-card {
                padding: 10px;
                margin: 2px;
            }
            .pengumuman-card img {
                max-height: 150px;
            }
            .pengumuman-card h3 {
                font-size: 14px;
            }
            .pengumuman-card p {
                font-size: 12px;
            }
            .overlay {
                font-size: 12px;
            }
        }

    </style>
</head>
<body>
    <?php require 'navbar.php'; ?>
    <div class="hero-caption">
        <h1>Pengumuman</h1>
        <p>Berita dan pengumuman terbaru dari SMK Budiniah 2. Dapatkan informasi terkini seputar kegiatan sekolah, prestasi siswa, dan berita penting lainnya.</p>
    </div>
    <div class="cart-pengumuman">
        <?php
        $query = "SELECT * FROM tb_pengumuman";
        $result = mysqli_query($host,$query);
        if ($result && mysqli_num_rows($result) > 0){
            while ($row = mysqli_fetch_assoc($result)){
                $imgSrc = !empty($row['gambar_pengumuman']) ? "upload/" . htmlspecialchars($row['gambar_pengumuman']) : "upload/default.jpg";
                $judul = htmlspecialchars($row['judul_pengumuman']);
                $tanggal = date('d M Y', strtotime($row['tanggal']));
                $deskripsi = htmlspecialchars($row['deskripsi_pengumuman']);
                echo '<div class="pengumuman-card">';
                echo '<div class="card-image">';
                echo '<a href="detail_pengumuman.php?id=' . $row['id_pengumuman'] . '"><img src="' . $imgSrc . '" alt="' . $judul . '" style="width: 400px; height: 300px; object-fit: cover;"></a>';
                echo '<div class="overlay">Baca Selengkapnya</div>';
                echo '</div>';
                echo '<div class="card-content">';
                echo '<h3>' . $judul . '</h3>';
                echo "<p>" . $deskripsi . "</p>";
                echo '<p>' . $tanggal . '</p>';
                echo '</div>';
                echo '</div>';
            }
        } else {
            echo '<p>Tidak ada pengumuman tersedia.</p>';
        }
        ?>
    </div>
    <?php require 'footer.php' ?>
</body>
</html>

