<form>
    <input type="hidden" wire:model="quote_id">
    <input type="hidden" wire:model="user_id">

    <div class="row match-height mt-5">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h4 class="card-title">Datos de la reclamación</h4>
                </div>
                <div class="card-content">
                    <div class="card-body">
                        <div class="row">
                            @include('livewire.claims._buttons')

                            <div class="col-lg-8">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="form-group">
                                            <label for="user_document">Fecha de creación</label>
                                            <input type="text" class="form-control-plaintext" wire:model="datetime_formatted" readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group form-autocomplete">
                                            <label for="user_document">Cédula</label>
                                            <input type="text" class="form-control-plaintext" wire:model="user_document"
                                                readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label for="user_name">Nombre</label>
                                            <input type="text" class="form-control-plaintext" wire:model="user_name"
                                                readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label for="user_lastname">Apellido</label>
                                            <input type="text" class="form-control-plaintext" wire:model="user_lastname"
                                                readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label for="user_email">Email</label>
                                            <input type="email" class="form-control-plaintext" wire:model="user_email"
                                                readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label for="user_email_optional">Emails opcionales</label>
                                            <input type="email" class="form-control-plaintext" wire:model="user_email_optional" readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label for="user_phone">Teléfono</label>
                                            <input type="text" class="form-control-plaintext" wire:model="user_phone"
                                                readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group" wire:ignore>
                                            <label for="user_main">Usuario principal</label>
                                                @foreach ($users_list as $user)
                                                    @if($user->id == $user_main)
                                                        <input type="text" class="form-control-plaintext" value="{{ $user->document }} - {{ $user->fullname }}" readonly>
                                                    @endif
                                                @endforeach
                                        </div>
                                    </div>
                                    <div class="col-12 mt-4 mb-2">
                                        <div class="form-group">
                                            <label>Tipo de Póliza:</label>
                                            <input type="text" class="form-control-plaintext" wire:model="type_name"
                                                readonly>
                                        </div>
                                    </div>
                                    @if (Auth::user()->type == 'admin')
                                        <div class="col-md-12">
                                            @if (!empty($quote->admin->id))
                                                @if (!$quote->admin->status)
                                                    <div class="alert alert-warning" role="alert">
                                                        El agente <strong>{{ $quote->admin->fullname }}</strong> ha
                                                        sido inactivado, debe seleccionar un nuevo agente.
                                                    </div>
                                                @endif
                                            @endif
                                            <div class="form-group">
                                                <label for="admin_id">Agente</label>
                                                <input type="text" class="form-control-plaintext"
                                                    wire:model="admin_name" readonly>
                                            </div>
                                        </div>
                                    @endif
                                    <div class="col-md-12">
                                        <div class="form-group">
                                            <label for="product_detail_id">Producto</label>
                                            <input type="hidden" wire:model="product_detail_id">
                                            <input type="text" class="form-control-plaintext" wire:model="product_name"
                                                readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label for="policy_number">Número de póliza</label>
                                            <input type="text" class="form-control" wire:model="policy_number" readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label for="reclaimed_amount">Monto reclamado</label>
                                            <input type="text" class="form-control money" wire:model="reclaimed_amount" readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label for="amount_approved">Monto aprobado</label>
                                            <input type="text" class="form-control money" wire:model="amount_approved" readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group" wire:ignore>
                                            <label for="description">Último Histórico de la reclamación</label>
                                            <br>
                                            <div class="border border-bottom mb-2"></div>
                                            @foreach ($claim_historys as $value)
                                                @if ($loop->first)
                                                    <div>
                                                        @php
                                                            echo $value->item;
                                                        @endphp
                                                    </div>
                                                @endif
                                            @endforeach
                                        </div>
                                    </div>
                                </div>

                                @if ($mode == 'approve')
                                    <div class="row mt-5">
                                        <div class="col-12">
                                            <div class="form-group">
                                                <label for="">Seleccionar la opción a aprobar</label>
                                                <select class="form-control" wire:model="quote_detail_id">
                                                    <option value="">::. Seleccione .::</option>
                                                    @foreach ($details as $key => $value)
                                                        <option value="{{ $detail_id[$key] }}">Opción
                                                            #{{ $key + 1 }} ({{ $detail_insurer_name[$key] }})
                                                        </option>
                                                    @endforeach
                                                </select>
                                                @error('quote_detail_id') <span
                                                    class="text-danger">{{ $message }}</span>@enderror
                                            </div>
                                        </div>
                                    </div>
                                @endif
                            </div>

                            <div class="col-lg-4">
                                <div class="card card-quote-details border">
                                    <div class="card-header">
                                        <h4>Histórico de Actualizaciones</h4>
                                    </div>
                                    <div class="card-body">
                                        <div class="border min-vh-100">
                                            @if ($this->mode == 'show')
                                                @foreach ($claim_historys as $item)
                                                    <div class="m-1 p-2 border-bottom mb-3">
                                                        <span class="mb-2 d-block">{{ $item->date_formatted }}</span>
                                                        <div>
                                                            @php
                                                                echo $item->item;
                                                            @endphp
                                                        </div>
                                                    </div>
                                                @endforeach
                                            @elseif($this->mode == 'create')
                                                @if (count($claim_historys) > 0)
                                                    @foreach ($claim_historys as $item)
                                                        <div class="m-1 p-2 border-bottom mb-3">
                                                            <span class="mb-2 d-block">{{ $item->date_format }}</span>
                                                            @foreach ($item->claim_history as $value)
                                                                @if ($loop->last)
                                                                    <div>
                                                                        @php
                                                                            echo $value->item;
                                                                        @endphp
                                                                    </div>
                                                                @endif
                                                            @endforeach
                                                        </div>
                                                    @endforeach
                                                @else
                                                    <div class="m-1 p-2 border-bottom mb-3">
                                                        <p>Cliente sin histórico de reclamaciones</p>
                                                    </div>
                                                @endif
                                            @endif
                                        </div>
                                    </div>
                                </div>
                            </div>

                            @include('livewire.claims._buttons')
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
