<?php $__env->startSection('title', 'Fundação'); ?>

<?php $__env->startSection('content'); ?>
    <div class="page-heading"><div><span class="eyebrow">FASE 1</span><h1>Fundação do NESTAB OPS</h1><p>Estrutura única, configurável e auditável para sustentar todos os módulos.</p></div><span class="phase-pill"><i></i> Núcleo activo</span></div>

    <section class="summary-strip">
        <div><small>ORGANIZAÇÃO</small><strong><?php echo e($organization?->name); ?></strong><span><?php echo e($organization?->legal_name); ?></span></div>
        <div><small>FILIAIS</small><strong><?php echo e($branches->count()); ?></strong><span>Luanda e Huíla/Lubango</span></div>
        <div><small>DEPARTAMENTOS</small><strong><?php echo e($departments->count()); ?></strong><span>Estrutura inicial</span></div>
        <div><small>PERMISSÕES</small><strong><?php echo e($permissionCount); ?></strong><span>Acções granulares</span></div>
        <div><small>REGISTOS DE AUDITORIA</small><strong><?php echo e(number_format($auditCount, 0, ',', '.')); ?></strong><span>Alterações rastreadas</span></div>
    </section>

    <div class="foundation-grid">
        <section class="panel span-7">
            <div class="panel-heading"><div><span class="eyebrow">REDE NESTAB</span><h2>Filiais e contexto operacional</h2></div><span class="status-badge active">Preparado para expansão</span></div>
            <div class="table-wrap"><table><thead><tr><th>Unidade</th><th>Código</th><th>Localização</th><th>Tipo</th><th>Estado</th></tr></thead><tbody>
                <?php $__currentLoopData = $branches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><tr><td><strong><?php echo e($branch->name); ?></strong></td><td><code><?php echo e($branch->code); ?></code></td><td><?php echo e($branch->province); ?> · <?php echo e($branch->municipality); ?></td><td><?php echo e(ucfirst($branch->type)); ?></td><td><span class="status-badge active">Activa</span></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody></table></div>
        </section>

        <section class="panel span-5">
            <div class="panel-heading"><div><span class="eyebrow">ESTRUTURA</span><h2>Departamentos</h2></div><span><?php echo e($departments->count()); ?></span></div>
            <div class="department-list"><?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><div><span><?php echo e(str_pad($loop->iteration, 2, '0', STR_PAD_LEFT)); ?></span><strong><?php echo e($department->name); ?></strong><i></i></div><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div>
        </section>

        <section class="panel span-7">
            <div class="panel-heading"><div><span class="eyebrow">IDENTIDADE E ACESSO</span><h2>Utilizadores e afectações</h2></div><span class="status-badge"><?php echo e($users->count()); ?> registado(s)</span></div>
            <div class="table-wrap"><table><thead><tr><th>Utilizador</th><th>Unidade</th><th>Perfis</th><th>Estado</th></tr></thead><tbody>
                <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><tr><td><div class="table-user"><span class="avatar small"><?php echo e(mb_strtoupper(mb_substr($user->name, 0, 1))); ?></span><div><strong><?php echo e($user->name); ?></strong><small><?php echo e($user->email); ?></small></div></div></td><td><?php echo e($user->assignments->first()?->department?->name ?? 'Global'); ?></td><td><div class="tag-row"><?php $__currentLoopData = $user->assignments->pluck('role.name')->unique(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><span class="tag"><?php echo e($role); ?></span><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div></td><td><span class="status-badge active">Activo</span></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody></table></div>
        </section>

        <section class="panel span-5">
            <div class="panel-heading"><div><span class="eyebrow">AUTORIZAÇÃO</span><h2>Perfis iniciais</h2></div><span><?php echo e($roles->count()); ?></span></div>
            <div class="role-list"><?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><div><span class="role-mark <?php echo e($role->is_privileged ? 'privileged' : ''); ?>"><?php echo e($role->is_privileged ? '◆' : '◇'); ?></span><div><strong><?php echo e($role->name); ?></strong><small><?php echo e($role->is_privileged ? 'Modo de Administração' : $role->permissions_count.' permissões por defeito'); ?></small></div></div><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div>
        </section>

        <section class="panel span-12" id="auditoria">
            <div class="panel-heading"><div><span class="eyebrow">CONTROLO</span><h2>Políticas configuradas</h2></div><span class="status-badge active">Auditáveis</span></div>
            <div class="settings-grid"><?php $__currentLoopData = $settings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $setting): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><div><small><?php echo e(strtoupper($setting->group)); ?></small><strong><?php echo e($setting->description); ?></strong><span><?php echo e($setting->value); ?><?php echo e($setting->type === 'integer' && str_contains($setting->key, 'minutes') ? ' minutos' : ''); ?></span></div><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div>
        </section>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Joe B\.codex\.chatgpt-projects\g-p-6a6ce038586481919be04257dc687fef\nestab-ops\resources\views/foundation/index.blade.php ENDPATH**/ ?>