<div>
    <x-layouts.app title="{{ __('Accounting Settings') }}">
        <div class="page-header">
            <h1 class="page-title">{{ __('Accounting Settings') }}</h1>
            <p class="text-muted mb-0">{{ __('Configure Chart of Accounts mappings') }}</p>
        </div>

        <div class="card">
            <div class="card-body">
                <form wire:submit="save">
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Cash Drawer Account') }}</label>
                            <select class="form-select @error('account_cash_drawer') is-invalid @enderror" wire:model="account_cash_drawer">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_cash_drawer') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Cash on Hand (Safe) Account') }}</label>
                            <select class="form-select @error('account_cash_on_hand') is-invalid @enderror" wire:model="account_cash_on_hand">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_cash_on_hand') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Bank Account') }}</label>
                            <select class="form-select @error('account_bank') is-invalid @enderror" wire:model="account_bank">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_bank') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Accounts Receivable') }}</label>
                            <select class="form-select @error('account_receivable') is-invalid @enderror" wire:model="account_receivable">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_receivable') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Inventory Account') }}</label>
                            <select class="form-select @error('account_inventory') is-invalid @enderror" wire:model="account_inventory">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_inventory') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Accounts Payable') }}</label>
                            <select class="form-select @error('account_payable') is-invalid @enderror" wire:model="account_payable">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_payable') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Sales Revenue Account') }}</label>
                            <select class="form-select @error('account_sales_revenue') is-invalid @enderror" wire:model="account_sales_revenue">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_sales_revenue') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Cost of Goods Sold (COGS)') }}</label>
                            <select class="form-select @error('account_cogs') is-invalid @enderror" wire:model="account_cogs">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_cogs') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                         <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Intermediate Sales Account') }}</label>
                            <select class="form-select @error('account_intermediate_sales') is-invalid @enderror" wire:model="account_intermediate_sales">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_intermediate_sales') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Cash Overage Account (Income)') }}</label>
                            <select class="form-select @error('account_cash_overage') is-invalid @enderror" wire:model="account_cash_overage">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_cash_overage') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="form-label">{{ __('Cash Shortage Account (Expense)') }}</label>
                            <select class="form-select @error('account_cash_shortage') is-invalid @enderror" wire:model="account_cash_shortage">
                                <option value="">{{ __('Select Account') }}</option>
                                @foreach($accounts as $account)
                                    <option value="{{ $account->code }}">{{ $account->code }} - {{ $account->localized_name }}</option>
                                @endforeach
                            </select>
                            @error('account_cash_shortage') <div class="invalid-feedback">{{ $message }}</div> @enderror
                        </div>

                    </div>

                    <button type="submit" class="btn btn-primary">
                        <span wire:loading.remove wire:target="save"><i class="fas fa-save me-2"></i>{{ __('Save Settings') }}</span>
                        <span wire:loading wire:target="save"><i class="fas fa-spinner fa-spin me-2"></i>{{ __('Saving...') }}</span>
                    </button>
                </form>
            </div>
        </div>
    </x-layouts.app>
</div>
