<head>
    <link rel="icon" href="upload/bn2.png" type="image/png">
    <link rel="stylesheet" href="style.css">
    <link href="https://cdn.jsdelivr.net/npm/remixicon@4.7.0/fonts/remixicon.css" rel="stylesheet"/>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
    <link href="https://fonts.googleapis.com/css2?family=Oswald:wght@700&display=swap" rel="stylesheet">
</head>
<?php include 'koneksi.php';
$query = "SELECT * FROM tb_jurusan ";
$result = mysqli_query($host,$query);
$row = mysqli_fetch_assoc($result);
$nama_jurusan = htmlspecialchars($row['nama_jurusan']);
$kata_pertama = strtok($nama_jurusan,"");
$kata_singkat = ucfirst($kata_pertama);

$query_sekolah = "SELECT * FROM sekolah";
$result_sekolah = mysqli_query($host,$query_sekolah);
$row_sekolah = mysqli_fetch_assoc($result_sekolah);
$nama_sekolah = htmlspecialchars($row_sekolah['nama_sekolah']);
$slogan_sekolah = htmlspecialchars($row_sekolah['slogan_sekolah']);
$logo_sekolah = htmlspecialchars($row_sekolah['logo_sekolah']);
?>
<nav id="top">
    <div class="top-navbar">
        <div class="left-section">
            <a href="dashboard.php"><img src="upload/<?php echo $logo_sekolah; ?>" alt="gambar bn" class="logo"></a>
        </div>
            <div class="site-info">
            <h2 class="site-name"><a href="dashboard.php" style="text-decoration: none; color: #333;"><?php echo $nama_sekolah; ?></a></h2>
            <p style="font-size:12px;"><?php echo $slogan_sekolah; ?></p>
        </div>
        <div class="hamburger" onclick="toggleSidebar()">
            <span></span>
            <span></span>
            <span></span>
        </div>
        <div class="right-section">
        <div class="dropdown">
            <a href="dashboard.php">Beranda</a>
        </div>
        <div class="dropdown"><a href="profil.php">profil<i class="ri-arrow-down-s-fill"></i></a>
            <div class="dropdown-content">
                <div class="dropdown-submenu">
                <a href="">sekolah      ▶</a>
                <div class="submenu-content">
                    <a href="visimisi.php" title="visi dan misi">visi & misi</a>
                    <a href="struktur.php">struktur organisasi</a>
                    <a href="detail_kepsek.php">kepala sekolah</a>
                </div>
                </div>
                <div class="dropdown-submenu">
                <a href="jurusan.php">Jurusan      ▶</a>
                <div class="submenu-content">
                    <?php
                    $query_jurusan = "SELECT id_jurusan, nama_jurusan FROM tb_jurusan";
                    $result_jurusan = mysqli_query($host, $query_jurusan);
                    $abbreviations = [1 => 'akl', 2 => 'bdp', 3 => 'rpl'];
                    if ($result_jurusan && mysqli_num_rows($result_jurusan) > 0) {
                        while ($row_jurusan = mysqli_fetch_assoc($result_jurusan)) {
                            $id = $row_jurusan['id_jurusan'];
                            $first_word = explode(' ', htmlspecialchars($row_jurusan['nama_jurusan']))[0];
                            $abbr = isset($abbreviations[$id]) ? $abbreviations[$id] : '';
                            echo '<a href="detail_jurusan.php?id_jurusan=' . $id . '">' . ucfirst($first_word) . '(' . $abbr . ')</a>';
                        }
                    }
                    ?>
                    </div>
                </div>
                <div class="dropdown-submenu">
                    <a href="prestasi.php">prestasi</a>
                </div>
            </div>
        </div>
        <div class="dropdown"><a href="">berita<i class="ri-arrow-down-s-fill"></i></a>
            <div class="dropdown-content">
                <div class="dropdown-submenu"><a href="berita_sekolah.php">Berita Sekolah</a></div>
                <div class="dropdown-submenu"><a href="pengumuman.php">Pengumuman</a></div>
            </div>
        </div>
        <div class="dropdown"><a href="">GTK<i class="ri-arrow-down-s-fill"></i></a>
            <div class="dropdown-content">
                <div class="dropdown-submenu"><a href="guru.php">Guru</a></div>
                <div class="dropdown-submenu"><a href="tenaga.php">Tenaga Kependidikan</a></div>
                </div>
    </div>
    <div class="dropdown"><a href="">Siswa<i class="ri-arrow-down-s-fill"></i></a>
        <div class="dropdown-content">
            <div class="dropdown-submenu"><a href="data_siswa.php">Data Siswa</a></div>
            <div class="dropdown-submenu"><a href="organisasidaneskul.php">organisasi & Ekskul</a></div>
        </div>
    </div>
    <div class="dropdown"><a href="galeri.php">galeri</a>
    <div class="dropdown-content">
        <div class="dropdown-submenu"></div>
    </div>
    </div>
    <div class="dropdown"><a href="hubungi.php">hubungi kami</a>
        <div class="dropdown-content">
            <div class="dropdown-submenu"></div>
        </div>
    </div>
    <div class="dropdown"><a href="halamanlogin.php" class="login-button hias">login</a>
        <div class="dropdown-content">
            <div class="dropdown-submenu"></div>
        </div>
    </div>
    </div>
    </div>
    <div class="sidebar" id="sidebar">
        <div class="sidebar-header">
            <a href="dashboard.php"><img src="upload/bn2.png" alt="gambar bn" class="logo"></a>
            <span class="close-btn" onclick="toggleSidebar()">&times;</span>
        </div>
        <div class="sidebar-menu">
            <div class="sidebar-dropdown">
                <a href="dashboard.php">Beranda</a>
            </div>
            <div class="sidebar-dropdown">
                <a href="#" onclick="toggleSubmenu(this)">profil</a>
                <div class="sidebar-submenu">
                    <a href="visimisi.php">visi & misi</a>
                    <a href="struktur.php">struktur organisasi</a>
                    <a href="detail_kepsek.php">kepala sekolah</a>
                    <a href="jurusan.php">Jurusan</a>
                    <a href="prestasi.php">prestasi</a>
                </div>
            </div>
            <div class="sidebar-dropdown">
                <a href="#" onclick="toggleSubmenu(this)">berita</a>
                <div class="sidebar-submenu">
                    <a href="berita_sekolah.php">Berita Sekolah</a>
                    <a href="pengumuman.php">Pengumuman</a>
                </div>
            </div>
            <div class="sidebar-dropdown">
                <a href="#" onclick="toggleSubmenu(this)">GTK</a>
                <div class="sidebar-submenu">
                    <a href="guru.php">Guru</a>
                    <a href="tenaga.php">Tenaga Kependidikan</a>
                </div>
            </div>
            <div class="sidebar-dropdown">
                <a href="#" onclick="toggleSubmenu(this)">Siswa</a>
                <div class="sidebar-submenu">
                    <a href="data_siswa.php">Data Siswa</a>
                    <a href="organisasidaneskul.php">organisasi & Ekskul</a>
                </div>
            </div>
            <div class="sidebar-dropdown">
                <a href="galeri.php">galeri</a>
            </div>
            <div class="sidebar-dropdown">
                <a href="hubungi.php">hubungi kami</a>
            </div>
            <div class="sidebar-dropdown">
                <a href="halamanlogin.php" class="login-button">login</a>
            </div>
        </div>
    </div>
</nav>
<script>
    // Sidebar toggle functionality
function toggleSidebar() {
    const sidebar = document.getElementById('sidebar');
    sidebar.classList.toggle('open');
}

// Submenu toggle functionality
function toggleSubmenu(element) {
    const submenu = element.nextElementSibling;
    submenu.style.display = submenu.style.display === 'block' ? 'none' : 'block';
}


</script>
