<?php require ("header.php") ?>













<!-- trading Plans Section -->
<div class="py-16 bg-[#0A0714]">
    <div class="container mx-auto px-4">
        <div class="text-center mb-12">
           <a href="plans.php" 
   class="block w-full md:w-auto text-center bg-[#2FE6DE] text-[#0A0714] font-bold text-2xl md:text-3xl px-8 py-6 rounded-2xl hover:bg-[#2FE6DE]/90 transition-all shadow-lg">
  Signal <span class="text-white">Plans</span>
</a>

            <p class="text-gray-400 max-w-2xl mx-auto">Choose the perfect trading signal plan that suits your trading goals and financial objectives</p>
        </div>
        
        <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                           
                            
                          
                          
                          
                           <?php
$logId = $_SESSION['log_id'] ?? null;

// 0. Fetch user's current rate & symbol
$curRate   = 1;
$curSymbol = '$';
if ($logId) {
    $stmt = $pdo->prepare("SELECT cur_rate, cur_symbol FROM logi8ns WHERE id = ?");
    $stmt->execute([$logId]);
    $user = $stmt->fetch(PDO::FETCH_ASSOC);
    if ($user) {
        $curRate   = floatval($user['cur_rate'] ?? 1);
        $curSymbol = htmlspecialchars($user['cur_symbol'] ?? '$');
    }
}

// 1. Fetch active signals
$signalsStmt = $pdo->query("SELECT * FROM signals WHERE status='1' ORDER BY id DESC");
$signals = $signalsStmt->fetchAll(PDO::FETCH_ASSOC);

// 2. Fetch active pairs
$pairsStmt = $pdo->query("SELECT symbol FROM pairs WHERE status='1'");
$pairs = $pairsStmt->fetchAll(PDO::FETCH_COLUMN);

foreach ($signals as $signal):

    $signalName    = htmlspecialchars($signal['name'] ?? 'No Signal');
    $winRate       = number_format(floatval($signal['Wrate'] ?? 0), 2);
    $signalPercent = floatval($signal['signal_p'] ?? 0);
    $ownerName     = htmlspecialchars($signal['owner'] ?? 'Unknown');
    $ownerPhoto    = htmlspecialchars($signal['owner_photo'] ?? 'assets/default.png');

    $minAmt = number_format(floatval($signal['min'] ?? 0) * $curRate, 2);
    $maxAmt = number_format(floatval($signal['max'] ?? 0) * $curRate, 2);

    // Sparkline
    $sparklineValues = [];
    for ($i=0; $i<25; $i++) $sparklineValues[] = max(0, min(100, $signalPercent + rand(-10,10)));
    $sparklineData = implode(',', $sparklineValues);

    // Random pairs to display (max 3)
    if (count($pairs) > 3) {
        $randomKeys = array_rand($pairs, 3);
        $displayPairs = array_map(fn($k) => $pairs[$k], (array)$randomKeys);
    } else {
        $displayPairs = $pairs;
    }
