<?php require_once 'includes/i18n.php'; ?>
<!DOCTYPE html>
<html lang="<?php echo $lang; ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NovaEx | Leading Crypto Exchange</title>
    <link rel="icon" type="image/png" href="assets/pasted-20260211-152742-c4035b1b.png">
    <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
        .logo-text { display: flex; align-items: center; }
        /* High Definition Original Image Size: 500x200px */
        .logo-img { width: 500px !important; height: 200px !important; object-fit: contain; }
        
        /* Navbar adjustment for large logo */
        .navbar { height: auto !important; min-height: 64px; padding: 10px 1.5rem !important; }
        
        /* Floating CS Chat */
        .floating-service { position: fixed; bottom: 30px; right: 30px; width: 60px; height: 60px; background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 1.5rem; cursor: pointer; box-shadow: 0 10px 25px rgba(0,242,254,0.3); z-index: 1000; transition: transform 0.3s ease; }
        .floating-service:hover { transform: scale(1.1) rotate(5deg); }
        
        #cs-chat-window { position: fixed; bottom: 100px; right: 30px; width: 380px; height: 500px; background: #161a1e; border: 1px solid #2b3139; border-radius: 16px; display: none; flex-direction: column; box-shadow: 0 20px 40px rgba(0,0,0,0.5); z-index: 1001; overflow: hidden; }
        #cs-chat-window iframe { border: none; width: 100%; height: 100%; }
        .chat-header { background: #2b3139; padding: 15px; display: flex; justify-content: space-between; align-items: center; color: white; }

        @media (max-width: 768px) {
            .logo-img { width: 250px !important; height: 100px !important; }
        }
    </style>
</head>
<body>

<div class="floating-service" onclick="toggleCSChat()" title="Customer Service">
    <i class="fas fa-headset"></i>
</div>

<div id="cs-chat-window">
    <div class="chat-header">
        <span>NovaEx Support</span>
        <i class="fas fa-times" onclick="toggleCSChat()" style="cursor: pointer;"></i>
    </div>
    <iframe src="chat_iframe.php"></iframe>
</div>

<nav class="navbar">
    <div style="display: flex; align-items: center; gap: 2rem;">
        <a href="index.php" style="text-decoration: none;">
            <div class="logo-text">
                <img src="assets/pasted-20260211-152742-c4035b1b.png" alt="Logo" class="logo-img">
            </div>
        </a>
        <div class="nav-links">
            <a href="index.php"><i class="fas fa-home nav-link-icon"></i><?php echo __('nav_home', '首页'); ?></a>
            <a href="markets.php"><i class="fas fa-chart-line nav-link-icon"></i><?php echo __('nav_market', '行情'); ?></a>
            <a href="spot.php"><i class="fas fa-coins nav-link-icon"></i><?php echo __('nav_spot', '现货交易'); ?></a>
            <a href="futures.php"><i class="fas fa-file-contract nav-link-icon"></i><?php echo __('nav_futures', '合约交易'); ?></a>
            <a href="convert.php"><i class="fas fa-bolt nav-link-icon"></i><?php echo __('nav_convert', '闪兑'); ?></a>
            <a href="mining.php"><i class="fas fa-pickaxe nav-link-icon"></i><?php echo __('nav_mining', '挖矿'); ?></a>
            <a href="profile.php"><i class="fas fa-wallet nav-link-icon"></i><?php echo __('nav_assets', '资产'); ?></a>
        </div>
    </div>
    
    <div style="display: flex; gap: 1.5rem; align-items: center;">
        <div class="dropdown">
            <a href="#" style="color: white; display: flex; align-items: center; gap: 5px;">
                <i class="fas fa-globe"></i>
                <span style="font-size: 13px;"><?php echo strtoupper($lang); ?></span>
            </a>
            <div class="dropdown-content" style="right: 0; min-width: 120px;">
                <a href="?lang=en" style="display: flex; align-items: center; gap: 10px;">
                    <img src="https://flagcdn.com/w20/us.png" width="20" alt="English"> English
                </a>
                <a href="?lang=zh" style="display: flex; align-items: center; gap: 10px;">
                    <img src="https://flagcdn.com/w20/cn.png" width="20" alt="Chinese"> 简体中文
                </a>
            </div>
        </div>
        
        <?php if(isset($_SESSION['user_id'])): ?>
            <div class="dropdown">
                <a href="#" style="color: white; display: flex; align-items: center; gap: 8px;">
                    <i class="fas fa-user-circle" style="font-size: 1.5rem;"></i>
                    <i class="fas fa-chevron-down" style="font-size: 10px;"></i>
                </a>
                <div class="dropdown-content user-profile-dropdown" style="right: 0;">
                    <div class="user-info-header">
                        <div style="font-weight: bold; margin-bottom: 4px;"><?php echo $_SESSION['username'] ?? 'User'; ?></div>
                        <div class="uid-badge">UID: <?php echo $_SESSION['uid'] ?? '------'; ?></div>
                    </div>
                    <a href="profile.php"><i class="fas fa-id-card" style="color: #4facfe;"></i> <?php echo __('nav_profile', '个人中心'); ?></a>
                    <a href="deposit.php"><i class="fas fa-plus-circle" style="color: #00f2fe;"></i> <?php echo __('nav_deposit', '充值'); ?></a>
                    <a href="logout.php" style="color: var(--danger-color);"><i class="fas fa-sign-out-alt"></i> <?php echo __('nav_logout', '退出登录'); ?></a>
                </div>
            </div>
        <?php else: ?>
            <a href="login.php" style="color: white; text-decoration: none; font-size: 14px;"><?php echo __('nav_login'); ?></a>
            <a href="register.php" class="btn-primary"><?php echo __('nav_register'); ?></a>
        <?php endif; ?>
    </div>
</nav>

<script>
    function toggleCSChat() {
        const chat = document.getElementById('cs-chat-window');
        chat.style.display = chat.style.display === 'flex' ? 'none' : 'flex';
    }
</script>