<?php
// Detect the current page for auto-active state
$current_page = basename($_SERVER['PHP_SELF']);
if ($current_page == '' || $current_page == '/') {
    $current_page = 'index.php';
}
?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

<style>
    .footer-container {
        position: fixed;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        max-width: 420px;
        z-index: 1000;
    }

    .footer-bg-img {
        width: 100%;
        height: auto;
        display: block; 
    }

    .footer-nav {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: space-between;
        align-items: flex-end; 
        /* Reduced bottom padding to shift all icons/text down */
        padding: 0 10px 2px 10px; 
    }

    .footer-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
        text-decoration: none;
        color: #d3b8a5; 
        font-size: 13px; 
        height: 100%;
        padding-bottom: 2px; 
        transition: color 0.2s ease;
    }

    .footer-icon-img {
        /* STRICTLY locked dimensions to prevent the active image from resizing */
        width: 25px !important; 
        height: 25px !important; 
        min-width: 25px;
        min-height: 25px;
        max-width: 25px;
        max-height: 25px;
        object-fit: contain;
        /* Tighter gap between icon and text */
        margin-bottom: 3px; 
        display: block;
    }

    /* Active State - Solid Orange, ZERO GLOW */
    .footer-btn.active span {
        color: #f26d0f; 
        font-weight: 600;
    }

    /* Center Wheel Text - Solid Yellow, ZERO GLOW */
    .footer-btn-center {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
        text-decoration: none;
        color: #ffea00; 
        font-size: 13px; 
        font-weight: bold;
        height: 100%;
        padding-bottom: 2px; 
    }
    
    /* Invisible clickable area over the wheel graphic */
    .wheel-click-area {
        position: absolute;
        bottom: 25%; 
        width: 22vw;  
        max-width: 85px; 
        aspect-ratio: 1 / 1; 
        border-radius: 50%;
        left: 50%;
        transform: translateX(-50%);
        z-index: 3;
    }

    /* Utility class for unavailable items */
    .disabled-link {
        cursor: not-allowed;
        opacity: 0.6;
    }

    /* iOS Glassy Toast Styles */
    #ios-toast-container {
        position: fixed;
        bottom: 110px; 
        left: 50%;
        transform: translateX(-50%) scale(0.9);
        z-index: 9999;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.25s ease, transform 0.25s ease;
    }

    #ios-toast-container.show {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }

    .ios-toast {
        background: rgba(20, 20, 20, 0.55); 
        backdrop-filter: blur(20px); 
        -webkit-backdrop-filter: blur(20px);
        padding: 10px 24px; 
        border-radius: 10px; 
        color: #ffffff;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        font-size: 14px;
        font-weight: 500;
        text-align: center;
        border: 1px solid rgba(255, 255, 255, 0.15); 
        box-shadow: none; 
        white-space: nowrap;
    }
</style>

<div id="ios-toast-container">
    <div class="ios-toast" id="ios-toast-message">Not available</div>
</div>

<div class="footer-container">
    <img src="https://pakclub.club/assets/deepOrange/tabIcon/barBg-852da525.webp" class="footer-bg-img" alt="Footer Background">
    
    <a href="games.php" class="wheel-click-area"></a>

    <div class="footer-nav">
        <a href="index.php" class="footer-btn <?php echo ($current_page == 'index.php') ? 'active' : ''; ?>">
            <img src="<?php echo ($current_page == 'index.php') ? 'https://pakclub.club/assets/deepOrange/tabIcon/home_a-353d3f96.webp' : 'https://pakclub.club/assets/deepOrange/tabIcon/home-d1bc32c4.webp'; ?>" class="footer-icon-img" alt="Home">
            <span>Home</span>
        </a>
        
        <a href="promo.php" class="footer-btn <?php echo ($current_page == 'promo.php') ? 'active' : ''; ?>">
            <img src="<?php echo ($current_page == 'promo.php') ? 'https://pakclub.club/assets/deepOrange/tabIcon/activity_a-20ee0506.webp' : 'https://pakclub.club/assets/deepOrange/tabIcon/activity-895970bd.webp'; ?>" class="footer-icon-img" alt="Promo">
            <span>Promo</span>
        </a>
        
        <a href="games.php" class="footer-btn-center <?php echo ($current_page == 'games.php') ? 'active' : ''; ?>">
            <span>Games</span>
        </a>
        
        <a href="earn.php" class="footer-btn <?php echo ($current_page == 'earn.php') ? 'active' : ''; ?>">
            <img src="<?php echo ($current_page == 'earn.php') ? 'https://pakclub.club/assets/deepOrange/tabIcon/promotion_a-adbfc8ce.webp' : 'https://pakclub.club/assets/deepOrange/tabIcon/promotion-e98e0efb.webp'; ?>" class="footer-icon-img" alt="Earn">
            <span>Earn</span>
        </a>
        
        <a href="me.php" class="footer-btn <?php echo ($current_page == 'me.php') ? 'active' : ''; ?>">
            <img src="<?php echo ($current_page == 'me.php') ? 'https://pakclub.club/assets/deepOrange/tabIcon/main_a-f91256a4.webp' : 'https://pakclub.club/assets/deepOrange/tabIcon/main-38c69605.webp'; ?>" class="footer-icon-img" alt="Mine">
            <span>Mine</span>
        </a>
    </div>
</div>

<script>
    let toastTimeout;

    function showToast(message) {
        const toastContainer = document.getElementById('ios-toast-container');
        const toastMessage = document.getElementById('ios-toast-message');
        
        toastMessage.innerText = message;
        toastContainer.classList.add('show');
        
        // Clear any existing timeout so rapid clicks don't hide it instantly
        clearTimeout(toastTimeout);
        
        // Hide after 2 seconds
        toastTimeout = setTimeout(() => {
            toastContainer.classList.remove('show');
        }, 2000);
    }
</script>