<?php
declare(strict_types=1);

require_once __DIR__.'/../../security/auth_guard.php';
require_once __DIR__.'/../../config/database.php';
require_once __DIR__.'/../../core/Response.php';

if(($_SESSION['role']??'')!=='seo_manager'){
 Response::error('Permission denied',403);
}

$data=json_decode(file_get_contents('php://input'),true);
if(!is_array($data)) Response::error('Invalid JSON',400);

$imageId=$data['image_id']??null;
if(!is_numeric($imageId)) Response::error('image_id is required',422);

$db=Database::getInstance();
$stmt=$db->prepare("UPDATE dealer_images SET is_deleted=1,is_active=0 WHERE id=:i LIMIT 1");
$stmt->execute(['i'=>(int)$imageId]);

Response::success('Image deleted');
