<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('contact_requests', function (Blueprint $table) {
            $table->id();
            $table->string('name', 150);
            $table->string('email', 191);
            $table->string('organization', 191)->nullable();
            $table->string('phone', 60)->nullable();
            $table->text('message')->nullable();
            $table->string('source', 60)->default('website_contact_form');
            $table->string('status', 30)->default('new'); // new | in_progress | resolved | archived
            $table->string('ip_address', 60)->nullable();
            $table->string('user_agent', 255)->nullable();
            $table->text('admin_notes')->nullable();
            $table->timestamp('read_at')->nullable();
            $table->timestamp('responded_at')->nullable();
            $table->timestamps();

            $table->index('status');
            $table->index('created_at');
            $table->index('email');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('contact_requests');
    }
};
