@php
    $pathSystem = $_SERVER['DOCUMENT_ROOT'] . "/";
    $angraDefault = asset("/pmar/assets/img/angra-default.png");
    $totalNoticias = isset($noticias) ? $noticias->count() : 0;
@endphp

@if($destaque)
<div class="row gx-5 gy-5">
    <div class="col-xl-6 col-lg-12 col-md-12">
        <div class="card" style="cursor: pointer" onclick="javascript:window.location.href='{{ route('paginas.slug', [date('d-m-Y', strtotime($destaque->created_at)), $destaque->slug]) }}'">
            <img src="{{ file_exists( $pathSystem . $destaque->featuredPhoto ) ? asset($destaque->featuredPhoto) : asset($angraDefault) }}" class="card-img-top-left w-100 h-100" alt="{{ $destaque->title }}">
            <div class="card-body">
                <h5 class="card-title">{{ $destaque->title }}</h5>
            </div>
        </div>
    </div>
    @if($totalNoticias >= 2)
    <div class="col-xl-6 col-lg-12 col-md-12">
        <div class="col noticias-bloco-2">
            <div class="card noticias-card-subdestaque" onclick="javascript:window.location.href='{{ route('paginas.slug', [date('d-m-Y', strtotime($noticias[0]->created_at)), $noticias[0]->slug]) }}'">
                <img src="{{ file_exists( $pathSystem . $noticias[0]->featuredPhoto ) ? asset($noticias[0]->featuredPhoto) : asset($angraDefault) }}" class="card-img" alt="{{ $noticias[0]->title }}">
                <div class="card-body">
                    <h5 class="card-title">{{ $noticias[0]->title }}</h5>
                </div>
            </div>
            <div class="card noticias-card-subdestaque" onclick="javascript:window.location.href='{{ route('paginas.slug', [date('d-m-Y', strtotime($noticias[1]->created_at)), $noticias[1]->slug]) }}'">
                <img src="{{ file_exists( $pathSystem . $noticias[1]->featuredPhoto ) ? asset($noticias[1]->featuredPhoto) : asset($angraDefault) }}" class="card-img" alt="{{ $noticias[1]->title }}">
                <div class="card-body">
                    <h5 class="card-title">{{ $noticias[1]->title }}</h5>
                </div>
            </div>
        </div>
    </div>
    @endif
</div>
@endif

@if($totalNoticias > 2)
<div class="row gx-5 gy-5 noticias-bloco-inferior">
    @for ($i = 2; $i < min($totalNoticias, 6); $i++)
        <div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-3">
            <div class="card" onclick="javascript:window.location.href='{{ route('paginas.slug', [date('d-m-Y', strtotime($noticias[$i]->created_at)), $noticias[$i]->slug]) }}'">
                <img src="{{ file_exists( $pathSystem . $noticias[$i]->featuredPhoto ) ? asset($noticias[$i]->featuredPhoto) : asset($angraDefault) }}" class="card-img-top rounded-top-4" alt="{{ $noticias[$i]->title }}">
                <div class="card-body">
                    <h5 class="card-title">{{ $noticias[$i]->title }}</h5>
                </div>
            </div>
        </div>
    @endfor
</div>
@endif
