<?php $__env->startSection('title', __('Lista - Boletins Meteorológicos')); ?>

<?php $__env->startSection('content'); ?>
<?php echo $__env->make('errors.messageFlash', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

<?php
    $perms = auth()->user()?->getPermissaoDetalhes('GERENCIADOR_DE_BOLETINS_METEOROLOGICOS') ?? [];
    $canAdd = $perms['adicionar'] ?? false;
    $canEdit = $perms['editar'] ?? false;
    $canDelete = $perms['excluir'] ?? false;
?>

<div class="card shadow-sm border-0" id="boletim-meteorologico-admin"
    data-toggle-url="<?php echo e(route('admin.boletim.meteorologico.toggle-status')); ?>"
    data-toggle-success="<?php echo e(__('Status atualizado com sucesso!')); ?>"
    data-toggle-error="<?php echo e(__('Erro ao atualizar status!')); ?>">
    <?php $__env->startComponent('components.buttons._headLineButtonsBackAdd', [
        'headLine' => "<i class='fa fa-cloud-sun me-2'></i> " . __('Boletins Meteorológicos'),
        'routeAdd' => 'admin.boletim.meteorologico.create',
        'nameAdd' => __('Novo Boletim'),
        'routeBack' => null,
        'permission' => 'GERENCIADOR_DE_BOLETINS_METEOROLOGICOS',
    ]); ?>
    <?php echo $__env->renderComponent(); ?>

    <div class="card-body">
        
        <div class="row g-2 mb-4">
            <?php if($canAdd): ?>
                <div class="col-12 col-md-4">
                    <a href="<?php echo e(route('admin.sobreavisos.index')); ?>" class="card text-decoration-none border h-100 action-card">
                        <div class="card-body text-center py-2 px-3">
                            <div class="mb-1">
                                <i class="fa-solid fa-triangle-exclamation fa-lg text-warning"></i>
                            </div>
                            <small class="card-title mb-0 fw-semibold text-dark d-block" style="font-size: 0.875rem;">
                                <?php echo e(__('Sobreaviso')); ?>

                            </small>
                        </div>
                    </a>
                </div>
                <div class="col-12 col-md-4">
                    <a href="<?php echo e(route('admin.tabua.index')); ?>" class="card text-decoration-none border h-100 action-card">
                        <div class="card-body text-center py-2 px-3">
                            <div class="mb-1">
                                <i class="fa-solid fa-water fa-lg text-info"></i>
                            </div>
                            <small class="card-title mb-0 fw-semibold text-dark d-block" style="font-size: 0.875rem;">
                                <?php echo e(__('Tábua de Marés')); ?>

                            </small>
                        </div>
                    </a>
                </div>
            <?php endif; ?>
            <div class="col-12 <?php echo e($canAdd ? 'col-md-4' : 'col-md-6 offset-md-3'); ?>">
                <a href="<?php echo e(route('paginas.boletim-meteorologico.index')); ?>" target="_blank" class="card text-decoration-none border h-100 action-card">
                    <div class="card-body text-center py-2 px-3">
                        <div class="mb-1">
                            <i class="fa-solid fa-newspaper fa-lg text-primary"></i>
                        </div>
                        <small class="card-title mb-0 fw-semibold text-dark d-block" style="font-size: 0.875rem;">
                            <?php echo e(__('Boletins Publicados')); ?>

                            <i class="fa-solid fa-external-link-alt ms-1" style="font-size: 0.7em; opacity: 0.6;"></i>
                        </small>
                    </div>
                </a>
            </div>
        </div>
        <?php
            $hasActiveFilters = request()->filled('q') || request()->filled('status');
        ?>

        <div class="card border-0 shadow-sm mb-4">
            <div class="card-header bg-light border-bottom">
                <h5 class="mb-0">
                    <i class="fa-solid fa-filter me-2 text-primary"></i>
                    <?php echo e(__('Filtros de Busca')); ?>

                </h5>
            </div>
            <div class="card-body">
                <form method="GET" action="<?php echo e(route('admin.boletim.meteorologico.index')); ?>" id="filtrosForm">
                    <div class="row g-2 align-items-end">
                        <div class="col-12 col-lg-5">
                            <label for="filtro_q" class="form-label fw-semibold">
                                <i class="fa-solid fa-magnifying-glass me-1 text-muted"></i>
                                <?php echo e(__('Pesquisar')); ?>

                            </label>
                            <div class="input-group">
                                <span class="input-group-text bg-light">
                                    <i class="fa-solid fa-newspaper text-muted"></i>
                                </span>
                                <input
                                    type="text"
                                    id="filtro_q"
                                    name="q"
                                    class="form-control"
                                    placeholder="<?php echo e(__('Buscar boletins...')); ?>"
                                    value="<?php echo e(request('q')); ?>"
                                >
                            </div>
                        </div>

                        <div class="col-12 col-lg-3">
                            <label for="filtro_status" class="form-label fw-semibold">
                                <i class="fa-solid fa-toggle-on me-1 text-muted"></i>
                                <?php echo e(__('Status')); ?>

                            </label>
                            <div class="input-group">
                                <span class="input-group-text bg-light">
                                    <i class="fa-solid fa-circle-check text-muted"></i>
                                </span>
                                <select
                                    id="filtro_status"
                                    name="status"
                                    class="form-select"
                                >
                                    <option value=""><?php echo e(__('Todos os Status')); ?></option>
                                    <option value="ATIVO" <?php echo e(request('status') == 'ATIVO' ? 'selected' : ''); ?>><?php echo e(__('Ativos')); ?></option>
                                    <option value="INATIVO" <?php echo e(request('status') == 'INATIVO' ? 'selected' : ''); ?>><?php echo e(__('Inativos')); ?></option>
                                </select>
                            </div>
                        </div>

                        <div class="col-12 col-lg-4">
                            <div class="d-flex gap-2">
                                <button class="btn btn-primary flex-fill" type="submit">
                                    <i class="fa-solid fa-magnifying-glass me-1"></i>
                                    <?php echo e(__('Filtrar')); ?>

                                </button>
                                <a href="<?php echo e(route('admin.boletim.meteorologico.index')); ?>" class="btn btn-outline-secondary">
                                    <i class="fa-solid fa-rotate-left me-1"></i>
                                    <?php echo e(__('Limpar')); ?>

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

                    <?php if($hasActiveFilters): ?>
                        <div class="row mt-3">
                            <div class="col-12">
                                <div class="d-flex flex-wrap gap-2 align-items-center">
                                    <small class="text-muted fw-semibold me-2">
                                        <i class="fa-solid fa-info-circle me-1"></i>
                                        <?php echo e(__('Filtros ativos:')); ?>

                                    </small>
                                    <?php if(request()->filled('q')): ?>
                                        <span class="badge bg-secondary">
                                            <i class="fa-solid fa-magnifying-glass me-1"></i>
                                            <?php echo e(__('Busca')); ?>: "<?php echo e(request()->input('q')); ?>"
                                            <button type="button" class="btn-close btn-close-white ms-2" style="font-size: 0.7em;" onclick="document.getElementById('filtro_q').value=''; document.getElementById('filtrosForm').submit();"></button>
                                        </span>
                                    <?php endif; ?>
                                    <?php if(request()->filled('status')): ?>
                                        <span class="badge bg-<?php echo e(request()->input('status') === 'ATIVO' ? 'success' : 'secondary'); ?>">
                                            <i class="fa-solid fa-toggle-<?php echo e(request()->input('status') === 'ATIVO' ? 'on' : 'off'); ?> me-1"></i>
                                            <?php echo e(request()->input('status') === 'ATIVO' ? __('Ativos') : __('Inativos')); ?>

                                            <button type="button" class="btn-close btn-close-white ms-2" style="font-size: 0.7em;" onclick="document.getElementById('filtro_status').value=''; document.getElementById('filtrosForm').submit();"></button>
                                        </span>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>
                </form>
            </div>
        </div>

        
        <?php if (isset($component)) { $__componentOriginal0650541a119648223455610148c86d0b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal0650541a119648223455610148c86d0b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.tables._table','data' => ['thead' => [
            __('Status'),
            __('Número'),
            __('Data'),
            __('Estado Manhã'),
            __('Estado Tarde'),
            __('Estado Noite'),
            __('Nível de Ação'),
            __('Link'),
            __('Ações'),
        ],'pagination' => $boletins->links()]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('tables._table'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['thead' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute([
            __('Status'),
            __('Número'),
            __('Data'),
            __('Estado Manhã'),
            __('Estado Tarde'),
            __('Estado Noite'),
            __('Nível de Ação'),
            __('Link'),
            __('Ações'),
        ]),'pagination' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($boletins->links())]); ?>
             <?php $__env->slot('body', null, []); ?> 
                <?php $__empty_1 = true; $__currentLoopData = $boletins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $boletim): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td>
                            <?php if($canEdit): ?>
                                <div class="form-check form-switch d-flex justify-content-center">
                                    <input class="form-check-input status-toggle js-status-toggle" type="checkbox"
                                        data-boletim-id="<?php echo e($boletim->id); ?>"
                                        <?php echo e($boletim->status == 'ATIVO' ? 'checked' : ''); ?>

                                        style="transform: scale(1.5); cursor: pointer;">
                                </div>
                            <?php else: ?>
                                <span class="badge <?php echo e($boletim->status === 'ATIVO' ? 'bg-success' : 'bg-secondary'); ?>">
                                    <?php echo e(__($boletim->status === 'ATIVO' ? 'Ativo' : 'Inativo')); ?>

                                </span>
                            <?php endif; ?>
                        </td>
                        <td><?php echo e($boletim->numero_boletim); ?></td>
                        <td><?php echo e(\Carbon\Carbon::parse($boletim->data)->format('d/m/Y')); ?></td>
                        <td><?php echo e($boletim->estado_manha); ?></td>
                        <td><?php echo e($boletim->estado_tarde); ?></td>
                        <td><?php echo e($boletim->estado_noite); ?></td>
                        <td>
                            <?php
                                $cores = [
                                    'VIGILÂNCIA' => 'success',
                                    'OBSERVAÇÃO' => 'warning',
                                    'ATENÇÃO' => 'danger',
                                    'ALERTA' => 'red',
                                    'ALERTA MÁXIMO' => 'purple',
                                ];
                                $cor = $cores[$boletim->nivel_de_acao] ?? 'secondary';
                            ?>
                            <span class="badge bg-<?php echo e($cor); ?>">
                                <?php echo e($boletim->nivel_de_acao); ?>

                            </span>
                        </td>
                        <td>
                            <div class="link-container" data-boletim-id="<?php echo e($boletim->id); ?>">
                                <?php if($boletim->status == 'ATIVO'): ?>
                                    <a target="_blank" href="<?php echo e(route('paginas.boletim-meteorologico.show', $boletim->id)); ?>"
                                        class="btn btn-sm btn-outline-primary">
                                        <i class="fa fa-external-link-alt"></i>
                                    </a>
                                <?php else: ?>
                                    <button class="btn btn-sm btn-outline-secondary" disabled title="Boletim desativado">
                                        <i class="fa fa-external-link-alt"></i>
                                    </button>
                                <?php endif; ?>
                            </div>
                        </td>
                        <td>
                            <?php if($canEdit || $canDelete): ?>
                                <div class="d-flex justify-content-center gap-1">
                                    <?php if($canEdit): ?>
                                        <a href="<?php echo e(route('admin.boletim.meteorologico.edit', $boletim->id)); ?>"
                                            class="btn btn-warning btn-sm" title="<?php echo e(__('Editar')); ?>">
                                            <i class="fa fa-pen"></i>
                                        </a>
                                    <?php endif; ?>

                                    <?php if($canDelete): ?>
                                        <form action="<?php echo e(route('admin.boletim.meteorologico.destroy', $boletim->id)); ?>"
                                            method="POST"
                                            onsubmit="return confirm('<?php echo e(__('Deseja realmente excluir este boletim?')); ?>')">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button class="btn btn-danger btn-sm" title="<?php echo e(__('Excluir')); ?>">
                                                <i class="fa fa-trash"></i>
                                            </button>
                                        </form>
                                    <?php endif; ?>
                                </div>
                            <?php else: ?>
                                <span class="text-muted">—</span>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="9" class="text-center text-muted">
                            <i class="fa fa-info-circle"></i> <?php echo e(__('Nenhum boletim encontrado')); ?>

                        </td>
                    </tr>
                <?php endif; ?>
             <?php $__env->endSlot(); ?>
         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal0650541a119648223455610148c86d0b)): ?>
