<div class="container py-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h1 class="h3 mb-1">Edit Solicitor</h1>
            <p class="text-muted mb-0">Update solicitor details</p>
        </div>

        <div class="d-flex gap-2">
            <a wire:navigate href="{{ route('solicitors.index') }}" class="btn btn-outline-secondary">
                Back to List
            </a>
        </div>
    </div>

    @if (session()->has('success'))
        <div class="alert alert-success">
            {{ session('success') }}
        </div>
    @endif

    <div class="card shadow-sm">
        <div class="card-body">
            <form wire:submit="save">
                <div class="row g-3">
                    <div class="col-md-6">
                        <label for="name" class="form-label">Name</label>
                        <input
                                id="name"
                                type="text"
                                class="form-control @error('name') is-invalid @enderror"
                                wire:model.live="name"
                        >
                        @error('name')
                        <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="col-md-6">
                        <label for="domain" class="form-label">Domain</label>
                        <input
                                id="domain"
                                type="text"
                                class="form-control @error('domain') is-invalid @enderror"
                                wire:model.live="domain"
                                placeholder="example.com"
                        >
                        @error('domain')
                        <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="col-md-6">
                        <label for="company_number" class="form-label">Company Registration Number</label>
                        <input
                                id="company_number"
                                type="text"
                                class="form-control @error('company_number') is-invalid @enderror"
                                wire:model.live="company_number"
                                placeholder="e.g. 13900519"
                        >
                        @error('company_number')
                        <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="col-md-6">
                        <label for="sra_number" class="form-label">SRA Number</label>
                        <input
                                id="sra_number"
                                type="text"
                                class="form-control @error('sra_number') is-invalid @enderror"
                                wire:model.live="sra_number"
                                placeholder="e.g. 8000579"
                        >
                        @error('sra_number')
                        <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>
                </div>

                <hr class="my-4"/>

                <h5 class="mb-3">
                    <i class="mdi mdi-account-question me-1"></i>Application form help contact
                </h5>
                <p class="text-muted small">
                    The named person who helps clients complete their application forms. Used in the
                    &ldquo;who is helping you complete this form&rdquo; section of generated documents.
                    The contact phone, email and firm name are taken from the firm&rsquo;s primary
                    phone number, default email sender and name.
                </p>

                <div class="row g-3">
                    <div class="col-md-6">
                        <label for="help_contact_first_name" class="form-label">Help contact first name</label>
                        <input
                                id="help_contact_first_name"
                                type="text"
                                class="form-control @error('help_contact_first_name') is-invalid @enderror"
                                wire:model.live="help_contact_first_name"
                        >
                        @error('help_contact_first_name')
                        <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="col-md-6">
                        <label for="help_contact_last_name" class="form-label">Help contact last name</label>
                        <input
                                id="help_contact_last_name"
                                type="text"
                                class="form-control @error('help_contact_last_name') is-invalid @enderror"
                                wire:model.live="help_contact_last_name"
                        >
                        @error('help_contact_last_name')
                        <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>
                </div>

                <hr class="my-4"/>

                <h5 class="mb-3">
                    <i class="mdi mdi-draw-pen me-1"></i>Default email signature
                </h5>
                <p class="text-muted small">
                    The firm-wide signature appended to outbound emails.
                    Per-sender signatures (under <em>Email Senders</em>) override this when present.
                </p>

                <x-ui.signature-editor
                    name="signature"
                    text-name="signature_text"
                    label="Signature"
                    help="Used as the default for any sender that does not have its own signature."
                    :initial="$signature"
                />

                <div class="d-flex justify-content-end gap-2 mt-4">
                    <a wire:navigate href="{{ route('solicitors.index') }}" class="btn btn-outline-secondary">
                        Cancel
                    </a>

                    <button type="submit" class="btn btn-primary">
                        Save Changes
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>