<?php
require_once __DIR__ . '/app_shell.php';
require_user(); app_head('Investments'); app_open('investments', 'Investments');
$plans = [
 ['key'=>'digital-assets','icon'=>'bi-bar-chart-line','name'=>'Digital assets','minimum'=>500,'months'=>4,'rate'=>1,'risk'=>'Higher','copy'=>'Selected digital-asset strategies. Values can move quickly.'],
 ['key'=>'precious-metals','icon'=>'bi-gem','name'=>'Precious metals','minimum'=>1000,'months'=>6,'rate'=>1,'risk'=>'Moderate','copy'=>'Asset-backed exposure for a longer planning horizon.'],
 ['key'=>'real-assets','icon'=>'bi-buildings','name'=>'Real assets','minimum'=>2500,'months'=>8,'rate'=>0.75,'risk'=>'Moderate-higher','copy'=>'Opportunities tied to operating assets and plan conditions.'],
];
?>
<div class="page-heading"><div><h2>Investment opportunities</h2><p>Select a plan, review its conditions, then allocate from your available balance.</p></div><div class="balance-pill">Available to invest <b id="availableToInvest">—</b></div></div>
<div id="investmentFeedback" aria-live="polite"></div><section class="plans">
<?php foreach ($plans as $plan): ?><article class="plan" data-plan-card="<?= $plan['key'] ?>"><i class="bi <?= $plan['icon'] ?> icon"></i><h3><?= $plan['name'] ?></h3><p><?= $plan['copy'] ?></p><div class="terms"><span><small>Minimum</small><b>£<?= number_format($plan['minimum']) ?></b></span><span><small>Term</small><b><?= $plan['months'] ?> months</b></span><span><small>Plan rate</small><b><?= $plan['rate'] ?>% monthly</b></span><span><small>Risk</small><b><?= $plan['risk'] ?></b></span></div><button class="btn-v plan-select" type="button" data-plan="<?= $plan['key'] ?>" data-name="<?= $plan['name'] ?>" data-min="<?= $plan['minimum'] ?>" data-months="<?= $plan['months'] ?>" data-rate="<?= $plan['rate'] ?>">Choose <?= $plan['name'] ?></button></article><?php endforeach; ?>
</section>
<section class="investment-workspace" id="investmentWorkspace" hidden><div class="panel"><div class="panel-title"><h3>Confirm your allocation</h3><button class="plain-button" type="button" id="closeInvestment">Close</button></div><form id="investmentForm" novalidate><input type="hidden" id="selectedPlan" name="plan"><div class="form-grid"><div class="field"><label>Selected plan</label><input id="selectedPlanName" readonly></div><div class="field"><label>Investment amount (GBP)</label><input id="investmentAmount" name="amount" type="number" min="0" step="0.01" inputmode="decimal" required placeholder="0.00"><small id="amountHelp"></small></div></div><div class="investment-summary"><div><span>Term</span><b id="summaryTerm">—</b></div><div><span>Return payment rate</span><b id="summaryRate">—</b></div><div><span>Projected maturity date</span><b id="summaryDate">—</b></div><div><span>Projected total paid back</span><b id="summaryAmount">—</b></div></div><label class="acknowledgement"><input type="checkbox" id="termsAcknowledgement" required> I have reviewed the plan conditions and understand investing involves risk; projected values are subject to the plan terms.</label><button class="btn-v" id="submitInvestment" type="submit">Confirm investment</button></form></div></section>
<section class="panel" style="margin-top:18px"><div class="panel-title"><h3>Your investments</h3><span>Current and completed allocations</span></div><div id="investmentList" class="investment-list"><div class="empty-state">Loading investment records…</div></div></section>
<script>window.APP_BASE=<?= json_encode(APP_BASE) ?></script><script src="<?= APP_BASE ?>/investment.js"></script><?php app_close(); ?>