@extends('layouts.layoutMaster')

@section('title', __('Edit Tax Configuration'))

@section('content')
<x-breadcrumb
    :title="__('Edit Tax Configuration')"
    :breadcrumbs="[
        ['name' => __('System Core'), 'url' => route('systemcore.dashboard')],
        ['name' => __('Tax Configurations'), 'url' => route('systemcore.tax-configurations.index')],
        ['name' => __('Edit')]
    ]"
/>

<div class="row">
    <div class="col-md-8">
        <form id="taxConfigurationForm" action="{{ route('systemcore.tax-configurations.update', $taxConfiguration->id) }}" method="POST">
            @csrf
            @method('PUT')

            <div class="card mb-4">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h5 class="mb-0">{{ __('Tax Configuration Information') }}</h5>
                    <span class="badge bg-label-primary">{{ $taxConfiguration->code }}</span>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label for="name" class="form-label">{{ __('Name') }} <span class="text-danger">*</span></label>
                            <input type="text" class="form-control @error('name') is-invalid @enderror"
                                   id="name" name="name" value="{{ old('name', $taxConfiguration->name) }}" required>
                            @error('name')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label for="code" class="form-label">{{ __('Code') }} <span class="text-danger">*</span></label>
                            <input type="text" class="form-control @error('code') is-invalid @enderror"
                                   id="code" name="code" value="{{ old('code', $taxConfiguration->code) }}" required>
                            @error('code')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label for="rate" class="form-label">{{ __('Rate (%)') }} <span class="text-danger">*</span></label>
                            <input type="number" step="0.01" class="form-control @error('rate') is-invalid @enderror"
                                   id="rate" name="rate" value="{{ old('rate', $taxConfiguration->rate) }}" min="0" max="100" required>
                            @error('rate')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label for="is_active" class="form-label">{{ __('Status') }}</label>
                            <div class="form-check form-switch mt-2">
                                <input class="form-check-input" type="checkbox" id="is_active" name="is_active" value="1" {{ old('is_active', $taxConfiguration->is_active) ? 'checked' : '' }}>
                                <label class="form-check-label" for="is_active">{{ __('Active') }}</label>
                            </div>
                        </div>

                        <div class="col-md-12 mb-3">
                            <label for="description" class="form-label">{{ __('Description') }}</label>
                            <textarea class="form-control @error('description') is-invalid @enderror"
                                      id="description" name="description" rows="3">{{ old('description', $taxConfiguration->description) }}</textarea>
                            @error('description')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>
                    </div>
                </div>
            </div>

            <div class="card">
                <div class="card-body">
                    <div class="d-flex gap-2">
                        <button type="submit" class="btn btn-primary">
                            <i class="bx bx-save me-1"></i> {{ __('Update Tax Configuration') }}
                        </button>
                        <a href="{{ route('systemcore.tax-configurations.index') }}" class="btn btn-label-secondary">
                            <i class="bx bx-x me-1"></i> {{ __('Cancel') }}
                        </a>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
@endsection
