<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('settings', function (Blueprint $table) {
            $table->id();
            $table->string('key')->unique();
            $table->text('value')->nullable();
            $table->timestamps();
        });

        // Seed defaults
        DB::table('settings')->insert([
            ['key' => 'app_name', 'value' => 'TaskFlow', 'created_at' => now(), 'updated_at' => now()],
            ['key' => 'app_logo', 'value' => null, 'created_at' => now(), 'updated_at' => now()],
            ['key' => 'primary_color', 'value' => '#6366f1', 'created_at' => now(), 'updated_at' => now()],
            ['key' => 'accent_color', 'value' => '#818cf8', 'created_at' => now(), 'updated_at' => now()],
            ['key' => 'sidebar_color', 'value' => '#1a1a2e', 'created_at' => now(), 'updated_at' => now()],
            ['key' => 'sidebar_text_color', 'value' => '#a1a1aa', 'created_at' => now(), 'updated_at' => now()],
        ]);
    }

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