<?php require_roles('super_admin');$banners=db()->query('SELECT * FROM banners ORDER BY sort_order,id DESC')->fetchAll();?>
<section class="panel"><div class="panel-header"><div><h2>Banners e anúncios</h2><p>Gerencie destaques da página inicial, painel e marketplace.</p></div><button class="btn btn-primary" data-modal-open="#bannerModal">+ Novo banner</button></div><div class="cards-list"><?php foreach($banners as $item):?><article class="item-card"><div class="item-cover"><?php if($item['image']):?><img src="<?= e(media_url($item['image'])) ?>" alt=""><?php else:?>✨<?php endif;?><?= status_badge($item['status']) ?></div><div class="item-body"><h3><?= e($item['title']) ?></h3><p><?= e($item['subtitle']) ?></p><div class="item-meta"><span><?= e($item['position']) ?></span><span>Ordem <?= (int)$item['sort_order'] ?></span></div><div class="actions"><button class="btn btn-secondary btn-sm" data-modal-open="#bannerModal<?= (int)$item['id'] ?>">Editar</button><form method="post" action="actions.php"><?= csrf_field() ?><input type="hidden" name="action" value="toggle_banner"><input type="hidden" name="return_page" value="banners"><input type="hidden" name="id" value="<?= (int)$item['id'] ?>"><button class="btn btn-sm <?= $item['status']==='active'?'btn-danger':'btn-accent' ?>" type="submit"><?= $item['status']==='active'?'Ocultar':'Ativar' ?></button></form><form method="post" action="actions.php"><?=csrf_field()?><input type="hidden" name="action" value="delete_banner"><input type="hidden" name="return_page" value="banners"><input type="hidden" name="id" value="<?=(int)$item['id']?>"><button class="btn btn-danger btn-sm" data-confirm="Apagar definitivamente este banner?">Apagar</button></form></div></div></article><div class="modal" id="bannerModal<?= (int)$item['id'] ?>"><div class="modal-card"><div class="modal-head"><h2>Editar banner</h2><button class="close-btn" data-modal-close>×</button></div><?php include __DIR__.'/_banner_form.php';?></div></div><?php endforeach;?></div></section>
<div class="modal" id="bannerModal"><div class="modal-card"><div class="modal-head"><h2>Novo banner</h2><button class="close-btn" data-modal-close>×</button></div><?php $item=['id'=>'','title'=>'','subtitle'=>'','image'=>'','link'=>'','position'=>'home','status'=>'active','sort_order'=>0];include __DIR__.'/_banner_form.php';?></div></div>
