<?php
require_once 'includes/config.php';
require_once 'includes/functions.php';
require_once 'includes/auth.php';
if (isUserLoggedIn()) { header('Location: /dashboard.php'); exit; }
$siteName = getSetting($pdo, 'site_name', SITE_NAME);
$tagline  = getSetting($pdo, 'site_tagline', SITE_TAGLINE);
$tawk     = getSetting($pdo, 'tawk_widget_id', '');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title><?= htmlspecialchars($siteName) ?> – <?= htmlspecialchars($tagline) ?></title>
<meta name="description" content="<?= htmlspecialchars(getSetting($pdo,'seo_description','Flexi Access Bank – secure online banking.')) ?>">
<link rel="icon" href="/assets/img/logo.png">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
<link rel="stylesheet" href="/assets/css/style.css">
</head>
<body style="background:#fff;">

<!-- Top Nav -->
<nav class="navbar navbar-expand-lg navbar-dark portal-nav sticky-top">
  <div class="container">
    <a class="navbar-brand d-flex align-items-center gap-2" href="/">
      <img src="/assets/img/logo.png" alt="<?= htmlspecialchars($siteName) ?>" height="38">
      <span class="fw-bold text-white d-none d-sm-inline"><?= htmlspecialchars($siteName) ?></span>
    </a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav"><span class="navbar-toggler-icon"></span></button>
    <div class="collapse navbar-collapse" id="mainNav">
      <ul class="navbar-nav ms-auto align-items-lg-center gap-lg-1">
        <li class="nav-item"><a class="nav-link" href="#features">Features</a></li>
        <li class="nav-item"><a class="nav-link" href="#services">Services</a></li>
        <li class="nav-item"><a class="nav-link" href="#security">Security</a></li>
        <li class="nav-item"><a class="nav-link" href="#contact">Contact</a></li>
        <li class="nav-item ms-lg-2"><a class="btn btn-outline-light btn-sm" href="/login.php">Login</a></li>
        <li class="nav-item ms-2"><a class="btn btn-danger btn-sm fw-bold" href="/register.php">Open Account</a></li>
      </ul>
    </div>
  </div>
</nav>

<!-- Hero -->
<section class="landing-hero">
  <div class="container">
    <div class="row align-items-center g-5">
      <div class="col-lg-6">
        <span class="hero-badge"><i class="fa fa-shield-alt me-1"></i> Bank-grade Security</span>
        <h1 class="fw-black mb-4"><?= htmlspecialchars($tagline) ?></h1>
        <p class="lead opacity-85 mb-4">Experience next-generation digital banking with Flexi Access Bank. Manage your finances, send money worldwide, and grow your wealth — all in one secure platform.</p>
        <div class="d-flex flex-wrap gap-3">
          <a href="/register.php" class="btn btn-danger btn-lg fw-bold px-5"><i class="fa fa-rocket me-2"></i>Open Free Account</a>
          <a href="/login.php" class="btn btn-outline-light btn-lg px-5">Sign In <i class="fa fa-arrow-right ms-1"></i></a>
        </div>
        <div class="d-flex gap-4 mt-5 flex-wrap">
          <?php foreach ([['50K+','Active Clients'],['100%','Secure Transfers'],['24/7','Customer Support'],['$2B+','Assets Managed']] as [$num,$lbl]): ?>
          <div>
            <div class="fw-black fs-4 text-white"><?= $num ?></div>
            <div class="small opacity-75"><?= $lbl ?></div>
          </div>
          <?php endforeach; ?>
        </div>
      </div>
      <div class="col-lg-6">
        <div class="card p-0" style="border-radius:20px;overflow:hidden;box-shadow:0 30px 80px rgba(0,0,0,.4);">
          <div style="background:linear-gradient(135deg,#c0392b,#922b21);padding:1.5rem 2rem;">
            <div class="d-flex justify-content-between align-items-center">
              <div class="text-white"><div class="small opacity-75">Account Balance</div><h3 class="fw-bold mb-0">$128,450.00</h3></div>
              <img src="/assets/img/logo.png" height="36" alt="logo">
            </div>
          </div>
          <div style="background:#1a1a2e;color:#fff;padding:1.5rem 2rem;">
            <div class="small opacity-60 mb-1 text-uppercase letter-spacing-1">**** **** **** 4721</div>
            <div class="d-flex justify-content-between mt-3">
              <div><div class="small opacity-60">Card Holder</div><div class="fw-bold">JOHN DOE</div></div>
              <div><div class="small opacity-60">Expires</div><div class="fw-bold">12/29</div></div>
              <div class="fs-4 fw-black italic text-danger">VISA</div>
            </div>
          </div>
          <div class="bg-white p-3">
            <div class="row g-2 text-center">
              <?php foreach ([['paper-plane','Send'],['arrow-down','Receive'],['exchange-alt','Transfer'],['chart-line','Invest']] as [$ico,$lbl]): ?>
              <div class="col-3">
                <a href="/login.php" class="text-decoration-none">
                  <div class="rounded-circle mx-auto mb-1" style="width:44px;height:44px;background:var(--primary-light);color:var(--primary);display:flex;align-items:center;justify-content:center;"><i class="fa fa-<?= $ico ?>"></i></div>
                  <div class="small text-muted"><?= $lbl ?></div>
                </a>
              </div>
              <?php endforeach; ?>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- Brands/Trust Bar -->
