<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // Add admin management fields to inquiries table
        Schema::table('inquiries', function (Blueprint $table) {
            $table->unsignedBigInteger('assigned_by_admin_id')->nullable()->after('product_id');
            $table->timestamp('assigned_at')->nullable()->after('assigned_by_admin_id');
            $table->enum('admin_status', ['pending', 'assigned', 'rejected'])->default('pending')->after('assigned_at');
            $table->text('admin_notes')->nullable()->after('admin_status');
            
            $table->foreign('assigned_by_admin_id')->references('id')->on('users')->onDelete('set null');
        });

        // Add notification settings to sellers table
        Schema::table('sellers', function (Blueprint $table) {
            $table->boolean('notification_enabled')->default(false)->after('is_verified');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('inquiries', function (Blueprint $table) {
            $table->dropForeign(['assigned_by_admin_id']);
            $table->dropColumn(['assigned_by_admin_id', 'assigned_at', 'admin_status', 'admin_notes']);
        });

        Schema::table('sellers', function (Blueprint $table) {
            $table->dropColumn('notification_enabled');
        });
    }
};
