<?php
$designation_name = '-';
if (!empty($all_dept_info->designations)) {
	$designation_name = $all_dept_info->designations;
}
$show_custom_fields = custom_form_label(16, $promotion_details->id);
?>

<div class="max-h-[70vh] overflow-y-auto">
	<div class="mx-auto max-w-5xl space-y-4">
		<div class="rounded-2xl bg-gradient-to-r from-sky-500 via-indigo-500 to-blue-600 p-[1px] shadow-lg">
			<div class="rounded-2xl bg-white p-4 dark:bg-gray-800">
				<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-[0.2em] text-indigo-600 dark:text-indigo-300"><?= lang('promotion_title') ?></p>
						<p class="mt-1 text-lg font-semibold text-gray-900 dark:text-white">
							<?= !empty($promotion_details->promotion_title) ? html_escape($promotion_details->promotion_title) : '-' ?>
						</p>
					</div>
					<div class="flex flex-wrap items-center gap-2">
						<a href="<?= base_url('admin/promotion/promotion_letter_pdf/' . $promotion_details->id) ?>" class="inline-flex items-center gap-2 rounded-lg bg-indigo-600 px-3 py-2 text-xs font-semibold text-white transition hover:bg-indigo-700">
							<i data-lucide="file-text" class="h-4 w-4"></i>
							<span><?= lang('pdf') ?></span>
						</a>
						<a href="<?= base_url('admin/promotion/promotion_letter_print/' . $promotion_details->id) ?>" target="_blank" class="inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-semibold text-gray-700 transition hover:bg-gray-50 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800">
							<i data-lucide="printer" class="h-4 w-4"></i>
							<span><?= lang('print') ?></span>
						</a>
						<div class="rounded-lg bg-indigo-50 px-3 py-2 text-sm text-indigo-700 dark:bg-indigo-900/40 dark:text-indigo-200">
							<?= lang('promotion_date') ?>: <?= !empty($promotion_details->promotion_date) ? display_date($promotion_details->promotion_date) : '-' ?>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="grid grid-cols-1 gap-4 lg:grid-cols-12">
			<div class="space-y-4 lg:col-span-4">
				<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800">
					<p class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"><?= lang('employee') ?></p>
					<p class="mt-1 text-sm font-medium text-gray-800 dark:text-gray-100">
						<?= !empty($promotion_details->fullname) ? html_escape($promotion_details->fullname) : '-' ?>
					</p>
				</div>

				<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800">
					<p class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"><?= lang('designation') ?></p>
					<p class="mt-1 text-sm font-medium text-gray-800 dark:text-gray-100"><?= html_escape($designation_name) ?></p>
				</div>

				<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800">
					<p class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"><?= lang('department') ?></p>
					<p class="mt-1 text-sm text-gray-700 dark:text-gray-200">
						<?= !empty($all_dept_info->department) ? html_escape($all_dept_info->department) : '-' ?>
					</p>
				</div>

				<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800">
					<p class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"><?= lang('print') . ' ' . lang('date') ?></p>
					<p class="mt-1 text-sm font-medium text-gray-800 dark:text-gray-100">
						<?= !empty($promotion_details->print_date) ? display_date($promotion_details->print_date) : '-' ?>
					</p>
				</div>
			</div>

			<div class="space-y-4 lg:col-span-8">
				<?php if (!empty($show_custom_fields)) : ?>
					<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800">
						<p class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"><?= lang('custom_fields') ?></p>
						<div class="mt-3 divide-y divide-gray-200 dark:divide-gray-700">
							<?php foreach ($show_custom_fields as $c_label => $v_fields) :
								if (empty($v_fields)) {
									continue;
								} ?>
								<div class="grid grid-cols-12 gap-2 py-2">
									<div class="col-span-5 text-sm font-medium text-gray-700 dark:text-gray-300"><?= html_escape($c_label) ?></div>
									<div class="col-span-7 text-sm text-gray-700 dark:text-gray-100"><?= $v_fields ?></div>
								</div>
							<?php endforeach; ?>
						</div>
					</div>
				<?php endif; ?>

				<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800">
					<p class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"><?= lang('description') ?></p>
					<div class="mt-3 rounded-lg border-l-4 border-sky-500 bg-sky-50 p-3 text-sm leading-6 text-gray-700 dark:border-sky-400 dark:bg-sky-900/20 dark:text-gray-200">
						<?= !empty($promotion_details->description) ? $promotion_details->description : '-' ?>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
