<?= message_box('success'); ?>
<?= message_box('error'); ?>

<?php
$permissionL = null;
if (!empty($credit_note_info->permission)) {
	$permissionL = $credit_note_info->permission;
}

$client_selected = !empty($project_info->client_id) ? $project_info->client_id : '';
$client_selected_label = '';
if (!empty($client_selected)) {
	$client_row = $this->db->select('name')->where('client_id', $client_selected)->get('tbl_client')->row();
	if (!empty($client_row)) {
		$client_selected_label = $client_row->name;
	}
}

$new_client_html = form_lookup_add_link(
	'client_id',
	base_url('admin/client/new_client'),
	lang('create') . ' ' . lang('client'),
);
?>

<div class="space-y-6">
	<div class="rounded-2xl border border-border bg-card p-6">
		<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
			<div>
				<p class="text-xs font-semibold uppercase tracking-wide text-muted-foreground"><?= lang('project'); ?></p>
				<h1 class="text-2xl font-semibold text-foreground"><?= lang('import') . ' ' . lang('project') ?></h1>
			</div>
			<div class="flex items-center gap-2">
				<a href="<?= base_url('assets/sample/project_sample.xlsx') ?>"
					class="inline-flex items-center gap-2 rounded-lg border border-border bg-card px-3 py-2 text-sm font-medium text-foreground hover:bg-muted">
					<i data-lucide="download" class="h-4 w-4"></i>
					<?= lang('download_sample') ?>
				</a>
			</div>
		</div>
	</div>

	<?= form_open(base_url('admin/projects/save_imported'), [
		'id' => 'form',
		'class' => 'space-y-6',
		'enctype' => 'multipart/form-data',
		'data-parsley-validate' => '',
		'novalidate' => '',
	]); ?>
		<div class="grid grid-cols-1 xl:grid-cols-12 gap-6">
			<div class="xl:col-span-8 space-y-6">
				<div class="rounded-xl border border-border bg-card p-6 space-y-5">
					<div class="flex items-center gap-2 border-b border-slate-200 pb-3 dark:border-slate-700">
						<i data-lucide="upload" class="h-5 w-5"></i>
						<h2 class="text-base font-semibold text-foreground"><?= lang('import') . ' ' . lang('details') ?></h2>
					</div>

					<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
						<div class="md:col-span-2">
							<label for="upload_file" class="text-sm font-medium text-foreground">
								<?= lang('choose_file') ?> <span class="text-rose-500">*</span>
							</label>
							<input id="upload_file" name="upload_file" type="file" required
								class="mt-2 block w-full rounded-lg border border-border bg-card px-3 py-2 text-sm text-foreground shadow-sm file:mr-4 file:rounded-md file:border-0 file:bg-muted file:px-3 file:py-2 file:text-sm file:font-semibold hover:file:bg-muted/80">
							<p class="mt-2 text-xs text-muted-foreground"><?= lang('select_file') ?></p>
						</div>

						<?= form_lookup_group('client_id', lang('select_client'), $client_selected, $client_selected_label, true, array(), '', array('type' => 'client', 'append' => $new_client_html)); ?>
					</div>
				</div>
			</div>

			<aside class="xl:col-span-4 space-y-6">
				<?= form_permission_modern($assign_user, $permissionL, lang('assined_to')); ?>
			</aside>
		</div>

		<div class="sticky bottom-4 z-20">
			<div class="flex flex-wrap justify-end gap-3 rounded-2xl border border-border bg-card px-4 py-3 shadow-sm">
				<button type="submit" class="inline-flex items-center gap-2 rounded-lg bg-indigo-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500">
					<i data-lucide="upload" class="h-4 w-4"></i>
					<?= lang('upload') ?>
				</button>
			</div>
		</div>
	<?= form_close(); ?>
</div>
