<?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('customers', function (Blueprint $table) {
            // Company / billing profile (edited on the customer Settings page).
            $table->string('contact_name')->nullable()->after('name');
            $table->string('phone')->nullable()->after('email');
            $table->string('vat_id')->nullable()->after('phone');
            $table->text('billing_address')->nullable()->after('vat_id');

            // Branding — NULL means "use CluPilot defaults" (resolved deterministically).
            $table->string('brand_display_name')->nullable()->after('billing_address');
            $table->string('brand_logo_path')->nullable()->after('brand_display_name');
            $table->string('brand_primary_color')->nullable()->after('brand_logo_path');
            $table->string('brand_accent_color')->nullable()->after('brand_primary_color');

            // Account lifecycle: set when the customer closes their CluPilot account.
            $table->timestamp('closed_at')->nullable()->after('status');
        });
    }

    public function down(): void
    {
        Schema::table('customers', function (Blueprint $table) {
            $table->dropColumn([
                'contact_name', 'phone', 'vat_id', 'billing_address',
                'brand_display_name', 'brand_logo_path', 'brand_primary_color', 'brand_accent_color',
                'closed_at',
            ]);
        });
    }
};
