@extends('layouts.app')
@section('title', 'Filiais')
@section('content')
    <div class="page-heading"><div><span class="eyebrow">ADMINISTRAÇÃO · ORGANIZAÇÃO</span><h1>Filiais</h1><p>Gestão da sede, unidades existentes e expansão nacional.</p></div><a class="primary-link" href="{{ route('admin.branches.create') }}">+ Nova filial</a></div>
    <section class="panel"><div class="table-wrap"><table class="management-table"><thead><tr><th>Unidade</th><th>Código</th><th>Localização</th><th>Hierarquia</th><th>Estado</th><th></th></tr></thead><tbody>
        @foreach($branches as $branch)<tr class="{{ $branch->trashed() ? 'archived-row' : '' }}"><td><strong>{{ $branch->name }}</strong><small>{{ $branch->email ?: 'Sem email registado' }}</small></td><td><code>{{ $branch->code }}</code></td><td>{{ $branch->province }} · {{ $branch->municipality }}</td><td>{{ $branch->is_headquarters ? 'Sede principal' : ($branch->parent?->name ?? 'Filial') }}</td><td><span class="status-badge {{ !$branch->trashed() && $branch->is_active ? 'active' : '' }}">{{ $branch->trashed() ? 'Arquivada' : ($branch->is_active ? 'Activa' : 'Inactiva') }}</span></td><td class="row-actions">@unless($branch->trashed())<a href="{{ route('admin.branches.edit', $branch) }}">Editar</a><form method="POST" action="{{ route('admin.branches.destroy', $branch) }}" data-confirm="Arquivar esta filial? O histórico será preservado.">@csrf @method('DELETE')<button type="submit">Arquivar</button></form>@endunless</td></tr>@endforeach
    </tbody></table></div></section>
@endsection
