<?php
require_once 'config/db.php';

try {
    $sql = "CREATE TABLE IF NOT EXISTS reports (
        id INT AUTO_INCREMENT PRIMARY KEY,
        reporter_id INT NOT NULL, -- Who reported
        reported_id INT NULL, -- Who was reported (optional if it's general support)
        type ENUM('spam', 'harassment', 'inappropriate', 'bug', 'billing', 'other') NOT NULL,
        description TEXT,
        status ENUM('pending', 'in_progress', 'resolved', 'rejected') DEFAULT 'pending',
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        FOREIGN KEY (reporter_id) REFERENCES users(id),
        FOREIGN KEY (reported_id) REFERENCES users(id)
    )";
    $pdo->exec($sql);
    echo "✅ Table 'reports' created successfully.<br>";

    echo "<hr>🎉 Reports & Support DB Setup Complete!";

} catch (PDOException $e) {
    die("❌ DB Error: " . $e->getMessage());
}
?>
