@extends('layouts.app')
@section('title', __('nav.settings'))
@section('content')
<h1 class="h4 mb-3">{{ __('nav.settings') }}</h1>
<form method="post" action="{{ route('settings.update') }}" enctype="multipart/form-data" class="card card-body">
@csrf @method('PUT')
<div class="row g-3">
<div class="col-md-6"><label class="form-label">{{ __('messages.company_name') }}</label><input class="form-control" name="company_name" value="{{ $settings['company_name'] ?? '' }}" required></div>
<div class="col-md-6">
    <label class="form-label">{{ __('messages.logo') }}</label>
    @if(company_logo_url($settings['company_logo'] ?? null))
        <div class="d-flex align-items-center gap-3 mb-2">
            <img src="{{ company_logo_url($settings['company_logo'] ?? null) }}" alt="{{ __('messages.current_logo') }}" class="border rounded bg-white p-1" style="max-height:64px;max-width:160px;object-fit:contain">
            <span class="small text-muted">{{ __('messages.current_logo') }}</span>
        </div>
    @endif
    <input class="form-control" type="file" name="company_logo" accept=".jpg,.jpeg,.png,.gif,.webp,image/png,image/jpeg,image/webp,image/gif">
    <div class="form-text">{{ __('messages.logo_hint') }}</div>
</div>
<div class="col-md-6"><label class="form-label">{{ __('messages.phone') }}</label><input class="form-control" name="company_phone" value="{{ $settings['company_phone'] ?? '' }}"></div>
<div class="col-md-6"><label class="form-label">{{ __('messages.email') }}</label><input class="form-control" name="company_email" value="{{ $settings['company_email'] ?? '' }}"></div>
<div class="col-12"><label class="form-label">{{ __('messages.address') }}</label><input class="form-control" name="company_address" value="{{ $settings['company_address'] ?? '' }}"></div>
<div class="col-md-3"><label class="form-label">{{ __('messages.currency') }}</label><input class="form-control" name="currency" value="{{ $settings['currency'] ?? 'EGP' }}"></div>
<div class="col-md-3"><label class="form-label">{{ __('messages.tax') }}</label><input class="form-control" name="tax_rate" value="{{ $settings['tax_rate'] ?? 0 }}"></div>
<div class="col-md-3"><label class="form-label">{{ __('messages.invoice_prefix') }}</label><input class="form-control" name="invoice_prefix" value="{{ $settings['invoice_prefix'] ?? 'INV' }}"></div>
<div class="col-md-3"><label class="form-label">{{ __('messages.default_language') }}</label><select class="form-select" name="default_language"><option value="ar">{{ __('messages.arabic') }}</option><option value="en" @selected(($settings['default_language'] ?? '')==='en')>{{ __('messages.english') }}</option></select></div>
<div class="col-md-4"><label class="form-label">{{ __('messages.payment_method') }}</label><select class="form-select" name="default_payment_method">@foreach(['cash','visa','bank','wallet','other'] as $m)<option value="{{ $m }}" @selected(($settings['default_payment_method'] ?? 'cash')===$m)>{{ __('status.method_'.$m) }}</option>@endforeach</select></div>
<div class="col-md-4"><label class="form-label">{{ __('messages.printer_type') }}</label><select class="form-select" name="printer_type"><option value="a4" @selected(($settings['printer_type'] ?? 'a4')==='a4')>A4</option><option value="thermal" @selected(($settings['printer_type'] ?? '')==='thermal')>{{ __('messages.thermal') }}</option></select></div>
<div class="col-md-4"><label class="form-label">{{ __('messages.date_format') }}</label><input class="form-control" name="date_format" value="{{ $settings['date_format'] ?? 'Y-m-d' }}"></div>
<div class="col-md-4"><label class="form-label">{{ __('messages.timezone') }}</label><input class="form-control" name="timezone" value="{{ $settings['timezone'] ?? 'Africa/Cairo' }}"></div>
<div class="col-md-4"><label class="form-label">{{ __('messages.backup_retention_days') }}</label><input class="form-control" name="backup_retention_days" value="{{ $settings['backup_retention_days'] ?? 30 }}"></div>
<div class="col-12"><label class="form-label">{{ __('messages.invoice_footer') }}</label><textarea class="form-control" name="invoice_footer">{{ $settings['invoice_footer'] ?? '' }}</textarea></div>
</div>
<button class="btn btn-success mt-3">{{ __('messages.save') }}</button>
</form>
@endsection
