<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 cotización</h4>
                </div>
                <div class="card-content">
                    <div class="card-body">
                        <div class="row">
                            @include('livewire.quotes._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-12">
                                        <div class="form-group" wire:ignore>
                                            <label for="description">Descripción de la cotización</label>
                                            <br>
                                            {!! $description !!}
                                        </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>Listado de Opciones</h4>
                                    </div>
                                    <div class="card-body">
                                        @foreach ($details as $key => $value)
                                            <div class="quote-details-item border-bottom mb-4">
                                                <div class="row">
                                                    <div class="col-12 mb-3">
                                                        <b>Opcion <span class="badge badge-dark">#{{ $key + 1 }}</span></b>
                                                        <input type="hidden" wire:model="detail_id.{{ $key }}">

                                                        @if ($detail_accepted[$key])
                                                            <span class="badge badge-success float-right">Aprobada</span>
                                                        @endif
                                                    </div>
                                                    <div class="col-12">
                                                        <div class="form-group">
                                                            <label for="">Aseguradora</label>
                                                            <input type="text" class="form-control-plaintext" wire:model="detail_insurer_name.{{ $key }}" readonly>
                                                        </div>
                                                    </div>
                                                    <div class="col-12">
                                                        <div class="form-group">
                                                            <label for="">Monto de la cotización</label>
                                                            <input type="text" class="form-control-plaintext" wire:model="detail_amount.{{ $key }}" readonly>
                                                        </div>
                                                    </div>
                                                    {{-- <div class="col-xl-6 col-lg-12">
                                                        <div class="form-group">
                                                            <label for="">Fecha máxima de vigencia</label>
                                                            <input type="text" class="form-control-plaintext" wire:model="detail_date_max.{{ $key }}" readonly>
                                                        </div>
                                                    </div> --}}
                                                    @if (!empty($detail_file[$key]))
                                                        <div class="col-12">
                                                            <div class="form-group">
                                                                <label for="" class="form-label">
                                                                    Archivo adjunto
                                                                </label>
                                                                <a href="{{ Storage::url($detail_file[$key]) }}" download class="btn btn-link btn-link2 text-dark">
                                                                    <i class="fas fa-download"></i>
                                                                    Descargar Archivo
                                                                </a>
                                                            </div>
                                                        </div>
                                                    @endif
                                                </div>
                                            </div>
                                        @endforeach
                                    </div>
                                </div>
                            </div>

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