<?php
// 取得目前執行的檔案名稱，用來判斷哪個選單要亮起
$current_page = basename($_SERVER['PHP_SELF']);

// 依據不同頁面顯示對應的標題
$nav_title = "👋 " . htmlspecialchars($_SESSION['display_name'] ?? '玩家');
if ($current_page == 'bank.php') {
    $nav_title = "🏦 時光銀行";
} elseif ($current_page == 'shop.php') {
    $nav_title = "🛒 時光商店街";
} elseif ($current_page == 'stocks.php') {
    $nav_title = "📈 證券交易所";
} elseif ($current_page == 'estate.php') {
    $nav_title = "🏘️ 地產大亨面板"; 
} elseif ($current_page == 'leaderboard.php') {
    $nav_title = "🏆 全球排行榜"; // ★ 新增排行榜標題
}
?>
<style>
    /* 小孩端專屬導覽列樣式 */
    .player-navbar { 
        background-color: #2c3e50; 
        color: white; 
        padding: 15px 20px; 
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        box-shadow: 0 4px 6px rgba(0,0,0,0.1); 
    }
    .player-navbar h2 { margin: 0; font-size: 1.1rem; }
    .player-nav-links { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end;}
    
    .player-nav-links a { 
        color: white; 
        text-decoration: none; 
        font-size: 0.85rem; 
        border: 1px solid rgba(255,255,255,0.4); 
        padding: 6px 12px; 
        border-radius: 15px; 
        transition: 0.2s; 
        font-weight: bold;
    }
    .player-nav-links a.active { 
        background-color: #f1c40f; 
        color: #2c3e50; 
        border-color: #f1c40f; 
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }
    .player-nav-links a:hover:not(.active) { 
        background-color: rgba(255,255,255,0.2); 
    }
    
    @media (max-width: 580px) {
        .player-navbar { flex-direction: column; gap: 15px; text-align: center; }
        .player-nav-links { justify-content: center; }
    }
</style>

<div class="player-navbar">
    <h2><?php echo $nav_title; ?></h2>
    <div class="player-nav-links">
        <a href="dashboard.php" class="<?php echo ($current_page == 'dashboard.php') ? 'active' : ''; ?>">🏠 首頁</a>
        <a href="bank.php" class="<?php echo ($current_page == 'bank.php') ? 'active' : ''; ?>">🏦 銀行</a>
        <a href="shop.php" class="<?php echo ($current_page == 'shop.php') ? 'active' : ''; ?>">🛒 商店</a>
        <a href="stocks.php" class="<?php echo ($current_page == 'stocks.php') ? 'active' : ''; ?>">📈 股市</a>
        <a href="estate.php" class="<?php echo ($current_page == 'estate.php') ? 'active' : ''; ?>">🏘️ 房產</a>
        <a href="leaderboard.php" class="<?php echo ($current_page == 'leaderboard.php' || isset($_GET['tab'])) ? 'active' : ''; ?>">🏆 排行</a> <a href="../logout.php" style="background-color: #e74c3c; border-color: #e74c3c;">登出</a>
    </div>
</div>