<div>
    @if($searchable)
        <div class="mb-4">
            <input type="text"
                   wire:model.live.debounce.300ms="search"
                   placeholder="{{ $searchPlaceholder }}"
                   class="w-full rounded border border-gray-300 px-3 py-2 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500">
        </div>
    @endif

    <div class="overflow-hidden rounded bg-white shadow">
        <table class="min-w-full text-left text-sm">
            <thead class="bg-gray-100 text-xs uppercase text-gray-600">
                <tr>
                    @foreach($columns as $column)
                        <th class="px-4 py-3">{{ $column['label'] }}</th>
                    @endforeach
                    @if(count($actions) > 0)
                        <th class="px-4 py-3 text-right">Acciones</th>
                    @endif
                </tr>
            </thead>
            <tbody class="divide-y">
                @forelse($data as $item)
                    <tr class="hover:bg-gray-50">
                        @foreach($columns as $column)
                            <td class="px-4 py-3">
                                @if(isset($column['format']) && $column['format'] === 'html')
                                    {!! $column['value']($item) !!}
                                @else
                                    {{ $column['value']($item) }}
                                @endif
                            </td>
                        @endforeach
                        @if(count($actions) > 0)
                            <td class="px-4 py-3 text-right">
                                @foreach($actions as $action)
                                    @if($action['type'] === 'link')
                                        <a href="{{ $action['url']($item) }}"
                                           class="{{ $action['class'] ?? 'text-blue-600 hover:text-blue-800' }}">
                                            {{ $action['label'] }}
                                        </a>
                                    @elseif($action['type'] === 'button')
                                        <button wire:click="{{ $action['method'] }}('{{ $item->id }}')"
                                                class="{{ $action['class'] ?? 'text-red-600 hover:text-red-800' }}">
                                            {{ $action['label'] }}
                                        </button>
                                    @endif
                                @endforeach
                            </td>
                        @endif
                    </tr>
                @empty
                    <tr>
                        <td colspan="{{ count($columns) + (count($actions) > 0 ? 1 : 0) }}" 
                            class="px-4 py-3 text-center text-gray-500">
                            {{ $emptyMessage }}
                        </td>
                    </tr>
                @endforelse
            </tbody>
        </table>
    </div>

    @if(method_exists($data, 'links'))
        <div class="mt-4">
            {{ $data->links() }}
        </div>
    @endif
</div>

