<div class=" p-4">
    <div class="max-w-6xl mx-auto bg-white rounded-lg">
        <!-- Header -->
        <div class="text-black p-4 rounded-t-lg flex justify-between items-center">
            <h1 class="text-lg font-semibold">{{ $company }} (SN={{ $serverKey }}):: CSV Mapping</h1>
            <button class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded">
                Export Query
            </button>
        </div>

        <!-- Table Section -->
        <div class="overflow-x-auto p-4">
           <table aria-describedby="mydesc"  class="min-w-full bg-white border border-gray-300">
                <thead>
                    <tr class="bg-slate-300 text-gray-700">
                        <th scope="col"  class="py-2 px-4 border-b">ID</th>
                        <th scope="col"  class="py-2 px-4 border-b">Map Name</th>
                        <th scope="col"  class="py-2 px-4 border-b">Map Type</th>
                        <th scope="col"  class="py-2 px-4 border-b">Map To</th>
                        <th scope="col"  class="py-2 px-4 border-b">Map Config</th>
                    </tr>
                </thead>
                <tbody>
                    @if (count($mappingList) > 0)
                        @foreach ($mappingList['mapId'] as $index => $mapId)
                            <tr class="border-b">
                                <td class="py-2 px-4 border">{{ $index + 1 }}</td>
                                <td class="py-2 px-4 border w-1/4"><input type="text"
                                        class="w-3/4 p-2 border border-gray-300 rounded-md"
                                        wire:model.defer="mappingList.mapName.{{ $index }}" /></td>
                                <td class="py-2 px-4 border"><input type="text"
                                        class="w-3/4 p-2 border border-gray-300 rounded-md"
                                        wire:model.defer="mappingList.mapType.{{ $index }}" /></td>
                                <td class="py-2 px-4 border"><input type="text"
                                        class="w-3/4 p-2 border border-gray-300 rounded-md"
                                        wire:model.defer="mappingList.mapTo.{{ $index }}" /></td>
                                <td class="py-2 px-4 border w-2/4">
                                    <textarea class="w-full p-1 border rounded" wire:model.defer="mappingList.mapConfig.{{ $index }}"></textarea>
                                </td>
                            </tr>
                        @endforeach
                    @endif
                </tbody>
            </table>
            <div class="p-4">
                <button wire:click="saveMapping"
                    class="bg-primary hover:bg-primary-focus text-white font-bold py-2 px-4 rounded">
                    Save
                </button>
            </div>
        </div>
    </div>
</div>
