@php
    $accountId = old("lines.$i.account_id", isset($line) && $line ? ($line->account_id ?? '') : '');
@endphp
<td style="vertical-align:middle;min-width:220px">
    <div class="voucher-account-picker">
        <input type="hidden"
               name="lines[{{ $i }}][account_id]"
               value="{{ $accountId }}"
               class="voucher-account-input"
               required>
        <button type="button" class="form-select form-select-sm voucher-account-picker-toggle text-start">
            <span class="voucher-account-picker-label">— Select Account —</span>
        </button>
        <div class="voucher-account-picker-menu d-none">
            <div class="voucher-account-picker-search">
                <i class="bi bi-search"></i>
                <input type="search" class="form-control form-control-sm voucher-account-picker-search-input" placeholder="Search accounts..." autocomplete="off">
            </div>
            <div class="voucher-account-picker-columns">
                <span></span>
                <span>Code</span>
                <span>Name</span>
                <span>Type</span>
            </div>
            <div class="voucher-account-picker-tree"></div>
            <div class="voucher-account-picker-empty d-none">No matching accounts</div>
            <div class="voucher-account-picker-actions">
                <button type="button" class="btn btn-link btn-sm p-0 voucher-account-picker-clear">Clear</button>
            </div>
        </div>
    </div>
</td>
