@csrf
<div class="row g-3">
    <div class="col-md-6">
        <label class="form-label">Branch Name <span class="text-danger">*</span></label>
        <input type="text" name="name" value="{{ old('name', $branch->name) }}" class="form-control @error('name') is-invalid @enderror" required>
        @error('name')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
    <div class="col-md-3">
        <label class="form-label">Branch Code <span class="text-danger">*</span></label>
        <input type="text" name="code" value="{{ old('code', $branch->code) }}" class="form-control text-uppercase @error('code') is-invalid @enderror" required>
        @error('code')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>
    <div class="col-md-3">
        <label class="form-label">Status</label>
        <select name="is_active" class="form-select">
            <option value="1" @selected(old('is_active', $branch->is_active ?? true))>Active</option>
            <option value="0" @selected(!old('is_active', $branch->is_active ?? true))>Inactive</option>
        </select>
    </div>

    <div class="col-md-6">
        <label class="form-label">Principal Name</label>
        <input type="text" name="principal_name" value="{{ old('principal_name', $branch->principal_name) }}" class="form-control">
    </div>
    <div class="col-md-3">
        <label class="form-label">Phone</label>
        <input type="text" name="phone" value="{{ old('phone', $branch->phone) }}" class="form-control">
    </div>
    <div class="col-md-3">
        <label class="form-label">Email</label>
        <input type="email" name="email" value="{{ old('email', $branch->email) }}" class="form-control @error('email') is-invalid @enderror">
        @error('email')<div class="invalid-feedback">{{ $message }}</div>@enderror
    </div>

    <div class="col-md-4">
        <label class="form-label">City</label>
        <input type="text" name="city" value="{{ old('city', $branch->city) }}" class="form-control">
    </div>
    <div class="col-md-8">
        <label class="form-label">Address</label>
        <input type="text" name="address" value="{{ old('address', $branch->address) }}" class="form-control">
    </div>

    <div class="col-md-6">
        <label class="form-label">Logo</label>
        <input type="file" name="logo" accept="image/*" class="form-control @error('logo') is-invalid @enderror">
        @error('logo')<div class="invalid-feedback">{{ $message }}</div>@enderror
        @if($branch->logo)<div class="form-text">Current: {{ basename($branch->logo) }}</div>@endif
    </div>
</div>

<div class="mt-4 d-flex gap-2">
    <button class="btn btn-primary"><i class="bi bi-check-lg me-1"></i>{{ $submitLabel ?? 'Save' }}</button>
    <a href="{{ route('branches.index') }}" class="btn btn-light border">Cancel</a>
</div>
