<?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('sellers', function (Blueprint $table) {
            // Fix: Add missing social columns if they don't exist
            if (!Schema::hasColumn('sellers', 'facebook')) $table->string('facebook')->nullable();
            if (!Schema::hasColumn('sellers', 'twitter')) $table->string('twitter')->nullable();
            if (!Schema::hasColumn('sellers', 'linkedin')) $table->string('linkedin')->nullable();
            if (!Schema::hasColumn('sellers', 'instagram')) $table->string('instagram')->nullable();

            // Add new columns
            if (!Schema::hasColumn('sellers', 'theme_color')) {
                $table->string('theme_color')->default('#0d6efd')->after('instagram');
            }
            if (!Schema::hasColumn('sellers', 'google_map_embed')) {
                $table->text('google_map_embed')->nullable()->after('theme_color');
            }
        });
    }

    public function down(): void
    {
        Schema::table('sellers', function (Blueprint $table) {
            $table->dropColumn(['theme_color', 'google_map_embed']);
        });
    }
};
