@extends('layouts.app')

@section('title', __('messages.company_profile'))

@section('content')
<div class="d-flex align-items-center justify-content-between mb-3">
    <div>
        <h5 class="fw-bold mb-0">{{ __('messages.company_profile') }}</h5>
        <span class="text-muted fs-xs">Company Name, Saudi Tax Registration, Addresses & Invoice Templates</span>
    </div>
</div>

<div class="card-erp p-3">
    <form method="POST" action="{{ route('settings.company.update') }}" enctype="multipart/form-data">
        @csrf

        <div class="row g-3 mb-3">
            <div class="col-md-6">
                <label class="form-label small fw-semibold">Company Name (English) <span class="text-danger">*</span></label>
                <input type="text" name="company_name_en" class="form-control form-control-sm" value="{{ old('company_name_en', $company->company_name_en) }}" required>
            </div>
            <div class="col-md-6">
                <label class="form-label small fw-semibold">Company Name (Arabic) / اسم الشركة بالعربي</label>
                <input type="text" name="company_name_ar" class="form-control form-control-sm" value="{{ old('company_name_ar', $company->company_name_ar) }}">
            </div>

            <div class="col-md-4">
                <label class="form-label small fw-semibold">Trade Name</label>
                <input type="text" name="trade_name" class="form-control form-control-sm" value="{{ old('trade_name', $company->trade_name) }}">
            </div>
            <div class="col-md-4">
                <label class="form-label small fw-semibold">VAT Registration Number (15 Digits)</label>
                <input type="text" name="vat_number" class="form-control form-control-sm font-monospace fw-bold" value="{{ old('vat_number', $company->vat_number) }}" placeholder="302176698800003">
            </div>
            <div class="col-md-4">
                <label class="form-label small fw-semibold">Commercial Registration (CR Number)</label>
                <input type="text" name="cr_number" class="form-control form-control-sm" value="{{ old('cr_number', $company->cr_number) }}">
            </div>
        </div>

        <h6 class="fw-bold border-bottom pb-2 mt-4 text-primary"><i class="bi bi-geo-alt me-1"></i> Saudi National Address Details</h6>
        <div class="row g-3 mb-3">
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Building Number</label>
                <input type="text" name="building_number" class="form-control form-control-sm" value="{{ old('building_number', $company->building_number) }}" placeholder="1234">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Street Name (EN)</label>
                <input type="text" name="street_name_en" class="form-control form-control-sm" value="{{ old('street_name_en', $company->street_name_en) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Street Name (AR)</label>
                <input type="text" name="street_name_ar" class="form-control form-control-sm" value="{{ old('street_name_ar', $company->street_name_ar) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">District (EN)</label>
                <input type="text" name="district_en" class="form-control form-control-sm" value="{{ old('district_en', $company->district_en) }}">
            </div>

            <div class="col-md-3">
                <label class="form-label small fw-semibold">District (AR)</label>
                <input type="text" name="district_ar" class="form-control form-control-sm" value="{{ old('district_ar', $company->district_ar) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">City (EN)</label>
                <input type="text" name="city_en" class="form-control form-control-sm" value="{{ old('city_en', $company->city_en) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">City (AR)</label>
                <input type="text" name="city_ar" class="form-control form-control-sm" value="{{ old('city_ar', $company->city_ar) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Postal Code</label>
                <input type="text" name="postal_code" class="form-control form-control-sm" value="{{ old('postal_code', $company->postal_code) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Additional Number</label>
                <input type="text" name="additional_number" class="form-control form-control-sm" value="{{ old('additional_number', $company->additional_number) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Country</label>
                <input type="text" name="country" class="form-control form-control-sm" value="{{ old('country', $company->country) }}" required>
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Country Code</label>
                <input type="text" name="country_code" class="form-control form-control-sm" value="{{ old('country_code', $company->country_code) }}" required>
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Phone / Mobile</label>
                <input type="text" name="phone" class="form-control form-control-sm" value="{{ old('phone', $company->phone) }}">
            </div>
        </div>

        <h6 class="fw-bold border-bottom pb-2 mt-4 text-primary"><i class="bi bi-bank me-1"></i> Banking & Currency</h6>
        <div class="row g-3 mb-3">
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Bank Name</label>
                <input type="text" name="bank_name" class="form-control form-control-sm" value="{{ old('bank_name', $company->bank_name) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Bank Account Name</label>
                <input type="text" name="bank_account_name" class="form-control form-control-sm" value="{{ old('bank_account_name', $company->bank_account_name) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Account Number</label>
                <input type="text" name="account_number" class="form-control form-control-sm" value="{{ old('account_number', $company->account_number) }}">
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">IBAN</label>
                <input type="text" name="iban" class="form-control form-control-sm" value="{{ old('iban', $company->iban) }}">
            </div>

            <div class="col-md-3">
                <label class="form-label small fw-semibold">Default Currency</label>
                <input type="text" name="default_currency" class="form-control form-control-sm" value="{{ old('default_currency', $company->default_currency) }}" required readonly>
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Currency Display</label>
                <input type="text" name="currency_display" class="form-control form-control-sm" value="{{ old('currency_display', $company->currency_display) }}" required>
            </div>
            <div class="col-md-3">
                <label class="form-label small fw-semibold">Default VAT Rate (%)</label>
                <input type="number" step="0.01" name="default_vat_rate" class="form-control form-control-sm" value="{{ old('default_vat_rate', $company->default_vat_rate) }}" required>
            </div>
            <div class="col-md-3 align-self-end">
                <div class="form-check">
                    <input type="checkbox" name="vat_registered" value="1" class="form-check-input" id="vatReg" {{ old('vat_registered', $company->vat_registered) ? 'checked' : '' }}>
                    <label class="form-check-label small fw-semibold" for="vatReg">
                        VAT Registered Company
                    </label>
                </div>
            </div>
        </div>

        <h6 class="fw-bold border-bottom pb-2 mt-4 text-primary"><i class="bi bi-file-earmark-text me-1"></i> Tax Invoice Footers & Terms</h6>
        <div class="row g-3 mb-3">
            <div class="col-md-6">
                <label class="form-label small fw-semibold">Tax Invoice Footer (English)</label>
                <textarea name="tax_invoice_footer_en" class="form-control form-control-sm" rows="2">{{ old('tax_invoice_footer_en', $company->tax_invoice_footer_en) }}</textarea>
            </div>
            <div class="col-md-6">
                <label class="form-label small fw-semibold">Tax Invoice Footer (Arabic)</label>
                <textarea name="tax_invoice_footer_ar" class="form-control form-control-sm" rows="2">{{ old('tax_invoice_footer_ar', $company->tax_invoice_footer_ar) }}</textarea>
            </div>
            <div class="col-md-6">
                <label class="form-label small fw-semibold">Terms & Conditions (English)</label>
                <textarea name="terms_conditions_en" class="form-control form-control-sm" rows="2">{{ old('terms_conditions_en', $company->terms_conditions_en) }}</textarea>
            </div>
            <div class="col-md-6">
                <label class="form-label small fw-semibold">Terms & Conditions (Arabic)</label>
                <textarea name="terms_conditions_ar" class="form-control form-control-sm" rows="2">{{ old('terms_conditions_ar', $company->terms_conditions_ar) }}</textarea>
            </div>
            <div class="col-md-4">
                <label class="form-label small fw-semibold">Received By Label</label>
                <input type="text" name="received_by_label" class="form-control form-control-sm" value="{{ old('received_by_label', $company->received_by_label) }}">
            </div>
        </div>

        <div class="d-flex justify-content-end gap-2 mt-4">
            <button type="submit" class="btn btn-sm btn-primary"><i class="bi bi-save me-1"></i> Save Company Profile</button>
        </div>
    </form>
</div>
@endsection
