@extends('install.layout')

@section('title', 'Prérequis')

@section('content')
<div>
    <h2 class="text-2xl font-bold text-slate-800 mb-4">Vérification des prérequis</h2>
    <div class="space-y-4 mb-8">
        <div class="flex items-center justify-between p-3 rounded-lg {{ $requirements['php']['met'] ? 'bg-green-50' : 'bg-red-50' }}">
            <span>PHP {{ $requirements['php']['version'] }} ou supérieur</span>
            <span class="{{ $requirements['php']['met'] ? 'text-green-600' : 'text-red-600' }} font-medium">{{ $requirements['php']['met'] ? 'OK' : 'ÉCHEC' }}</span>
        </div>
        @foreach($requirements['extensions'] as $ext => $met)
            <div class="flex items-center justify-between p-3 rounded-lg {{ $met ? 'bg-green-50' : 'bg-red-50' }}">
                <span>Extension {{ $ext }}</span>
                <span class="{{ $met ? 'text-green-600' : 'text-red-600' }} font-medium">{{ $met ? 'OK' : 'Manquante' }}</span>
            </div>
        @endforeach
        @foreach($requirements['writable'] as $dir => $met)
            <div class="flex items-center justify-between p-3 rounded-lg {{ $met ? 'bg-green-50' : 'bg-red-50' }}">
                <span>{{ $dir }} (écriture)</span>
                <span class="{{ $met ? 'text-green-600' : 'text-red-600' }} font-medium">{{ $met ? 'OK' : 'Non accessible' }}</span>
            </div>
        @endforeach
    </div>
    @if(collect($requirements['extensions'])->merge($requirements['writable'])->merge(['php' => $requirements['php']['met']])->every(fn($v) => $v))
        <a href="{{ route('install.database') }}" class="gdev-btn">
            Continuer
        </a>
    @else
        <p class="text-red-600 mb-4">Corrigez les erreurs ci-dessus sur le serveur, puis rechargez cette page.</p>
        <a href="{{ route('install.requirements') }}" class="gdev-btn">
            Vérifier à nouveau
        </a>
    @endif
</div>
@endsection
