<?php
define('SECURE_ACCESS', true);
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/database.php';
require_once __DIR__ . '/../includes/functions.php';

$page_title = 'Marcas';
$db = db();
$stmt = $db->query('SELECT * FROM marcas WHERE activo = 1 ORDER BY nombre');
$marcas = $stmt->fetchAll();

require_once __DIR__ . '/../includes/header.php';
?>
<section class="page-header"><div class="container"><h1>Marcas</h1><nav aria-label="breadcrumb"><ol class="breadcrumb mb-0"><li class="breadcrumb-item"><a href="<?= url('') ?>">Inicio</a></li><li class="breadcrumb-item active">Marcas</li></ol></nav></div></section>
<section class="py-5">
  <div class="container">
    <div class="row g-3">
      <?php foreach ($marcas as $m): ?>
      <div class="col-6 col-md-3">
        <a href="<?= url('pages/productos.php?marca=' . $m['slug']) ?>" class="brand-card text-decoration-none text-dark d-block">
          <div class="fw-bold fs-4 text-primary"><?= e($m['nombre']) ?></div>
          <p class="small text-muted mb-0"><?= e($m['descripcion'] ?? 'Ver productos') ?></p>
        </a>
      </div>
      <?php endforeach; ?>
    </div>
  </div>
</section>
<?php require_once __DIR__ . '/../includes/footer.php'; ?>
