<?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('forms', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->uuid('uuid')->unique();
            $table->string('type')->default('inline'); // inline|popup
            $table->string('status')->default('draft'); // draft|active|paused
            $table->json('fields')->nullable();
            $table->json('settings')->nullable();
            $table->json('style')->nullable();
            $table->unsignedInteger('total_views')->default(0);
            $table->unsignedInteger('total_submissions')->default(0);
            $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
            $table->timestamps();
        });
    }

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