<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;

$__newAttributes = [];
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames((['company']));

foreach ($attributes->all() as $__key => $__value) {
    if (in_array($__key, $__propNames)) {
        $$__key = $$__key ?? $__value;
    } else {
        $__newAttributes[$__key] = $__value;
    }
}

$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);

unset($__propNames);
unset($__newAttributes);

foreach (array_filter((['company']), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
}

$__defined_vars = get_defined_vars();

foreach ($attributes->all() as $__key => $__value) {
    if (array_key_exists($__key, $__defined_vars)) unset($$__key);
}

unset($__defined_vars, $__key, $__value); ?>

<div class="flex items-center justify-between mb-3">
	<h2 class="text-lg font-semibold">Contacts</h2>

	
	<button type="button" data-dialog-open="contact-create-<?php echo e($company->id); ?>"
		class="inline-flex h-9 items-center justify-center rounded-sm px-3 text-sm leading-none bg-info/10 text-info hover:bg-info hover:text-white">
		<i class="ti ti-plus text-[18px]"></i>
		<span class="ml-2">Add</span>
	</button>
</div>


<table class="ti-custom-table ti-striped-table ti-custom-table-hover tabulator">
	<thead>
		<tr class="text-xs uppercase text-gray-500">
			<th class="text-left px-3 py-2">Name</th>
			<th class="text-left px-3 py-2">Dept</th>
			<th class="text-left px-3 py-2">Email</th>
			<th class="text-left px-3 py-2">Phone</th>
			<th class="text-left px-3 py-2">Note</th>
			<th class="text-right px-3 py-2">Actions</th>
		</tr>
	</thead>

	<tbody>
		<?php $__empty_1 = true; $__currentLoopData = $company->contacts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
			
			<tr class="align-middle rounded-lg bg-gray-50 dark:bg-white/5">
				<td class="px-3 py-2 font-medium">
					<?php echo e($c->name); ?>

				</td>

				<td class="px-3 py-2 text-sm text-gray-600">
					<?php echo e($c->department); ?>

				</td>

				<td class="px-3 py-2 text-sm text-gray-600">
					<?php if($c->email): ?>
						<a href="mailto:<?php echo e($c->email); ?>" class="underline"><?php echo e($c->email); ?></a>
					<?php endif; ?>
				</td>

				<td class="px-3 py-2 text-sm text-gray-600">
					<?php echo e($c->phone); ?>

				</td>
				<td class="px-3 py-2 text-sm text-gray-600">
					<?php if (isset($component)) { $__componentOriginaldb8317859d68422b351c6e7ca9546180 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginaldb8317859d68422b351c6e7ca9546180 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.note-modal','data' => ['id' => $c->id,'note' => $c->note,'contentMaxWidth' => 'max-w-xl lg:max-w-3xl','bodyMaxHeight' => 'max-h-[80vh]']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('note-modal'); ?>
<?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(['id' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($c->id),'note' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($c->note),'content-max-width' => 'max-w-xl lg:max-w-3xl','body-max-height' => 'max-h-[80vh]']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginaldb8317859d68422b351c6e7ca9546180)): ?>
<?php $attributes = $__attributesOriginaldb8317859d68422b351c6e7ca9546180; ?>
<?php unset($__attributesOriginaldb8317859d68422b351c6e7ca9546180); ?>
<?php endif; ?>
<?php if (isset($__componentOriginaldb8317859d68422b351c6e7ca9546180)): ?>
<?php $component = $__componentOriginaldb8317859d68422b351c6e7ca9546180; ?>
<?php unset($__componentOriginaldb8317859d68422b351c6e7ca9546180); ?>
<?php endif; ?>

				</td>

				<td class="px-3 py-2">
					<div class="flex items-center justify-end gap-2">
						
						<button type="button" data-dialog-open="contact-edit-<?php echo e($c->id); ?>"
							class="inline-flex h-9 items-center justify-center rounded-sm px-3 text-sm leading-none bg-info/10 text-info hover:bg-info hover:text-white"
							title="Edit" aria-label="Edit">
							<i class="ti ti-edit text-[18px]"></i>
						</button>

						
						<form method="POST" action="<?php echo e(route('crm.companies.contacts.destroy', [$company, $c])); ?>" class="contents"
							onsubmit="return confirm('Delete this contact?')">
							<?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
							<button type="submit"
								class="inline-flex h-9 items-center justify-center rounded-sm px-3 text-sm leading-none bg-danger/10 text-danger hover:bg-danger hover:text-white"
								title="Delete" aria-label="Delete">
								<i class="ti ti-trash text-[18px]"></i>
							</button>
						</form>
					</div>
				</td>
			</tr>

			
			<dialog id="contact-edit-<?php echo e($c->id); ?>" class="rounded-2xl p-0 w-full max-w-lg">
				<form method="POST" action="<?php echo e(route('crm.companies.contacts.update', [$company, $c])); ?>">
					<?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
					<div class="p-4">
						<div class="mb-3 flex items-center justify-between">
							<h3 class="text-base font-semibold">Edit Contact</h3>
							<button type="button" data-dialog-close class="h-9 px-3 rounded-sm">✕</button>
						</div>

						
						<!-- wider modal container (adjust as you like) -->
						<div class="w-full max-w-4xl lg:max-w-5xl p-6 bg-white dark:bg-zinc-900 rounded-2xl shadow-xl">
							<div class="grid grid-cols-1 md:grid-cols-2 gap-4 items-start">
								<div>
									<label class="block text-sm mb-1">Name <span class="text-red-600">*</span></label>
									<input name="name" required class="ti-form-input" value="<?php echo e($c->name); ?>">
								</div>

								<div>
									<label class="block text-sm mb-1">Department</label>
									<input name="department" class="ti-form-input" value="<?php echo e($c->department); ?>">
								</div>

								<div>
									<label class="block text-sm mb-1">Email</label>
									<input type="email" name="email" class="ti-form-input" value="<?php echo e($c->email); ?>">
								</div>

								<div>
									<label class="block text-sm mb-1">Phone</label>
									<input name="phone" class="ti-form-input" value="<?php echo e($c->phone); ?>">
								</div>

								<div class="md:col-span-2">
									<label class="block text-sm mb-1">Note</label>
									<textarea name="note" rows="3" class="ti-form-input !font-normal"><?php echo e($c->note); ?></textarea>
								</div>
							</div>
						</div>

						<div class="mt-4 flex justify-end gap-2">
							<button type="button" data-dialog-close class="rounded-sm h-9 px-3">Cancel</button>
							<button type="submit"
								class="inline-flex h-9 items-center justify-center rounded-sm px-3 text-sm leading-none bg-success/10 text-success hover:bg-success hover:text-white">
								<i class="ti ti-check text-[18px]"></i><span class="ml-2">Update</span>
							</button>
						</div>
					</div>
				</form>
			</dialog>
		<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
			<tr>
				<td class="px-3 py-2 text-sm text-gray-500" colspan="5">No contacts added for this company.</td>
			</tr>
		<?php endif; ?>
	</tbody>
</table>


<dialog id="contact-create-<?php echo e($company->id); ?>" class="rounded-2xl p-0 w-full max-w-lg">
	<form method="POST" action="<?php echo e(route('crm.companies.contacts.store', $company)); ?>">
		<?php echo csrf_field(); ?>
		<div class="p-4">
			<div class="mb-3 flex items-center justify-between">
				<h3 class="text-base font-semibold">Add Contact</h3>
				<button type="button" data-dialog-close class="h-9 px-3 rounded-sm">✕</button>
			</div>

			
			<!-- Modal container (example sizing) -->
			<div class="w-full max-w-3xl md:max-w-4xl bg-white dark:bg-zinc-900 rounded-2xl shadow-xl p-6">
				<div class="grid grid-cols-1 md:grid-cols-2 gap-4 items-start">
					<div>
						<label class="block text-sm mb-1">Name <span class="text-red-600">*</span></label>
						<input name="name" required class="ti-form-input" placeholder="Full name">
					</div>

					<div>
						<label class="block text-sm mb-1">Department</label>
						<input name="department" class="ti-form-input" placeholder="Department">
					</div>

					<div>
						<label class="block text-sm mb-1">Email</label>
						<input type="email" name="email" class="ti-form-input" placeholder="email@example.com">
					</div>

					<div>
						<label class="block text-sm mb-1">Phone</label>
						<input name="phone" class="ti-form-input" placeholder="+381 ...">
					</div>

					<!-- Note spans full width on md+ -->
					<div class="md:col-span-2">
						<label class="block text-sm mb-1">Note</label>
						<textarea name="note" rows="3" class="ti-form-input !font-normal" placeholder="Note"></textarea>
					</div>
				</div>
			</div>

			<div class="mt-4 flex justify-end gap-2">
				<button type="button" data-dialog-close class="rounded-sm h-9 px-3">Cancel</button>
				<button type="submit"
					class="inline-flex h-9 items-center justify-center rounded-sm px-3 text-sm leading-none bg-success/10 text-success hover:bg-success hover:text-white">
					<i class="ti ti-check text-[18px]"></i><span class="ml-2">Save</span>
				</button>
			</div>
		</div>
	</form>
</dialog>
<?php /**PATH C:\laragon\www\policypilot\resources\views/backend/crm/companies/partials/contacts-list-simple.blade.php ENDPATH**/ ?>