@extends('layouts.app')

@section('title', 'Service Packages & Bundles')

@section('content')
<div class="space-y-6" x-data="{ modal: false }">
    <div class="flex items-center justify-between">
        <div>
            <h1 class="text-xl font-bold text-slate-900 dark:text-white">Service Packages & Bundles</h1>
            <p class="text-xs text-slate-500">Group multi-step government services (e.g., Work Permit + Entry Permit + Medical + EID + Visa).</p>
        </div>
        <button @click="modal = true" class="px-4 py-2 bg-sky-600 text-white font-bold text-xs rounded-xl shadow-sm">+ Create Service Bundle</button>
    </div>

    <!-- Bundles Grid (Requirements 45-48) -->
    <div class="grid grid-cols-1 md:grid-cols-2 gap-6 text-xs">
        @foreach($bundles as $bundle)
            <div class="bg-white dark:bg-slate-800 rounded-3xl p-6 border border-slate-200 dark:border-slate-700/60 shadow-sm space-y-4">
                <div class="flex items-center justify-between border-b border-slate-100 dark:border-slate-700 pb-3">
                    <div>
                        <h3 class="font-bold text-slate-900 dark:text-white text-sm">{{ $bundle->name_en }}</h3>
                        <span class="font-mono text-slate-400 font-bold text-[10px]">{{ $bundle->bundle_code }}</span>
                    </div>
                    <span class="font-mono font-extrabold text-sky-600 text-base">AED {{ number_format($bundle->bundle_price, 2) }}</span>
                </div>

                <div class="space-y-1 text-slate-600 dark:text-slate-300">
                    <p>Workflow Mode: <strong class="uppercase text-sky-600 font-bold text-[10px]">{{ $bundle->workflow_mode }}</strong></p>
                    <p>{{ $bundle->description }}</p>
                </div>
            </div>
        @endforeach
    </div>

    <!-- Create Bundle Modal -->
    <div x-show="modal" class="fixed inset-0 bg-slate-950/80 backdrop-blur-sm z-50 flex items-center justify-center p-4" x-cloak>
        <div class="bg-white dark:bg-slate-800 rounded-3xl max-w-md w-full p-6 border border-slate-200 dark:border-slate-700 shadow-2xl space-y-4 text-xs">
            <h3 class="text-sm font-bold text-slate-900 dark:text-white uppercase tracking-wider">Create Service Package Bundle</h3>
            <form action="{{ route('app.services.bundles.store') }}" method="POST" class="space-y-3">
                @csrf
                <div>
                    <label class="block font-semibold mb-1">Bundle Package Name *</label>
                    <input type="text" name="name_en" required placeholder="New Employee Full Visa Package" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl font-bold">
                </div>
                <div>
                    <label class="block font-semibold mb-1">Package Price (AED) *</label>
                    <input type="number" name="bundle_price" required value="2500.00" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl font-bold font-mono">
                </div>
                <div>
                    <label class="block font-semibold mb-1">Workflow Execution Mode</label>
                    <select name="workflow_mode" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl">
                        <option value="sequential">Sequential (Step 1 ➔ Step 2 ➔ Step 3)</option>
                        <option value="parallel">Parallel (Simultaneous Processing)</option>
                    </select>
                </div>
                <div class="flex justify-end space-x-2 rtl:space-x-reverse pt-2">
                    <button type="button" @click="modal = false" class="px-4 py-2 bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-200 font-bold rounded-xl">Cancel</button>
                    <button type="submit" class="px-5 py-2 bg-sky-600 text-white font-bold rounded-xl">Create Bundle</button>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection
