<?php
// #33 Tela de verificação 2FA (chamada após login com senha correta)
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Verificação 2FA — MonitorPing</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
    <style>
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
        body { font-family: 'Inter', sans-serif; background: #0f172a; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
        .card { background: #1e293b; border-radius: 20px; padding: 40px 36px; width: 100%; max-width: 400px; border: 1px solid rgba(255,255,255,0.08); }
        h1 { color: #f1f5f9; font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
        p { color: #94a3b8; font-size: 0.9rem; margin-bottom: 28px; }
        label { display: block; font-size: 0.85rem; font-weight: 600; color: #94a3b8; margin-bottom: 8px; }
        input[type=text] { width: 100%; padding: 14px; background: #0f172a; border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; color: #f1f5f9; font-size: 1.6rem; text-align: center; letter-spacing: 10px; font-weight: 700; font-family: monospace; outline: none; margin-bottom: 20px; }
        input[type=text]:focus { border-color: #3b82f6; }
        button { width: 100%; padding: 13px; background: #3b82f6; color: #fff; border: none; border-radius: 10px; font-weight: 700; font-size: 1rem; cursor: pointer; }
        button:hover { background: #2563eb; }
        .error { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); padding: 12px 16px; border-radius: 10px; font-size: 0.9rem; font-weight: 600; margin-bottom: 20px; }
        .back { display: block; text-align: center; margin-top: 20px; color: #64748b; font-size: 0.85rem; text-decoration: none; }
        .back:hover { color: #94a3b8; }
        .icon { font-size: 2.5rem; margin-bottom: 16px; display: block; }
    </style>
</head>
<body>
    <div class="card">
        <span class="icon">🔐</span>
        <h1>Verificação 2FA</h1>
        <p>Digite o código de 6 dígitos do seu app autenticador.</p>

        <?php if (!empty($error)): ?>
            <div class="error"><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></div>
        <?php endif; ?>

        <form method="post" action="index.php?page=verify_2fa">
            <input type="hidden" name="csrf_token" value="<?= htmlspecialchars(csrf_token(), ENT_QUOTES, 'UTF-8') ?>">
            <label>Código de verificação</label>
            <input type="text" name="code" inputmode="numeric" pattern="\d{6}" maxlength="6"
                   autocomplete="one-time-code" required autofocus placeholder="000000">
            <button type="submit">Verificar</button>
        </form>

        <a href="index.php?page=login" class="back">Voltar ao login</a>
    </div>
</body>
</html>
