<?php

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

/**
 * PRC-1143 — konsolide şema: `brands` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('brands', function (Blueprint $t) {
            $t->id();
            $t->unsignedBigInteger('reseller_id')->nullable();
            $t->string('name', 255);
            $t->string('slug', 255);
            $t->string('domain', 255)->nullable();
            $t->string('domain_verification_token', 255)->nullable();
            $t->boolean('domain_verified')->default(0);
            $t->timestamp('domain_verified_at')->nullable();
            $t->string('logo', 255)->nullable();
            $t->string('favicon', 255)->nullable();
            $t->string('theme', 255)->default('default');
            $t->string('primary_color', 20)->nullable();
            $t->string('secondary_color', 20)->nullable();
            $t->text('footer_text')->nullable();
            $t->string('contact_email', 255)->nullable();
            $t->string('contact_phone', 255)->nullable();
            $t->json('visible_product_groups')->nullable();
            $t->json('visible_tlds')->nullable();
            $t->string('default_language', 255)->default('en');
            $t->string('default_currency', 255)->default('TRY');
            $t->json('settings')->nullable();
            $t->json('email_settings')->nullable();
            $t->json('seo_overrides')->nullable();
            $t->text('custom_css')->nullable();
            $t->text('custom_js')->nullable();
            $t->boolean('is_default')->default(0);
            $t->boolean('is_active')->default(1);
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->unique('domain', 'brands_domain_unique');
            $t->index('reseller_id', 'brands_reseller_id_index');
            $t->unique('slug', 'brands_slug_unique');
        });
    }

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