@extends('installer.layout')

@section('title', 'Installer: Welcome & System Check')

@section('content')
<div class="min-h-screen flex flex-col items-center justify-center p-4 sm:p-8">
    <!-- Main Card Container -->
    <div class="w-full max-w-[800px] bg-white dark:bg-[#1e293b] rounded-xl shadow-xl overflow-hidden flex flex-col border border-gray-200 dark:border-gray-700 transition-colors duration-300">
        <!-- Header Section -->
        <div class="p-8 sm:px-12 pt-10 pb-6 text-center">
            <!-- Product Logo -->
            <div class="flex justify-center mb-6">
                <img src="{{ asset('Proinvest.png') }}" alt="ProInvoice Logo" class="h-20 w-auto object-contain">
            </div>
            <h1 class="text-[#111418] dark:text-white text-3xl font-bold leading-tight mb-3">Welcome to ProInvoice Installer</h1>
            <p class="text-[#617589] dark:text-gray-400 text-base font-normal max-w-lg mx-auto leading-relaxed">Let's get your accounting platform up and running. We just need to check if your server meets the requirements.</p>
        </div>
        
        <!-- Progress Bar Section -->
        <div class="px-8 sm:px-12 py-4 bg-white dark:bg-[#1e293b]">
            <div class="flex justify-between items-end mb-2">
                <div class="flex flex-col">
                    <span class="text-xs font-semibold text-primary uppercase tracking-wider mb-1">Step {{ $step }} of {{ $totalSteps }}</span>
                    <span class="text-[#111418] dark:text-white font-medium">System Check</span>
                </div>
                <span class="text-[#617589] dark:text-gray-400 text-sm font-medium">{{ round(($step / $totalSteps) * 100) }}%</span>
            </div>
            <div class="h-2 w-full bg-[#dbe0e6] dark:bg-gray-700 rounded-full overflow-hidden">
                <div class="h-full bg-primary rounded-full shadow-[0_0_10px_rgba(19,127,236,0.5)]" style="width: {{ ($step / $totalSteps) * 100 }}%"></div>
            </div>
        </div>
        
        <!-- Scrollable Content Area: Checklists -->
        <div class="p-8 sm:px-12 space-y-8 max-h-[500px] overflow-y-auto">
            <!-- Section 1: PHP Version & Settings -->
            <div>
                <h3 class="text-[#111418] dark:text-gray-200 text-lg font-bold leading-tight tracking-[-0.015em] mb-4 flex items-center gap-2">
                    <span class="material-symbols-outlined text-gray-400">settings</span>
                    PHP Version & Settings
                </h3>
                <div class="space-y-3">
                    <!-- PHP Version -->
                    <div class="flex items-center justify-between p-4 rounded-lg bg-background-light dark:bg-gray-800/50 border border-gray-100 dark:border-gray-700">
                        <div class="flex items-center gap-3">
                            <span class="material-symbols-outlined text-{{ $requirements['php_version']['passed'] ? 'emerald' : 'red' }}-500 text-[22px] filled">check_circle</span>
                            <div class="flex flex-col">
                                <span class="text-[#111418] dark:text-gray-200 font-medium">PHP Version {{ $requirements['php_version']['required'] }}</span>
                                <span class="text-xs text-gray-500 dark:text-gray-400">Required for core system</span>
                            </div>
                        </div>
                        <span class="text-xs text-{{ $requirements['php_version']['passed'] ? 'emerald' : 'red' }}-700 dark:text-{{ $requirements['php_version']['passed'] ? 'emerald' : 'red' }}-400 font-bold bg-{{ $requirements['php_version']['passed'] ? 'emerald' : 'red' }}-100 dark:bg-{{ $requirements['php_version']['passed'] ? 'emerald' : 'red' }}-900/30 px-3 py-1.5 rounded-full border border-{{ $requirements['php_version']['passed'] ? 'emerald' : 'red' }}-200 dark:border-{{ $requirements['php_version']['passed'] ? 'emerald' : 'red' }}-800">
                            {{ $requirements['php_version']['passed'] ? 'Passed (' . $requirements['php_version']['current'] . ')' : 'Failed' }}
                        </span>
                    </div>
                    <!-- Timezone -->
                    <div class="flex items-center justify-between p-4 rounded-lg bg-background-light dark:bg-gray-800/50 border border-gray-100 dark:border-gray-700">
                        <div class="flex items-center gap-3">
                            <span class="material-symbols-outlined text-{{ $requirements['timezone']['passed'] ? 'emerald' : 'red' }}-500 text-[22px] filled">check_circle</span>
                            <span class="text-[#111418] dark:text-gray-200 font-medium">Timezone Settings</span>
                        </div>
                        <span class="text-xs text-{{ $requirements['timezone']['passed'] ? 'emerald' : 'red' }}-700 dark:text-{{ $requirements['timezone']['passed'] ? 'emerald' : 'red' }}-400 font-bold bg-{{ $requirements['timezone']['passed'] ? 'emerald' : 'red' }}-100 dark:bg-{{ $requirements['timezone']['passed'] ? 'emerald' : 'red' }}-900/30 px-3 py-1.5 rounded-full border border-{{ $requirements['timezone']['passed'] ? 'emerald' : 'red' }}-200 dark:border-{{ $requirements['timezone']['passed'] ? 'emerald' : 'red' }}-800">
                            {{ $requirements['timezone']['passed'] ? 'Valid' : 'Invalid' }}
                        </span>
                    </div>
                </div>
            </div>
            
            <!-- Section 2: Extensions Grid -->
            <div>
                <h3 class="text-[#111418] dark:text-gray-200 text-lg font-bold leading-tight tracking-[-0.015em] mb-4 flex items-center gap-2">
                    <span class="material-symbols-outlined text-gray-400">extension</span>
                    Required Extensions
                </h3>
                <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
                    @foreach($requirements['php_extensions'] as $extension => $status)
                    <div class="flex items-center gap-3 p-3.5 rounded-lg bg-background-light dark:bg-gray-800/50 border border-gray-100 dark:border-gray-700">
                        <span class="material-symbols-outlined text-{{ $status['passed'] ? 'emerald' : 'red' }}-500 text-[20px] filled">check_circle</span>
                        <span class="text-[#111418] dark:text-gray-200 font-medium text-sm">{{ ucfirst($extension) }}</span>
                    </div>
                    @endforeach
                </div>
            </div>
            
            <!-- Section 3: Folder Permissions -->
            <div>
                <h3 class="text-[#111418] dark:text-gray-200 text-lg font-bold leading-tight tracking-[-0.015em] mb-4 flex items-center gap-2">
                    <span class="material-symbols-outlined text-gray-400">folder_open</span>
                    Folder Permissions
                </h3>
                <div class="space-y-3">
                    @foreach($requirements['writable_directories'] as $directory => $status)
                    <div class="flex items-center justify-between p-4 rounded-lg bg-background-light dark:bg-gray-800/50 border border-gray-100 dark:border-gray-700 group hover:border-emerald-200 dark:hover:border-emerald-900 transition-colors">
                        <div class="flex items-center gap-3 flex-1">
                            <span class="material-symbols-outlined text-{{ $status['passed'] ? 'emerald' : 'red' }}-500 text-[22px] filled">check_circle</span>
                            <div class="flex flex-col">
                                <span class="text-[#111418] dark:text-gray-200 font-medium font-mono text-sm">/{{ $directory }}</span>
                                <span class="text-xs text-gray-500 dark:text-gray-400 mt-0.5">
                                    Expected: <span class="font-mono font-semibold text-gray-700 dark:text-gray-300">{{ $status['expected_permissions'] ?? '775' }}</span>
                                    @if($status['current_permissions'])
                                        | Current: <span class="font-mono {{ $status['current_permissions'] === $status['expected_permissions'] ? 'text-emerald-600 dark:text-emerald-400' : 'text-amber-600 dark:text-amber-400' }}">{{ $status['current_permissions'] }}</span>
                                    @endif
                                </span>
                            </div>
                        </div>
                        <span class="text-xs text-{{ $status['passed'] ? 'emerald' : 'red' }}-700 dark:text-{{ $status['passed'] ? 'emerald' : 'red' }}-400 font-bold bg-{{ $status['passed'] ? 'emerald' : 'red' }}-100 dark:bg-{{ $status['passed'] ? 'emerald' : 'red' }}-900/30 px-3 py-1.5 rounded-full border border-{{ $status['passed'] ? 'emerald' : 'red' }}-200 dark:border-{{ $status['passed'] ? 'emerald' : 'red' }}-800 shrink-0">
                            {{ $status['passed'] ? 'Writable' : 'Not Writable' }}
                        </span>
                    </div>
                    @endforeach
                </div>
            </div>
        </div>
        
        <!-- Footer / Action Area -->
        <div class="px-8 sm:px-12 py-6 bg-gray-50 dark:bg-gray-800/30 border-t border-gray-200 dark:border-gray-700 flex flex-col sm:flex-row justify-between items-center gap-4">
            <button onclick="location.reload()" class="flex items-center gap-2 px-4 py-2 rounded-lg text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors font-medium text-sm">
                <span class="material-symbols-outlined text-[20px]">refresh</span>
                Check Again
            </button>
            @if($requirements['all_passed'])
            <a href="{{ route('installer.step2') }}" class="w-full sm:w-auto bg-primary hover:bg-blue-600 active:bg-blue-700 text-white px-8 py-3 rounded-lg font-bold shadow-md shadow-blue-500/20 flex items-center justify-center gap-2 transition-all transform hover:-translate-y-0.5">
                Next Step
                <span class="material-symbols-outlined text-[20px]">arrow_forward</span>
            </a>
            @else
            <button disabled class="w-full sm:w-auto bg-gray-400 text-white px-8 py-3 rounded-lg font-bold cursor-not-allowed flex items-center justify-center gap-2">
                Please fix requirements
            </button>
            @endif
        </div>
    </div>
</div>
@endsection