<section class="py-4" style="background:#f8f9fa;border-bottom:1px solid #eee;">
  <div class="container text-center">
    <p class="text-muted small mb-3">Trusted and certified by</p>
    <div class="d-flex justify-content-center align-items-center gap-4 flex-wrap opacity-50">
      <?php foreach (['Visa','Mastercard','SWIFT','ISO 27001','PCI DSS'] as $brand): ?>
      <span class="fw-bold fs-6"><?= $brand ?></span>
      <?php endforeach; ?>
    </div>
  </div>
</section>

<!-- Features -->
<section class="py-6 py-5" id="features">
  <div class="container">
    <div class="text-center mb-5">
      <span class="badge bg-danger mb-2">Features</span>
      <h2 class="section-title">Everything you need to bank better</h2>
      <p class="section-subtitle">Powerful tools designed for modern banking needs</p>
    </div>
    <div class="row g-4">
      <?php $features = [
        ['paper-plane','Instant Transfers','Send money locally or internationally with real-time processing and competitive rates.'],
        ['shield-alt','Bank-Grade Security','Multi-layer security with OTP, IMF, COT, ATC, and TXC verification protocols.'],
        ['credit-card','Virtual & Physical Cards','Request Visa, Mastercard, or Verve cards. Freeze, unfreeze, and manage limits instantly.'],
        ['chart-line','Investment Plans','Grow your wealth with plans from 5% to 18% APR. Choose from Starter to VIP tier.'],
        ['hand-holding-usd','Flexible Loans','Personal, business, mortgage, auto, and student loans with competitive rates.'],
        ['id-card','KYC Verification','Seamless identity verification to unlock full account features and higher limits.'],
        ['bell','Real-Time Notifications','Stay informed with instant alerts on every transaction and account activity.'],
        ['headset','24/7 Customer Support','Our dedicated support team is always ready to assist via tickets.'],
      ]; foreach ($features as [$icon,$title,$desc]): ?>
      <div class="col-6 col-md-3">
        <div class="card h-100 p-3 text-center border-0" style="background:#f8f9fa;transition:all .2s;" onmouseenter="this.style.boxShadow='0 8px 30px rgba(192,57,43,.15)';this.style.transform='translateY(-4px)'" onmouseleave="this.style.boxShadow='';this.style.transform=''">
          <div class="feature-icon-box mx-auto"><i class="fa fa-<?= $icon ?>"></i></div>
          <h6 class="fw-bold mb-1"><?= $title ?></h6>
          <p class="text-muted small mb-0"><?= $desc ?></p>
        </div>
      </div>
      <?php endforeach; ?>
    </div>
  </div>
</section>

<!-- Services -->
<section class="py-5" id="services" style="background:linear-gradient(135deg,var(--secondary),#16213e);color:#fff;">
  <div class="container">
    <div class="text-center mb-5">
      <span class="badge bg-danger mb-2">Services</span>
      <h2 class="section-title text-white">World-Class Banking Services</h2>
    </div>
    <div class="row g-4">
      <?php $services = [
        ['🌍','International Transfers','Send money to 180+ countries via SWIFT with real-time tracking.','primary'],
        ['💎','Premium Investment','Earn up to 18% APR with our VIP investment portfolio.','dark'],
        ['🏦','Business Banking','Dedicated business accounts with enhanced transfer limits.','primary'],
        ['🔐','Crypto Deposits','Deposit crypto and have it credited to your account balance.','dark'],
      ]; foreach ($services as [$emoji,$title,$desc,$cls]): ?>
      <div class="col-md-6 col-lg-3">
        <div class="card h-100 text-center p-4" style="background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.1);color:#fff;">
          <div style="font-size:2.5rem;margin-bottom:1rem;"><?= $emoji ?></div>
          <h5 class="fw-bold"><?= $title ?></h5>
          <p class="small opacity-75 mb-0"><?= $desc ?></p>
        </div>
      </div>
      <?php endforeach; ?>
    </div>
  </div>
</section>

