<div class="py-12">
    <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
        <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
            <div class="p-6 sm:p-10">
                <!-- Header -->
                <div class="mb-8">
                    <h1 class="text-3xl font-bold text-gray-900 mb-2">
                        Bulk Upload Menu Items
                    </h1>
                    <p class="text-gray-600">
                        Download our sample template, fill in your menu items, and upload it. Our team will process your file and import your items.
                    </p>
                </div>

                <!-- Success Message -->
                @if($uploadSuccess)
                    <div class="mb-6 bg-green-50 border border-green-200 rounded-lg p-4 flex items-start">
                        <svg class="w-6 h-6 text-green-500 mr-3 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                        </svg>
                        <div>
                            <h3 class="text-green-800 font-semibold mb-1">Upload Successful!</h3>
                            <p class="text-green-700 text-sm">
                                Your file has been uploaded successfully. Our team will review and process it shortly.
                            </p>
                        </div>
                    </div>
                @endif

                <!-- Error Message -->
                @if($errorMessage)
                    <div class="mb-6 bg-red-50 border border-red-200 rounded-lg p-4 flex items-start">
                        <svg class="w-6 h-6 text-red-500 mr-3 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                        </svg>
                        <div>
                            <h3 class="text-red-800 font-semibold mb-1">Error</h3>
                            <p class="text-red-700 text-sm">{{ $errorMessage }}</p>
                        </div>
                    </div>
                @endif

                <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
                    <!-- Left Column: Instructions -->
                    <div>
                        <div class="bg-blue-50 border border-blue-200 rounded-lg p-6">
                            <div class="flex items-center mb-4">
                                <div class="bg-blue-100 rounded-full p-2 mr-3">
                                    <svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                                    </svg>
                                </div>
                                <h2 class="text-xl font-semibold text-gray-900">How It Works</h2>
                            </div>

                            <div class="space-y-6 text-sm text-gray-700">
                                <!-- Step 1 -->
                                <div class="flex">
                                    <div class="flex-shrink-0">
                                        <div class="flex items-center justify-center w-8 h-8 bg-blue-600 text-white rounded-full font-bold text-sm">
                                            1
                                        </div>
                                    </div>
                                    <div class="ml-4">
                                        <h3 class="font-semibold text-gray-900 mb-2">Download Sample File</h3>
                                        <p class="mb-3">Click the button below to download our Excel template with the correct format.</p>
                                        <button wire:click="downloadSample" 
                                                class="inline-flex items-center px-4 py-2 bg-blue-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition">
                                            <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
                                            </svg>
                                            Download Sample File
                                        </button>
                                    </div>
                                </div>

                                <!-- Step 2 -->
                                <div class="flex">
                                    <div class="flex-shrink-0">
                                        <div class="flex items-center justify-center w-8 h-8 bg-blue-600 text-white rounded-full font-bold text-sm">
                                            2
                                        </div>
                                    </div>
                                    <div class="ml-4">
                                        <h3 class="font-semibold text-gray-900 mb-2">Fill Your Data</h3>
                                        <p class="mb-2">Open the downloaded file and add your menu items with these columns:</p>
                                        <div class="bg-white rounded p-3 space-y-1 text-xs">
                                            <div class="flex items-center">
                                                <span class="font-mono bg-gray-100 px-2 py-1 rounded mr-2">item_name</span>
                                                <span class="text-gray-600">Name of the item <span class="text-red-500">*</span></span>
                                            </div>
                                            <div class="flex items-center">
                                                <span class="font-mono bg-gray-100 px-2 py-1 rounded mr-2">category_name</span>
                                                <span class="text-gray-600">Category <span class="text-red-500">*</span></span>
                                            </div>
                                            <div class="flex items-center">
                                                <span class="font-mono bg-gray-100 px-2 py-1 rounded mr-2">menu_name</span>
                                                <span class="text-gray-600">Menu <span class="text-red-500">*</span></span>
                                            </div>
                                            <div class="flex items-center">
                                                <span class="font-mono bg-gray-100 px-2 py-1 rounded mr-2">price</span>
                                                <span class="text-gray-600">Price <span class="text-red-500">*</span></span>
                                            </div>
                                            <div class="flex items-center">
                                                <span class="font-mono bg-gray-100 px-2 py-1 rounded mr-2">description</span>
                                                <span class="text-gray-600">Description (optional)</span>
                                            </div>
                                            <div class="flex items-center">
                                                <span class="font-mono bg-gray-100 px-2 py-1 rounded mr-2">type</span>
                                                <span class="text-gray-600">Veg/Non-Veg (optional)</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- Step 3 -->
                                <div class="flex">
                                    <div class="flex-shrink-0">
                                        <div class="flex items-center justify-center w-8 h-8 bg-blue-600 text-white rounded-full font-bold text-sm">
                                            3
                                        </div>
                                    </div>
                                    <div class="ml-4">
                                        <h3 class="font-semibold text-gray-900 mb-2">Upload Your File</h3>
                                        <p>Use the upload form on the right to submit your completed file. Our team will process it and add your items.</p>
                                    </div>
                                </div>

                                <div class="bg-yellow-50 border border-yellow-200 rounded p-3 mt-4">
                                    <div class="flex">
                                        <svg class="w-5 h-5 text-yellow-600 mr-2 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
                                        </svg>
                                        <p class="text-yellow-800 text-xs">
                                            <strong>Note:</strong> After uploading, our admin team will review your file and manually import your menu items. You will be notified once the process is complete.
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Right Column: Upload Form -->
                    <div>
                        <div class="bg-gray-50 border border-gray-200 rounded-lg p-6">
                            <div class="flex items-center mb-6">
                                <div class="bg-green-100 rounded-full p-2 mr-3">
                                    <svg class="w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path>
                                    </svg>
                                </div>
                                <h2 class="text-xl font-semibold text-gray-900">Upload File</h2>
                            </div>

                            <form wire:submit.prevent="submitUpload">
                                <!-- File Upload Area -->
                                <div class="mb-6">
                                    <label class="block text-sm font-medium text-gray-700 mb-2">
                                        Select Your File <span class="text-red-500">*</span>
                                    </label>
                                    
                                    <div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md hover:border-blue-400 transition">
                                        <div class="space-y-1 text-center">
                                            <svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none" viewBox="0 0 48 48">
                                                <path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
                                            </svg>
                                            <div class="flex text-sm text-gray-600">
                                                <label for="file-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-blue-600 hover:text-blue-500 focus-within:outline-none">
                                                    <span>Upload a file</span>
                                                    <input id="file-upload" wire:model="uploadedFile" type="file" class="sr-only" accept=".csv,.xlsx,.xls">
                                                </label>
                                                <p class="pl-1">or drag and drop</p>
                                            </div>
                                            <p class="text-xs text-gray-500">CSV, XLS, XLSX up to 10MB</p>
                                            
                                            @if($uploadedFile)
                                                <p class="text-sm text-green-600 font-medium mt-2">{{ $uploadedFile->getClientOriginalName() }}</p>
                                            @endif
                                        </div>
                                    </div>

                                    @error('uploadedFile')
                                        <p class="mt-2 text-sm text-red-600">{{ $message }}</p>
                                    @enderror

                                    <!-- Loading Indicator -->
                                    <div wire:loading wire:target="uploadedFile" class="mt-2 text-sm text-blue-600">
                                        <div class="flex items-center">
                                            <svg class="animate-spin h-4 w-4 mr-2" fill="none" viewBox="0 0 24 24">
                                                <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
                                                <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
                                            </svg>
                                            Uploading file...
                                        </div>
                                    </div>
                                </div>

                                <!-- File Info Display -->
                                @if($uploadedFile && !$errors->has('uploadedFile'))
                                    <div class="mb-6 bg-white border border-gray-200 rounded-md p-4">
                                        <div class="flex items-center justify-between">
                                            <div class="flex items-center">
                                                <svg class="w-8 h-8 text-green-500 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
                                                </svg>
                                                <div>
                                                    <p class="text-sm font-medium text-gray-900">{{ $uploadedFile->getClientOriginalName() }}</p>
                                                    <p class="text-xs text-gray-500">{{ number_format($uploadedFile->getSize() / 1024, 2) }} KB</p>
                                                </div>
                                            </div>
                                            <button type="button" wire:click="$set('uploadedFile', null)" class="text-red-600 hover:text-red-800">
                                                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
                                                </svg>
                                            </button>
                                        </div>
                                    </div>
                                @endif

                                <!-- Submit Button -->
                                <div class="flex justify-end">
                                    <button type="submit" 
                                            wire:loading.attr="disabled"
                                            wire:target="submitUpload"
                                            @if(!$uploadedFile) disabled @endif
                                            class="inline-flex items-center px-6 py-3 bg-blue-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition disabled:opacity-50 disabled:cursor-not-allowed">
                                        <svg wire:loading.remove wire:target="submitUpload" class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path>
                                        </svg>
                                        <svg wire:loading wire:target="submitUpload" class="animate-spin h-4 w-4 mr-2" fill="none" viewBox="0 0 24 24">
                                            <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
                                            <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
                                        </svg>
                                        <span wire:loading.remove wire:target="submitUpload">Submit to Admin</span>
                                        <span wire:loading wire:target="submitUpload">Uploading...</span>
                                    </button>
                                </div>
                            </form>
                        </div>

                        <!-- Help Section -->
                        <div class="mt-6 bg-white border border-gray-200 rounded-lg p-4">
                            <h3 class="text-sm font-semibold text-gray-900 mb-2 flex items-center">
                                <svg class="w-5 h-5 text-blue-600 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                                </svg>
                                Need Help?
                            </h3>
                            <p class="text-xs text-gray-600 mb-2">
                                If you have questions or encounter any issues, contact our support team.
                            </p>
                            <a href="mailto:support@ewiidine.ca" class="text-xs text-blue-600 hover:text-blue-800 font-medium">
                                support@ewiidine.ca
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
