<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlspecialchars($identitas['nama_fakultas'] ?? APP_NAME) ?></title>
<meta name="description" content="<?= htmlspecialchars($identitas['tagline'] ?? '') ?>">

<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="<?= APP_URL ?>/assets/css/style.css">
<?php if (!empty($identitas['favicon'])): ?>
<link rel="icon" href="<?= APP_URL . '/uploads/identitas/' . htmlspecialchars($identitas['favicon']) ?>">
<?php endif; ?>
</head>
<body>

<header class="site-header">
  <div class="container navbar">
    <a href="<?= APP_URL ?>/" class="brand">
      <span class="brand-logo">
        <?php if (!empty($identitas['logo'])): ?>
          <img src="<?= APP_URL . '/uploads/identitas/' . htmlspecialchars($identitas['logo']) ?>" alt="Logo">
        <?php else: ?>
          <?= htmlspecialchars(mb_substr($identitas['singkatan'] ?? 'F', 0, 2)) ?>
        <?php endif; ?>
      </span>
      <?= htmlspecialchars($identitas['singkatan'] ?? ($identitas['nama_fakultas'] ?? APP_NAME)) ?>
    </a>

    <nav>
      <ul class="nav-menu">
        <?php foreach ($menus as $menu): ?>
          <li>
            <a href="<?= $menu['tipe'] === 'custom' && str_starts_with($menu['url'], '#') ? $menu['url'] : APP_URL . '/' . ltrim($menu['url'], '/') ?>"
               <?= $menu['target_blank'] ? 'target="_blank" rel="noopener"' : '' ?>>
              <?= htmlspecialchars($menu['label']) ?>
            </a>
            <?php if (!empty($menu['children'])): ?>
              <ul class="submenu">
                <?php foreach ($menu['children'] as $sub): ?>
                  <li><a href="<?= APP_URL . '/' . ltrim($sub['url'], '/') ?>"><?= htmlspecialchars($sub['label']) ?></a></li>
                <?php endforeach; ?>
              </ul>
            <?php endif; ?>
          </li>
        <?php endforeach; ?>
      </ul>
    </nav>

    <div class="nav-social">
      <?php if (!empty($identitas['facebook'])): ?><a href="<?= htmlspecialchars($identitas['facebook']) ?>" target="_blank" rel="noopener">f</a><?php endif; ?>
      <?php if (!empty($identitas['instagram'])): ?><a href="<?= htmlspecialchars($identitas['instagram']) ?>" target="_blank" rel="noopener">ig</a><?php endif; ?>
      <?php if (!empty($identitas['youtube'])): ?><a href="<?= htmlspecialchars($identitas['youtube']) ?>" target="_blank" rel="noopener">yt</a><?php endif; ?>
    </div>

    <button class="nav-toggle" aria-label="Buka menu" aria-expanded="false">☰</button>
  </div>
</header>
