<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $nama_aplikasi ?> - Portal Berita Siswa Berprestasi</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body class="bg-slate-50 text-slate-800 font-sans">

    <nav class="bg-white/80 backdrop-blur-md sticky top-0 z-50 border-b border-slate-200">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between h-16 items-center">
                <div class="flex items-center gap-3">
                    <div class="h-9 w-9 rounded-lg bg-indigo-600 flex items-center justify-center font-bold text-white shadow-lg shadow-indigo-500/30">A</div>
                    <span class="font-extrabold text-xl bg-gradient-to-r from-indigo-600 to-blue-500 bg-clip-text text-transparent"><?= $nama_aplikasi ?></span>
                </div>
                <div class="flex items-center gap-4">
                    <a href="#berita" class="text-sm font-medium text-slate-600 hover:text-indigo-600 transition-colors">Berita</a>
                    <a href="#statistik" class="text-sm font-medium text-slate-600 hover:text-indigo-600 transition-colors">Statistik</a>
                    <a href="/login" class="bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-semibold py-2 px-4 rounded-lg shadow-md shadow-indigo-600/10 transition-all">
                        <i class="fa fa-sign-in-alt mr-1"></i> Login Sistem
                    </a>
                </div>
            </div>
        </div>
    </nav>

    <header class="relative bg-slate-900 overflow-hidden py-24 text-center md:text-left">
        <div class="absolute inset-0 bg-[radial-gradient(#38bdf8_1px,transparent_1px)] [background-size:16px_16px] opacity-10"></div>
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10 grid grid-cols-1 md:grid-cols-2 gap-12 items-center">
            <div class="space-y-6">
                <span class="inline-block bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 text-xs font-bold tracking-widest uppercase px-3 py-1.5 rounded-full">Etalase Juara Regional</span>
                <h1 class="text-4xl md:text-5xl font-black text-white leading-tight">Apresiasi Nyata untuk <span class="bg-gradient-to-r from-indigo-400 to-blue-400 bg-clip-text text-transparent">Siswa Berprestasi</span></h1>
                <p class="text-base text-slate-400 leading-relaxed">Platform resmi pendataan, verifikasi, dan publikasi capaian prestasi siswa madrasah. Menginspirasi generasi, mendokumentasikan dedikasi.</p>
                <div class="pt-2">
                    <a href="#berita" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-6 rounded-lg shadow-lg shadow-indigo-600/20 transition-all">Lihat Berita Prestasi</a>
                </div>
            </div>
            <div class="hidden md:flex justify-center">
                <div class="relative w-96 h-72 bg-gradient-to-tr from-indigo-600 to-blue-500 rounded-2xl shadow-2xl p-6 text-white flex flex-col justify-between transform rotate-2 hover:rotate-0 transition-all duration-300">
                    <div class="flex justify-between items-center">
                        <i class="fa fa-trophy text-4xl text-amber-300 animate-bounce"></i>
                        <span class="text-xs bg-white/20 px-2 py-1 rounded-full font-bold">Live Data</span>
                    </div>
                    <div>
                        <p class="text-2xl font-bold">Sertifikat Tervalidasi</p>
                        <p class="text-sm text-indigo-100 mt-1">Sistem Keamanan Anti-Manipulasi Dokumen.</p>
                    </div>
                </div>
            </div>
        </div>
    </header>

    <section id="statistik" class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 -mt-8 relative z-20">
        <div class="bg-white border border-slate-200 rounded-2xl p-8 shadow-xl grid grid-cols-1 md:grid-cols-2 gap-8 text-center divide-y md:divide-y-0 md:divide-x divide-slate-100">
            <div class="pt-4 md:pt-0">
                <p class="text-4xl font-black text-indigo-600"><?= $total_prestasi ?></p>
                <p class="text-sm font-semibold text-slate-500 mt-1 uppercase tracking-wider">Total Prestasi Tervalidasi</p>
            </div>
            <div class="pt-4 md:pt-0">
                <p class="text-4xl font-black text-blue-600"><?= $total_madrasah ?></p>
                <p class="text-sm font-semibold text-slate-500 mt-1 uppercase tracking-wider">Madrasah Terintegrasi</p>
            </div>
        </div>
    </section>

    <section id="berita" class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-20">
        <div class="text-center md:text-left mb-12">
            <h2 class="text-3xl font-extrabold text-slate-900">Kabar Prestasi Terbaru</h2>
            <p class="text-sm text-slate-500 mt-2">Artikel apresiasi resmi yang dirilis langsung oleh Admin Kantor.</p>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
            <?php if(empty($list_berita)): ?>
                <div class="col-span-full bg-white border rounded-xl p-12 text-center text-slate-400">
                    <i class="fa fa-newspaper text-4xl mb-3 block text-slate-300"></i>
                    Belum ada berita prestasi publik yang diterbitkan.
                </div>
            <?php endif; ?>

            <?php foreach($list_berita as $b): ?>
            <article class="bg-white border border-slate-200 rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-shadow flex flex-col justify-between">
                <div>
                    <div class="h-48 w-full bg-slate-200 overflow-hidden relative">
                        <img src="/uploads/berita/<?= $b['gambar'] ?>" alt="Cover" class="w-full h-full object-cover">
                    </div>
                    <div class="p-5 space-y-3">
                        <span class="text-[10px] bg-indigo-50 text-indigo-600 border border-indigo-100 px-2.5 py-0.5 rounded font-bold uppercase tracking-wider"><?= date('d M Y', strtotime($b['created_at'])) ?></span>
                        <h3 class="font-bold text-lg text-slate-900 leading-snug line-clamp-2 hover:text-indigo-600 transition-colors">
                            <a href="/berita/detail/<?= $b['slug'] ?>"><?= $b['judul'] ?></a>
                        </h3>
                        <p class="text-sm text-slate-500 line-clamp-3"><?= strip_tags($b['isi']) ?></p>
                    </div>
                </div>
                <div class="p-5 pt-0 border-t border-slate-50 mt-4">
                    <a href="/berita/detail/<?= $b['slug'] ?>" class="text-sm text-indigo-600 hover:text-indigo-700 font-bold inline-flex items-center gap-1 group">
                        Baca Selengkapnya <i class="fa fa-arrow-right text-xs group-hover:translate-x-1 transition-transform"></i>
                    </a>
                </div>
            </article>
            <?php endforeach; ?>
        </div>
    </section>

    <footer class="bg-slate-900 border-t border-slate-800 text-slate-400 py-8 text-center text-sm">
        <p>&copy; <?= date('Y') ?> <?= $nama_aplikasi ?>. Hak Cipta Dilindungi Undang-Undang.</p>
    </footer>

</body>
</html>