@extends('layouts.app')

@section('title', 'Produits')
@section('page-title', 'Produits')

@section('content')
<div class="space-y-6">
    <!-- En-tête avec bouton d'ajout -->
    <div class="flex justify-between items-center">
        <div>
            <h1 class="text-2xl font-bold text-gray-900">Gestion des Produits</h1>
            <p class="mt-1 text-sm text-gray-600">Gérez tous les produits de l'hôpital</p>
        </div>
        <button type="button" data-modal-toggle="modal-new-product" class="inline-flex items-center px-5 py-2.5 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg shadow-sm hover:shadow-md transition-all">
            <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
            </svg>
            Nouveau produit
        </button>
    </div>

    {{-- <x-modal-form id="modal-new-product" title="Nouveau produit">
        @include('components.modals.product', ['modalId' => 'modal-new-product'])
    </x-modal-form>  --}}

    <!-- Filtres et recherche -->
    <div class="bg-white dark:bg-white shadow-sm border border-gray-200 rounded-xl p-4">
        <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
            <div class="md:col-span-2">
                <input type="text" placeholder="Rechercher un produit..." class="w-full px-4 py-2.5 border border-gray-200 rounded-lg bg-white text-gray-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all">
            </div>
            <div>
                <select class="w-full px-4 py-2.5 border border-gray-200 rounded-lg bg-white text-gray-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all">
                    <option>Toutes les catégories</option>
                    <option>Alimentaire</option>
                    <option>Entretien</option>
                    <option>Fournitures</option>
                </select>
            </div>
            <div>
                <select class="w-full px-4 py-2.5 border border-gray-200 rounded-lg bg-white text-gray-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all">
                    <option>Tous les statuts</option>
                    <option>Actif</option>
                    <option>Inactif</option>
                </select>
            </div>
        </div>
    </div>

    <!-- Tableau des produits -->
    <div class="bg-white dark:bg-white shadow-sm border border-gray-200 rounded-xl overflow-hidden">
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-200">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">
                            Produit
                        </th>
                        <th class="px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">
                            Catégorie
                        </th>
                        <th class="px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">
                            Fournisseur
                        </th>
                        <th class="px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">
                            Unité
                        </th>
                        <th class="px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">
                            Stock
                        </th>
                        <th class="px-6 py-4 text-right text-xs font-semibold text-gray-700 uppercase tracking-wider">
                            Actions
                        </th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200">
                    <tr class="hover:bg-blue-50/50 transition-colors">
                        <td colspan="6" class="px-6 py-12 text-center">
                            <div class="flex flex-col items-center">
                                <svg class="w-16 h-16 text-gray-300 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" />
                                </svg>
                                <p class="text-sm font-medium text-gray-600 mb-1">Aucun produit trouvé</p>
                                <p class="text-xs text-gray-500">Cliquez sur "Nouveau produit" pour en ajouter un.</p>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
@endsection


<!-- Modal Create Category -->
<x-modal id="modal-new-product" title="Nouveau produit">
    <form action="" method="POST" class="space-y-5">
        @csrf
        <div>
            <label for="create_category_name" class="block text-sm font-semibold text-gray-700 mb-2">Nom *</label>
            <input type="text" id="create_category_name" name="name" value="{{ old('name') }}" required placeholder="Entrez le nom de la catégorie" class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all outline-none">
        </div>
        <div class="grid grid-cols-3 gap-4">
            <div>
                <label for="create_normal_price" class="block text-sm font-semibold text-gray-700 mb-2">Prix normal *</label>
                <input type="number" id="create_normal_price" name="normal_price" value="{{ old('normal_price') }}" required min="0" step="0.01" placeholder="0" class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all outline-none">
            </div>
            <div>
                <label for="create_express_price" class="block text-sm font-semibold text-gray-700 mb-2">Prix express</label>
                <input type="number" id="create_express_price" name="express_price" value="{{ old('express_price') }}" min="0" step="0.01" placeholder="0" class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all outline-none">
            </div>
            <div>
                <label for="create_super_express_price" class="block text-sm font-semibold text-gray-700 mb-2">Prix super express</label>
                <input type="number" id="create_super_express_price" name="super_express_price" value="{{ old('super_express_price') }}" min="0" step="0.01" placeholder="0" class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all outline-none">
            </div>
        </div>
        <div>
            <label for="create_category_description" class="block text-sm font-semibold text-gray-700 mb-2">Description</label>
            <textarea id="create_category_description" name="description" rows="4" placeholder="Entrez la description de la catégorie" class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all outline-none resize-none">{{ old('description') }}</textarea>
        </div>
        <div class="flex items-center justify-end space-x-3 pt-6 border-t border-gray-200">
            <button type="button" onclick="closeModal('category-create-modal')" class="px-6 py-2.5 text-gray-700 bg-white border border-gray-300 rounded-xl hover:bg-gray-50 transition-colors font-medium">
                Annuler
            </button>
            <button type="submit" class="px-6 py-2.5 bg-gradient-to-r from-blue-600 to-indigo-600 text-white rounded-xl hover:from-blue-700 hover:to-indigo-700 transition-all font-medium shadow-lg shadow-blue-500/25">
                Enregistrer
            </button>
        </div>
    </form>
</x-modal>
