<?php

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}


// Cek apakah sudah login

if (!isset($_SESSION['user_id'])) {

    header("Location: login.php");

    exit;
}


// Pastikan yang masuk adalah Admin

if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {

    header("Location: ../index.php");

    exit;
}

?>

<!DOCTYPE html>

<html lang="id">

<head>

    <link rel="icon"
        type="image/png"
        href="/website-dispussip/assets/img/logo.PNG">
    <meta charset="UTF-8">

    <meta
        name="viewport"
        content="width=device-width, initial-scale=1.0">

    <title>
        Dashboard Admin - DISPUSIP Banyuwangi
    </title>


    <link
        href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
        rel="stylesheet">


    <style>
        body {

            background: #f5f7fb;

        }


        .sidebar {

            min-height: 100vh;

            background: #07357e;

        }


        .sidebar-header {

            padding: 25px 15px;

            text-align: center;

            color: white;

        }


        .sidebar-header h4 {

            margin-bottom: 5px;

        }


        .sidebar a {

            color: white;

            text-decoration: none;

            display: block;

            padding: 13px 20px;

            transition: 0.3s;

        }


        .sidebar a:hover {

            background: rgba(255, 255, 255, .2);

        }


        .sidebar hr {

            margin: 10px 15px;

        }


        .content {

            padding: 30px;

        }


        .menu-card {

            border: none;

            transition: .3s;

        }


        .menu-card:hover {

            transform: translateY(-5px);

        }


        .menu-icon {

            font-size: 40px;

            margin-bottom: 15px;

        }


        .topbar {

            background: white;

            padding: 20px;

            border-radius: 10px;

            margin-bottom: 25px;

        }
    </style>


</head>

<body>

    <div class="container-fluid">


        <div class="row">


            <!-- ================================= -->
            <!-- SIDEBAR -->
            <!-- ================================= -->

            <div class="col-md-3 col-lg-2 p-0 sidebar">


                <!-- HEADER SIDEBAR -->

                <div class="sidebar-header">

                    <img
                        src="../assets/img/logo dispussip.png"
                        alt="Logo DISPUSIP"
                        width="160"
                        height="160"
                        style="display:block; margin:0 auto 10px; object-fit:contain;">

                    <small>PANEL ADMIN</small>

                </div>
                <hr class="text-white mx-3">
                <!-- DASHBOARD -->

                <a href="dashboard.php">

                    Dashboard

                </a>



                <!-- EDIT SAMBUTAN -->

                <a href="edit-sambutan.php">

                    Edit Sambutan

                </a>



                <!-- BERITA -->

                <a href="berita/index.php">

                    Berita

                </a>



                <!-- PENGUMUMAN -->

                <a href="pengumuman/index.php">

                    Pengumuman

                </a>



                <!-- GALERI -->

                <a href="galeri/index.php">

                    Galeri

                </a>




                <hr class="text-white">



                <!-- WEBSITE PUBLIK -->

                <a
                    href="../index.php"
                    target="_blank">

                    🌐 Lihat Website

                </a>



                <!-- LOGOUT -->

                <a href="logout.php">

                    🚪 Logout

                </a>


            </div>



            <!-- ================================= -->
            <!-- KONTEN UTAMA -->
            <!-- ================================= -->

            <div class="col-md-9 col-lg-10 content">


                <!-- TOPBAR -->

                <div class="topbar
            d-flex
            justify-content-between
            align-items-center">


                    <div>

                        <h2 class="mb-1">

                            Dashboard Admin

                        </h2>

                    </div>



                    <a
                        href="logout.php"
                        class="btn btn-danger">

                        Logout

                    </a>


                </div>



                <!-- INFORMASI -->

                <div class="alert alert-primary">

                    <strong>

                        Selamat Datang di Panel Admin!

                    </strong>

                    <br>

                </div>



                <!-- MENU SAMBUTAN -->

                <div class="row g-4">


                    <!-- SAMBUTAN KEPALA DINAS -->

                    <div class="col-lg-8">


                        <div class="card shadow-sm
                    menu-card
                    h-100">


                            <div class="card-body
                        text-center
                        p-5">


                                <div class="menu-icon">

                                </div>


                                <h4>

                                    Sambutan Kepala Dinas

                                </h4>


                                <p class="text-muted">

                                    Ubah isi Sambutan Kepala Dinas

                                </p>


                                <a
                                    href="edit-sambutan.php"
                                    class="btn btn-primary">

                                    Ubah

                                </a>


                            </div>


                        </div>


                    </div>



                    <!-- LIHAT WEBSITE -->

                    <div class="col-lg-4">


                        <div class="card shadow-sm
                    menu-card
                    h-100">


                            <div class="card-body
                        text-center
                        p-5">


                                <div class="menu-icon">

                                    🌐

                                </div>


                                <h4>

                                    Website Publik

                                </h4>


                                <p class="text-muted">

                                    Lihat tampilan website
                                    DISPUSIP
                                </p>


                                <a
                                    href="../index.php"
                                    target="_blank"
                                    class="btn btn-success">

                                    Lihat

                                </a>


                            </div>


                        </div>


                    </div>


                </div>


            </div>


        </div>


    </div>

</body>

</html>