<?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::table('organizations', function (Blueprint $table): void {
            $table->string('widget_title')->nullable()->after('widget_allowed_origins');
            $table->string('widget_subtitle')->nullable()->after('widget_title');
            $table->string('widget_status_message')->nullable()->after('widget_subtitle');
            $table->text('widget_greeting')->nullable()->after('widget_status_message');
            $table->string('widget_launcher_label', 40)->nullable()->after('widget_greeting');
            $table->string('widget_accent_color', 20)->nullable()->after('widget_launcher_label');
            $table->string('widget_logo_url', 2048)->nullable()->after('widget_accent_color');
            $table->text('widget_quick_replies')->nullable()->after('widget_logo_url');
            $table->string('widget_position', 20)->default('bottom-right')->after('widget_quick_replies');
            $table->boolean('widget_powered_by_branding')->default(true)->after('widget_position');
        });
    }

    public function down(): void
    {
        Schema::table('organizations', function (Blueprint $table): void {
            $table->dropColumn([
                'widget_title',
                'widget_subtitle',
                'widget_status_message',
                'widget_greeting',
                'widget_launcher_label',
                'widget_accent_color',
                'widget_logo_url',
                'widget_quick_replies',
                'widget_position',
                'widget_powered_by_branding',
            ]);
        });
    }
};
