<?php
require_once __DIR__ . '/../auth/verifica.php';
require_once __DIR__ . '/../config/conexao.php';
$id = intval($_GET['id'] ?? 0);
if ($id > 0) {
    $stmt = $pdo->prepare("SELECT status FROM categorias WHERE id = :id");
    $stmt->execute(['id' => $id]);
    $c = $stmt->fetch();
    if ($c) {
        $novo = $c['status'] === 'ativo' ? 'inativo' : 'ativo';
        $pdo->prepare("UPDATE categorias SET status = :s WHERE id = :id")->execute(['s' => $novo, 'id' => $id]);
    }
}
header("Location: categorias.php"); exit;