<?php $attributes = $__attributesOriginal0650541a119648223455610148c86d0b; ?>
<?php unset($__attributesOriginal0650541a119648223455610148c86d0b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal0650541a119648223455610148c86d0b)): ?>
<?php $component = $__componentOriginal0650541a119648223455610148c86d0b; ?>
<?php unset($__componentOriginal0650541a119648223455610148c86d0b); ?>
<?php endif; ?>
    </div>
</div>

<?php $__env->startPush('styles'); ?>
<link rel="stylesheet" href="<?php echo e(asset('pmar/css/defesa-civil/boletim-meteorologico-admin.css')); ?>">
<style>
    /* Cards de Ação Rápida - Pequenos e Sutis */
    .action-card {
        border: 1px solid #e9ecef !important;
        background: #fff;
        transition: all 0.2s ease;
        cursor: pointer;
    }

    .action-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important;
        border-color: #ced4da !important;
        text-decoration: none;
        background-color: #f8f9fa;
    }

    .action-card .card-body {
        padding: 0.75rem 0.5rem;
    }

    .action-card:hover .fa-lg {
        transform: scale(1.05);
        transition: transform 0.2s ease;
    }

    .action-card .fa-lg {
        transition: transform 0.2s ease;
        opacity: 0.8;
    }

    .action-card:hover .fa-lg {
        opacity: 1;
    }

    .action-card .card-title {
        color: #495057;
        font-size: 0.875rem;
        line-height: 1.3;
    }

    .action-card:hover .card-title {
        color: #212529;
    }

    /* Melhorias visuais para os filtros */
    .card-header.bg-light {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    }

    .input-group-text {
        border-right: none;
        transition: all 0.3s ease;
    }

    .form-control:focus,
    .form-select:focus {
        border-left: none;
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
    }

    .input-group:focus-within .input-group-text {
        background-color: #e7f1ff;
        border-color: #86b7fe;
    }

    .badge {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
    }

    .badge .btn-close {
        opacity: 0.8;
        transition: opacity 0.2s ease;
    }

    .badge .btn-close:hover {
        opacity: 1;
    }

    .btn-primary {
        box-shadow: 0 2px 4px rgba(13, 110, 253, 0.2);
        transition: all 0.3s ease;
    }

    .btn-primary:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(13, 110, 253, 0.3);
    }

    .btn-outline-secondary {
        transition: all 0.3s ease;
        min-width: 100px;
    }

    .btn-outline-secondary:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2);
    }

    .d-flex.gap-2 {
        align-items: stretch;
    }

    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }

    @media (max-width: 991px) {
        .d-flex.gap-2 {
            flex-direction: column;
        }

        .d-flex.gap-2 .btn {
            width: 100%;
        }

        .badge {
            font-size: 0.75rem;
            padding: 0.4rem 0.6rem;
        }
    }

    /* Animação suave para os badges de filtros ativos */
    .badge {
        animation: fadeIn 0.3s ease-in;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(-5px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

</style>
<?php $__env->stopPush(); ?>

<?php $__env->startPush('scripts'); ?>
<script src="<?php echo e(asset('pmar/js/defesa-civil/boletim-meteorologico-admin.js')); ?>"></script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

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