<?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
    {
        Schema::create('homepage_widgets', function (Blueprint $table) {
            $table->id();
            $table->enum('widget_type', ['hero', 'stats', 'features', 'blog_posts', 'forum_topics', 'cta', 'adsense', 'custom_html']);
            $table->string('title')->nullable();
            $table->json('content')->nullable();
            $table->boolean('is_active')->default(true);
            $table->integer('sort_order')->default(0);
            $table->enum('width', ['full', 'half'])->default('full');
            $table->string('position')->default('main')->nullable();
            $table->timestamps();

            $table->index(['is_active', 'sort_order']);
            $table->index('widget_type');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('homepage_widgets');
    }
};
