<?php
$settings_sql = "SELECT website_name FROM settings WHERE id = 1";
$site_settings = $pdo->query($settings_sql)->fetch();
$site_name = $site_settings['website_name'] ?? 'CRS Delhi';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $site_name; ?></title>
    <!-- Google Fonts - Inter -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <!-- Custom Premium Styles -->
    <link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>

<nav class="navbar navbar-expand-lg navbar-dark sticky-top mb-5">
  <div class="container">
    <a class="navbar-brand d-flex align-items-center" href="dashboard.php">
      <i class="fas fa-certificate text-warning me-2"></i>
      <span><?php echo $site_name; ?></span>
    </a>
    <button class="navbar-toggler border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav ms-auto align-items-center">
        <?php if (isLoggedIn()): ?>
            <?php if (isAdmin()): ?>
                <li class="nav-item"><a class="nav-link px-3" href="dashboard.php">Dashboard</a></li>
                <li class="nav-item"><a class="nav-link px-3" href="manage_users.php">Users</a></li>
                <li class="nav-item"><a class="nav-link px-3" href="manage_certificates.php">Certificates</a></li>
                <li class="nav-item"><a class="nav-link px-3" href="manage_wallet.php">Wallet</a></li>
                <li class="nav-item"><a class="nav-link px-3" href="settings.php">Settings</a></li>
            <?php else: ?>
                <li class="nav-item"><a class="nav-link px-3" href="dashboard.php">Dashboard</a></li>
                <li class="nav-item"><a class="nav-link px-3" href="apply.php">New Application</a></li>
                <li class="nav-item"><a class="nav-link px-3" href="my_certificates.php">My List</a></li>
                <li class="nav-item">
                    <span class="nav-link badge bg-glass text-white mx-2 px-3">
                        <i class="fas fa-wallet me-1"></i> ₹<?php echo number_format($_SESSION['balance'] ?? 0, 2); ?>
                    </span>
                </li>
            <?php endif; ?>
            <li class="nav-item ms-lg-3">
                <a class="nav-link btn btn-light text-primary fw-bold px-3 py-1 mb-2 mb-lg-0" href="profile.php">
                    <i class="fas fa-user-circle me-1"></i> My Profile
                </a>
            </li>
            <li class="nav-item ms-lg-2">
                <a class="nav-link btn btn-danger btn-sm text-white px-3 py-1" href="../logout.php">
                    <i class="fas fa-sign-out-alt"></i>
                </a>
            </li>
        <?php else: ?>
            <li class="nav-item"><a class="nav-link px-3" href="../login.php">Login</a></li>
            <li class="nav-item"><a class="nav-link px-3 btn btn-light text-primary py-1" href="../register.php">Register</a></li>
        <?php endif; ?>
      </ul>
    </div>
  </div>
</nav>
<div class="container pb-5">
