<!DOCTYPE html>
<html>
<head>
    <title>Google OAuth Callback</title>
    <style>
        body { font-family: Arial, sans-serif; max-width: 800px; margin: 40px auto; padding: 20px; }
        .code { background: #f5f5f5; padding: 15px; border-radius: 5px; font-family: monospace; word-break: break-all; }
        .success { color: green; font-weight: bold; }
        .error { color: red; }
    </style>
</head>
<body>
    <h1>Google OAuth Callback</h1>

    <?php
    if (isset($_GET['code'])) {
        $code = htmlspecialchars($_GET['code']);

        echo '<p class="success">✅ Google authorization successful!</p>';
        echo '<p>Paste this code back into the terminal:</p>';
        echo '<h3>Authorization Code:</h3>';
        echo '<div class="code">' . $code . '</div>';

    } elseif (isset($_GET['error'])) {
        $error = htmlspecialchars($_GET['error']);
        $desc  = isset($_GET['error_description']) ? htmlspecialchars($_GET['error_description']) : '';
        echo '<p class="error">❌ OAuth Error: ' . $error . '</p>';
        if ($desc) echo '<p>' . $desc . '</p>';
    } else {
        echo '<p class="error">❌ No code received.</p>';
    }
    ?>
</body>
</html>