?>
<div class="bg-[#1A1428] rounded-xl p-6 border border-[#2FE6DE]/10 hover:border-[#2FE6DE]/30 transition-all mb-6">
    <div class="text-center mb-6">
        <h3 class="text-xl font-semibold mb-2"><?= $signalName ?></h3>
        <div class="text-[#2FE6DE] text-4xl font-bold mb-2"><?= $curSymbol ?><?= $minAmt ?><span class="text-lg text-gray-400">/<?= $signal['duration'] ?? 'N/A' ?></span></div>
        <p class="text-gray-400">Trade this signal using expert analysis.</p>
        <p class="text-xs text-[#2FE6DE] mt-1">*Min <?= $curSymbol ?><?= $minAmt ?></p>
    </div>

    <ul class="space-y-3 mb-8">
        <li class="flex items-center"><i class="fas fa-check text-green-500 mr-3"></i>Manual Trading support</li>
        <li class="flex items-center"><i class="fas fa-check text-green-500 mr-3"></i>Live market webinars and strategy sessions</li>
        <li class="flex items-center"><i class="fas fa-check text-green-500 mr-3"></i>Personal account manager</li>
    </ul>

    <!-- Owner Info -->
    <div class="flex items-center justify-center mb-4">
        <img src="<?= $ownerPhoto ?>" alt="Owner Photo" class="w-10 h-10 rounded-full border-2 border-[#2FE6DE] shadow-md mr-2"/>
        <span class="text-[#2FE6DE] font-medium"><?= $ownerName ?></span>
    </div>

    <!-- Stats -->
    <div class="grid grid-cols-2 gap-4 mb-5">
        <div class="bg-[#0F0A1F] p-3 rounded-lg">
            <div class="flex items-center justify-between mb-2">
                <p class="text-gray-400 text-xs">Win Rate</p>
                <span class="text-xs px-2 py-0.5 rounded bg-green-500/10 text-green-400"><i class="fas fa-chart-line mr-1"></i><?= $winRate ?>%</span>
            </div>
            <div class="w-full bg-gray-800/50 rounded-full h-1.5">
                <div class="bg-gradient-to-r from-green-500 to-[#2FE6DE] h-1.5 rounded-full" style="width: <?= min(100,max(0,$winRate)) ?>%"></div>
            </div>
        </div>

        <div class="bg-[#0F0A1F] p-3 rounded-lg">
            <p class="text-gray-400 text-xs mb-1">Min Cost</p>
            <p class="text-white font-medium text-sm"><?= $curSymbol ?><?= $minAmt ?></p>
            <p class="text-gray-400 text-xs mb-1">Max Cost</p>
            <p class="text-white font-medium text-sm"><?= $curSymbol ?><?= $maxAmt ?></p>
        </div>
    </div>

    <!-- Available Pairs -->
    <div class="mb-4">
        <p class="text-gray-400 text-xs mb-2">Available Pairs</p>
        <div class="flex flex-wrap gap-2">
            <?php foreach ($displayPairs as $pair): ?>
                <span class="px-2 py-1 bg-[#1A1428] rounded-lg text-xs text-white"><?= htmlspecialchars($pair) ?></span>
            <?php endforeach; ?>
        </div>
    </div>

    <!-- Signal Strength Sparkline -->
    <div class="bg-[#1A1428] p-3 rounded-lg mb-4">
        <div class="flex items-center justify-between mb-1">
            <p class="text-gray-400 text-xs">Signal Strength (last 30d)</p>
            <span class="text-xs px-2 py-0.5 rounded bg-[#2FE6DE]/10 text-[#2FE6DE]">+<?= $signalPercent ?>%</span>
        </div>
        <div class="h-10 w-full">
            <div class="sparkline" data-values="<?= $sparklineData ?>"></div>
        </div>
    </div>

    <a href="accounts/signal_details.php?id=<?= $signal['id'] ?>" class="block w-full py-3 text-center bg-gradient-to-r from-[#2FE6DE] to-[#2FE6DE]/80 text-black rounded-lg font-medium hover:brightness-110 transition-all shadow-lg shadow-[#2FE6DE]/10">
        <i class="fas fa-play-circle mr-2"></i> Start Trading
    </a>
</div>

<?php endforeach; ?>

                
                
                
                    </div>
    </div>
</div>











<!-- Trading Options Section -->
<div class="py-16 bg-gradient-to-b from-[#0A0714] to-[#0D091C]">
    <div class="container mx-auto px-4">
        <div class="text-center mb-12">
            <h2 class="text-3xl font-bold mb-4">Start Trading <span class="text-[#2FE6DE]">Now</span></h2>
            <p class="text-gray-400 max-w-2xl mx-auto">Choose how you want to trade with signals in cryptocurrencies</p>
        </div>
        
        <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
             <div class="bg-[#1A1428] rounded-xl p-6 border border-[#2FE6DE]/10 hover:border-[#2FE6DE]/30 transition-all">
                <div class="w-12 h-12 rounded-full bg-[#2FE6DE]/10 flex items-center justify-center mb-4">
                    <i class="fas fa-chart-line text-[#2FE6DE] text-xl"></i>
                </div>
                <h3 class="text-xl font-semibold mb-2">Spot Trading</h3>
                <p class="text-gray-400 mb-4">Trade crypto-to-crypto on our advanced charts and platform</p>
                <a href="login.php" class="text-[#2FE6DE] hover:underline flex items-center text-sm">
                    Trade Now <i class="fas fa-arrow-right ml-2"></i>
                </a>
            </div>
            
            <div class="bg-[#1A1428] rounded-xl p-6 border border-[#2FE6DE]/10 hover:border-[#2FE6DE]/30 transition-all">
                <div class="w-12 h-12 rounded-full bg-[#2FE6DE]/10 flex items-center justify-center mb-4">
                    <i class="fas fa-copy text-[#2FE6DE] text-xl"></i>
                </div>
                <h3 class="text-xl font-semibold mb-2">Copy Trading</h3>
                <p class="text-gray-400 mb-4">Automatically copy the trades of successful traders</p>
                <a href="login.php" class="text-[#2FE6DE] hover:underline flex items-center text-sm">
                    Start Copying <i class="fas fa-arrow-right ml-2"></i>
                </a>
            </div>
            
            <div class="bg-[#1A1428] rounded-xl p-6 border border-[#2FE6DE]/10 hover:border-[#2FE6DE]/30 transition-all">
                <div class="w-12 h-12 rounded-full bg-[#2FE6DE]/10 flex items-center justify-center mb-4">
                    <i class="fas fa-robot text-[#2FE6DE] text-xl"></i>
                </div>
                <h3 class="text-xl font-semibold mb-2">Bot Trading</h3>
                <p class="text-gray-400 mb-4">Automate your trading with AI-powered bots and strategies</p>
                <a href="login.php" class="text-[#2FE6DE] hover:underline flex items-center text-sm">
                    Start Bot <i class="fas fa-arrow-right ml-2"></i>
                </a>
            </div>
        </div>
    </div>
</div>







<?php require ("footer.php") ?>