<?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('homepage_layouts', function (Blueprint $table) {
            $table->id();
            $table->string('name')->unique(); // minimal, modern, corporate, creative, elegant
            $table->string('label');
            $table->text('description')->nullable();
            $table->boolean('is_active')->default(false);
            $table->integer('sort_order')->default(0);
            
            // Layout-specific settings
            $table->string('hero_layout')->default('centered'); // centered, split, full-width, video-bg
            $table->string('hero_content_position')->default('center'); // left, center, right
            $table->boolean('show_hero_badge')->default(true);
            $table->boolean('show_hero_subtitle')->default(true);
            $table->boolean('show_hero_buttons')->default(true);
            
            // Stats section
            $table->string('stats_layout')->default('grid-4'); // grid-4, grid-2, carousel, none
            $table->boolean('show_stats_section')->default(true);
            $table->integer('stats_columns')->default(4);
            
            // Content sections visibility
            $table->boolean('show_blog_section')->default(true);
            $table->integer('blog_columns')->default(4);
            $table->integer('blog_limit')->default(8);
            
            $table->boolean('show_features_section')->default(true);
            $table->integer('features_columns')->default(3);
            
            $table->boolean('show_cta_section')->default(true);
            $table->string('cta_position')->default('bottom'); // top, bottom, middle, none
            
            // Widget settings
            $table->boolean('use_widget_system')->default(true);
            $table->string('widget_order')->default('auto'); // auto, custom
            
            // Custom styles
            $table->text('custom_css')->nullable();
            $table->text('custom_html_before_hero')->nullable();
            $table->text('custom_html_after_hero')->nullable();
            $table->text('custom_html_after_stats')->nullable();
            $table->text('custom_html_before_cta')->nullable();
            $table->text('custom_html_after_cta')->nullable();
            
            // Metadata
            $table->string('preview_image')->nullable();
            $table->json('settings')->nullable();
            
            $table->timestamps();
        });
    }

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