<?php

declare(strict_types=1);

$result = is_array($finalizationResult ?? null)
    ? $finalizationResult
    : [];

$administrator = is_array($result['administrator'] ?? null)
    ? $result['administrator']
    : [];

$migrations = is_array($result['migrations'] ?? null)
    ? $result['migrations']
    : [];
?>
<div class="darlink-success-screen text-center">
    <div class="darlink-success-icon">
        <i class="bi bi-check2-circle"></i>
    </div>

    <span class="darlink-welcome-badge">Installation réussie</span>
    <h2>Darlink ERP est prêt</h2>

    <p class="darlink-welcome-lead">
        L’installation est terminée et l’assistant est verrouillé.
    </p>

    <div class="darlink-execution-summary">
        <div>
            <strong><?= htmlspecialchars((string)($result['version'] ?? ''), ENT_QUOTES, 'UTF-8') ?></strong>
            <span>Version</span>
        </div>
        <div>
            <strong><?= (int)($migrations['successes'] ?? 0) ?></strong>
            <span>Migrations</span>
        </div>
        <div>
            <strong><?= (int)($migrations['statements'] ?? 0) ?></strong>
            <span>Instructions SQL</span>
        </div>
        <div>
            <strong><?= htmlspecialchars((string)($administrator['login'] ?? ''), ENT_QUOTES, 'UTF-8') ?></strong>
            <span>Administrateur</span>
        </div>
    </div>

    <div class="darlink-success-actions">
        <a
            href="<?= htmlspecialchars((string)($result['app_url'] ?? '../public'), ENT_QUOTES, 'UTF-8') ?>"
            class="btn darlink-install-btn-primary"
        >
            <i class="bi bi-box-arrow-in-right me-2"></i>
            Accéder à Darlink ERP
        </a>

        <a
            href="../storage/install/installation-report.html"
            target="_blank"
            class="btn darlink-install-btn-secondary"
        >
            <i class="bi bi-file-earmark-text me-2"></i>
            Ouvrir le rapport
        </a>
    </div>
</div>
