<?php if (isset($component)) { $__componentOriginal4619374cef299e94fd7263111d0abc69 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal4619374cef299e94fd7263111d0abc69 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.app-layout','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('title', null, []); ?> Customers <?php $__env->endSlot(); ?>
    <div x-data="{ tab: 'profile' }">
        <div class="mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
            <div>
                <h1 class="text-2xl font-bold text-gray-900"><?php echo e($customer->full_name); ?></h1>
                <p class="text-sm text-gray-500 mt-1">Customer ID: CUS-<?php echo e(str_pad($customer->id, 5, '0', STR_PAD_LEFT)); ?></p>
            </div>
            <div class="flex items-center gap-3">
                <a href="<?php echo e(route('customers.index')); ?>" class="text-gray-500 hover:text-gray-700 font-medium text-sm transition-colors">
                    &larr; Back to Customers
                </a>
                <a href="<?php echo e(route('customers.edit', $customer->id)); ?>" class="inline-flex items-center justify-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-lg text-gray-700 bg-white hover:bg-gray-50">
                    Edit Profile
                </a>
            </div>
        </div>

        <!-- Tabs -->
        <div class="border-b border-gray-200 mb-6">
            <nav class="-mb-px flex space-x-8" aria-label="Tabs">
                <button @click="tab = 'profile'" :class="tab === 'profile' ? 'border-primary-500 text-primary-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm">
                    Profile & Details
                </button>
                <button @click="tab = 'documents'" :class="tab === 'documents' ? 'border-primary-500 text-primary-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm flex items-center">
                    Documents
                    <span class="ml-2 bg-gray-100 text-gray-600 py-0.5 px-2 rounded-full text-xs"><?php echo e($customer->documents()->count() ?? 0); ?></span>
                </button>
                <button @click="tab = 'interests'" :class="tab === 'interests' ? 'border-primary-500 text-primary-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm flex items-center">
                    Interested Properties
                    <span class="ml-2 bg-gray-100 text-gray-600 py-0.5 px-2 rounded-full text-xs"><?php echo e(count($customer->propertyInterests ?? [])); ?></span>
                </button>
                <button @click="tab = 'bookings'" :class="tab === 'bookings' ? 'border-primary-500 text-primary-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm">
                    Bookings & Financials
                </button>
            </nav>
        </div>

        <!-- Profile Tab -->
        <div x-show="tab === 'profile'" class="space-y-6">
            <?php if($customer->is_defaulter): ?>
                <div class="mb-4 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
                    <strong class="font-bold">Defaulter Alert!</strong>
                    <span class="block sm:inline"> This customer has overdue installments exceeding the allowed grace period.</span>
                </div>
            <?php endif; ?>
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <h3 class="text-lg font-medium text-gray-900 mb-4 border-b pb-2">Personal Information</h3>
                <dl class="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-6">
                    <div>
                        <dt class="text-sm font-medium text-gray-500">Full Name</dt>
                        <dd class="mt-1 text-sm text-gray-900"><?php echo e($customer->full_name); ?></dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500">Father/Husband Name</dt>
                        <dd class="mt-1 text-sm text-gray-900"><?php echo e($customer->father_name ?? 'N/A'); ?></dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500">CNIC</dt>
                        <dd class="mt-1 text-sm text-gray-900"><?php echo e($customer->cnic ?? 'N/A'); ?></dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500">Passport</dt>
                        <dd class="mt-1 text-sm text-gray-900"><?php echo e($customer->passport ?? 'N/A'); ?></dd>
                    </div>
                </dl>
            </div>

            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <h3 class="text-lg font-medium text-gray-900 mb-4 border-b pb-2">Contact Details</h3>
                <dl class="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-6">
                    <div>
                        <dt class="text-sm font-medium text-gray-500">Primary Phone</dt>
                        <dd class="mt-1 text-sm text-gray-900"><?php echo e($customer->phone ?? 'N/A'); ?></dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500">WhatsApp</dt>
                        <dd class="mt-1 text-sm text-gray-900"><?php echo e($customer->whatsapp ?? 'N/A'); ?></dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500">Email Address</dt>
                        <dd class="mt-1 text-sm text-gray-900"><?php echo e($customer->email ?? 'N/A'); ?></dd>
                    </div>
                    <div class="sm:col-span-2">
                        <dt class="text-sm font-medium text-gray-500">Full Address</dt>
                        <dd class="mt-1 text-sm text-gray-900"><?php echo e($customer->address ?? 'N/A'); ?>, <?php echo e($customer->city ?? 'N/A'); ?></dd>
                    </div>
                </dl>
            </div>

            <!-- Portal Access -->
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex justify-between items-center mb-4 border-b pb-2">
                    <h3 class="text-lg font-medium text-gray-900">Customer Portal Access</h3>
                    <?php if($customer->portal_password): ?>
                        <a href="https://web.whatsapp.com/send?phone=<?php echo e(preg_replace('/[^0-9]/', '', $customer->phone ?? '')); ?>&text=<?php echo e(urlencode('Hello ' . $customer->full_name . ', your Customer Portal account has been created. Login using your Email: ' . $customer->email . ' and Password: ' . $customer->portal_password . ' at ' . url('/login'))); ?>" target="_blank" class="inline-flex items-center px-3 py-1.5 border border-transparent shadow-sm text-xs font-medium rounded-md text-white bg-green-500 hover:bg-green-600 transition-colors">
                            <svg class="h-3.5 w-3.5 mr-1.5" fill="currentColor" viewBox="0 0 24 24">
                                <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51a12.8 12.8 0 00-.57-.01c-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/>
                            </svg>
                            Send Credentials
                        </a>
                    <?php endif; ?>
                    <form action="<?php echo e(route('customers.password.generate', $customer)); ?>" method="POST" class="inline">
                        <?php echo csrf_field(); ?>
                        <button type="submit" class="inline-flex items-center px-3 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 transition-colors ml-2">
                            <svg class="h-3.5 w-3.5 mr-1.5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"></path></svg>
                            <?php echo e($customer->portal_password ? 'Reset Password' : 'Generate Password'); ?>

                        </button>
                    </form>
                </div>
                <dl class="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-6">
                    <div>
                        <dt class="text-sm font-medium text-gray-500">Login Email</dt>
                        <dd class="mt-1 text-sm font-medium text-gray-900"><?php echo e($customer->email ?? 'No email provided'); ?></dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500">Portal Password</dt>
                        <dd class="mt-1 text-sm font-mono bg-gray-100 px-2 py-1 inline-block rounded border border-gray-200">
                            <?php echo e($customer->portal_password ?? 'Not generated'); ?>

                        </dd>
                    </div>
                </dl>
            </div>
        </div>

        <!-- Documents Tab -->
        <div x-show="tab === 'documents'" style="display: none;">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex justify-between items-center mb-6">
                    <h3 class="text-lg font-medium text-gray-900">Customer Documents</h3>
                    <button onclick="document.getElementById('upload-modal').classList.remove('hidden')" class="px-4 py-2 bg-primary-600 text-white rounded-md hover:bg-primary-700 text-sm font-medium">
                        Upload Document
                    </button>
                </div>
                
                <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
                    <?php $__empty_1 = true; $__currentLoopData = $customer->documents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $doc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <div class="border border-gray-200 rounded-lg p-4 flex items-center justify-between">
                            <div class="flex items-center space-x-3">
                                <svg class="h-8 w-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
                                <div>
                                    <p class="text-sm font-medium text-gray-900"><?php echo e($doc->title); ?></p>
                                    <p class="text-xs text-gray-500"><?php echo e($doc->document_type); ?> &bull; <?php echo e($doc->created_at->format('M d, Y')); ?></p>
                                </div>
                            </div>
                            <div class="flex space-x-2">
                                <a href="<?php echo e(Storage::url($doc->file_path)); ?>" target="_blank" class="text-blue-600 hover:text-blue-800">
                                    <svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path></svg>
                                </a>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <div class="col-span-full py-8 text-center text-gray-500 bg-gray-50 rounded-lg border border-dashed border-gray-300">
                            No documents uploaded yet.
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>

        <!-- Interested Properties Tab -->
        <div x-show="tab === 'interests'" style="display: none;">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex justify-between items-center border-b pb-2 mb-4">
                    <h3 class="text-lg font-medium text-gray-900">Interested Properties</h3>
                    <button class="px-3 py-1.5 bg-primary-600 text-white text-sm font-medium rounded-md hover:bg-primary-700">
                        + Add Interest
                    </button>
                </div>
                
                <?php if(isset($customer->propertyInterests) && count($customer->propertyInterests) > 0): ?>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead>
                                <tr>
                                    <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Property</th>
                                    <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Interest Level</th>
                                    <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Notes</th>
                                    <th class="px-4 py-2 text-right text-xs font-medium text-gray-500 uppercase">Added On</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200">
                                <?php $__currentLoopData = $customer->propertyInterests; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $property): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td class="px-4 py-3 text-sm text-gray-900"><?php echo e($property->plot_number); ?> - <?php echo e($property->block->name ?? ''); ?> (<?php echo e($property->block->project->name ?? ''); ?>)</td>
                                        <td class="px-4 py-3 text-sm">
                                            <span class="px-2 py-1 text-xs font-medium rounded-full <?php echo e($property->pivot->interest_level === 'High' ? 'bg-red-100 text-red-800' : ($property->pivot->interest_level === 'Medium' ? 'bg-yellow-100 text-yellow-800' : 'bg-green-100 text-green-800')); ?>">
                                                <?php echo e($property->pivot->interest_level); ?>

                                            </span>
                                        </td>
                                        <td class="px-4 py-3 text-sm text-gray-500"><?php echo e($property->pivot->notes); ?></td>
                                        <td class="px-4 py-3 text-sm text-gray-500 text-right"><?php echo e($property->pivot->created_at->format('M d, Y')); ?></td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php else: ?>
                    <div class="text-center py-8 text-gray-500">
                        No property interests recorded yet.
                    </div>
                <?php endif; ?>
            </div>
        </div>

        <!-- Bookings Tab -->
        <div x-show="tab === 'bookings'" style="display: none;">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex justify-between items-center mb-4 border-b pb-2">
                    <h3 class="text-lg font-medium text-gray-900">Active Bookings</h3>
                    <a href="<?php echo e(route('bookings.create')); ?>" class="text-sm font-medium text-primary-600 hover:text-primary-800">+ New Booking</a>
                </div>
                
                <?php if($customer->bookings && $customer->bookings->count() > 0): ?>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Booking ID</th>
                                    <th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Property</th>
                                    <th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Total Price</th>
                                    <th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Status</th>
                                    <th scope="col" class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase">Date</th>
                                </tr>
                            </thead>
                            <tbody class="bg-white divide-y divide-gray-200">
                                <?php $__currentLoopData = $customer->bookings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $booking): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td class="px-4 py-3 text-sm font-medium text-gray-900">
                                            <a href="<?php echo e(route('bookings.show', $booking)); ?>" class="text-primary-600 hover:text-primary-900">BKG-<?php echo e(str_pad($booking->id, 5, '0', STR_PAD_LEFT)); ?></a>
                                        </td>
                                        <td class="px-4 py-3 text-sm text-gray-500"><?php echo e($booking->property->plot_number ?? 'N/A'); ?></td>
                                        <td class="px-4 py-3 text-sm text-gray-500 font-medium">PKR <?php echo e(number_format($booking->total_price)); ?></td>
                                        <td class="px-4 py-3 text-sm">
                                            <span class="px-2 py-1 text-xs font-semibold rounded-full <?php echo e($booking->status === 'Confirmed' ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800'); ?>">
                                                <?php echo e($booking->status); ?>

                                            </span>
                                        </td>
                                        <td class="px-4 py-3 text-sm text-gray-500 text-right"><?php echo e($booking->booking_date->format('M d, Y')); ?></td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php else: ?>
                    <div class="text-center py-8 text-gray-500">
                        No bookings found for this customer.
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <!-- Upload Document Modal -->
    <div id="upload-modal" class="hidden fixed z-10 inset-0 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
        <div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
            <div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div>
            <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
            <div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
                <form action="<?php echo e(route('customers.documents.store', $customer)); ?>" method="POST" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
                        <h3 class="text-lg leading-6 font-medium text-gray-900">Upload Document</h3>
                        <div class="mt-4 space-y-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700">Document Title</label>
                                <input type="text" name="title" required class="mt-1 focus:ring-primary-500 focus:border-primary-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700">Document Type</label>
                                <select name="document_type" required class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm rounded-md">
                                    <option value="CNIC">CNIC / ID Card</option>
                                    <option value="Passport">Passport</option>
                                    <option value="Bank Statement">Bank Statement</option>
                                    <option value="Agreement">Agreement / Contract</option>
                                    <option value="Other">Other</option>
                                </select>
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700">File</label>
                                <input type="file" name="document" required class="mt-1 block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-primary-50 file:text-primary-700 hover:file:bg-primary-100">
                            </div>
                        </div>
                    </div>
                    <div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
                        <button type="submit" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-primary-600 text-base font-medium text-white hover:bg-primary-700 focus:outline-none sm:ml-3 sm:w-auto sm:text-sm">Upload</button>
                        <button type="button" onclick="document.getElementById('upload-modal').classList.add('hidden')" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">Cancel</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal4619374cef299e94fd7263111d0abc69)): ?>
<?php $attributes = $__attributesOriginal4619374cef299e94fd7263111d0abc69; ?>
<?php unset($__attributesOriginal4619374cef299e94fd7263111d0abc69); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal4619374cef299e94fd7263111d0abc69)): ?>
<?php $component = $__componentOriginal4619374cef299e94fd7263111d0abc69; ?>
<?php unset($__componentOriginal4619374cef299e94fd7263111d0abc69); ?>
<?php endif; ?>
<?php /**PATH C:\wamp64\www\my-project\resources\views/customers/show.blade.php ENDPATH**/ ?>