<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<div class="space-y-4">
	<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-3">
		<div>
			<h2 class="text-xl font-semibold">Projects</h2>
			<p class="text-sm text-muted-foreground">Manage your project pipeline.</p>
		</div>
		<a href="<?php echo base_url('projects/create'); ?>" class="inline-flex items-center gap-2 px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 text-sm font-medium transition-colors shadow-lg shadow-primary/20">
			<i data-lucide="plus" class="h-4 w-4"></i> New Project
		</a>
	</div>

	<div class="bg-card border border-border rounded-xl shadow-sm overflow-hidden">
		<div class="overflow-x-auto">
			<table class="min-w-full text-sm">
				<thead class="bg-muted/60 text-muted-foreground">
					<tr>
						<th class="px-4 py-3 text-left font-semibold">Name</th>
						<th class="px-4 py-3 text-left font-semibold">Client</th>
						<th class="px-4 py-3 text-left font-semibold">Priority</th>
						<th class="px-4 py-3 text-left font-semibold">Status</th>
						<th class="px-4 py-3 text-left font-semibold">Budget</th>
						<th class="px-4 py-3 text-left font-semibold">Due</th>
						<th class="px-4 py-3 text-right font-semibold">Actions</th>
					</tr>
				</thead>
				<tbody>
					<?php if (!empty($projects)): ?>
						<?php foreach ($projects as $project): ?>
							<tr class="border-t border-border">
								<td class="px-4 py-3 font-medium text-foreground"><?php echo $project['name']; ?></td>
								<td class="px-4 py-3 text-muted-foreground"><?php echo $project['client']; ?></td>
								<td class="px-4 py-3 text-muted-foreground"><?php echo $project['priority']; ?></td>
								<td class="px-4 py-3">
									<span class="px-2 py-1 text-xs rounded-full bg-muted text-muted-foreground"><?php echo $project['status']; ?></span>
								</td>
								<td class="px-4 py-3 text-foreground"><?php echo $project['budget']; ?></td>
								<td class="px-4 py-3 text-muted-foreground"><?php echo $project['due_date']; ?></td>
								<td class="px-4 py-3 text-right">
									<div class="inline-flex items-center gap-2">
										<a href="<?php echo base_url('projects/show/' . $project['id']); ?>" class="text-primary hover:underline text-xs">View</a>
										<a href="<?php echo base_url('projects/edit/' . $project['id']); ?>" class="text-primary hover:underline text-xs">Edit</a>
										<?php echo form_open('projects/delete/' . $project['id'], array('class' => 'inline')); ?>
										<button type="submit" class="text-red-500 hover:underline text-xs" onclick="return confirm('Delete this project?');">Delete</button>
										<?php echo form_close(); ?>
									</div>
								</td>
							</tr>
						<?php endforeach; ?>
					<?php else: ?>
						<tr>
							<td colspan="7" class="px-4 py-6 text-center text-muted-foreground">No projects yet.</td>
						</tr>
					<?php endif; ?>
				</tbody>
			</table>
		</div>
	</div>
</div>
