<?php
$pageTitle = $pageTitle ?? 'Install PPPHP';
$stepDescription = $currentStep === 1
    ? 'Connect the central database used for accounts, projects, and application settings.'
    : 'Create the first superadministrator and finish preparing your studio.';
?>
<!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><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></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">
    <link href="<?= $assetsUrl ?>/installer/installer-polish.css?v=<?= urlencode($installerAssetVersion) ?>" rel="stylesheet">
</head>
<body data-installer-step="<?= $currentStep ?>">
<a class="installer-skip" href="#installerForm">Skip to setup form</a>
<main class="installer-shell">
    <aside class="installer-story" aria-labelledby="installerStoryTitle">
        <div class="installer-orb orb-one"></div><div class="installer-orb orb-two"></div>
        <header class="installer-brand"><?php $brandLockupHeight = 32; include __DIR__ . '/../../core/views/brand-lockup.php'; ?><small>Setup studio</small></header>
        <div class="installer-story-copy">
            <span class="installer-eyebrow"><i class="bi bi-stars"></i> Two-minute setup</span>
            <h1 id="installerStoryTitle">Your rapid application studio starts here.</h1>
            <p>Connect one database, secure the first administrator, and begin shaping production-minded PHP applications.</p>
            <div class="installer-outcomes">
                <article><i class="bi bi-database-check"></i><div><strong>Central project catalog</strong><span>Securely stores accounts, projects, templates, and settings.</span></div></article>
                <article><i class="bi bi-shield-lock"></i><div><strong>Administrator control</strong><span>Your first account owns security and workspace configuration.</span></div></article>
                <article><i class="bi bi-rocket-takeoff"></i><div><strong>Ready to build</strong><span>Land directly on the polished login experience when setup completes.</span></div></article>
            </div>
        </div>
        <footer><span><i class="bi bi-hdd-network"></i> Self-hosted</span><span><i class="bi bi-code-slash"></i> Developer-first</span><span><i class="bi bi-phone"></i> Responsive</span></footer>
    </aside>

    <section class="installer-workspace" aria-labelledby="installerPageTitle">
        <div class="installer-panel">
            <header class="installer-panel-head">
                <div class="mobile-installer-brand"><?php $brandLockupHeight = 28; include __DIR__ . '/../../core/views/brand-lockup.php'; ?></div>
                <div class="installer-progress" aria-label="Installation progress">
                    <div class="progress-step <?= $currentStep >= 1 ? 'is-active' : '' ?> <?= $currentStep > 1 ? 'is-complete' : '' ?>">
                        <span><?= $currentStep > 1 ? '<i class="bi bi-check-lg"></i>' : '1' ?></span><div><strong>Database</strong><small>Connect storage</small></div>
                    </div>
                    <div class="progress-line <?= $currentStep > 1 ? 'is-complete' : '' ?>"></div>
                    <div class="progress-step <?= $currentStep >= 2 ? 'is-active' : '' ?>">
                        <span>2</span><div><strong>Administrator</strong><small>Secure access</small></div>
                    </div>
                </div>
                <div class="step-counter">Step <?= $currentStep ?> of 2</div>
            </header>

            <div class="installer-title-row">
                <span class="installer-title-icon"><i class="bi <?= $currentStep === 1 ? 'bi-database-gear' : 'bi-person-lock' ?>"></i></span>
                <div><span class="section-kicker"><?= $currentStep === 1 ? 'Connection profile' : 'Owner account' ?></span><h2 id="installerPageTitle"><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></h2><p><?= htmlspecialchars($stepDescription, ENT_QUOTES, 'UTF-8') ?></p></div>
            </div>

            <?php if (!empty($error)): ?>
                <div class="installer-alert" role="alert"><i class="bi bi-exclamation-triangle"></i><div><strong>Setup needs attention</strong><span><?= htmlspecialchars((string)$error, ENT_QUOTES, 'UTF-8') ?></span></div></div>
            <?php endif; ?>
