<?php
if (!function_exists('isLoggedIn')) {
    include __DIR__ . '/auth.php';
}
?>
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm fixed-top">
    <div class="container">
        <a class="navbar-brand brand-lockup" href="index.php">
            <img src="images/oldage-home-logo.svg" alt="Oldage Home logo" class="brand-logo">
            <span class="brand-text-wrap">
                <span class="brand-title">Oldage Home</span>
                <span class="brand-subtitle">Care &amp; Comfort</span>
            </span>
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <div class="nav-panel-head d-lg-none">
                <div>
                    <div class="nav-panel-title">Menu</div>
                    <div class="nav-panel-subtitle">Explore Oldage Home</div>
                </div>
                <button class="nav-panel-close" type="button" id="navPanelClose" aria-label="Close menu">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <ul class="navbar-nav me-auto">
                <li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
                <li class="nav-item"><a class="nav-link" href="about.php">About Us</a></li>
                <li class="nav-item"><a class="nav-link" href="services.php">Services</a></li>
                <li class="nav-item"><a class="nav-link" href="facilities.php">Facilities</a></li>
                <li class="nav-item"><a class="nav-link" href="gallery.php">Gallery</a></li>
                <li class="nav-item"><a class="nav-link" href="staff.php">Our Staff</a></li>
                <li class="nav-item"><a class="nav-link" href="testimonials.php">Testimonials</a></li>
                <li class="nav-item"><a class="nav-link" href="contact.php">Contact</a></li>
                <?php if (isLoggedIn() && !isAdmin()): ?>
                <li class="nav-item"><a class="nav-link" href="book-services.php">Book Services</a></li>
                <?php endif; ?>
                <?php if (isAdmin()): ?>
                <li class="nav-item"><a class="nav-link" href="admin.php">Admin Panel</a></li>
                <?php endif; ?>
            </ul>
            <ul class="navbar-nav">
                <?php if (isLoggedIn()): ?>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-bs-toggle="dropdown">
                        <i class="fas fa-user me-1"></i><?php echo htmlspecialchars($_SESSION['user_name']); ?>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-end">
                        <?php if (isAdmin()): ?>
                            <li><a class="dropdown-item" href="admin.php">Admin Panel</a></li>
                        <?php else: ?>
                            <li><a class="dropdown-item" href="dashboard.php">My Dashboard</a></li>
                            <li><a class="dropdown-item" href="profile.php">Edit Profile</a></li>
                            <li><a class="dropdown-item" href="book-services.php">Book Services</a></li>
                        <?php endif; ?>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="logout.php">Logout</a></li>
                    </ul>
                </li>
                <?php else: ?>
                <li class="nav-item"><a class="nav-link" href="login.php">Login</a></li>
                <li class="nav-item"><a class="nav-link btn btn-primary text-white ms-2" href="register.php">Register</a></li>
                <?php endif; ?>
            </ul>
        </div>
    </div>
</nav>
