<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->enum('user_type', ['individual', 'company'])->default('individual')->after('email');
            $table->string('first_name')->nullable()->after('name');
            $table->string('last_name')->nullable()->after('first_name');
            $table->string('phone')->nullable()->after('email');
            
            // Câmpuri pentru persoană juridică
            $table->string('company_cui')->nullable()->after('phone');
            $table->string('company_name')->nullable()->after('company_cui');
            $table->string('company_reg_com')->nullable()->after('company_name');
            $table->string('company_address')->nullable()->after('company_reg_com');
            $table->string('company_number')->nullable()->after('company_address');
            $table->string('company_city')->nullable()->after('company_number');
            $table->string('company_county')->nullable()->after('company_city');
            $table->string('company_postal_code')->nullable()->after('company_county');
            $table->string('company_country')->default('Romania')->after('company_postal_code');
            
            $table->boolean('terms_accepted')->default(false)->after('company_country');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn([
                'user_type',
                'first_name',
                'last_name',
                'phone',
                'company_cui',
                'company_name',
                'company_reg_com',
                'company_address',
                'company_number',
                'company_city',
                'company_county',
                'company_postal_code',
                'company_country',
                'terms_accepted'
            ]);
        });
    }
};
