<div class="relative">
    {{-- Botón de cierre X en la esquina superior derecha --}}
    <button wire:click="closeModal"
            class="absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors z-10"
            aria-label="Cerrar">
        <svg class="w-6 h-6" 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 class="p-6">
        <h3 class="text-lg font-semibold text-gray-900 mb-4 pr-8">
            Contactos de {{ $client->name }}
        </h3>
        
        @if(!empty($client->contacts) && count($client->contacts) > 0)
            <div class="space-y-4">
                @foreach($client->contacts as $index => $contact)
                    <div class="border border-gray-200 rounded-lg p-4 bg-gray-50">
                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                            {{-- Nombre --}}
                            <div>
                                <label class="block text-xs font-medium text-gray-600 mb-1">Nombre</label>
                                <p class="text-sm text-gray-900 font-medium">
                                    {{ $contact['name'] ?? 'N/A' }}
                                </p>
                            </div>

                            {{-- Email --}}
                            <div>
                                <label class="block text-xs font-medium text-gray-600 mb-1">Email</label>
                                <p class="text-sm text-gray-900">
                                    @if(!empty($contact['email']))
                                        <a href="mailto:{{ $contact['email'] }}" class="text-blue-600 hover:text-blue-800">
                                            {{ $contact['email'] }}
                                        </a>
                                    @else
                                        <span class="text-gray-400">N/A</span>
                                    @endif
                                </p>
                            </div>

                            {{-- Teléfono --}}
                            <div>
                                <label class="block text-xs font-medium text-gray-600 mb-1">Teléfono</label>
                                <p class="text-sm text-gray-900">
                                    @if(!empty($contact['phone']))
                                        <a href="tel:{{ $contact['phone'] }}" class="text-blue-600 hover:text-blue-800">
                                            {{ $contact['phone'] }}
                                        </a>
                                    @else
                                        <span class="text-gray-400">N/A</span>
                                    @endif
                                </p>
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>
        @else
            <div class="border border-gray-200 rounded-lg p-6 bg-gray-50 text-center">
                <p class="text-gray-500 text-sm">
                    No hay contactos registrados para este cliente.
                </p>
            </div>
        @endif
        
        <div class="flex justify-end mt-6">
            <button wire:click="closeModal"
                    class="px-4 py-2 rounded-lg bg-gray-600 hover:bg-gray-700 text-white transition-colors">
                Cerrar
            </button>
        </div>
    </div>
</div>
