<?php
ob_start();
require_once __DIR__ . '/../db/config.php';
session_start();

$user = null;
if (isset($_SESSION['user_id'])) {
    $stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
    $stmt->execute([$_SESSION['user_id']]);
    $user = $stmt->fetch();
}

$lang = $_GET['lang'] ?? $_SESSION['lang'] ?? 'en';
if (!in_array($lang, ['en', 'zh'])) {
    $lang = 'en';
}
$_SESSION['lang'] = $lang;

$translations = [
    'en' => [
        'Home' => 'Home', 'Spot' => 'Spot', 'Perpetual' => 'Perpetual', 'Markets' => 'Markets', 'Exchange' => 'Exchange',
        'Login' => 'Login', 'Register' => 'Register', 'Profile' => 'Profile', 'Logout' => 'Logout',
        'Deposit' => 'Deposit', 'Withdraw' => 'Withdraw', 'Assets' => 'Assets', 'Security' => 'Security',
        'Buy' => 'Buy', 'Sell' => 'Sell', 'Limit' => 'Limit', 'Market' => 'Market', 'Price' => 'Price',
        'Amount' => 'Amount', 'Total' => 'Total', 'Available' => 'Available', 'Trade' => 'Trade',
        'Market Trends' => 'Market Trends', 'Real-time Prices' => 'Real-time Prices', 'High' => 'High', 'Low' => 'Low',
        'Download App' => 'Download App', 'Customer Service' => 'Customer Service',
        'Identity Verification' => 'Identity Verification', 'Trading Password' => 'Trading Password',
        'Success' => 'Success', 'Error' => 'Error', 'Matching Account' => 'Matching Account',
        'Establishing secure connection with liquidity provider...' => 'Establishing secure connection with liquidity provider...',
        'Awaiting merchant confirmation...' => 'Awaiting merchant confirmation...',
        'Matching in progress' => 'Matching in progress',
        'The specialized account for this transaction will be provided by our agent shortly.' => 'The specialized account for this transaction will be provided by our agent shortly.',
        'Transfer the exact amount. Upload proof below.' => 'Transfer the exact amount. Upload proof below.',
        'Bank Name' => 'Bank Name', 'Account Number' => 'Account Number', 'Beneficiary' => 'Beneficiary', 'Reference' => 'Reference',
        'Copy' => 'Copy', 'Upload Proof' => 'Upload Proof', 'Selected' => 'Selected', 'Transfer Completed' => 'Transfer Completed',
        'Your transfer is being reviewed. ETA: 10-20 mins.' => 'Your transfer is being reviewed. ETA: 10-20 mins.',
        'Back to Wallet' => 'Back to Wallet', 'Matched & Active' => 'Matched & Active',
        'Services' => 'Services', 'Spot Trading' => 'Spot Trading', 'Futures Trading' => 'Futures Trading',
        'Support' => 'Support', 'Help Center' => 'Help Center', 'About Us' => 'About Us', 'Privacy Policy' => 'Privacy Policy', 'Terms of Service' => 'Terms of Service',
        'System Status' => 'System Status', 'Normal' => 'Normal', 'Overview' => 'Overview', 'Full Name' => 'Full Name', 'ID Number' => 'ID Number', 'Submit' => 'Submit', 'Next-Gen Trading Engine' => 'Next-Gen Trading Engine',
        'Experience ultra-low latency and institutional-grade liquidity on our professional K-line trading platform.' => 'Experience ultra-low latency and institutional-grade liquidity on our professional K-line trading platform.',
        'Register Now' => 'Register Now', 'Start Trading' => 'Start Trading', 'Go to Futures' => 'Go to Futures', 'Global Crypto Hub' => 'Global Crypto Hub',
        'Access real-time global market data and execute trades across multiple asset classes with one unified account.' => 'Access real-time global market data and execute trades across multiple asset classes with one unified account.',
        'Secure Asset Custody' => 'Secure Asset Custody', 'Your funds are safe with our institutional-grade security, multi-sig cold storage, and comprehensive insurance fund.' => 'Your funds are safe with our institutional-grade security, multi-sig cold storage, and comprehensive insurance fund.',
        'Security Center' => 'Security Center', '24/7 Global Support' => '24/7 Global Support', 'Our dedicated professional support team is available around the clock to assist you in multiple languages.' => 'Our dedicated professional support team is available around the clock to assist you in multiple languages.',
        'Contact Support' => 'Contact Support', 'Asset' => 'Asset', '24h Change' => '24h Change', '24h High' => '24h High', 'Action' => 'Action', 'All Markets' => 'All Markets',
        'Real-time updates from global exchanges' => 'Real-time updates from global exchanges', 'Safe & Secure' => 'Safe & Secure', 'Industry-leading encryption and multi-signature cold storage for your digital assets.' => 'Industry-leading encryption and multi-signature cold storage for your digital assets.',
        'Instant Execution' => 'Instant Execution', 'Advanced matching engine processing over 100,000 transactions per second.' => 'Advanced matching engine processing over 100,000 transactions per second.',
        'Recharge' => 'Recharge', 'Withdrawal' => 'Withdrawal', 'Funds' => 'Funds',
        'Wallet Balance' => 'Wallet Balance', 'Transaction History' => 'Transaction History',
        'Take Profit' => 'Take Profit', 'Stop Loss' => 'Stop Loss', 'Contract' => 'Contract',
        'Receipt uploaded successfully. Waiting for admin approval.' => 'Receipt uploaded successfully. Waiting for admin approval.',
        'Asset Overview' => 'Asset Overview', 'KYC Verification' => 'KYC Verification', 'Personal Center' => 'Personal Center',
        'Verification Status' => 'Verification Status', 'Security Settings' => 'Security Settings', 'Language' => 'Language',
        'Update' => 'Update', 'Change Password' => 'Change Password', 'Not Verified' => 'Not Verified', 'Pending Review' => 'Pending Review', 'Approved' => 'Approved', 'Rejected' => 'Rejected',
        'Withdrawal Address' => 'Withdrawal Address', 'Enter amount' => 'Enter amount', 'Available' => 'Available', 'Network' => 'Network', 'Fee' => 'Fee', 'Submit Withdrawal' => 'Submit Withdrawal',
        'Recharge Crypto' => 'Recharge Crypto', 'Select Currency' => 'Select Currency', 'Deposit Address' => 'Deposit Address', 'Transfer to this address and upload screenshot.' => 'Transfer to this address and upload screenshot.',
        'Confirm' => 'Confirm', 'Cancel' => 'Cancel', 'Please login to trade' => 'Please login to trade', 'Contract Trading' => 'Contract Trading',
        'Long' => 'Long', 'Short' => 'Short', 'Leverage' => 'Leverage', 'Open Position' => 'Open Position', 'Close Position' => 'Close Position',
        'Market' => 'Market', 'Limit' => 'Limit', 'Price' => 'Price', 'Amount' => 'Amount', 'Balance' => 'Balance',
        'Orders' => 'Orders', 'Positions' => 'Positions', 'History' => 'History', 'Sign In' => 'Sign In', 'Sign Up' => 'Sign Up',
        'Forgot Password?' => 'Forgot Password?', 'Don\'t have an account?' => 'Don\'t have an account?', 'Already have an account?' => 'Already have an account?',
        'Username' => 'Username', 'Email' => 'Email', 'Password' => 'Password', 'Confirm Password' => 'Confirm Password',
        'Trade Anytime, Anywhere' => 'Trade Anytime, Anywhere', 'Experience the full power of our exchange on your mobile device. Trade spot and futures with ease.' => 'Experience the full power of our exchange on your mobile device. Trade spot and futures with ease.',
        'Download on the' => 'Download on the', 'Get it on' => 'Get it on', 'Scan to download' => 'Scan to download', 'Compatible with iOS and Android devices.' => 'Compatible with iOS and Android devices.',
        'Global Trust' => 'Global Trust', 'Our Global Partners' => 'Our Global Partners', 'Smart Contracts' => 'Smart Contracts', 'Primary Network' => 'Primary Network', 'Security Audit' => 'Security Audit', 'Financial Partner' => 'Financial Partner', 'Strategic Advisor' => 'Strategic Advisor',
        'Markets' => 'Markets', 'Trade' => 'Trade', 'Spot Trading' => 'Spot Trading', 'Contract Trading' => 'Contract Trading', 'Download App' => 'Download App', 'Register' => 'Register',
        'Enter username' => 'Enter username', 'Enter password' => 'Enter password', 'Remember me' => 'Remember me', 'Forgot password?' => 'Forgot password?',
        'Please fill in all fields.' => 'Please fill in all fields.', 'Invalid username or password.' => 'Invalid username or password.', 'Login failed.' => 'Login failed.',
        'Login to BITCrypto' => 'Login to BITCrypto',
        'Asset Overview' => 'Asset Overview', 'Total Balance' => 'Total Balance', 'Available Balance' => 'Available Balance', 'Locked Balance' => 'Locked Balance',
        'Verify Now' => 'Verify Now', 'Personal Information' => 'Personal Information', 'Security Center' => 'Security Center',
        'Change' => 'Change', 'Transaction History' => 'Transaction History', 'Date' => 'Date', 'Type' => 'Type', 'Amount' => 'Amount', 'Status' => 'Status',
        'Why Choose BITCrypto?' => 'Why Choose BITCrypto?', 'Experience the most professional trading environment with institutional-grade security and liquidity.' => 'Experience the most professional trading environment with institutional-grade security and liquidity.',
        'Safe & Secure' => 'Safe & Secure', 'Industry-leading encryption and multi-signature cold storage for your digital assets.' => 'Industry-leading encryption and multi-signature cold storage for your digital assets.',
        'Multi-sig Cold Storage' => 'Multi-sig Cold Storage', 'DDoS Protection' => 'DDoS Protection', '2FA Security' => '2FA Security',
        'Instant Execution' => 'Instant Execution', 'Advanced matching engine processing over 100,000 transactions per second.' => 'Advanced matching engine processing over 100,000 transactions per second.',
        'Ultra-low Latency' => 'Ultra-low Latency', 'High Liquidity' => 'High Liquidity', 'Zero Slippage' => 'Zero Slippage',
        '24/7 Global Support' => '24/7 Global Support', 'Get help whenever you need it with our around-the-clock professional customer service.' => 'Get help whenever you need it with our around-the-clock professional customer service.',
        'Multi-language Support' => 'Multi-language Support', 'Live Chat' => 'Live Chat', 'Fast Response' => 'Fast Response',
        'Get Started' => 'Get Started', 'View Markets' => 'View Markets', 'Search assets...' => 'Search assets...',
        'Name' => 'Name', 'Action' => 'Action', 'View All' => 'View All', 'Stay updated with real-time price changes' => 'Stay updated with real-time price changes',
        'The World\'s Leading' => 'The World\'s Leading', 'Crypto Exchange' => 'Crypto Exchange', 'Secure & Trusted' => 'Secure & Trusted', 'Institutional Grade' => 'Institutional Grade', 'Deep Liquidity' => 'Deep Liquidity', 'Global Access' => 'Global Access', 'Perpetual Contracts' => 'Perpetual Contracts', '100x Leverage' => '100x Leverage', 'Join the Elite' => 'Join the Elite', 'Trust BITCrypto' => 'Trust BITCrypto',
        'Trade Bitcoin, Ethereum, and hundreds of other cryptocurrencies with the lowest fees in the industry.' => 'Trade Bitcoin, Ethereum, and hundreds of other cryptocurrencies with the lowest fees in the industry.',
        'Go to Trade' => 'Go to Trade', 'Search Pairs' => 'Search Pairs', 'Change' => 'Change', 'High' => 'High', 'Low' => 'Low', 'Time' => 'Time', 'Pair' => 'Pair', 'Side' => 'Side', 'Filled' => 'Filled', 'No open orders' => 'No open orders', 'Take-Profit' => 'Take-Profit', 'Stop-Loss' => 'Stop-Loss', 'Order submitted successfully!' => 'Order submitted successfully!', 'Please enter a valid amount.' => 'Please enter a valid amount.',
    ],
    'zh' => [
        'Home' => '首页', 'Spot' => '现货', 'Perpetual' => '合约', 'Markets' => '行情', 'Exchange' => '交易',
        'Login' => '登录', 'Register' => '注册', 'Profile' => '个人中心', 'Logout' => '退出',
        'Deposit' => '充值', 'Withdraw' => '提现', 'Assets' => '资产', 'Security' => '安全',
        'Buy' => '买入', 'Sell' => '卖出', 'Limit' => '限价', 'Market' => '市价', 'Price' => '价格',
        'Amount' => '数量', 'Total' => '合计', 'Available' => '可用', 'Trade' => '交易',
        'Market Trends' => '市场趋势', 'Real-time Prices' => '实时价格', 'High' => '最高', 'Low' => '最低',
        'Download App' => '下载APP', 'Customer Service' => '联系客服',
        'Identity Verification' => '身份认证', 'Trading Password' => '交易密码',
        'Success' => '成功', 'Error' => '错误', 'Matching Account' => '匹配账户',
        'Establishing secure connection with liquidity provider...' => '正在与流动性提供商建立安全连接...',
        'Awaiting merchant confirmation...' => '等待商家确认...',
        'Matching in progress' => '正在匹配中',
        'The specialized account for this transaction will be provided by our agent shortly.' => '本次交易的专用账户将由我们的代理稍后提供。',
        'Transfer the exact amount. Upload proof below.' => '请转账准确金额。在下方上传凭证。',
        'Bank Name' => '银行名称', 'Account Number' => '账号', 'Beneficiary' => '收款人', 'Reference' => '备注',
        'Copy' => '复制', 'Upload Proof' => '上传凭证', 'Selected' => '已选择', 'Transfer Completed' => '我已完成转账',
        'Your transfer is being reviewed. ETA: 10-20 mins.' => '您的转账正在审核中。预计时间：10-20分钟。',
        'Back to Wallet' => '返回钱包', 'Matched & Active' => '已匹配并激活',
        'Services' => '服务', 'Spot Trading' => '现货交易', 'Futures Trading' => '合约交易',
        'Support' => '支持', 'Help Center' => '帮助中心', 'About Us' => '关于我们', 'Privacy Policy' => '隐私政策', 'Terms of Service' => '服务条款',
        'System Status' => '系统状态', 'Normal' => '正常', 'Overview' => '总览', 'Full Name' => '姓名', 'ID Number' => '证件号', 'Submit' => '提交', 'Next-Gen Trading Engine' => '下一代交易引擎',
        'Experience ultra-low latency and institutional-grade liquidity on our professional K-line trading platform.' => '在我们的专业 K 线交易平台上体验极低延迟和机构级流动性。',
        'Register Now' => '立即注册', 'Start Trading' => '开始交易', 'Go to Futures' => '前往合约', 'Global Crypto Hub' => '全球加密中心',
        'Access real-time global market data and execute trades across multiple asset classes with one unified account.' => '通过一个统一账户访问实时全球市场数据并执行跨多个资产类别的交易。',
        'Secure Asset Custody' => '安全资产托管', 'Your funds are safe with our institutional-grade security, multi-sig cold storage, and comprehensive insurance fund.' => '您的资金通过我们的机构级安全、多重签名冷存储和综合保险基金得到保障。',
        'Security Center' => '安全中心', '24/7 Global Support' => '24/7 全球支持', 'Our dedicated professional support team is available around the clock to assist you in multiple languages.' => '我们专业的支持团队全天候为您提供多种语言的帮助。',
        'Contact Support' => '联系支持', 'Asset' => '资产', '24h Change' => '24h 涨跌', '24h High' => '24h 最高', 'Action' => '操作', 'All Markets' => '所有市场',
        'Real-time updates from global exchanges' => '来自全球交易所的实时更新', 'Safe & Secure' => '安全可靠', 'Industry-leading encryption and multi-signature cold storage for your digital assets.' => '行业领先的加密技术和多重签名冷存储，保护您的数字资产。',
        'Instant Execution' => '即时执行', 'Advanced matching engine processing over 100,000 transactions per second.' => '先进的撮合引擎，每秒处理超过 100,000 笔交易。',
        'Recharge' => '充值', 'Withdrawal' => '提现', 'Funds' => '资产',
        'Wallet Balance' => '钱包余额', 'Transaction History' => '交易记录',
        'Take Profit' => '止盈', 'Stop Loss' => '止损', 'Contract' => '合约',
        'Receipt uploaded successfully. Waiting for admin approval.' => '凭证上传成功。等待管理员审核。',
        'Asset Overview' => '资产总览', 'KYC Verification' => '身份认证', 'Personal Center' => '个人中心',
        'Verification Status' => '认证状态', 'Security Settings' => '安全设置', 'Language' => '语言',
        'Update' => '更新', 'Change Password' => '修改密码', 'Not Verified' => '未认证', 'Pending Review' => '待审核', 'Approved' => '已通过', 'Rejected' => '已驳回',
        'Withdrawal Address' => '提现地址', 'Enter amount' => '输入金额', 'Available' => '可用', 'Network' => '网络', 'Fee' => '手续费', 'Submit Withdrawal' => '提交提现',
        'Recharge Crypto' => '加密货币充值', 'Select Currency' => '选择币种', 'Deposit Address' => '充值地址', 'Transfer to this address and upload screenshot.' => '转账至此地址并上传截图。',
        'Confirm' => '确认', 'Cancel' => '取消', 'Please login to trade' => '请先登录以进行交易', 'Contract Trading' => '合约交易',
        'Long' => '做多', 'Short' => '做空', 'Leverage' => '杠杆', 'Open Position' => '开仓', 'Close Position' => '平仓',
        'Market' => '市价', 'Limit' => '限价', 'Price' => '价格', 'Amount' => '数量', 'Balance' => '余额',
        'Orders' => '订单', 'Positions' => '持仓', 'History' => '历史', 'Sign In' => '登录', 'Sign Up' => '注册',
        'Forgot Password?' => '忘记密码？', 'Don\'t have an account?' => '还没有账号？', 'Already have an account?' => '已有账号？',
        'Username' => '用户名', 'Email' => '邮箱', 'Password' => '密码', 'Confirm Password' => '确认密码',
        'Trade Anytime, Anywhere' => '随时随地进行交易', 'Experience the full power of our exchange on your mobile device. Trade spot and futures with ease.' => '在您的移动设备上体验我们交易所的全部功能。轻松进行现货和合约交易。',
        'Download on the' => '下载于', 'Get it on' => '获取于', 'Scan to download' => '扫码下载', 'Compatible with iOS and Android devices.' => '兼容 iOS 和 Android 设备。',
        'Global Trust' => '全球信赖', 'Our Global Partners' => '我们的全球合作伙伴', 'Smart Contracts' => '智能合约', 'Primary Network' => '主网', 'Security Audit' => '安全审计', 'Financial Partner' => '金融合作伙伴', 'Strategic Advisor' => '战略顾问',
        'Markets' => '行情', 'Trade' => '交易', 'Spot Trading' => '现货交易', 'Contract Trading' => '合约交易', 'Download App' => '下载应用', 'Register' => '注册',
        'Enter username' => '输入用户名', 'Enter password' => '输入密码', 'Remember me' => '记住我', 'Forgot password?' => '忘记密码？',
        'Please fill in all fields.' => '请填写所有字段。', 'Invalid username or password.' => '用户名或密码错误。', 'Login failed.' => '登录失败。',
        'Login to BITCrypto' => '登录到 BITCrypto',
        'Asset Overview' => '资产总览', 'Total Balance' => '总余额', 'Available Balance' => '可用余额', 'Locked Balance' => '锁定余额',
        'Verify Now' => '立即认证', 'Personal Information' => '个人信息', 'Security Center' => '安全中心',
        'Change' => '修改', 'Transaction History' => '交易历史', 'Date' => '日期', 'Type' => '类型', 'Amount' => '金额', 'Status' => '状态',
        'Why Choose BITCrypto?' => '为什么选择 BITCrypto？', 'Experience the most professional trading environment with institutional-grade security and liquidity.' => '体验最专业的交易环境，拥有机构级的安全和流动性。',
        'Safe & Secure' => '安全可靠', 'Industry-leading encryption and multi-signature cold storage for your digital assets.' => '行业领先的加密和多重签名冷存储，保护您的数字资产。',
        'Multi-sig Cold Storage' => '多重签名冷存储', 'DDoS Protection' => 'DDoS 防护', '2FA Security' => '双重身份验证',
        'Instant Execution' => '即时执行', 'Advanced matching engine processing over 100,000 transactions per second.' => '先进的撮合引擎，每秒处理超过 100,000 笔交易。',
        'Ultra-low Latency' => '极低延迟', 'High Liquidity' => '高流动性', 'Zero Slippage' => '零滑点',
        '24/7 Global Support' => '24/7 全球支持', 'Get help whenever you need it with our around-the-clock professional customer service.' => '随时随地获得我们全天候专业客服的帮助。',
        'Multi-language Support' => '多语言支持', 'Live Chat' => '在线聊天', 'Fast Response' => '快速响应',
        'Get Started' => '开始使用', 'View Markets' => '查看行情', 'Search assets...' => '搜索资产...',
        'Name' => '名称', 'Action' => '操作', 'View All' => '查看全部', 'Stay updated with real-time price changes' => '实时掌握价格变动',
        'The World\'s Leading' => '世界领先的', 'Crypto Exchange' => '加密货币交易所', 'Secure & Trusted' => '安全可信', 'Institutional Grade' => '机构级', 'Deep Liquidity' => '深度流动性', 'Global Access' => '全球访问', 'Perpetual Contracts' => '永续合约', '100x Leverage' => '100倍杠杆', 'Join the Elite' => '加入精英行列', 'Trust BITCrypto' => '信赖 BITCrypto',
        'Trade Bitcoin, Ethereum, and hundreds of other cryptocurrencies with the lowest fees in the industry.' => '以行业最低的手续费交易比特币、以太坊和数百种其他加密货币。',
        'Go to Trade' => '去交易', 'Search Pairs' => '搜索交易对', 'Change' => '涨跌', 'High' => '最高', 'Low' => '最低', 'Time' => '时间', 'Pair' => '交易对', 'Side' => '方向', 'Filled' => '已成交', 'No open orders' => '暂无挂单', 'Take-Profit' => '止盈', 'Stop-Loss' => '止损', 'Order submitted successfully!' => '订单提交成功！', 'Please enter a valid amount.' => '请输入有效金额。',
    ]
];

