@extends('layouts.app')

@section('title', 'Settings')

@section('content')
    <x-breadcrumbs :items="[
        ['label' => 'Dashboard', 'url' => route('dashboard')],
        ['label' => 'Administration'],
        ['label' => 'Settings'],
    ]" />

    <x-page-header title="Application Settings" subtitle="Property defaults, numbering, and document terms" />

    <form method="POST" action="{{ route('admin.settings.update') }}">
        @csrf
        @method('PUT')

        <div class="row g-4">
            <div class="col-lg-6">
                <x-card title="Property">
                    <x-form.input label="Property Name" name="property_name" :value="$settings['property_name'] ?? ''" required />
                    <x-form.input label="Company Address" name="company_address" :value="$settings['company_address'] ?? ''" />
                    <x-form.input label="Company Phone" name="company_phone" :value="$settings['company_phone'] ?? ''" />
                    <x-form.input label="Company Email" name="company_email" type="email" :value="$settings['company_email'] ?? ''" />
                </x-card>

                <x-card title="Regional" class="mt-4">
                    <x-form.input label="Timezone" name="timezone" :value="$settings['timezone'] ?? ''" required />
                    <x-form.input label="Currency Code" name="currency" :value="$settings['currency'] ?? ''" required />
                    <x-form.input label="Currency Symbol" name="currency_symbol" :value="$settings['currency_symbol'] ?? ''" required />
                    <x-form.input label="Date Format" name="date_format" :value="$settings['date_format'] ?? ''" required help="e.g. d/m/Y" />
                    <x-form.input label="Time Format" name="time_format" :value="$settings['time_format'] ?? ''" required help="e.g. H:i" />
                </x-card>
            </div>

            <div class="col-lg-6">
                <x-card title="Financial Defaults">
                    <x-form.input label="Default Tax (%)" name="default_tax" type="number" step="0.01" :value="$settings['default_tax'] ?? ''" required />
                    <x-form.input label="Default Service Charge (%)" name="default_service_charge" type="number" step="0.01" :value="$settings['default_service_charge'] ?? ''" required />
                    <x-form.input label="Default Deposit (%)" name="default_deposit_percentage" type="number" step="0.01" :value="$settings['default_deposit_percentage'] ?? ''" required />
                    <x-form.input label="Quotation Validity (days)" name="default_quotation_validity_days" type="number" :value="$settings['default_quotation_validity_days'] ?? ''" required />
                    <x-form.input label="Hold Duration (hours)" name="default_hold_duration_hours" type="number" :value="$settings['default_hold_duration_hours'] ?? ''" required />
                </x-card>

                <x-card title="Document Numbering" class="mt-4">
                    <div class="row">
                        <div class="col-6">
                            <x-form.input label="Booking Prefix" name="booking_prefix" :value="$settings['booking_prefix'] ?? ''" required />
                            <x-form.input label="Quotation Prefix" name="quotation_prefix" :value="$settings['quotation_prefix'] ?? ''" required />
                        </div>
                        <div class="col-6">
                            <x-form.input label="Invoice Prefix" name="invoice_prefix" :value="$settings['invoice_prefix'] ?? ''" required />
                            <x-form.input label="Payment Prefix" name="payment_prefix" :value="$settings['payment_prefix'] ?? ''" required />
                        </div>
                    </div>
                    <x-form.input label="Number Padding" name="number_padding" type="number" :value="$settings['number_padding'] ?? ''" required />
                </x-card>
            </div>
        </div>

        <div class="mt-4">
            <button type="submit" class="btn btn-primary">
                <i class="bi bi-check-lg me-1" aria-hidden="true"></i> Save Settings
            </button>
        </div>
    </form>
@endsection
