<?php $__env->startSection('title', env('APP_NAME') . ' :: ' . __('Visualizar Contrato')); ?>

<?php $__env->startSection('content'); ?>
    <?php echo $__env->make('errors.messageFlash', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <div class="card shadow border-0 mt-3">
    <?php 
        $headLine = "<i class='fa-solid fa-file-contract'></i> " . __('Contrato') . " #{$contrato->con_numero}";
    ?>

    <?php echo $__env->make('components.buttons._headLineButtonsBackAdd', [
        'headLine' => __($headLine),
        'routeBack' => 'admin.contratos.index',
        'routeBackParams' => request()->only(['q', 'ano', 'con_modalidade', 'con_status', 'page']),
        'nameBack' => __('Voltar'),
        'routeAdd' => 'admin.contratos.create',
        'routeAddParams' => request()->only(['q', 'ano', 'con_modalidade', 'con_status', 'page'])
    ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
        <div class="card-body">

            <!-- TOPO -->
            <div class="d-flex justify-content-between align-items-center mb-4 flex-wrap">
                <div>
                    <h4 class="mb-1 fw-bold">
                        <?php echo e($contrato->con_titulo ?: 'Sem título'); ?>

                    </h4>
                    <small class="text-muted">
                        Processo: <?php echo e($contrato->con_processo ?: '-'); ?>

                    </small>
                </div>

                <div class="text-end">
                    <span class="badge bg-primary">
                        <?php echo e($contrato->modalidade_label ?: '-'); ?>

                    </span>
                    <span class="badge bg-success">
                        <?php echo e($contrato->status_label ?: '-'); ?>

                    </span>
                </div>
            </div>

            <hr>

            <!-- INFORMAÇÕES GERAIS -->
            <h6 class="text-uppercase text-muted mb-3"><?php echo e(__('Informações Gerais')); ?></h6>

            <div class="row g-3 mb-4">
                <div class="col-md-2">
                    <small class="text-muted"><?php echo e(__('Número')); ?></small>
                    <div class="fw-semibold"><?php echo e($contrato->con_numero ?: '-'); ?></div>
                </div>

                <div class="col-md-2">
                    <small class="text-muted"><?php echo e(__('Ano')); ?></small>
                    <div class="fw-semibold"><?php echo e($contrato->con_ano ?: '-'); ?></div>
                </div>

                <div class="col-md-2">
                    <small class="text-muted"><?php echo e(__('Valor')); ?></small>
                    <div class="fw-semibold text-success">
                        R$ <?php echo e($contrato->con_valor ? number_format((float) $contrato->con_valor, 2, ',', '.') : '-'); ?>

                    </div>
                </div>

                <div class="col-md-2">
                    <small class="text-muted"><?php echo e(__('Data de Assinatura')); ?></small>
                    <div class="fw-semibold"><?php echo e($contrato->con_dataassinatura ?: '-'); ?></div>
                </div>

                <div class="col-md-2">
                    <small class="text-muted"><?php echo e(__('CPF/CNPJ')); ?></small>
                    <div class="fw-semibold"><?php echo e($contrato->con_favorecido ?: '-'); ?></div>
                </div>

                <div class="col-md-4">
                    <small class="text-muted"><?php echo e(__('Licitação vinculada')); ?></small>
                    <div class="fw-semibold">
                        <?php if($contrato->licitacao_procedimento_id): ?>
                            <a href="<?php echo e(route('paginas.licitacoes-e-procedimentos.detalhe', $contrato->licitacao_procedimento_id)); ?>" target="_blank" rel="noopener noreferrer">
                                <?php echo e($contrato->licitacao?->nr_licitacao ?? ('#' . $contrato->licitacao_procedimento_id)); ?>

                            </a>
                        <?php else: ?>
                            -
                        <?php endif; ?>
                    </div>
                </div>
            </div>

            <!-- ENVOLVIDOS -->
            <h6 class="text-uppercase text-muted mb-3">Envolvidos:</h6>

            <div class="row g-3 mb-4">
                <div class="col-md-3">
                    <small class="text-muted">Favorecido</small>
                    <div class="fw-semibold">
                        <?php echo e($contrato->favorecido?->fav_nome ?: '-'); ?>

                    </div>
                </div>

                <div class="col-md-3">
                    <small class="text-muted">Secretaria</small>
                    <div class="fw-semibold">
                        <?php echo e($contrato->secretaria?->name ?: '-'); ?>

                    </div>
                </div>

                <div class="col-md-3">
                    <small class="text-muted">Secretaria Gestora</small>
                    <div class="fw-semibold">
                        <?php echo e($contrato->secretariaGestora?->name ?: '-'); ?>

                    </div>
                </div>
            </div>

            <!-- FISCAIS -->
            <h6 class="text-uppercase text-muted mb-3"><?php echo e(__('Fiscalização')); ?></h6>

            <div class="p-3 bg-light rounded mb-4">
                <?php echo e($contrato->con_fiscais ?: __('Não informado')); ?>

            </div>

            <!-- ARQUIVOS -->
            <h6 class="text-uppercase text-muted mb-3"><?php echo e(__('Arquivos vinculados')); ?></h6>

            <?php if($contrato->arquivos->isNotEmpty()): ?>
                <div class="row g-3">
                    <?php $__currentLoopData = $contrato->arquivos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $arquivo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                            $ext = strtolower(pathinfo((string) $arquivo->arq_arquivo, PATHINFO_EXTENSION));
                            $iconClass = match($ext) {
                                'pdf'                    => 'fa-file-pdf text-danger',
                                'doc', 'docx'            => 'fa-file-word text-primary',
                                'xls', 'xlsx'            => 'fa-file-excel text-success',
                                'zip', 'rar', '7z'       => 'fa-file-zipper text-warning',
                                'jpg', 'jpeg', 'png', 'gif', 'webp' => 'fa-file-image text-info',
                                default                  => 'fa-file text-secondary',
                            };
                        ?>
                        <div class="col-12 col-sm-6 col-lg-4">
                            <div class="border rounded-3 p-3 h-100 d-flex flex-column gap-2 shadow-sm">
                                <div class="d-flex align-items-center gap-3">
                                    <i class="fa-solid <?php echo e($iconClass); ?> fa-2x flex-shrink-0"></i>
                                    <div class="overflow-hidden">
                                        <div class="fw-semibold text-truncate" title="<?php echo e($arquivo->arq_titulo ?: basename((string) $arquivo->arq_arquivo)); ?>">
                                            <?php echo e($arquivo->arq_titulo ?: basename((string) $arquivo->arq_arquivo)); ?>

                                        </div>
                                        <?php if($arquivo->arq_numero): ?>
                                            <small class="text-muted"><?php echo e(__('Nº')); ?> <?php echo e($arquivo->arq_numero); ?></small>
                                        <?php endif; ?>
                                    </div>
                                </div>

                                <?php if($arquivo->arq_dataini || $arquivo->arq_datafim): ?>
                                    <div class="d-flex align-items-center gap-1 text-muted small">
                                        <i class="fa-regular fa-calendar fa-sm"></i>
                                        <span><?php echo e($arquivo->arq_dataini ?: '?'); ?></span>
                                        <span>-</span>
                                        <span><?php echo e($arquivo->arq_datafim ?: '?'); ?></span>
                                    </div>
                                <?php endif; ?>

                                <?php if($arquivo->arq_arquivo): ?>
                                    <div class="mt-auto pt-1">
                                        <a href="<?php echo e($arquivo->arquivo_url); ?>"
                                           target="_blank"
                                           rel="noopener noreferrer"
                                           class="btn btn-sm btn-outline-primary w-100">
                                            <i class="fa-solid fa-file-arrow-down me-1"></i>
                                            <?php echo e(__('Visualizar arquivo')); ?>

                                        </a>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            <?php else: ?>
                <div class="d-flex flex-column align-items-center justify-content-center text-muted py-4 border rounded-3 bg-light">
                    <i class="fa-regular fa-folder-open fa-2x mb-2"></i>
                    <span><?php echo e(__('Nenhum arquivo vinculado a este contrato.')); ?></span>
                </div>
            <?php endif; ?>

        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin.theme', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/portal/resources/views/admin/contratos/show.blade.php ENDPATH**/ ?>