<?php
// customer/includes/footer.php
// Unified fixed bottom navigation for all customer pages.
//
// Always show only:
// Home, Request, My Requests, Messages, Profile

$currentPage = basename($_SERVER['PHP_SELF'] ?? '');
$currentActive = $activePage ?? '';

function customer_footer_active(string $key, string $currentPage, string $currentActive): string {
    $matches = [
        'dashboard' => ['dashboard.php'],
        'request' => ['request.php'],
        'requests' => ['my_requests.php', 'my_request.php'],
        'messages' => ['messages.php'],
        'profile' => ['profile.php'],
    ];

    if ($currentActive === $key) {
        return 'active';
    }

    if ($key === 'requests' && in_array($currentActive, ['my_requests', 'requests'], true)) {
        return 'active';
    }

    return in_array($currentPage, $matches[$key] ?? [], true) ? 'active' : '';
}
?>

<style>
/* Unified fixed customer footer */
.bottom-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 64px;
    background: #080240 !important;
    display: flex !important;
    justify-content: space-around !important;
    align-items: center !important;
    padding: 8px 0 !important;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.22) !important;
    border-top: 1px solid rgba(96, 165, 250, 0.18) !important;
    z-index: 9999 !important;
}

.bottom-nav .nav-item {
    flex: 1 !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    text-align: center !important;
    color: #aebbd4 !important;
    text-decoration: none !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    border-radius: 0 !important;
}

.bottom-nav .nav-item i {
    font-size: 20px !important;
    display: block !important;
    margin: 0 !important;
    color: inherit !important;
}

.bottom-nav .nav-item span {
    color: inherit !important;
    line-height: 1 !important;
}

.bottom-nav .nav-item.active {
    color: #ffffff !important;
    background: rgba(255,255,255,0.08) !important;
}

body {
    padding-bottom: 72px !important;
}
</style>

<!-- Bottom Navigation -->
<nav class="bottom-nav">
    <a href="dashboard.php" class="nav-item <?= customer_footer_active('dashboard', $currentPage, $currentActive) ?>">
        <i class="fas fa-home"></i>
        <span>Home</span>
    </a>

    <a href="request.php" class="nav-item <?= customer_footer_active('request', $currentPage, $currentActive) ?>">
        <i class="fas fa-plus-circle"></i>
        <span>Request</span>
    </a>

    <a href="my_requests.php" class="nav-item <?= customer_footer_active('requests', $currentPage, $currentActive) ?>">
        <i class="fas fa-clipboard-list"></i>
        <span>My Requests</span>
    </a>

    <a href="messages.php" class="nav-item <?= customer_footer_active('messages', $currentPage, $currentActive) ?>">
        <i class="fas fa-comments"></i>
        <span>Messages</span>
    </a>

    <a href="profile.php" class="nav-item <?= customer_footer_active('profile', $currentPage, $currentActive) ?>">
        <i class="fas fa-user"></i>
        <span>Profile</span>
    </a>
</nav>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
