<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/** PARTNERS LIST — Expects: $partners. */
?>
<div class="page-head">
	<div><h2>Partners</h2><p>Manage client and partner logos shown across the site.</p></div>
	<a href="<?= base_url('admin/partners/create') ?>" class="btn btn-primary"><?= bloom_icon('plus', 16) ?> Add Partner</a>
</div>

<div class="card"><div class="card-body flush">
	<?php if ($partners): ?>
		<div class="table-wrap">
			<table class="data">
				<thead><tr><th>Logo</th><th>Name</th><th>Category</th><th>Featured</th><th>Status</th><th class="text-right">Actions</th></tr></thead>
				<tbody>
				<?php foreach ($partners as $p): ?>
					<tr>
						<td>
							<?php if ($p['logo']): ?>
								<img class="thumb" style="object-fit:contain;background:#f4f1f5;" src="<?= upload_url($p['logo']) ?>" alt="">
							<?php else: ?>
								<div class="thumb" style="display:grid;place-items:center;"><?= bloom_icon('handshake', 18) ?></div>
							<?php endif; ?>
						</td>
						<td><div class="row-title"><?= html_escape($p['name']) ?></div>
							<?php if ($p['website']): ?><div class="row-sub"><?= html_escape($p['website']) ?></div><?php endif; ?></td>
						<td><span class="pill pill-grey"><?= html_escape(ucfirst($p['category'])) ?></span></td>
						<td><a href="<?= base_url('admin/partners/feature/'.$p['id']) ?>"><?= $p['is_featured'] ? '<span class="pill pill-amber">★</span>' : '<span class="pill pill-grey">—</span>' ?></a></td>
						<td><a href="<?= base_url('admin/partners/toggle/'.$p['id']) ?>"><?= status_pill($p['is_active'] ? 'published' : 'draft') ?></a></td>
						<td><div class="row-actions" style="justify-content:flex-end;">
							<a href="<?= base_url('admin/partners/edit/'.$p['id']) ?>" class="icon-btn"><?= bloom_icon('edit', 16) ?></a>
							<a href="<?= base_url('admin/partners/delete/'.$p['id']) ?>" class="icon-btn danger" data-confirm="Delete this partner?"><?= bloom_icon('trash', 16) ?></a>
						</div></td>
					</tr>
				<?php endforeach; ?>
				</tbody>
			</table>
		</div>
	<?php else: ?>
		<div class="empty"><?= bloom_icon('handshake', 44) ?><p>No partners yet. Add your first client logo.</p></div>
	<?php endif; ?>
</div></div>
