@extends('layouts.arte-sacra.theme')

@section('title', env('APP_NAME') . ' :: Galeria de Arte Sacra')
@section('content')
    <div class="container py-5">
        <div class="text-left pt-5 pb-4">
            <a href="{{ route('paginas.cultura.arteSacra.index') }}" class="btn btn-secondary d-inline-block"><i
                    class="fa-solid fa-arrow-left-long"></i> Voltar </a>
        </div>

        <div class="text-center mb-5 mt-2">
            <h1 class="display-4 mb-5 text-secondary text-center cinzel-decorative-bold">Galeria de Arte Sacra</h1>

            @include('errors.messageFlash')

            <div class="mb-3 mt-5">
                <form method="GET" action="{{ route('paginas.cultura.arteSacra.galeria') }}" class="mb-3">
                    <div class="input-group">
                        <input type="text" name="busca" value="{{ request('busca') }}" class="form-control"
                            placeholder="Buscar por nome da arte..." style="border-radius: 30px;" />
                        <button class="btn btn-primary" type="submit">Buscar</button>
                        <a href="{{ route('paginas.cultura.arteSacra.galeria') }}" class="btn btn-outline-secondary">Limpar</a>
                    </div>
                </form>
            </div>
        </div>

        <div id="artes-container">
            @if ($acervos->isEmpty())
                <p class="text-center">Nenhum item disponível para exibição no momento.</p>
            @else
                <div class="row">
                    @foreach ($acervos as $arte)
                        <div class="col-md-4 mb-4">
                            <div class="card h-100 shadow-sm card-hover">
                                @if ($arte->imagem && $arte->imagem !== 'default.jpg')
                                    <img src="{{ asset('pmar/assets/img/arte_sacra/' . $arte->imagem) }}" class="img-fluid"
                                        style="height: 250px; width: 100%; object-fit: cover;" alt="{{ $arte->nome_peca }}">
                                @else
                                    <img src="{{ asset('pmar/assets/img/arte_sacra/default.jpg') }}" class="img-fluid"
                                        style="height: 250px; width: 100%; object-fit: cover;" alt="Imagem não disponível">
                                @endif

                                <div class="card-body">
                                    <h5 class="card-title">{{ $arte->nome_peca }}</h5>
                                    <p>{{ $arte->created_at->format('d \d\e F \d\e Y') }}</p>

                                    <a href="{{ route('paginas.cultura.arteSacra.show', Str::slug($arte->nome_peca)) }}"
                                        class="btn btn-primary" target="_blank">Ver detalhes</a>
                                </div>
                            </div>
                        </div>
                    @endforeach
                </div>

                @if ($acervos->hasPages())
                    <nav class="mt-4">
                        <ul class="pagination justify-content-center">
                            @if ($acervos->onFirstPage())
                                <li class="page-item disabled"><span class="page-link">&laquo; Anterior</span></li>
                            @else
                                <li class="page-item">
                                    <a class="page-link" href="{{ $acervos->previousPageUrl() }}" rel="prev">&laquo;
                                        Anterior</a>
                                </li>
                            @endif

                            @foreach ($acervos->getUrlRange(1, $acervos->lastPage()) as $page => $url)
                                <li class="page-item {{ $acervos->currentPage() == $page ? 'active' : '' }}">
                                    <a class="page-link" href="{{ $url }}">{{ $page }}</a>
                                </li>
                            @endforeach

                            @if ($acervos->hasMorePages())
                                <li class="page-item">
                                    <a class="page-link" href="{{ $acervos->nextPageUrl() }}" rel="next">Próximo
                                        &raquo;</a>
                                </li>
                            @else
                                <li class="page-item disabled"><span class="page-link">Próximo &raquo;</span></li>
                            @endif
                        </ul>
                    </nav>
                @endif
            @endif
        </div>
    </div>

    <a href="#" id="backToTop" class="back-to-top">
        <i class="fa-solid fa-chevron-up fw-bold fs-4"></i>
    </a>

    <style>
        main {
            background-color: #f5f3f0;
            background-image: url("https://www.transparenttextures.com/patterns/dark-stripes-light.png");
        }
    </style>
@endsection