<!-- Security -->
<section class="py-5" id="security">
  <div class="container">
    <div class="row align-items-center g-5">
      <div class="col-lg-6">
        <span class="badge bg-danger mb-2">Security</span>
        <h2 class="section-title">5-Layer Security for every transfer</h2>
        <p class="text-muted">Your funds are protected by our comprehensive multi-factor authentication system:</p>
        <?php $gates = [
          ['1','fa fa-envelope','OTP Verification','One-time password sent to your registered email for every transfer.'],
          ['2','fa fa-bank','IMF Code','International Monetary Fund clearance code for large transfers.'],
          ['3','fa fa-briefcase','COT Code','Cost of Transfer code ensuring compliance with banking regulations.'],
          ['4','fa fa-shield-alt','ATC Code','Anti-Terrorist Clearance code required for international wires.'],
          ['5','fa fa-file-alt','Tax Clearance','Tax Clearance Certificate code for regulatory compliance.'],
        ]; foreach ($gates as [$num,$icon,$title,$desc]): ?>
        <div class="d-flex gap-3 mb-3">
          <div class="flex-shrink-0" style="width:40px;height:40px;background:var(--primary);color:#fff;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:700;"><?= $num ?></div>
          <div><div class="fw-bold"><?= $title ?></div><div class="text-muted small"><?= $desc ?></div></div>
        </div>
        <?php endforeach; ?>
      </div>
      <div class="col-lg-6">
        <div class="bg-light rounded-4 p-4 text-center" style="border:2px dashed var(--primary);">
          <div style="font-size:5rem;margin-bottom:1rem;">🔒</div>
          <h4 class="fw-bold text-danger">Bank-Grade Encryption</h4>
          <p class="text-muted">All data is encrypted using 256-bit SSL/TLS encryption. Your personal and financial information is always protected.</p>
          <div class="row g-2 mt-3">
            <?php foreach (['HTTPS/SSL','256-bit Encryption','2FA Ready','GDPR Compliant','PCI DSS'] as $badge]: ?>
            <div class="col-auto mx-auto"><span class="badge bg-success p-2"><?= $badge ?></span></div>
            <?php endforeach; ?>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- CTA -->
<section class="py-5" style="background:linear-gradient(135deg,var(--primary),#e74c3c);color:#fff;text-align:center;">
  <div class="container">
    <h2 class="fw-black mb-3">Ready to experience better banking?</h2>
    <p class="lead opacity-90 mb-4">Join thousands of customers who trust Flexi Access Bank with their finances.</p>
    <a href="/register.php" class="btn btn-light btn-lg fw-bold px-5 text-danger">Open Free Account Today <i class="fa fa-arrow-right ms-2"></i></a>
  </div>
</section>

<!-- Footer -->
<footer class="py-5" style="background:var(--secondary);color:rgba(255,255,255,.7);" id="contact">
  <div class="container">
    <div class="row g-4">
      <div class="col-md-4">
        <img src="/assets/img/logo.png" height="45" alt="<?= htmlspecialchars($siteName) ?>" class="mb-3">
        <p class="small"><?= htmlspecialchars($tagline) ?>. Secure, fast, and reliable digital banking for everyone.</p>
        <div class="d-flex gap-3 mt-3">
          <?php foreach (['facebook-f','twitter','instagram','linkedin-in'] as $sn): ?>
          <a href="#" class="text-white opacity-75 hover-opacity-100"><i class="fab fa-<?= $sn ?> fa-lg"></i></a>
          <?php endforeach; ?>
        </div>
      </div>
      <div class="col-md-2">
        <h6 class="text-white fw-bold mb-3">Products</h6>
        <?php foreach (['Personal Banking','Business Banking','Investments','Loans','Cards'] as $p): ?>
        <div><a href="/login.php" class="text-decoration-none" style="color:rgba(255,255,255,.7);font-size:.88rem;"><?= $p ?></a></div>
        <?php endforeach; ?>
      </div>
      <div class="col-md-2">
        <h6 class="text-white fw-bold mb-3">Company</h6>
        <?php foreach (['About Us','Careers','Blog','Press','Partners'] as $p): ?>
        <div><a href="#" class="text-decoration-none" style="color:rgba(255,255,255,.7);font-size:.88rem;"><?= $p ?></a></div>
        <?php endforeach; ?>
      </div>
      <div class="col-md-4">
        <h6 class="text-white fw-bold mb-3">Contact</h6>
        <div class="small mb-2"><i class="fa fa-envelope me-2"></i><?= SITE_EMAIL ?></div>
        <div class="small mb-2"><i class="fa fa-phone me-2"></i>+1 (800) FLEXI-BANK</div>
        <div class="small mb-4"><i class="fa fa-clock me-2"></i>24/7 Support via online portal</div>
        <a href="/register.php" class="btn btn-danger btn-sm fw-bold w-100">Open Account</a>
      </div>
    </div>
    <hr style="border-color:rgba(255,255,255,.1);margin-top:2rem;">
    <div class="d-flex flex-wrap justify-content-between align-items-center small">
      <span>&copy; <?= date('Y') ?> <?= htmlspecialchars($siteName) ?>. All rights reserved.</span>
      <div class="d-flex gap-3 mt-2 mt-md-0">
        <a href="#" style="color:rgba(255,255,255,.6)" class="text-decoration-none" id="privacy">Privacy Policy</a>
        <a href="#" style="color:rgba(255,255,255,.6)" class="text-decoration-none" id="terms">Terms of Service</a>
        <a href="/login.php" style="color:rgba(255,255,255,.6)" class="text-decoration-none">Login</a>
      </div>
    </div>
  </div>
</footer>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<?php if ($tawk): echo $tawk; endif; ?>
</body></html>
