<?php
require_once __DIR__ . '/../app/bootstrap.php';
use App\Core\Database;
$brands=Database::safeFetchAll('SELECT b.*,COUNT(p.id) product_count FROM brands b LEFT JOIN products p ON p.brand_id=b.id AND p.status="published" WHERE b.status="active" GROUP BY b.id ORDER BY b.name');
$pageTitle='Brands | '.BRAND_NAME; require ROOT_PATH.'/app/Layouts/frontend_header.php';
?>
<section class="container py-5"><div class="landing-hero p-4 p-lg-5 mb-4"><h1>Brands</h1><p class="lead mb-0">Explore products from active marketplace brands.</p></div><div class="row g-4">
<?php if(!$brands): ?><div class="col-12"><div class="alert alert-info">No active brands found.</div></div><?php endif; ?>
<?php foreach($brands as $b): ?><div class="col-sm-6 col-lg-3"><div class="card module-card h-100"><div class="card-body text-center"><?php if(!empty($b['logo'])): ?><img src="<?= e(product_image(['image'=>$b['logo']])) ?>" alt="<?= e($b['name']) ?>" class="img-fluid mb-3" style="max-height:90px"><?php endif; ?><h5><?= e($b['name']) ?></h5><p class="small text-muted"><?= e($b['description'] ?? '') ?></p><p><span class="badge bg-light text-dark"><?= (int)$b['product_count'] ?> products</span></p><a class="btn btn-outline-primary btn-sm" href="<?= url('brand/'.$b['slug']) ?>">View Brand</a></div></div></div><?php endforeach; ?>
</div></section><?php require ROOT_PATH.'/app/Layouts/frontend_footer.php'; ?>
