<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/** SERVICES LIST — Expects: $services. */
?>
<div class="page-head">
	<div><h2>Services</h2><p>Manage the agency's creative service offerings.</p></div>
	<a href="<?= base_url('admin/services/create') ?>" class="btn btn-primary"><?= bloom_icon('plus', 16) ?> Add Service</a>
</div>

<div class="card">
	<div class="card-body flush">
		<?php if ($services): ?>
			<div class="table-wrap">
				<table class="data">
					<thead><tr><th>Service</th><th>Summary</th><th>Order</th><th>Status</th><th class="text-right">Actions</th></tr></thead>
					<tbody>
					<?php foreach ($services as $s): ?>
						<tr>
							<td>
								<div style="display:flex;align-items:center;gap:10px;">
									<span style="width:36px;height:36px;border-radius:9px;background:rgba(180,95,154,.13);color:var(--plum);display:grid;place-items:center;">
										<?= bloom_icon($s['icon'] ?: 'sparkle', 18) ?>
									</span>
									<span class="row-title"><?= html_escape($s['title']) ?></span>
								</div>
							</td>
							<td class="muted"><?= html_escape(excerpt($s['summary'], 12)) ?></td>
							<td><?= (int) $s['sort_order'] ?></td>
							<td><a href="<?= base_url('admin/services/toggle/'.$s['id']) ?>"><?= status_pill($s['is_active'] ? 'published' : 'draft') ?></a></td>
							<td>
								<div class="row-actions" style="justify-content:flex-end;">
									<a href="<?= base_url('admin/services/edit/'.$s['id']) ?>" class="icon-btn"><?= bloom_icon('edit', 16) ?></a>
									<a href="<?= base_url('admin/services/delete/'.$s['id']) ?>" class="icon-btn danger" data-confirm="Delete this service?"><?= bloom_icon('trash', 16) ?></a>
								</div>
							</td>
						</tr>
					<?php endforeach; ?>
					</tbody>
				</table>
			</div>
		<?php else: ?>
			<div class="empty"><?= bloom_icon('sparkle', 44) ?><p>No services yet. Add your first service offering.</p></div>
		<?php endif; ?>
	</div>
</div>
