<?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::create('company_profiles', function (Blueprint $table) {
            $table->id();
            $table->string('company_name_en');
            $table->string('company_name_ar')->nullable();
            $table->string('trade_name')->nullable();
            $table->string('legal_name')->nullable();
            $table->string('vat_number')->nullable();
            $table->string('cr_number')->nullable();
            $table->string('building_number')->nullable();
            $table->string('street_name_en')->nullable();
            $table->string('street_name_ar')->nullable();
            $table->string('district_en')->nullable();
            $table->string('district_ar')->nullable();
            $table->string('city_en')->nullable();
            $table->string('city_ar')->nullable();
            $table->string('postal_code')->nullable();
            $table->string('additional_number')->nullable();
            $table->string('country')->default('Saudi Arabia');
            $table->string('country_code')->default('+966');
            $table->string('phone')->nullable();
            $table->string('mobile')->nullable();
            $table->string('email')->nullable();
            $table->string('website')->nullable();
            $table->string('logo_path')->nullable();
            $table->string('invoice_logo_path')->nullable();
            $table->string('company_stamp_path')->nullable();
            $table->string('authorized_signature_path')->nullable();
            $table->string('bank_name')->nullable();
            $table->string('bank_account_name')->nullable();
            $table->string('account_number')->nullable();
            $table->string('iban')->nullable();
            $table->string('default_currency')->default('SAR');
            $table->string('currency_display')->default('SAR');
            $table->boolean('vat_registered')->default(true);
            $table->decimal('default_vat_rate', 5, 2)->default(15.00);
            $table->text('tax_invoice_footer_en')->nullable();
            $table->text('tax_invoice_footer_ar')->nullable();
            $table->text('terms_conditions_en')->nullable();
            $table->text('terms_conditions_ar')->nullable();
            $table->string('received_by_label')->default('Received By / المستلم');
            $table->timestamps();
        });

        Schema::create('vat_settings', function (Blueprint $table) {
            $table->id();
            $table->string('zatca_mode')->default('Phase 1');
            $table->boolean('vat_registered')->default(true);
            $table->string('vat_number')->nullable();
            $table->decimal('default_vat_rate', 5, 2)->default(15.00);
            $table->boolean('invoice_qr_enabled')->default(true);
            $table->boolean('simplified_qr_mandatory')->default(true);
            $table->boolean('tax_invoice_qr_enabled')->default(true);
            $table->string('qr_size')->default('Medium');
            $table->string('invoice_language')->default('Bilingual');
            $table->string('price_mode')->default('Exclusive VAT');
            $table->string('default_invoice_type')->default('Tax Invoice');
            $table->timestamps();
        });
    }

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