<?php
/**
 * Installation complete.
 *
 * Rendered inline (not redirected to) because install.php sends any later visit
 * straight to the app once config/database.php exists — so this is the one and
 * only moment we can tell the person what just happened and what to do next.
 *
 * Vars: $baseUrl, $assetsUrl, $installerAssetVersion, $adminUser, $isLicensed
 */
// $appUrl is passed by the Controller (correct for the deployment's doc-root). Only
// fall back to the "{base}/public/" default when it wasn't provided.
$appUrl  = (isset($appUrl) && $appUrl !== '') ? $appUrl : ($baseUrl . '/public/');
$helpUrl = rtrim($appUrl, '/') . '/help';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="color-scheme" content="light">
    <meta name="theme-color" content="#111a3b">
    <title>PPPHP is ready</title>
    <link href="<?= $assetsUrl ?>/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="<?= $assetsUrl ?>/icons/bootstrap-icons.css" rel="stylesheet">
    <link href="<?= $assetsUrl ?>/installer/installer.css?v=<?= urlencode($installerAssetVersion) ?>" rel="stylesheet">
    <style>
        body { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px;
            background: radial-gradient(1200px 600px at 20% -10%, #1e2a63 0%, #111a3b 45%, #0b1029 100%);
            font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #0f172a; }
        .done { width: min(680px, 100%); background: #fff; border-radius: 20px; padding: 34px 34px 28px;
            box-shadow: 0 30px 90px rgba(0,0,0,.45); animation: rise .35s ease-out both; }
        @keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
        .tick { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; font-size: 30px;
            background: linear-gradient(135deg, #10b981, #059669); color: #fff; margin-bottom: 16px;
            box-shadow: 0 10px 26px rgba(16,185,129,.35); }
        .done h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
        .done .lede { color: #64748b; font-size: .95rem; margin: 0 0 22px; }
        .who { display: inline-flex; align-items: center; gap: .45rem; background: #f1f5f9; border: 1px solid #e2e8f0;
            border-radius: 999px; padding: 5px 12px; font-size: .82rem; color: #334155; margin-bottom: 20px; }
        .steps { display: grid; gap: 10px; margin-bottom: 24px; }
        .st { display: flex; gap: 13px; align-items: flex-start; border: 1px solid #e6e9f0; border-radius: 13px; padding: 13px 15px; }
        .st .n { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
            background: #eef2ff; color: #4338ca; font-size: .78rem; font-weight: 800; }
        .st strong { display: block; font-size: .92rem; }
        .st span { font-size: .82rem; color: #64748b; line-height: 1.5; }
        .cta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
        .btn-go { flex: 1 1 auto; text-align: center; text-decoration: none; background: linear-gradient(135deg, #4f46e5, #4338ca);
            color: #fff; font-weight: 700; padding: 13px 20px; border-radius: 12px; box-shadow: 0 10px 24px rgba(79,70,229,.3); }
        .btn-go:hover { filter: brightness(1.07); color: #fff; }
        .btn-alt { text-decoration: none; color: #475569; font-weight: 600; font-size: .88rem; padding: 13px 16px;
            border: 1px solid #e2e8f0; border-radius: 12px; }
        .btn-alt:hover { background: #f8fafc; color: #0f172a; }
        .tipbar { margin-top: 20px; padding-top: 16px; border-top: 1px solid #eef1f6; font-size: .8rem; color: #64748b;
            display: flex; gap: .5rem; align-items: flex-start; }
        .tipbar i { color: #4f46e5; margin-top: 1px; }
        @media (max-width: 520px) { .done { padding: 26px 20px 22px; } .btn-alt, .btn-go { width: 100%; } }
    </style>
</head>
<body>
<main class="done">
    <div class="tick"><i class="bi bi-check-lg"></i></div>
    <h1>PPPHP is installed</h1>
    <p class="lede">Your database is connected and your administrator account is ready. Setup is complete.</p>

    <?php if ($adminUser !== ''): ?>
        <div class="who"><i class="bi bi-person-check"></i> Sign in as <strong><?= htmlspecialchars($adminUser, ENT_QUOTES, 'UTF-8') ?></strong></div>
    <?php endif; ?>

    <div class="steps">
        <div class="st">
            <span class="n">1</span>
            <div><strong>Sign in</strong>
                <span>Use the administrator account you just created. Keep those details safe — it owns everything.</span></div>
        </div>
        <?php if ($isLicensed): ?>
        <div class="st">
            <span class="n">2</span>
            <div><strong>Activate your licence</strong>
                <span>Paste the activation code from your licence email on the <em>Licence</em> page. Until then this
                      copy runs on a short trial window.</span></div>
        </div>
        <div class="st">
            <span class="n">3</span>
            <div><strong>Build your first app</strong>
                <span>Create a project, point it at a database, and design your pages. Nothing else to configure.</span></div>
        </div>
        <?php else: ?>
        <div class="st">
            <span class="n">2</span>
            <div><strong>Build your first app</strong>
                <span>Create a project, point it at a database, and design your pages. Nothing else to configure.</span></div>
        </div>
        <?php endif; ?>
    </div>

    <div class="cta">
        <a class="btn-go" href="<?= htmlspecialchars($appUrl, ENT_QUOTES, 'UTF-8') ?>">Sign in to PPPHP <i class="bi bi-arrow-right ms-1"></i></a>
        <a class="btn-alt" href="<?= htmlspecialchars($helpUrl, ENT_QUOTES, 'UTF-8') ?>"><i class="bi bi-life-preserver"></i> Help &amp; guides</a>
    </div>

    <div class="tipbar">
        <i class="bi bi-shield-lock-fill"></i>
        <div><strong>One last thing:</strong> delete <code>install.php</code> from your server. It refuses to run twice,
            but removing it leaves nothing to probe.</div>
    </div>
</main>
</body>
</html>
