<?php
/** AURA FARMING — Etapa 22: lista pessoal de bloqueios */
require_once __DIR__.'/../config/config.php';require_once __DIR__.'/../config/database.php';require_once __DIR__.'/../includes/functions.php';requireLogin();$uid=(int)$_SESSION['usuario_id'];
if($_SERVER['REQUEST_METHOD']==='POST'){
 try{if(!validarCsrfToken($_POST[CSRF_TOKEN_NAME]??''))throw new RuntimeException('Sessão expirada.');$target=(int)($_POST['user_id']??0);afModerationUnblockUser($pdo,$uid,$target);setFlash('success','Usuário desbloqueado.');}
 catch(Throwable $e){setFlash('error',$e->getMessage());}
 header('Location: '.SITE_URL.'/pages/bloqueios.php');exit;
}
$st=$pdo->prepare("SELECT b.*,u.nome,u.username,u.aura_id,u.foto_perfil,u.foto_externa FROM af_user_blocks b JOIN af_usuarios u ON u.id=b.blocked_user_id WHERE b.blocker_user_id=? AND b.active=1 ORDER BY b.updated_at DESC");$st->execute([$uid]);$items=$st->fetchAll()?:[];
$pageTitle='Usuários bloqueados';$activePage='perfil';require __DIR__.'/../includes/header.php';
?>
<header class="app-header"><a href="<?=SITE_URL?>/pages/seguranca.php" class="btn-back">← Segurança</a><div class="logo-inline"><span class="logo-main">AURA</span><span class="logo-sub">SAFE</span></div><span></span></header>
<main class="page-content"><?=renderFlash()?>
<section class="card card--glow"><p class="eyebrow">CONTROLE DE INTERAÇÕES</p><h1>Usuários bloqueados</h1><p class="text-muted">Contas bloqueadas não podem seguir, assistir, comentar ou interagir com você.</p></section>
<div class="moderation-block-list"><?php if(!$items):?><div class="empty-state"><span>🛡️</span><h3>Nenhum usuário bloqueado</h3></div><?php endif;?><?php foreach($items as $item):?><article class="card moderation-block-card"><img src="<?=esc(urlAvatar($item['foto_perfil']??null,$item['foto_externa']??null))?>" alt=""><div><b><?=esc($item['nome'])?></b><span><?=esc($item['aura_id'])?> • bloqueado em <?=date('d/m/Y',strtotime($item['updated_at']))?></span></div><form method="post"><?=camposCsrf()?><input type="hidden" name="user_id" value="<?=(int)$item['blocked_user_id']?>"><button class="btn btn-secondary">DESBLOQUEAR</button></form></article><?php endforeach;?></div>
</main><?php require __DIR__.'/../includes/navbar.php';require __DIR__.'/../includes/footer.php';?>
