<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <title>Dramasub Installer</title>
</head>
<body class="bg-slate-50 flex items-center justify-center min-h-screen p-6">
    <div class="max-w-md w-full">
        
        <div id="step-1" class="space-y-6">
            <div class="bg-white shadow-lg border border-slate-100 overflow-hidden">
                <div class="bg-slate-900 px-8 py-4">
                    <h2 class="text-white text-sm font-bold uppercase">System Requirements</h2>
                </div>
                <div class="p-8 space-y-3">
                    <div class="flex items-center justify-between text-sm">
                        <span class="text-slate-500 font-bold uppercase tracking-tight">PHP Version (Min 8.3)</span>
                        <span class="{{ $requirements['php']['supported'] ? 'text-emerald-500' : 'text-red-500' }} font-bold">
                            {{ $requirements['php']['current'] }} {!! $requirements['php']['supported'] ? '<i class="fas fa-check-circle ml-1"></i>' : '<i class="fas fa-times-circle ml-1"></i>' !!}
                        </span>
                    </div>

                    @foreach($requirements['paths'] as $label => $ok)
                    <div class="flex items-center justify-between text-sm border-t border-slate-50 pt-2">
                        <span class="text-slate-500 font-bold uppercase tracking-tight">Writable: {{ $label }}</span>
                        <span class="{{ $ok ? 'text-emerald-500' : 'text-red-500' }} font-bold uppercase">
                            {{ $ok ? 'OK' : 'Error' }} {!! $ok ? '<i class="fas fa-check-circle ml-1"></i>' : '<i class="fas fa-times-circle ml-1"></i>' !!}
                        </span>
                    </div>
                    @endforeach

                    @php $missing = array_keys($requirements['ext'], false); @endphp
                    @if(count($missing) > 0)
                    <div class="p-3 bg-red-50 rounded-lg text-[10px] text-red-600 border border-red-100 italic">
                        Missing Ext: {{ implode(', ', $missing) }}
                    </div>
                    @endif
                </div>
                <div class="px-8 pb-8">
                    @if(!$requirements['errors'])
                    <button onclick="nextStep()" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-4 transition-all shadow-lg flex items-center justify-center uppercase text-sm">
                        Next Step <i class="fas fa-arrow-right ms-2"></i>
                    </button>
                    @else
                    <button disabled class="w-full bg-slate-100 text-slate-400 font-bold py-4 cursor-not-allowed border border-slate-200 uppercase text-sm tracking-widest">
                        Fix Errors to Continue <i class="fas fa-lock ms-2"></i>
                    </button>
                    @endif
                </div>
            </div>
        </div>

        <div id="step-2" class="hidden">
            <div class="bg-white rounded-xl shadow-2xl overflow-hidden border border-slate-100">
                <div class="bg-white-900 p-8 text-center">
                    <h1 class="text-2xl font-black text-black tracking-tight uppercase">DRAMASUBS <span class="text-red-600">INSTALLER</span></h1>
                </div>
                <form action="{{ route('install.process') }}" method="POST" class="p-8 space-y-5">
                    @csrf
                    @if($errors->any())
                        <div class="p-4 bg-red-50 text-red-600 text-sm rounded-xl border border-red-100 italic">
                            {{ $errors->first() }}
                        </div>
                    @endif
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">App Name</label>
                        <input type="text" name="app_name" value="Dramasub" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">App URL</label>
                        <input type="url" name="app_url" value="{{ url('/') }}" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1 text-blue-600">Drama API Token</label>
                        <input type="text" name="drama_api_token" placeholder="Paste token here..." class="w-full px-4 py-3 bg-blue-50 border border-blue-100 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all text-blue-700 font-mono text-sm">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Admin Pass</label>
                        <input type="password" name="admin_password" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl outline-none">
                    </div>
                    <div>
                        <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Confirm Pass</label>
                        <input type="password" name="admin_password_confirmation" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl outline-none">
                    </div>
                    <button type="submit" class="w-full bg-red-600 hover:bg-red-900 text-white font-bold py-4 transition-all shadow-lg">
                        ACTIVATE <i class="fas fa-bolt ms-2"></i>
                    </button>
                    <button type="button" onclick="prevStep()" class="w-full text-[10px] text-slate-400 font-bold uppercase hover:text-blue-600 pt-2 tracking-widest">
                        Back to System Check
                    </button>
                </form>
            </div>
        </div>

    </div>

    <script>
        function nextStep() {
            document.getElementById('step-1').classList.add('hidden');
            document.getElementById('step-2').classList.remove('hidden');
        }
        function prevStep() {
            document.getElementById('step-2').classList.add('hidden');
            document.getElementById('step-1').classList.remove('hidden');
        }
    </script>
</body>
</html>
