<?php
$current = basename($_SERVER['PHP_SELF']); // Mengambil nama file saat ini
?>

<style>
  .dropdown {
    position: relative;
    display: inline-block;
    cursor: pointer;
  }

  .dropdown-content {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    min-width: 120px;
    box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 10;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
  }

  .dropdown-content a {
    color: black;
    padding: 10px 16px;
    text-decoration: none;
    display: block;
  }

  .dropdown-content a:hover {
    background-color: rgb(113, 113, 113);
    color: white;
  }

  .dropdown.show .dropdown-content {
    display: block;
  }
</style>

<div class="navbar">
  <a href="admin.php" class="nav-item">
    <div ><i class="fa-solid fa-home"></i></div>

  </a>
  <a class="nav-item">
    <div style="margin:10px; text-align:center;
"></div>
  </a>
  <!-- Dropdown Akun -->
  <a href="#" class="nav-item" id="menuLink">
    <div ><i class="fa-solid fa-bars"></i></div>

  </a>
</div>

<script>

  const navbar = document.querySelector('.navbar');
  let initialHeight = window.innerHeight;

  window.addEventListener('resize', () => {
    // Deteksi apakah keyboard muncul (dengan asumsi layar menjadi jauh lebih pendek)
    const keyboardActive = window.innerHeight < initialHeight * 0.7;

    if (keyboardActive) {
      navbar.style.display = 'none';
    } else {
      navbar.style.display = 'flex';
    }
  });


  document.getElementById('menuLink').addEventListener('click', function (e) {
    e.preventDefault();

    Swal.fire({
      title: 'Pilih Menu Tujuan',
      html: `
          <div class="flex-btns">

      <button id="btnIndex" class="swal2-custom-btn">Driver</button><br><br>
      <button id="btnAdmin" class="swal2-custom-btn">Admin</button>
   </div>
      `,
      showConfirmButton: false,
      background: '#2b2b2b',
      color: '#f1c40f',
                        imageWidth: 150,
                        imageHeight: 150,
                        imageUrl: 'img/head.png',      customClass: {
        popup: 'rounded-xl',
      },
      didOpen: () => {
        document.getElementById('btnIndex').addEventListener('click', () => {
          window.location.href = 'index.php';
        });
        document.getElementById('btnAdmin').addEventListener('click', () => {
          window.location.href = 'admin.php';
        });
      }
    });
  });
</script>