function mt($key) {
    global $lang, $translations;
    return $translations[$lang][$key] ?? $key;
}

$is_home = basename($_SERVER['PHP_SELF']) == 'index.php';

function getLangUrl($newLang) {
    $params = $_GET;
    $params['lang'] = $newLang;
    return basename($_SERVER['PHP_SELF']) . '?' . http_build_query($params);
}
?>
<!DOCTYPE html>
<html lang="<?php echo $lang; ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo mt('Next-Gen Trading Engine'); ?> | BITCrypto</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
    <script>
        window.translations = <?php echo json_encode($translations[$lang]); ?>;
        function t(key) {
            return window.translations[key] || key;
        }
    </script>
    <style>
        :root {
            --bg-deep: #0a0c0e;
            --bg-card: #101216;
            --primary: #00ff88;
            --primary-hover: #00e67a;
            --text-main: #f0f0f0;
            --text-muted: #848e9c;
            --border-color: #2b2f36;
            --up-color: #00c087;
            --down-color: #cf304a;
        }

        body {
            background-color: var(--bg-deep);
            color: var(--text-main);
            font-family: 'Inter', sans-serif;
            margin: 0;
            padding-top: 72px; /* For fixed header */
            padding-bottom: 70px; /* For mobile bottom nav */
            overflow-x: hidden;
        }

        /* Color consistency rule: White background MUST have black text */
        .bg-white, [style*="background-color: white"], [style*="background-color: #ffffff"], [style*="background: white"] {
            color: #000000 !important;
        }
        .bg-white .text-muted, .bg-white .small {
            color: #6c757d !important;
        }
        
        /* Black background MUST have white text */
        .bg-dark, .bg-black, .bg-deep, body, .card.bg-dark {
            color: #ffffff !important;
        }

        /* Modern Glassmorphism Header */
        .navbar {
            background: rgba(10, 12, 14, 0.85) !important;
            backdrop-filter: blur(12px);
            border-bottom: 1px solid var(--border-color);
            padding: 12px 0;
            z-index: 1050;
        }

        .navbar-brand {
            font-weight: 800;
            font-size: 24px;
            letter-spacing: -0.5px;
            color: var(--primary) !important;
            display: flex;
            align-items: center;
        }

        .logo-img {
            height: 40px;
            margin-right: 12px;
            background: transparent !important;
            border: none !important;
            display: block;
            box-shadow: none !important;
            object-fit: contain;
        }

        .back-button {
            display: <?php echo $is_home ? 'none' : 'flex'; ?>;
            align-items: center;
            gap: 8px;
            color: var(--text-muted);
            text-decoration: none;
            font-weight: 600;
            padding: 8px 16px;
            border-radius: 20px;
            background: rgba(255,255,255,0.05);
            transition: all 0.3s;
            margin-right: 15px;
        }
        .back-button:hover { background: rgba(255,255,255,0.1); color: white; }

        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: var(--bg-card);
            border-top: 1px solid var(--border-color);
            display: flex;
            justify-content: space-around;
            padding: 10px 0;
            z-index: 1000;
        }

        .nav-item-mobile {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-decoration: none;
            color: var(--text-muted);
            font-size: 11px;
            font-weight: 500;
        }

        .nav-item-mobile.active {
            color: var(--primary);
        }

        .nav-item-mobile i {
            font-size: 20px;
            margin-bottom: 4px;
        }

        @media (min-width: 992px) {
            .bottom-nav { display: none; }
        }

        .nav-link {
            color: var(--text-muted) !important;
            font-weight: 500;
            padding: 8px 16px !important;
            transition: all 0.2s;
        }
        .nav-link:hover, .nav-link.active {
            color: var(--text-main) !important;
        }

        .btn-primary {
            background-color: var(--primary);
            border: none;
            color: #000;
            font-weight: 600;
            padding: 10px 24px;
            border-radius: 8px;
            transition: all 0.3s;
        }
        .btn-primary:hover {
            background-color: var(--primary-hover);
            transform: translateY(-1px);
        }

        .dropdown-menu {
            background-color: var(--bg-card);
            border: 1px solid var(--border-color);
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        }
        .dropdown-item {
            color: var(--text-muted);
            padding: 10px 20px;
            transition: all 0.2s;
        }
        .dropdown-item:hover {
            background-color: rgba(255,255,255,0.05);
            color: var(--text-main);
        }

        /* Custom Scrollbar */
        ::-webkit-scrollbar { width: 6px; }
        ::-webkit-scrollbar-track { background: var(--bg-deep); }
        ::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }
        ::-webkit-scrollbar-thumb:hover { background: #444; }
    </style>
</head>
<body>

<nav class="navbar navbar-expand-lg fixed-top">
    <div class="container-fluid px-lg-5">
        <div class="d-flex align-items-center">
            <a href="index.php" class="back-button">
                <i class="bi bi-chevron-left"></i>
            </a>
            <a class="navbar-brand" href="index.php">
                <img src="assets/images/logo.png" alt="Logo" class="logo-img">
                BITCrypto
            </a>
        </div>

        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav me-auto">
                <li class="nav-item"><a class="nav-link" href="market.php"><?php echo mt('Markets'); ?></a></li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"><?php echo mt('Trade'); ?></a>
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" href="trade.php?type=spot"><?php echo mt('Spot Trading'); ?></a></li>
                        <li><a class="dropdown-item" href="trade.php?type=contract"><?php echo mt('Contract Trading'); ?></a></li>
                    </ul>
                </li>
                <?php if ($user):
                ?>                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"><?php echo mt('Funds'); ?></a>
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" href="deposit.php"><?php echo mt('Recharge'); ?></a></li>
                        <li><a class="dropdown-item" href="withdraw.php"><?php echo mt('Withdrawal'); ?></a></li>
                        <li><a class="dropdown-item" href="profile.php"><?php echo mt('Asset Overview'); ?></a></li>
                    </ul>
                </li>
                <?php endif; ?>                <li class="nav-item"><a class="nav-link" href="#"><?php echo mt('Download App'); ?></a></li>
            </ul>

            <div class="d-flex align-items-center gap-3">
                <a href="<?php echo getLangUrl($lang == 'en' ? 'zh' : 'en'); ?>" class="text-muted text-decoration-none">
                    <i class="bi bi-globe me-1"></i> <?php echo $lang == 'en' ? '中文' : 'EN'; ?>
                </a>
                
                <?php if ($user):
                ?>                    <div class="dropdown">
                        <a class="nav-link dropdown-toggle d-flex align-items-center gap-2" href="#" role="button" data-bs-toggle="dropdown">
                            <i class="bi bi-person-circle fs-5"></i>
                            <span><?php echo htmlspecialchars($user['username']); ?></span>
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end">
                            <li><a class="dropdown-item" href="profile.php"><i class="bi bi-person me-2"></i> <?php echo mt('Profile'); ?></a></li>
                            <li><a class="dropdown-item" href="deposit.php"><i class="bi bi-wallet2 me-2"></i> <?php echo mt('Deposit'); ?></a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item text-danger" href="logout.php"><i class="bi bi-box-arrow-right me-2"></i> <?php echo mt('Logout'); ?></a></li>
                        </ul>
                    </div>
                <?php else:
                ?>                    <a href="login.php" class="nav-link"><?php echo mt('Login'); ?></a>
                    <a href="register.php" class="btn btn-primary"><?php echo mt('Register Now'); ?></a>
                <?php endif; ?>            </div>
        </div>
    </div>
</nav>

<!-- Mobile Bottom Navigation -->
<div class="bottom-nav">
    <a href="index.php" class="nav-item-mobile <?php echo basename($_SERVER['PHP_SELF']) == 'index.php' ? 'active' : ''; ?>">
        <i class="bi bi-house-door"></i>
        <span><?php echo mt('Home'); ?></span>
    </a>
    <a href="market.php" class="nav-item-mobile <?php echo basename($_SERVER['PHP_SELF']) == 'market.php' ? 'active' : ''; ?>">
        <i class="bi bi-bar-chart"></i>
        <span><?php echo mt('Markets'); ?></span>
    </a>
    <a href="trade.php" class="nav-item-mobile <?php echo (strpos($_SERVER['PHP_SELF'], 'trade.php') !== false ? 'active' : ''); ?>">
        <i class="bi bi-arrow-left-right"></i>
        <span><?php echo mt('Trade'); ?></span>
    </a>
    <a href="profile.php" class="nav-item-mobile <?php echo (strpos($_SERVER['PHP_SELF'], 'profile.php') !== false ? 'active' : ''); ?>">
        <i class="bi bi-wallet2"></i>
        <span><?php echo mt('Assets'); ?></span>
    </a>
    <a href="profile.php" class="nav-item-mobile">
        <i class="bi bi-person"></i>
        <span><?php echo mt('Profile'); ?></span>
    </a>
</div>