<?php
// dashboard_awal/index.php
require_once "../admin/config.php";
$conn = connectDB(); // Create database connection

// Check for error messages
$error_message = '';
if (isset($_GET['error']) && $_GET['error'] == 'closed') {
    $error_message = 'Pendaftaran lomba telah ditutup oleh admin.';
} else if (isset($_GET['error']) && $_GET['error'] == 'unauthorized') {
    $error_message = 'Akses tidak sah! Silakan kembali ke halaman utama.';
} else if (isset($_GET['error']) && $_GET['error'] == 'session_expired') {
    $error_message = 'Sesi Anda telah berakhir. Silakan kembali ke halaman utama.';
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dashboard FLS3N 2025</title>
    <link rel="shortcut icon" href="../assets/logoFLS3N.png" type="image/x-icon">
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"/>
    <style>
        html, body {
            height: 100%;
            margin: 0;
            font-family: 'Poppins', sans-serif;
            background-color: #f8fafc;
            scroll-behavior: smooth;
        }

        .main-header {
            position: fixed;
            width: 100%;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            background: rgba(157, 23, 77, 0.95);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: space-between;
            z-index: 10;
            top: 0;
            height: 80px;
            padding: 0 2rem;
            box-shadow: 0 4px 20px rgba(157, 23, 77, 0.3);
            transition: all 0.3s ease;
        }

        .main-header:hover {
            background: rgba(157, 23, 77, 1);
        }

        /* Logo styling */
        .logo-container {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .main-header .logo-container img {
            height: 65px;
            transition: transform 0.3s ease;
        }

        .main-header .logo-container img:hover {
            transform: scale(1.05);
        }

        /* Nama instansi */
        .main-header .instansi-name {
            font-size: 26px;
            font-weight: 700;
            letter-spacing: 1px;
            background: linear-gradient(90deg, #fff, #f0abfc);
            background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
        }

        .page-container {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        .content-wrapper {
            flex: 1;
            margin-top: 100px;
            padding: 2rem 0;
        }

        .hero-section {
            text-align: center;
            padding: 2rem 1rem 4rem;
            position: relative;
            overflow: hidden;
        }

        .hero-section::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: url('https://api.placeholder/1200/600') no-repeat center center;
            background-size: cover;
            opacity: 0.05;
            z-index: -1;
        }

        .hero-title {
            position: relative;
            display: inline-block;
            margin-bottom: 1.5rem;
        }

        .hero-title::after {
            content: "";
            position: absolute;
            bottom: -10px;
            left: 50%;
            transform: translateX(-50%);
            width: 80px;
            height: 4px;
            background: linear-gradient(90deg, #9d174d, #db2777);
            border-radius: 4px;
        }

        .dashboard-cards {
            margin-top: 2rem;
        }

        .dashboard-card {
            background: white;
            border-radius: 16px;
            padding: 2rem;
            text-align: center;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
            transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            border: 1px solid rgba(0, 0, 0, 0.05);
            position: relative;
            overflow: hidden;
        }

        .dashboard-card::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 5px;
            transition: all 0.3s ease;
        }

        .dashboard-card.kota::before {
            background: linear-gradient(90deg, #ef4444, #f87171);
        }

        .dashboard-card.kabupaten::before {
            background: linear-gradient(90deg, #3b82f6, #60a5fa);
        }

        .dashboard-card.results::before {
            background: linear-gradient(90deg, #8b5cf6, #a78bfa);
        }

        .dashboard-card:hover {
            transform: translateY(-10px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        }

        .dashboard-card:hover::before {
            height: 10px;
        }

        .dashboard-card .icon-container {
            width: 160px;
            height: 160px;
            margin: 0 auto 1.5rem;
            padding: 1.5rem;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }

        .dashboard-card.kota .icon-container {
            background: linear-gradient(145deg, #fff5f5, #fee2e2);
            box-shadow: 0 10px 15px rgba(239, 68, 68, 0.15);
        }

        .dashboard-card.kabupaten .icon-container {
            background: linear-gradient(145deg, #eff6ff, #dbeafe);
            box-shadow: 0 10px 15px rgba(59, 130, 246, 0.15);
        }

        .dashboard-card.results .icon-container {
            background: linear-gradient(145deg, #f5f3ff, #ede9fe);
            box-shadow: 0 10px 15px rgba(139, 92, 246, 0.15);
        }

        .dashboard-card img {
            max-width: 100%;
            object-fit: contain;
            transition: transform 0.5s ease;
        }

        .dashboard-card:hover img {
            transform: scale(1.1);
        }

        .dashboard-card h2 {
            font-weight: 700;
            margin-bottom: 1rem;
            transition: all 0.3s ease;
        }

        .dashboard-card.kota h2 {
            color: #ef4444;
        }

        .dashboard-card.kabupaten h2 {
            color: #3b82f6;
        }

        .dashboard-card.results h2 {
            color: #8b5cf6;
        }

        .dashboard-card p {
            color: #64748b;
            margin-bottom: 1.5rem;
            font-size: 0.95rem;
            line-height: 1.6;
        }

        .btn-dashboard {
            padding: 0.75rem 2rem;
            border-radius: 50px;
            font-weight: 600;
            transition: all 0.3s ease;
            border: none;
            position: relative;
            overflow: hidden;
            z-index: 1;
            letter-spacing: 0.5px;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .btn-dashboard::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 0;
            height: 100%;
            z-index: -1;
            transition: all 0.3s ease;
            opacity: 0;
        }

        .btn-dashboard:hover::after {
            width: 100%;
            opacity: 1;
        }

        .btn-kota {
            background: linear-gradient(90deg, #ef4444, #f87171);
            color: white;
            box-shadow: 0 5px 15px rgba(239, 68, 68, 0.25);
        }

        .btn-kota::after {
            background: linear-gradient(90deg, #dc2626, #ef4444);
        }

        .btn-kabupaten {
            background: linear-gradient(90deg, #3b82f6, #60a5fa);
            color: white;
            box-shadow: 0 5px 15px rgba(59, 130, 246, 0.25);
        }

        .btn-kabupaten::after {
            background: linear-gradient(90deg, #2563eb, #3b82f6);
        }

        .btn-results {
            background: linear-gradient(90deg, #8b5cf6, #a78bfa);
            color: white;
            box-shadow: 0 5px 15px rgba(139, 92, 246, 0.25);
        }

        .btn-results::after {
            background: linear-gradient(90deg, #7c3aed, #8b5cf6);
        }

        .btn-dashboard i {
            transition: transform 0.3s ease;
        }

        .btn-dashboard:hover i {
            transform: translateX(3px);
        }

        .btn-dashboard:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
        }

        /* Trophy icons styling */
        .trophy-icon {
            font-size: 4rem;
            margin-bottom: 0.5rem;
            background: -webkit-linear-gradient(45deg, #ffd700, #f59e0b);
            background-clip: text;
            -webkit-text-fill-color: transparent;
            filter: drop-shadow(0 4px 6px rgba(245, 158, 11, 0.3));
            transition: all 0.3s ease;
        }

        .dashboard-card:hover .trophy-icon {
            transform: rotate(10deg);
        }

        .medal-container {
            display: flex;
            margin-top: 1rem;
            gap: 0.5rem;
            justify-content: center;
        }

        .medal {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: white;
            font-size: 1rem;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }

        .medal:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
        }

        .medal.gold {
            background: linear-gradient(45deg, #ffd700, #f59e0b);
        }

        .medal.silver {
            background: linear-gradient(45deg, #c0c0c0, #9ca3af);
        }

        .medal.bronze {
            background: linear-gradient(45deg, #cd7f32, #d97706);
        }

        .medal.top-10 {
            background: linear-gradient(45deg, #8b5cf6, #a78bfa);
        }

        footer {
            background: linear-gradient(90deg, #9d174d, #be185d);
            color: white;
            text-align: center;
            padding: 1.5rem 0;
            width: 100%;
            margin-top: auto;
            position: relative;
            box-shadow: 0 -5px 20px rgba(157, 23, 77, 0.2);
        }

        footer p {
            margin: 0;
            font-size: 0.9rem;
            letter-spacing: 0.5px;
        }

        /* Responsive Adjustments */
        @media (max-width: 1024px) {
            .grid-cols-3 {
                grid-template-columns: repeat(1, minmax(0, 1fr));
            }
        }

        @media (max-width: 768px) {
            .main-header {
                padding: 0 1rem;
                height: 70px;
            }
            
            .main-header .logo-container img {
                height: 45px;
            }
            
            .main-header .instansi-name {
                font-size: 20px;
            }
            
            .content-wrapper {
                margin-top: 80px;
            }
            
            .dashboard-card .icon-container {
                width: 130px;
                height: 130px;
            }
        }

        /* Animation Classes */
        .fade-in {
            animation: fadeIn 1s ease-in-out;
        }

        .slide-up {
            animation: slideUp 0.8s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes slideUp {
            from { transform: translateY(50px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        /* New styles for closed competitions */
        .dashboard-card.closed {
            background: #f9fafb;
            border: 1px solid #e5e7eb;
        }

        .dashboard-card.closed::before {
            background: linear-gradient(90deg, #6b7280, #9ca3af);
            height: 5px;
        }

        .dashboard-card.closed:hover::before {
            height: 10px;
        }

        .dashboard-card.closed .icon-container {
            filter: grayscale(1);
            opacity: 0.7;
        }

        .dashboard-card.closed h2 {
            color: #6b7280 !important;
        }

        .dashboard-card.closed p {
            color: #9ca3af;
        }

        .status-badge {
            position: absolute;
            top: 1rem;
            right: 1rem;
            padding: 0.35rem 0.85rem;
            border-radius: 50px;
            font-size: 0.85rem;
            font-weight: 600;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            z-index: 5;
        }

        .status-badge.open {
            background: linear-gradient(90deg, #10b981, #34d399);
            color: white;
        }

        .status-badge.closed {
            background: linear-gradient(90deg, #ef4444, #f87171);
            color: white;
        }

        .disabled-btn {
            background: linear-gradient(90deg, #9ca3af, #d1d5db) !important;
            color: #f3f4f6;
            box-shadow: none;
            cursor: not-allowed;
            opacity: 0.7;
        }

        .disabled-btn::after {
            display: none;
        }

        .disabled-btn:hover {
            transform: none;
            box-shadow: none;
        }

        .closed-message {
            background: #fee2e2;
            border: 1px solid #fecaca;
            border-radius: 8px;
            padding: 0.75rem 1rem;
            margin-bottom: 1.5rem;
            color: #ef4444;
            font-weight: 600;
            font-size: 0.9rem;
            box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        
        .toast-container {
            position: fixed;
            top: 100px;
            right: 20px;
            z-index: 1000;
            max-width: 350px;
        }
        
        .toast {
            background-color: #fff;
            color: #ef4444;
            padding: 15px 20px;
            border-radius: 8px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            border-left: 5px solid #ef4444;
            animation: slideInRight 0.5s forwards;
        }
        
        @keyframes slideInRight {
            from {
                transform: translateX(100%);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }
        
        @keyframes fadeOut {
            from {
                opacity: 1;
            }
            to {
                opacity: 0;
            }
        }
        
        .toast i {
            margin-right: 10px;
            font-size: 1.2rem;
        }
        
        .toast-close {
            margin-left: auto;
            cursor: pointer;
            font-size: 0.9rem;
            opacity: 0.7;
            transition: opacity 0.3s;
        }
        
        .toast-close:hover {
            opacity: 1;
        }
    </style>
</head>
<body>
    <?php if (!empty($error_message)): ?>
    <div class="toast-container">
        <div class="toast" id="errorToast">
            <i class="fas fa-exclamation-circle"></i>
            <span><?php echo $error_message; ?></span>
            <span class="toast-close">&times;</span>
        </div>
    </div>
    <?php endif; ?>

    <div class="page-container">
        <header class="main-header">
            <div class="logo-container"> 
            <img src="../assets/tutwurii.png" alt="Logo TI Unisbank">
            <img src="../assets/unisbank.png" alt="Logo Unisbank">
            <img src="../assets/logoFLS3N.png" alt="Logo FLS3N">    
            </div>
            <div class="instansi-name">FLS3N 2026</div>
        </header>

        <div class="content-wrapper">
            <div class="container mx-auto px-4">
                <div class="hero-section fade-in">
                    <h1 class="hero-title text-pink-600 font-bold text-4xl md:text-5xl text-center">DASHBOARD LOMBA FLS3N</h1>
                    <h2 class="text-gray-700 text-xl md:text-2xl font-medium text-center mb-3">SMA/MA/SMK/MAK/Sederajat TAHUN <?php echo date("Y"); ?></h2>
                    <p class="text-center text-gray-600 max-w-2xl mx-auto">Silahkan pilih domisili untuk melihat dan mendaftar pada cabang lomba yang tersedia. Festival dan Lomba Seni Siswa Nasional (FLS3N) merupakan ajang prestasi untuk mengembangkan bakat dan minat siswa.</p>
                </div>
                
                <div class="dashboard-cards">
                    <?php
                    // Retrieve competition status from the database
                    $sql_kab_semarang = "SELECT status FROM status_lomba WHERE name = 'kabupaten_semarang'";
                    $sql_kab_demak = "SELECT status FROM status_lomba WHERE name = 'kabupaten_demak'";
                    $sql_kota_salatiga = "SELECT status FROM status_lomba WHERE name = 'kota_salatiga'";
                    $sql_pendaftaran_sekolah = "SELECT status FROM status_lomba WHERE name = 'pendaftaran_sekolah'";
                    
                    $result_kab_semarang = $conn->query($sql_kab_semarang);
                    $result_kab_demak = $conn->query($sql_kab_demak);
                    $result_kota_salatiga = $conn->query($sql_kota_salatiga);
                    $result_pendaftaran_sekolah = $conn->query($sql_pendaftaran_sekolah);
                    
                    $kab_semarang_status = ($result_kab_semarang && $result_kab_semarang->num_rows > 0) ? 
                        $result_kab_semarang->fetch_assoc()['status'] : 'open';
                    $kab_demak_status = ($result_kab_demak && $result_kab_demak->num_rows > 0) ? 
                        $result_kab_demak->fetch_assoc()['status'] : 'open';
                    $kota_salatiga_status = ($result_kota_salatiga && $result_kota_salatiga->num_rows > 0) ? 
                        $result_kota_salatiga->fetch_assoc()['status'] : 'open';
                    $pendaftaran_sekolah_status = ($result_pendaftaran_sekolah && $result_pendaftaran_sekolah->num_rows > 0) ? 
                        $result_pendaftaran_sekolah->fetch_assoc()['status'] : 'open';
                    
                    $kab_semarang_closed = ($kab_semarang_status == 'closed');
                    $kab_demak_closed = ($kab_demak_status == 'closed');
                    $kota_salatiga_closed = ($kota_salatiga_status == 'closed');
                    $pendaftaran_sekolah_closed = ($pendaftaran_sekolah_status == 'closed');
                    
                    $all_closed = $kab_semarang_closed && $kab_demak_closed && $kota_salatiga_closed;
                    ?>
                    
                    <?php if ($all_closed): ?>
                    <div class="bg-gradient-to-r from-red-50 to-pink-50 border border-red-200 rounded-xl p-6 mb-8 max-w-4xl mx-auto">
                        <div class="text-center">
                            <i class="fas fa-info-circle text-4xl text-red-500 mb-4"></i>
                            <h3 class="text-2xl font-bold text-red-700 mb-2">Pendaftaran Telah Ditutup</h3>
                            <p class="text-red-600 text-lg">Pendaftaran lomba FLS3N untuk semua domisili telah ditutup. Terima kasih atas antusiasme dan partisipasi peserta. Nantikan informasi selanjutnya mengenai hasil penilaian dan pengumuman pemenang.</p>
                        </div>
                    </div>
                    <?php endif; ?>
                    <div class="grid <?php echo $all_closed ? 'grid-cols-1 md:grid-cols-3' : 'grid-cols-1 md:grid-cols-2 lg:grid-cols-4'; ?> gap-8 max-w-6xl mx-auto">
                        
                        <?php if (!$all_closed): ?>
                        <div class="slide-up" style="animation-delay: 0.2s">
                            <div class="dashboard-card kota <?php echo $kab_semarang_closed ? 'closed' : ''; ?>">
                                <span class="status-badge <?php echo $kab_semarang_closed ? 'closed' : 'open'; ?>">
                                    <?php echo $kab_semarang_closed ? 'DITUTUP' : 'DIBUKA'; ?>
                                </span>
                                <div class="icon-container">
                                    <img src="../assets/kabupaten-semarang.png" alt="Kabupaten Semarang">
                                </div>
                                <div>
                                    <h2 class="text-2xl md:text-3xl">Lomba FLS3N Kabupaten Semarang</h2>
                                    
                                    <?php if ($kab_semarang_closed): ?>
                                    <div class="closed-message">
                                        <i class="fas fa-exclamation-circle"></i>
                                        Pendaftaran lomba untuk Kabupaten Semarang telah ditutup
                                    </div>
                                    <p>Terima kasih atas antusiasme peserta. Pendaftaran telah ditutup dan tidak lagi menerima pendaftar baru. Nantikan informasi selanjutnya mengenai hasil penilaian.</p>
                                    <?php else: ?>
                                    <p>Daftar dan lihat cabang lomba seni yang tersedia untuk peserta dengan domisili Kabupaten Semarang. Jadilah bagian dari pesta seni terbesar se-Indonesia!</p>
                                    <?php endif; ?>
                                </div>
                                
                                <?php if ($kab_semarang_closed): ?>
                                <button class="btn btn-dashboard btn-kota disabled-btn" disabled>
                                    Pendaftaran Ditutup <i class="fas fa-lock"></i>
                                </button>
                                <?php else: ?>
                                <a href="redirect-kab-semarang.php" class="btn btn-dashboard btn-kota">
                                    Masuk Dashboard <i class="fas fa-arrow-right"></i>
                                </a>
                                <?php endif; ?>
                            </div>
                        </div>
                        <?php endif; ?>
                        
                        <?php if (!$all_closed): ?>
                        <div class="slide-up" style="animation-delay: 0.3s">
                            <div class="dashboard-card kabupaten <?php echo $kab_demak_closed ? 'closed' : ''; ?>">
                                <span class="status-badge <?php echo $kab_demak_closed ? 'closed' : 'open'; ?>">
                                    <?php echo $kab_demak_closed ? 'DITUTUP' : 'DIBUKA'; ?>
                                </span>
                                <div class="icon-container">
                                    <img src="../assets/kabupaten-demak.png" alt="Kabupaten Demak">
                                </div>
                                <div>
                                    <h2 class="text-2xl md:text-3xl">Lomba FLS3N Kabupaten Demak</h2>
                                    
                                    <?php if ($kab_demak_closed): ?>
                                    <div class="closed-message">
                                        <i class="fas fa-exclamation-circle"></i>
                                        Pendaftaran lomba untuk Kabupaten Demak telah ditutup
                                    </div>
                                    <p>Terima kasih atas antusiasme peserta. Pendaftaran telah ditutup dan tidak lagi menerima pendaftar baru. Nantikan informasi selanjutnya mengenai hasil penilaian.</p>
                                    <?php else: ?>
                                    <p>Daftar dan lihat cabang lomba seni yang tersedia untuk peserta dengan domisili Kabupaten Demak. Tunjukkan bakat senimu dan raih prestasi!</p>
                                    <?php endif; ?>
                                </div>
                                
                                <?php if ($kab_demak_closed): ?>
                                <button class="btn btn-dashboard btn-kabupaten disabled-btn" disabled>
                                    Pendaftaran Ditutup <i class="fas fa-lock"></i>
                                </button>
                                <?php else: ?>
                                <a href="redirect-kab-demak.php" class="btn btn-dashboard btn-kabupaten">
                                    Masuk Dashboard <i class="fas fa-arrow-right"></i>
                                </a>
                                <?php endif; ?>
                            </div>
                        </div>
                        <?php endif; ?>
                        
                        <?php if (!$all_closed): ?>
                        <div class="slide-up" style="animation-delay: 0.4s">
                            <div class="dashboard-card kota <?php echo $kota_salatiga_closed ? 'closed' : ''; ?>">
                                <span class="status-badge <?php echo $kota_salatiga_closed ? 'closed' : 'open'; ?>">
                                    <?php echo $kota_salatiga_closed ? 'DITUTUP' : 'DIBUKA'; ?>
                                </span>
                                <div class="icon-container">
                                    <img src="../assets/kota-salatiga.png" alt="Kota Salatiga">
                                </div>
                                <div>
                                    <h2 class="text-2xl md:text-3xl">Lomba FLS3N Kota Salatiga</h2>
                                    
                                    <?php if ($kota_salatiga_closed): ?>
                                    <div class="closed-message">
                                        <i class="fas fa-exclamation-circle"></i>
                                        Pendaftaran lomba untuk Kota Salatiga telah ditutup
                                    </div>
                                    <p>Terima kasih atas antusiasme peserta. Pendaftaran telah ditutup dan tidak lagi menerima pendaftar baru. Nantikan informasi selanjutnya mengenai hasil penilaian.</p>
                                    <?php else: ?>
                                    <p>Daftar dan lihat cabang lomba seni yang tersedia untuk peserta dengan domisili Kota Salatiga. Jadilah bagian dari pesta seni terbesar se-Indonesia!</p>
                                    <?php endif; ?>
                                </div>
                                
                                <?php if ($kota_salatiga_closed): ?>
                                <button class="btn btn-dashboard btn-kota disabled-btn" disabled>
                                    Pendaftaran Ditutup <i class="fas fa-lock"></i>
                                </button>
                                <?php else: ?>
                                <a href="redirect-kota-salatiga.php" class="btn btn-dashboard btn-kota">
                                    Masuk Dashboard <i class="fas fa-arrow-right"></i>
                                </a>
                                <?php endif; ?>
                            </div>
                        </div>
                        <?php endif; ?>
                        
                        <?php if (!$all_closed): ?>
                        <div class="slide-up" style="animation-delay: 0.5s">
                            <div class="dashboard-card <?php echo $pendaftaran_sekolah_closed ? 'closed' : ''; ?>" style="border-top: 5px solid <?php echo $pendaftaran_sekolah_closed ? '#d1d5db' : '#10b981'; ?>; position: relative;">
                                <span class="status-badge <?php echo $pendaftaran_sekolah_closed ? 'closed' : 'open'; ?>" style="<?php if (!$pendaftaran_sekolah_closed) echo "background: linear-gradient(90deg, #059669, #10b981);"; ?>">
                                    <?php echo $pendaftaran_sekolah_closed ? 'DITUTUP' : 'SELALU BUKA'; ?>
                                </span>
                                <div class="icon-container" style="background: linear-gradient(145deg, <?php echo $pendaftaran_sekolah_closed ? '#f3f4f6, #e5e7eb' : '#f0fdf4, #dcfce7'; ?>); box-shadow: 0 10px 15px rgba(<?php echo $pendaftaran_sekolah_closed ? '107, 114, 128' : '16, 185, 129'; ?>, 0.15);">
                                    <i class="fas fa-school" style="font-size: 3rem; color: <?php echo $pendaftaran_sekolah_closed ? '#9ca3af' : '#10b981'; ?>;"></i>
                                </div>
                                <div>
                                    <h2 class="text-2xl md:text-3xl" style="color: <?php echo $pendaftaran_sekolah_closed ? '#6b7280' : '#10b981'; ?>;">Pendaftaran Sekolah</h2>
                                    
                                    <?php if ($pendaftaran_sekolah_closed): ?>
                                    <div class="closed-message" style="background: #fee2e2; border: 1px solid #fecaca; color: #ef4444;">
                                        <i class="fas fa-exclamation-circle"></i>
                                        Pendaftaran sekolah telah ditutup
                                    </div>
                                    <p>Terima kasih atas antusiasme peserta. Pendaftaran sekolah telah ditutup dan tidak lagi menerima pendaftar baru.</p>
                                    <?php else: ?>
                                    <p>Daftarkan sekolah Anda untuk mengikuti Festival Lomba Seni Siswa Nasional (FLS3N) 2026. Lengkapi data sekolah dan upload bukti pendaftaran di BPTI.</p>
                                    <?php endif; ?>
                                </div>
                                
                                <?php if ($pendaftaran_sekolah_closed): ?>
                                <button class="btn btn-dashboard disabled-btn" disabled style="background: linear-gradient(90deg, #9ca3af, #d1d5db) !important;">
                                    Pendaftaran Ditutup <i class="fas fa-lock"></i>
                                </button>
                                <?php else: ?>
                                <a href="redirect-pendaftaran-sekolah.php" class="btn btn-dashboard" style="background: linear-gradient(90deg, #10b981, #34d399); box-shadow: 0 5px 15px rgba(16, 185, 129, 0.25);">
                                    Daftar Sekolah <i class="fas fa-arrow-right"></i>
                                </a>
                                <?php endif; ?>
                            </div>
                        </div>
                        <?php endif; ?>
                        
                        <?php if ($all_closed): ?>
                        <div class="slide-up" style="animation-delay: 0.6s; grid-column: 1 / -1; margin: 0 auto; max-width: 500px;">
                            <div class="dashboard-card results">
                                <div class="icon-container">
                                    <i class="fas fa-trophy trophy-icon"></i>
                                </div>
                                <div>
                                    <h2 class="text-2xl md:text-3xl">Hasil & Pemenang Lomba</h2>
                                    <p>Lihat hasil penilaian dan daftar 10 pemenang terbaik dari setiap cabang lomba FLS3N. Selamat kepada para juara yang telah menunjukkan bakat luar biasa!</p>
                                </div>
                                <a href="../hasil_penilaian" class="btn btn-dashboard btn-results">
                                    Lihat Pemenang <i class="fas fa-award"></i>
                                </a>
                            </div>
                        </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
        
        <footer class="bg-gradient-to-r from-pink-800 to-pink-700 text-white py-8">
            <div class="container mx-auto px-4">
                <div class="flex flex-col md:flex-row items-center md:items-start justify-between">
                    <!-- Logo and Copyright Section -->
                    <div class="flex flex-col items-center md:items-start mb-6 md:mb-0">
                        <div class="flex items-center gap-2 mb-4">
                            <img src="../assets/pkl.png" alt="Logo team" class="h-12">
                            <div class="text-xl font-bold">FTII Unisbank</div>
                        </div>
                        <p class="text-sm">Portal ini dikembangkan dan didukung oleh Fakultas Teknologi Informasi & Industri (FTII) Universitas Stikubank Semarang.</p>
                        <p class="text-sm text-gray-300 opacity-80">&copy;<?php echo date("Y"); ?> FTII Unisbank. All rights reserved.</p>
                        <a href="https://linktr.ee/ourteamftii" class="text-white hover:text-pink-200 transition-colors mt-2 flex items-center">
                            <span class="text-sm">Our Team</span>
                            <i class="fas fa-external-link-alt ml-1 text-xs"></i>
                        </a>
                    </div>
                    
                    <!-- PMB Unisbank Button Section -->
                    <div class="text-center md:text-right">
                        <h3 class="text-xl font-bold mb-4 relative inline-block pb-2 after:content-[''] after:absolute after:bottom-0 after:left-0 after:w-full after:h-1 after:bg-white after:rounded">PMB Unisbank</h3>
                        <div class="flex justify-end">
                            <a href="https://www.unisbank.ac.id/v3/pmb-unisbank/" target="_blank" class="relative overflow-hidden bg-gradient-to-r from-blue-600 to-blue-400 text-white px-5 py-3 rounded-full font-semibold shadow-lg flex items-center gap-2 group">
                                <span class="absolute inset-0 bg-gradient-to-r from-green-600 to-green-400 translate-x-full group-hover:translate-x-0 transition-transform duration-500 ease-in-out"></span>
                                <i class="fas fa-user-graduate text-lg relative z-10 group-hover:animate-bounce"></i>
                                <span class="relative z-10 group-hover:animate-pulse">Penerimaan Mahasiswa Baru Unisbank</span>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </footer>
    </div>
    
    <script>
        // Close toast notification
        document.addEventListener('DOMContentLoaded', function() {
            const toast = document.getElementById('errorToast');
            if (toast) {
                // Auto-hide after 5 seconds
                setTimeout(() => {
                    toast.style.animation = 'fadeOut 0.5s forwards';
                    setTimeout(() => {
                        toast.remove();
                    }, 500);
                }, 5000);
                
                // Close on click
                toast.querySelector('.toast-close').addEventListener('click', function() {
                    toast.style.animation = 'fadeOut 0.5s forwards';
                    setTimeout(() => {
                        toast.remove();
                    }, 500);
                });
            }
        });
    </script>
</body>
</html>
<?php $conn->close(); ?>