@if ($errors->any())
    <div class="alert alert-danger py-2 small"><ul class="mb-0">
        @foreach ($errors->all() as $e)<li>{{ $e }}</li>@endforeach
    </ul></div>
@endif

<div class="card border-0 shadow-sm">
    <div class="card-body">
        <form method="POST" action="{{ $action }}" style="max-width: 560px;">
            @csrf
            @if ($method === 'PUT') @method('PUT') @endif
            <div class="mb-3">
                <label class="form-label small fw-medium" for="name">Име</label>
                <input id="name" name="name" type="text" class="form-control @error('name') is-invalid @enderror"
                       value="{{ old('name', $client->name ?? '') }}" required autofocus>
            </div>
            <div class="mb-3">
                <label class="form-label small fw-medium" for="address">Адреса</label>
                <input id="address" name="address" type="text" class="form-control"
                       value="{{ old('address', $client->address ?? '') }}">
            </div>
            <div class="row">
                <div class="col-md-6 mb-3">
                    <label class="form-label small fw-medium" for="phone">Телефон</label>
                    <input id="phone" name="phone" type="text" class="form-control"
                           value="{{ old('phone', $client->phone ?? '') }}">
                </div>
                <div class="col-md-6 mb-3">
                    <label class="form-label small fw-medium" for="contact_person">Лице за контакт</label>
                    <input id="contact_person" name="contact_person" type="text" class="form-control"
                           value="{{ old('contact_person', $client->contact_person ?? '') }}">
                </div>
            </div>
            <div class="mb-3">
                <label class="form-label small fw-medium" for="email">Е-пошта</label>
                <input id="email" name="email" type="email" class="form-control @error('email') is-invalid @enderror"
                       value="{{ old('email', $client->email ?? '') }}">
            </div>
            <div class="mb-4">
                <label class="form-label small fw-medium" for="notes">Белешки</label>
                <textarea id="notes" name="notes" rows="3" class="form-control">{{ old('notes', $client->notes ?? '') }}</textarea>
            </div>
            <div class="d-flex gap-2">
                <button type="submit" class="btn btn-primary">Зачувај</button>
                <a href="{{ route('clients.index') }}" class="btn btn-light border">Откажи</a>
            </div>
        </form>
    </div>
</div>
