<?php $__env->startSection('title', env('APP_NAME') . ' :: Notícias'); ?>
<?php $__env->startSection('content'); ?>
<section>
    <div class="container py-5">
        <div class="row">
            <div class="col-12">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="<?php echo e(route('paginas.home')); ?>">Portal</a>
                        </li>
                        <li class="breadcrumb-item active" aria-current="page">Notícias</li>
                    </ol>
                </nav>
            </div>
            <div class="col-12">
                <h1 class="text-secondary text-center">Notícias</h1>
                <?php
                    $pathSystem = $_SERVER['DOCUMENT_ROOT'] . "/";
                    $angraDefault = asset("/pmar/assets/img/angra-default.png");
                    $noticiasFiltrosPainelAberto = request()->filled('secretaria_id')
                        || request()->filled('ano')
                        || request()->filled('categoria');
                ?>
            </div>
            <div class="col-12">
                <div id="searchForm" class="bg-light d-flex justify-content-center align-items-center py-5">
                    <div class="container">
                        <form method="get" action="<?php echo e(route('paginas.noticias')); ?>" class="text-center">
                            <?php
                                $noticiasFiltroBtnClass = 'btn btn-light border-0 rounded-5 shadow-sm text-secondary flex-shrink-0 px-3 py-3 d-flex align-items-center justify-content-center';
                            ?>
                            <div class="row justify-content-center align-items-center g-3 mb-3">
                                
                                <div class="col-auto d-none d-md-flex align-items-center order-md-1">
                                    <button type="button" class="<?php echo e($noticiasFiltroBtnClass); ?>"
                                        data-bs-toggle="collapse" data-bs-target="#noticias-filtros-collapse"
                                        aria-controls="noticias-filtros-collapse"
                                        aria-expanded="<?php echo e($noticiasFiltrosPainelAberto ? 'true' : 'false'); ?>"
                                        title="<?php echo e(__('Mostrar ou ocultar filtros')); ?>">
                                        <i class="fa-solid fa-filter fa-lg" aria-hidden="true"></i>
                                        <span class="visually-hidden"><?php echo e(__('Mostrar ou ocultar filtros')); ?></span>
                                    </button>
                                </div>
                                
                                <div class="col-12 col-md-6 col-xl-6 order-1 order-md-2">
                                    <label for="filtro-noticias-q" class="visually-hidden"><?php echo e(__('Buscar notícias')); ?></label>
                                    <input id="filtro-noticias-q" class="shadow-sm p-3 border-0 rounded-5 form-control w-100"
                                        type="search" name="q" value="<?php echo e(request('q')); ?>"
                                        placeholder="<?php echo e(__('Procure uma notícia...')); ?>"
                                        aria-label="<?php echo e(__('Buscar notícias')); ?>" maxlength="255" autocomplete="off">
                                </div>
                                
                                <div
                                    class="col-12 col-md-auto order-3 order-md-3 d-flex flex-wrap justify-content-center align-items-center gap-2">
                                    <button type="button" class="<?php echo e($noticiasFiltroBtnClass); ?> d-md-none"
                                        data-bs-toggle="collapse" data-bs-target="#noticias-filtros-collapse"
                                        aria-controls="noticias-filtros-collapse"
                                        aria-expanded="<?php echo e($noticiasFiltrosPainelAberto ? 'true' : 'false'); ?>"
                                        title="<?php echo e(__('Mostrar ou ocultar filtros')); ?>">
                                        <i class="fa-solid fa-filter fa-lg" aria-hidden="true"></i>
                                        <span class="visually-hidden"><?php echo e(__('Mostrar ou ocultar filtros')); ?></span>
                                    </button>
                                    <button class="px-4 rounded-5 fw-bolder btn btn-success text-secondary" type="submit"
                                        id="searchNewsButton"><?php echo e(__('Buscar')); ?></button>
                                    <a href="<?php echo e(route('paginas.noticias')); ?>"
                                        class="px-4 rounded-5 fw-bolder btn btn-outline-secondary text-secondary"><?php echo e(__('Limpar')); ?></a>
                                </div>
                            </div>
                            <div id="noticias-filtros-collapse"
                                class="row justify-content-center g-3 collapse w-100 <?php if($noticiasFiltrosPainelAberto): ?> show <?php endif; ?>">
                                <div class="col-12 col-sm-6 col-lg-4">
                                    <label for="filtro-noticias-secretaria" class="visually-hidden"><?php echo e(__('Secretaria')); ?></label>
                                    <select id="filtro-noticias-secretaria" name="secretaria_id"
                                        class="form-select shadow-sm border-0 rounded-5 py-3"
                                        aria-label="<?php echo e(__('Filtrar por secretaria')); ?>">
                                        <option value=""><?php echo e(__('Todas as secretarias')); ?></option>
                                        <?php $__currentLoopData = $secretariasFiltro; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $secretaria): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($secretaria->id); ?>" <?php if(request('secretaria_id') === $secretaria->id): echo 'selected'; endif; ?>>
                                                <?php echo e($secretaria->name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                                <div class="col-12 col-sm-6 col-lg-4">
                                    <label for="filtro-noticias-ano" class="visually-hidden"><?php echo e(__('Ano')); ?></label>
                                    <select id="filtro-noticias-ano" name="ano"
                                        class="form-select shadow-sm border-0 rounded-5 py-3"
                                        aria-label="<?php echo e(__('Filtrar por ano')); ?>">
                                        <option value=""><?php echo e(__('Todos os anos')); ?></option>
                                        <?php $__currentLoopData = $anos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ano): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($ano); ?>" <?php if((string) request('ano') === (string) $ano): echo 'selected'; endif; ?>><?php echo e($ano); ?>

                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                                <div class="col-12 col-sm-6 col-lg-4">
                                    <label for="filtro-noticias-categoria" class="visually-hidden"><?php echo e(__('Categoria')); ?></label>
                                    <select id="filtro-noticias-categoria" name="categoria"
                                        class="form-select shadow-sm border-0 rounded-5 py-3"
                                        aria-label="<?php echo e(__('Filtrar por categoria')); ?>">
                                        <option value=""><?php echo e(__('Todas as categorias')); ?></option>
                                        <?php $__currentLoopData = $categorias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $categoriaEnum): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($categoriaEnum->name); ?>" <?php if(request('categoria') === $categoriaEnum->name): echo 'selected'; endif; ?>>
                                                <?php echo e(__($categoriaEnum->value)); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <?php $i = 0; ?>
            <!-- Exibir as 2 primeiras notícias -->
            <?php $__currentLoopData = $noticias->slice(0, 2); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $noticia): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-6 bottom20">
                    <div onclick="window.location='<?php echo e(route('paginas.slug', [date('d-m-Y', strtotime($noticia->created_at)), $noticia->slug])); ?>';"
                        class="card news-card h-100">
                        <img src="<?php echo e(file_exists( $pathSystem . $noticia->featuredPhoto ) ? asset($noticia->featuredPhoto) : asset($angraDefault)); ?>" class="card-img-top news-image-large h-100"
                            alt="Notícia">
                        <div class="news-content p-3">
                            <h5 class="news-title"><?php echo e(html_entity_decode($noticia->title)); ?></h5>
                            <p class="card-text"><?php echo e(Str::limit(html_entity_decode($noticia->summary), 100)); ?></p>
                            <p class="news-date">
                                <?php echo e(app(App\Http\Controllers\Controller::class)->formatDateToPortuguese($noticia->created_at)); ?>

                            </p>
                        </div>
                    </div>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

            <!-- Exibir as próximas 3 notícias -->
            <?php $__currentLoopData = $noticias->slice(2, 3); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $noticia): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-4 bottom20">
                    <div onclick="window.location='<?php echo e(route('paginas.slug', [date('d-m-Y', strtotime($noticia->created_at)), $noticia->slug])); ?>';"
                        class="card news-card h-100">
                        <img src="<?php echo e(file_exists( $pathSystem . $noticia->featuredPhoto ) ? asset($noticia->featuredPhoto) : asset($angraDefault)); ?>" class="card-img-top news-image-small" alt="Notícia">
                        <div class="news-content p-3">
                            <h5 class="news-title"><?php echo e(html_entity_decode($noticia->title)); ?></h5>
                            <p class="card-text"><?php echo e(Str::limit(html_entity_decode($noticia->summary), 100)); ?></p>
                            <p class="news-date">
                                <?php echo e(app(App\Http\Controllers\Controller::class)->formatDateToPortuguese($noticia->created_at)); ?>

                            </p>
                        </div>
                    </div>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

            <div id="mainNews"></div>
            <div id="noticiasMenoresDesktop" class="row">
                <!-- Exibir as notícias restantes -->
                <div class="col-md-9">
                        <?php $__currentLoopData = $noticias->slice(5, 10); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $noticia): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div onclick="window.location='<?php echo e(route('paginas.slug', [date('d-m-Y', strtotime($noticia->created_at)), $noticia->slug])); ?>';"
                            class="card news-card mb-5 d-flex flex-row align-items-center">
                            <img src="<?php echo e(file_exists( $pathSystem . $noticia->featuredPhoto ) ? asset($noticia->featuredPhoto) : asset($angraDefault)); ?>" class="news-image-menor" alt="Notícia">
                            <div class="news-content p-4">
                                <h5 class="news-title mt-3"><?php echo e(html_entity_decode($noticia->title)); ?></h5>
                                <p class="news-summary"><?php echo e(Str::limit(html_entity_decode($noticia->summary), 150)); ?></p>
                                <p class="news-date">
                                    <?php echo e(app(App\Http\Controllers\Controller::class)->formatDateToPortuguese($noticia->created_at)); ?>

                                </p>
                            </div>
                        </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>

                <div class="col-md-3 d-flex flex-column align-items-end">
                    <?php $__empty_1 = true; $__currentLoopData = $banners; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $banner): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <div class="d-flex justify-content-center align-items-center my-2">
                            <a href='<?php echo e($banner->url); ?>' target="<?php echo e($banner->target); ?>" alt="<?php echo e($banner->title); ?>"
                                title="<?php echo e($banner->title); ?>">
                                <img src="<?php echo e(asset($banner->photo)); ?>" alt="<?php echo e($banner->title); ?>"
                                    title="<?php echo e($banner->title); ?>" class="img-fluid rounded shadow-sm">
                            </a>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <?php endif; ?>
                </div>
            </div>

            <!-- MOBILE - Cards menores empilhados e banners (restantes) -->
            <div id="noticiasMenoresMobile" class="row m-auto">
                <?php $i = 5; ?>
                <?php $__currentLoopData = $noticias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $noticia): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if($i >= 5 && $i < 15): ?>
                        <div class="col-12 bottom20">
                            <div onclick="window.location='<?php echo e(route('paginas.slug', [date('d-m-Y', strtotime($noticia->created_at)), $noticia->slug])); ?>';"
                                class="card news-card h-100" style="height: 100% !important;">
                                <img src="<?php echo e(asset($noticia->featuredPhoto)); ?>" class="card-img-top news-image-large h-100"
                                    alt="Notícia">
                                <div class="news-content p-3">
                                    <h5 class="news-title">
                                        <?php echo e(html_entity_decode($noticia->title)); ?>

                                    </h5>
                                    <p class="card-text"><?php echo e(Str::limit(html_entity_decode($noticia->summary), 100)); ?></p>
                                    <p class="news-date">
                                        <?php echo e(app(App\Http\Controllers\Controller::class)->formatDateToPortuguese($noticia->created_at)); ?>

                                    </p>
                                </div>
                            </div>
                        </div>
                        <?php $i++; ?>
                    <?php else: ?>
                        <?php break; ?>
                    <?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <div class="col-12 d-flex flex-column justify-content-center align-items-center">
                    <?php $__empty_1 = true; $__currentLoopData = $banners; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $banner): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <a class="my-2" href='<?php echo e($banner->url); ?>' target="<?php echo e($banner->target); ?>" alt="<?php echo e($banner->title); ?>"
                            title="<?php echo e($banner->title); ?>">
                            <img src="<?php echo e(asset($banner->photo)); ?>" alt="<?php echo e($banner->title); ?>" title="<?php echo e($banner->title); ?>"
                                class="img-fluid rounded shadow-sm">
                        </a>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                    <?php endif; ?>
                </div>
            </div>

            <div class="row">
                <div class="col-12 my-3">
                    <div class="d-flex justify-content-center">
                        <?php echo $noticias->appends(request()->query())->links(); ?>

                    </div>
                </div>
            </div>

        </div>
    </div>
</section>

<script>
    document.addEventListener("DOMContentLoaded", function () {
        if (window.location.hash) {
            var element = document.querySelector(window.location.hash);
            if (element) {
                element.scrollIntoView({
                    behavior: "smooth",
                    block: "start"
                });
            }
        }
    });

</script>

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

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