@extends('layouts.layoutMaster')

@section('title', __('Create Payment Term'))

@section('content')
<x-breadcrumb
    :title="__('Create Payment Term')"
    :breadcrumbs="[
        ['name' => __('System Core'), 'url' => route('systemcore.dashboard')],
        ['name' => __('Payment Terms'), 'url' => route('systemcore.payment-terms.index')],
        ['name' => __('Create')]
    ]"
/>

<div class="row">
    <div class="col-md-8">
        <form id="paymentTermForm" action="{{ route('systemcore.payment-terms.store') }}" method="POST">
            @csrf

            <div class="card mb-4">
                <div class="card-header">
                    <h5 class="mb-0">{{ __('Payment Term Information') }}</h5>
                </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') }}" 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') }}" required>
                            @error('code')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="col-md-6 mb-3">
                            <label for="days" class="form-label">{{ __('Days') }} <span class="text-danger">*</span></label>
                            <input type="number" class="form-control @error('days') is-invalid @enderror"
                                   id="days" name="days" value="{{ old('days', 0) }}" min="0" required>
                            @error('days')
                                <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', 1) ? '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') }}</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> {{ __('Save Payment Term') }}
                        </button>
                        <a href="{{ route('systemcore.payment-terms.index') }}" class="btn btn-label-secondary">
                            <i class="bx bx-x me-1"></i> {{ __('Cancel') }}
                        </a>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
@endsection
