<?php $__env->startSection('title', __('Cronograma') . ' - ' . $project->name); ?>
<?php $__env->startSection('content'); ?>

<link rel="stylesheet" href="<?php echo e(asset('pmar/css/cronogramas.css')); ?>?v=<?php echo e(filemtime(public_path('pmar/css/cronogramas.css'))); ?>">
<link rel="stylesheet" href="<?php echo e(asset('pmar/css/cronogramas-public.css')); ?>?v=<?php echo e(filemtime(public_path('pmar/css/cronogramas-public.css'))); ?>">

<?php
    $viewTab = $viewTab ?? 'timeline';
    $scopeParts = collect([
        ! empty($scopeLabels['structures']) ? __('Órgãos') . ': ' . implode(', ', $scopeLabels['structures']) : null,
        ! empty($scopeLabels['unidades']) ? __('Unidades') . ': ' . implode(', ', $scopeLabels['unidades']) : null,
        ! empty($scopeLabels['empresas']) ? __('Empresas') . ': ' . implode(', ', $scopeLabels['empresas']) : null,
    ])->filter()->values();
?>

<div class="cr-public-page">
    <header class="cr-public-header card shadow-sm border-0 mb-4">
        <div class="card-body">
            <div class="d-flex flex-wrap align-items-start gap-3 mb-3">
                <div class="cr-public-brand flex-shrink-0">
                    <img src="<?php echo e(asset('pmar/assets/img/brasao-2026.png')); ?>" alt="<?php echo e(__('Brasão da Prefeitura de Angra dos Reis')); ?>">
                </div>
                <div class="flex-grow-1 min-w-0">
                    <div class="d-flex flex-wrap align-items-center gap-2 mb-2">
                        <h1 class="h4 mb-0 text-primary"><?php echo e($project->name); ?></h1>
                        <span class="badge bg-secondary cr-public-readonly-badge">
                            <i class="fa-solid fa-eye" aria-hidden="true"></i> <?php echo e(__('Visualização executiva')); ?>

                        </span>
                    </div>
                    <div class="d-flex flex-wrap align-items-center gap-2 mb-2">
                        <span class="badge <?php echo e($project->isReadOnly() ? 'bg-dark' : 'bg-primary'); ?>">
                            <?php echo e(\App\Enums\Accounts\Cronogramas\CronogramaProjectStatus::tryFrom($project->status)?->label()); ?>

                        </span>
                        <span class="small text-muted">
                            <i class="fa-regular fa-calendar" aria-hidden="true"></i>
                            <?php echo e(__('Início')); ?>: <?php echo e($project->start_date?->format('d/m/Y') ?? '-'); ?>

                        </span>
                        <span class="small text-muted">
                            <i class="fa-regular fa-calendar-check" aria-hidden="true"></i>
                            <?php echo e(__('Término previsto')); ?>: <?php echo e($project->planned_end_date?->format('d/m/Y') ?? '-'); ?>

                        </span>
                    </div>
                    <?php if($project->description): ?>
                        <p class="text-muted mb-2"><?php echo e($project->description); ?></p>
                    <?php endif; ?>
                    <?php if($scopeParts->isNotEmpty()): ?>
                        <ul class="cr-public-scope-list small text-muted" aria-label="<?php echo e(__('Escopo organizacional')); ?>">
                            <?php $__currentLoopData = $scopeParts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $scopeLine): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <li><?php echo e($scopeLine); ?></li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </ul>
                    <?php endif; ?>
                </div>
            </div>

            <div class="row g-3 align-items-stretch">
                <div class="col-lg-7">
                    <div class="progress cr-progress-h-sm mb-1" role="progressbar" aria-label="<?php echo e(__('Progresso do projeto')); ?>" aria-valuenow="<?php echo e($project->completion_percent); ?>" aria-valuemin="0" aria-valuemax="100">
                        <div class="progress-bar bg-success cr-progress-bar-dynamic" style="--cr-w: <?php echo e($project->completion_percent); ?>%;"></div>
                    </div>
                    <small class="text-muted"><?php echo e($project->completion_percent); ?>% <?php echo e(__('concluído')); ?></small>
                </div>
                <div class="col-lg-5">
                    <div class="row g-2 text-center">
                        <div class="col-4">
                            <div class="border rounded py-2 h-100">
                                <div class="fw-bold"><?php echo e($projectStats['total_count'] ?? 0); ?></div>
                                <div class="small text-muted"><?php echo e(__('Atividades')); ?></div>
                            </div>
                        </div>
                        <div class="col-4">
                            <div class="border rounded py-2 h-100">
                                <div class="fw-bold text-success"><?php echo e($projectStats['completed_count'] ?? 0); ?></div>
                                <div class="small text-muted"><?php echo e(__('Concluídas')); ?></div>
                            </div>
                        </div>
                        <div class="col-4">
                            <div class="border rounded py-2 h-100">
                                <div class="fw-bold text-danger"><?php echo e($projectStats['overdue_count'] ?? 0); ?></div>
                                <div class="small text-muted"><?php echo e(__('Atrasadas')); ?></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </header>

    <ul class="nav nav-tabs cr-view-tabs cr-public-tabs mb-3" role="tablist">
        <?php
            $tabs = [
                'timeline' => ['icon' => 'fa-timeline', 'label' => __('Linha do tempo')],
                'table' => ['icon' => 'fa-table-list', 'label' => __('Tabela')],
            ];
        ?>
        <?php $__currentLoopData = $tabs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $tab): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <li class="nav-item" role="presentation">
                <a class="nav-link <?php if($viewTab === $key): ?> active <?php endif; ?>"
                   href="<?php echo e(route('cronogramas.public.show', ['token' => $project->public_share_token, 'tab' => $key])); ?>">
                    <i class="fa-solid <?php echo e($tab['icon']); ?>" aria-hidden="true"></i> <?php echo e($tab['label']); ?>

                </a>
            </li>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </ul>

    <main class="card shadow-sm border-0">
        <div class="card-body">
            <?php if($viewTab === 'table'): ?>
                <?php echo $__env->make('components.cronogramas.public-activities-table', ['rows' => $tableRows], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
            <?php else: ?>
                <?php if(empty($tableRows)): ?>
                    <div class="text-center text-muted py-5">
                        <i class="fa-solid fa-calendar-xmark fa-2x mb-2 d-block" aria-hidden="true"></i>
                        <?php echo e(__('Nenhuma atividade cadastrada.')); ?>

                    </div>
                <?php else: ?>
                    <?php echo $__env->make('components.cronogramas.timeline', ['rows' => $tableRows, 'dir' => 'asc'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                <?php endif; ?>
            <?php endif; ?>
        </div>
    </main>

    <footer class="cr-public-footer text-center mt-4">
        <?php echo e(__('Prefeitura Municipal de Angra dos Reis')); ?> · <?php echo e(__('Atualizado em')); ?> <?php echo e(now()->format('d/m/Y H:i')); ?>

    </footer>
</div>

<?php $__env->stopSection(); ?>

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