<?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('plan_features', function (Blueprint $table) {
            $table->id();
            $table->string('name'); // e.g., 'email_forwarding', 'auto_reply_rules'
            $table->string('display_name'); // e.g., 'Email Forwarding', 'Auto-Reply Rules'
            $table->text('description')->nullable();
            $table->string('category'); // e.g., 'core', 'advanced', 'premium'
            $table->string('type'); // e.g., 'boolean', 'numeric', 'toggle'
            $table->json('metadata')->nullable(); // Additional feature-specific data
            $table->boolean('is_active')->default(true);
            $table->integer('sort_order')->default(0);
            $table->timestamps();

            $table->unique(['name']);
            $table->index(['category', 'is_active']);
        });
    }

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