<?php $__env->startSection('title', 'Archive'); ?>
<?php $__env->startSection('meta_description', 'Browse all past editions of ' . $siteName); ?>

<?php $__env->startSection('sidebar'); ?>
    <div class="sidebar-heading">Filter by Year</div>
    <?php $__currentLoopData = $years; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <a href="<?php echo e(route('archive', ['year' => $year])); ?>"
           class="page-thumb-item d-flex align-items-center gap-2 <?php echo e(request('year') == $year ? 'active' : ''); ?>">
            <i class="bi bi-calendar3"></i>
            <span style="font-family:'Inter',sans-serif;font-size:.82rem"><?php echo e($year); ?></span>
        </a>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

    <?php if($months->count()): ?>
        <div class="sidebar-heading mt-2">Filter by Month</div>
        <?php $__currentLoopData = $months; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $month): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <a href="<?php echo e(route('archive', ['year' => request('year'), 'month' => $month->month_key])); ?>"
               class="page-thumb-item d-flex align-items-center gap-2 <?php echo e(request('month') === $month->month_key ? 'active' : ''); ?>">
                <i class="bi bi-calendar-month"></i>
                <span style="font-family:'Inter',sans-serif;font-size:.78rem"><?php echo e($month->month_label); ?></span>
            </a>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    <?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="d-flex align-items-center justify-content-between mb-3">
        <h1 class="h4 mb-0" style="font-family:'Playfair Display',serif">
            <i class="bi bi-archive me-2"></i>Archive
            <?php if(request('month')): ?><small class="text-muted fs-6">— <?php echo e(\Carbon\Carbon::createFromFormat('Y-m', request('month'))->format('F Y')); ?></small><?php endif; ?>
            <?php if(request('year') && !request('month')): ?><small class="text-muted fs-6">— <?php echo e(request('year')); ?></small><?php endif; ?>
        </h1>
        <div class="d-flex gap-2">
            <form class="d-flex gap-2" method="GET" action="<?php echo e(route('archive')); ?>">
                <input type="month" name="month" class="form-control form-control-sm" value="<?php echo e(request('month')); ?>"
                       style="font-family:'Inter',sans-serif;font-size:.8rem">
                <button type="submit" class="btn btn-sm btn-dark">Filter</button>
                <?php if(request()->hasAny(['month','year'])): ?>
                    <a href="<?php echo e(route('archive')); ?>" class="btn btn-sm btn-outline-secondary">Clear</a>
                <?php endif; ?>
            </form>
        </div>
    </div>

    <?php if($newspapers->count()): ?>
        <div class="row g-3">
            <?php $__currentLoopData = $newspapers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $newspaper): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="col-6 col-sm-4 col-md-3 col-xl-2">
                    <a href="<?php echo e(route('newspaper.show', $newspaper->publish_date->format('Y-m-d'))); ?>" class="edition-card">
                        <?php if($newspaper->pages->count()): ?>
                            <img src="<?php echo e($newspaper->pages->first()->thumbnail_url); ?>"
                                 alt="<?php echo e($newspaper->publish_date->format('d M Y')); ?>" loading="lazy">
                        <?php else: ?>
                            <div style="aspect-ratio:3/4;background:#f5f0e8;display:flex;align-items:center;justify-content:center">
                                <i class="bi bi-newspaper" style="font-size:2.5rem;opacity:.3"></i>
                            </div>
                        <?php endif; ?>
                        <div class="edition-card-body">
                            <div class="edition-date-label"><?php echo e($newspaper->publish_date->format('d M Y')); ?></div>
                            <?php if($newspaper->edition_name): ?>
                                <div style="font-size:.75rem;font-family:'Inter',sans-serif;color:#555;white-space:nowrap;overflow:hidden;text-overflow:ellipsis">
                                    <?php echo e($newspaper->edition_name); ?>

                                </div>
                            <?php endif; ?>
                            <div style="font-size:.7rem;font-family:'Inter',sans-serif;color:#888">
                                <?php echo e($newspaper->pages_count); ?> page<?php echo e($newspaper->pages_count !== 1 ? 's' : ''); ?>

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

        <div class="mt-4 d-flex justify-content-center">
            <?php echo e($newspapers->links()); ?>

        </div>
    <?php else: ?>
        <div class="alert alert-light text-center py-5">
            <i class="bi bi-search" style="font-size:3rem;opacity:.3;display:block"></i>
            <h5 class="mt-3" style="font-family:'Playfair Display',serif">No editions found</h5>
            <a href="<?php echo e(route('archive')); ?>" class="btn btn-sm btn-outline-dark mt-2">Clear Filters</a>
        </div>
    <?php endif; ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/boguraj1/public_html/epaper/resources/views/frontend/archive.blade.php ENDPATH**/ ?>