@props([
    'title'       => '',
    'breadcrumbs' => [
        ['name' => 'Inicio', 'href' => '/', 'active' => true],
    ],
])

<section class="page-header page-header-modern bg-color-grey page-header-lg m-0">
    <div class="container">
        <div class="row">
            <div class="col-md-8 order-2 order-md-1 align-self-center p-static">
                <h1 class="text-dark">{!! $title !!}</h1>
            </div>
            <div class="col-md-4 order-1 order-md-2 align-self-center">
                <ul class="breadcrumb d-block text-md-end">
                    @foreach ($breadcrumbs as $breadcrumb)
                        @php
                            $name     = $breadcrumb['name']  ?? '';
                            $active   = (bool)($breadcrumb['active'] ?? false);
                            $route    = $breadcrumb['route'] ?? null;
                            $params   = $breadcrumb['params'] ?? [];
                            $href     = $breadcrumb['href']  ?? null;

                            $routeExists = $route && \Illuminate\Support\Facades\Route::has($route);
                            $url = $routeExists ? route($route, $params) : ($href ?: null);
                        @endphp

                        <li class="breadcrumb-item {{ $active ? 'active' : '' }}" @if($active) aria-current="page" @endif>
                            @if (!$active && $url)
                                <a href="{{ $url }}">{{ $name }}</a>
                            @else
                                <span>{{ $name }}</span>
                            @endif
                        </li>
                    @endforeach
                </ul>
            </div>
        </div>
    </div>
</section>
