<?php $__env->startSection("title", env("APP_NAME") . " - Escolas Municipais"); ?>
<?php $__env->startSection('content'); ?>

    <div class="container my-4">

        
        <div class="row mb-4">
            <div class="col-12 my-3">
                <?php echo $__env->make('servicos.parts.breadcrumb', ['current' => __('Escolas Municipais')], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
            </div>

            
            <div class="col-12 mb-3">
                <h1 class="title"><?php echo e(__("Unidades Escolares da Rede Municipal")); ?></h1>
                <div class="card shadow-sm border-0">
                    <div class="card-body p-3">
                        <div class="row g-2 align-items-end">

                            
                            <div class="col-12 col-md-4">
                                <label for="searchInput" class="form-label small fw-semibold text-secondary mb-1">
                                    <i class="fas fa-search me-1"></i><?php echo e(__("Pesquisar")); ?>

                                </label>
                                <input type="text"
                                       id="searchInput"
                                       class="form-control form-control-sm"
                                       placeholder="<?php echo e(__('Nome da escola ou bairro...')); ?>"
                                       aria-label="<?php echo e(__('Pesquisar escola')); ?>">
                            </div>

                            
                            <div class="col-6 col-md-2">
                                <label for="bairroFilter" class="form-label small fw-semibold text-secondary mb-1">
                                    <i class="fas fa-map-marker-alt me-1"></i><?php echo e(__("Bairro")); ?>

                                </label>
                                <select id="bairroFilter"
                                        class="form-select form-select-sm"
                                        aria-label="<?php echo e(__('Filtrar por bairro')); ?>">
                                    <option value=""><?php echo e(__("Todos")); ?></option>
                                </select>
                            </div>

                            
                            <div class="col-6 col-md-2">
                                <label for="climatizacaoFilter" class="form-label small fw-semibold text-secondary mb-1">
                                    <i class="fas fa-snowflake me-1"></i><?php echo e(__("Climatização")); ?>

                                </label>
                                <select id="climatizacaoFilter"
                                        class="form-select form-select-sm"
                                        aria-label="<?php echo e(__('Filtrar por climatização')); ?>">
                                    <option value=""><?php echo e(__("Todas")); ?></option>
                                    <option value="CLIMATIZADA"><?php echo e(__("Climatizada")); ?></option>
                                    <option value="EM_ANDAMENTO"><?php echo e(__("Em andamento")); ?></option>
                                    <option value="PENDENTE"><?php echo e(__("Pendente")); ?></option>
                                </select>
                            </div>

                            
                            <div class="col-6 col-md-2">
                                <label for="recursosFilter" class="form-label small fw-semibold text-secondary mb-1">
                                    <i class="fas fa-universal-access me-1"></i><?php echo e(__("Recursos Especiais")); ?>

                                </label>
                                <select id="recursosFilter"
                                        class="form-select form-select-sm"
                                        aria-label="<?php echo e(__('Filtrar por recursos especiais')); ?>">
                                    <option value=""><?php echo e(__("Todos")); ?></option>
                                    <option value="sim"><?php echo e(__("Com recursos especiais")); ?></option>
                                </select>
                            </div>

                            
                            <div class="col-12 col-md-2 d-flex align-items-end">
                                <button id="clearFilters"
                                        class="btn btn-sm btn-outline-secondary w-100"
                                        title="<?php echo e(__('Limpar todos os filtros')); ?>"
                                        aria-label="<?php echo e(__('Limpar filtros')); ?>">
                                    <i class="fas fa-times me-1"></i><?php echo e(__("Limpar")); ?>

                                </button>
                            </div>

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

        
        <div class="row mb-3">
            <div class="col-12">
                <div class="alert alert-light mb-0" role="status" aria-live="polite">
                    <span id="resultCount">0</span> <?php echo e(__("escolas encontradas")); ?>

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

        
        <div class="row" id="escolasContainer">
            <?php $__currentLoopData = $escolas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $escola): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php
                    $bairro = strtolower(optional($escola->endereco)->bairro ?? '');
                    $bairroLabel = optional($escola->endereco)->bairro ?? __('Não informado');
                    $logradouro = optional($escola->endereco)->logradouro ?? __('Não informado');
                    $numero = optional($escola->endereco)->numero ?? __('S/N');
                    $cep = optional($escola->endereco)->cep ?? null;
                    $latitude = optional($escola->endereco)->latitude;
                    $longitude = optional($escola->endereco)->longitude;
                ?>
                <?php
                    $clima = $escola->climatizacao ?? 'PENDENTE';
                    $climaBadge = match($clima) {
                        'CLIMATIZADA'  => ['label' => __('Climatizada'),        'class' => 'badge-climatizada',  'icon' => 'fa-snowflake'],
                        'EM_ANDAMENTO' => ['label' => __('Climatiz. andamento'), 'class' => 'badge-em-andamento', 'icon' => 'fa-spinner'],
                        default        => ['label' => __('Pend. climatização'),  'class' => 'badge-pendente',     'icon' => 'fa-clock'],
                    };
                ?>

                <div class="col-md-6 col-lg-4 mb-4 escola-card"
                     data-nome="<?php echo e(strtolower($escola->nome)); ?>"
                     data-bairro="<?php echo e($bairro); ?>"
                     data-recursos="<?php echo e($escola->possuiRecursosMultifuncionais ? 'sim' : 'nao'); ?>"
                     data-climatizacao="<?php echo e($clima); ?>">
                    <div class="card h-100 shadow-sm">
                        <img src="<?php echo e($escola->foto_url); ?>"
                             class="card-img-top escola-card-foto escola-card-transition"
                             alt="<?php echo e($escola->nome); ?>"
                             onerror="this.onerror=null;this.src='<?php echo e(asset('pmar/assets/img/icons/escola.png')); ?>'">
                        <div class="card-body">
                            <h5 class="card-title"><?php echo e($escola->nome); ?></h5>
                            <p class="card-text text-muted mb-2">
                                <i class="fas fa-map-marker-alt text-danger me-1"></i>
                                <?php echo e($bairroLabel); ?>

                            </p>
                            <div class="d-flex flex-wrap gap-1">
                                <?php if($escola->possuiRecursosMultifuncionais): ?>
                                    <span class="badge badge-recursos">
                                        <i class="fas fa-universal-access me-1"></i><?php echo e(__("Recursos especiais")); ?>

                                    </span>
                                <?php endif; ?>
                                <?php if($clima === 'CLIMATIZADA'): ?>
                                    <span class="badge <?php echo e($climaBadge['class']); ?>">
                                        <i class="fas <?php echo e($climaBadge['icon']); ?> me-1"></i><?php echo e($climaBadge['label']); ?>

                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="card-footer bg-white border-top-0 pt-0">
                            <button type="button"
                                    class="btn btn-sm btn-primary w-100"
                                    data-bs-toggle="modal"
                                    data-bs-target="#modalEscolaMunicipal<?php echo e($escola->id); ?>"
                                    aria-label="<?php echo e(__('Ver detalhes de')); ?> <?php echo e($escola->nome); ?>">
                                <i class="fas fa-info-circle me-1"></i><?php echo e(__("Detalhes")); ?>

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

        
        <div id="noResults" class="row d-none">
            <div class="col-12">
                <div class="alert alert-warning text-center py-4">
                    <i class="fas fa-school fa-3x mb-3 d-block"></i>
                    <h4><?php echo e(__("Nenhuma escola encontrada")); ?></h4>
                    <p class="mb-0"><?php echo e(__("Tente ajustar os filtros de pesquisa")); ?></p>
                </div>
            </div>
        </div>

    </div>

    
    <?php $__currentLoopData = $escolas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $escola): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php
            $clima = $escola->climatizacao ?? 'PENDENTE';
            $climaBadge = match($clima) {
                'CLIMATIZADA'  => ['label' => __('Climatizada'),            'class' => 'badge-climatizada',  'icon' => 'fa-snowflake', 'text' => 'text-success'],
                'EM_ANDAMENTO' => ['label' => __('Climatização em andamento'), 'class' => 'badge-em-andamento', 'icon' => 'fa-spinner',  'text' => 'text-info'],
                default        => ['label' => __('Climatização pendente'),    'class' => 'badge-pendente',     'icon' => 'fa-clock',    'text' => 'text-secondary'],
            };
        ?>

        <div class="modal fade"
             id="modalEscolaMunicipal<?php echo e($escola->id); ?>"
             tabindex="-1"
             aria-labelledby="modalLabel<?php echo e($escola->id); ?>"
             aria-hidden="true">
            <div class="modal-dialog modal-xl modal-fullscreen-md-down">
                <div class="modal-content shadow-lg border-0 overflow-hidden">

                    
                    <div class="position-relative">
                        <img src="<?php echo e($escola->foto_url); ?>"
                             class="modal-escola-foto"
                             alt="<?php echo e($escola->nome); ?>"
                             onerror="this.onerror=null;this.src='<?php echo e(asset('pmar/assets/img/icons/escola.png')); ?>'">

                        <div class="position-absolute top-0 start-0 w-100 h-100 modal-escola-header-overlay"></div>

                        <button type="button"
                                class="btn-close btn-close-white position-absolute top-0 end-0 m-3"
                                data-bs-dismiss="modal"
                                aria-label="<?php echo e(__('Fechar')); ?>"></button>

                        <div class="position-absolute bottom-0 start-0 p-4 text-white">
                            <div class="d-flex flex-wrap gap-2 mb-2">
                                <span class="badge bg-primary"><?php echo e($escola->tipoUnidadeEscolar); ?></span>
                                <?php if($escola->possuiRecursosMultifuncionais): ?>
                                    <span class="badge badge-recursos">
                                        <i class="fas fa-universal-access me-1"></i><?php echo e(__("Recursos Especiais")); ?>

                                    </span>
                                <?php endif; ?>
                                <span class="badge <?php echo e($climaBadge['class']); ?>">
                                    <i class="fas <?php echo e($climaBadge['icon']); ?> me-1"></i><?php echo e($climaBadge['label']); ?>

                                </span>
                            </div>
                            <h2 class="fw-bold text-shadow mb-1" id="modalLabel<?php echo e($escola->id); ?>">
                                <?php echo e($escola->nome); ?>

                            </h2>
                            <p class="mb-0 text-white text-shadow">
                                <i class="fas fa-map-marker-alt me-1"></i>
                                <?php echo e($bairroLabel); ?> — Angra dos Reis/RJ
                            </p>
                        </div>
                    </div>

                    
                    <div class="modal-body p-0">
                        <div class="row g-0">

                            
                            <div class="col-md-5 p-4 border-end">

                                <h6 class="text-muted text-uppercase fw-semibold mb-3 small">
                                    <i class="fas fa-info-circle me-1"></i><?php echo e(__("Informações de Contato")); ?>

                                </h6>

                                <ul class="list-unstyled mb-0">
                                    <li class="d-flex align-items-start gap-3 mb-3">
                                        <span class="text-danger mt-1 flex-shrink-0">
                                            <i class="fas fa-map-marker-alt fa-fw"></i>
                                        </span>
                                        <div>
                                            <div class="fw-semibold small text-muted"><?php echo e(__("Endereço")); ?></div>
                                            <div><?php echo e($logradouro); ?>, <?php echo e($numero); ?></div>
                                            <div class="text-muted small">
                                                <?php echo e($bairroLabel); ?> — CEP: <?php echo e($cep ?? __('Não informado')); ?>

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

                                    <li class="d-flex align-items-start gap-3 mb-3">
                                        <span class="text-primary mt-1 flex-shrink-0">
                                            <i class="fas fa-envelope fa-fw"></i>
                                        </span>
                                        <div>
                                            <div class="fw-semibold small text-muted"><?php echo e(__("E-mail")); ?></div>
                                            <?php if($escola->email): ?>
                                                <a href="mailto:<?php echo e($escola->email); ?>" class="text-decoration-none"><?php echo e($escola->email); ?></a>
                                            <?php else: ?>
                                                <span class="text-muted fst-italic small"><?php echo e(__("Não informado")); ?></span>
                                            <?php endif; ?>
                                        </div>
                                    </li>

                                    <li class="d-flex align-items-start gap-3">
                                        <span class="text-success mt-1 flex-shrink-0">
                                            <i class="fas fa-phone-alt fa-fw"></i>
                                        </span>
                                        <div>
                                            <div class="fw-semibold small text-muted"><?php echo e(__("Telefone")); ?></div>
                                            <?php if($escola->telefone): ?>
                                                <a href="tel:+55<?php echo e($escola->telefone); ?>" class="text-decoration-none">
                                                    <?php echo e(preg_replace('/(\d{2})(\d{4,5})(\d{4})/', '($1) $2-$3', $escola->telefone)); ?>

                                                </a>
                                            <?php else: ?>
                                                <span class="text-muted fst-italic small"><?php echo e(__("Não informado")); ?></span>
                                            <?php endif; ?>
                                        </div>
                                    </li>
                                </ul>

                                
                                <hr class="my-3">
                                <h6 class="text-muted text-uppercase fw-semibold mb-2 small">
                                    <i class="fas fa-snowflake me-1"></i><?php echo e(__("Climatização")); ?>

                                </h6>
                                <div class="d-flex align-items-center gap-2 mb-2">
                                    <span class="badge <?php echo e($climaBadge['class']); ?> px-3 py-2">
                                        <i class="fas <?php echo e($climaBadge['icon']); ?> me-1"></i>
                                        <?php echo e($climaBadge['label']); ?>

                                    </span>
                                </div>
                                <?php if($escola->observacoes_climatizacao): ?>
                                    <p class="text-muted small mb-0"><?php echo e($escola->observacoes_climatizacao); ?></p>
                                <?php endif; ?>

                                
                                <?php if($escola->informacoes): ?>
                                    <hr class="my-3">
                                    <h6 class="text-muted text-uppercase fw-semibold mb-2 small">
                                        <i class="fas fa-file-alt me-1"></i><?php echo e(__("Informações Adicionais")); ?>

                                    </h6>
                                    <div class="small"><?php echo $escola->informacoes; ?></div>
                                <?php endif; ?>

                            </div>

                            
                            <div class="col-md-7 modal-escola-mapa d-flex flex-column">
                                <?php if($latitude && $longitude): ?>
                                    <iframe
                                        class="modal-escola-iframe"
                                        frameborder="0"
                                        scrolling="no"
                                        marginheight="0"
                                        marginwidth="0"
                                        src="https://maps.google.com/maps?q=<?php echo e($latitude); ?>,<?php echo e($longitude); ?>&z=17&output=embed"
                                        title="<?php echo e(__('Localização de')); ?> <?php echo e($escola->nome); ?>"
                                        allowfullscreen>
                                    </iframe>
                                <?php else: ?>
                                    <div class="flex-grow-1 d-flex flex-column justify-content-center align-items-center bg-light text-center p-4">
                                        <i class="fas fa-map-marker-alt fa-3x mb-3 text-secondary"></i>
                                        <p class="text-muted mb-0"><?php echo e(__("Localização não disponível")); ?></p>
                                    </div>
                                <?php endif; ?>
                            </div>

                        </div>
                    </div>

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

<?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/servicos/escolasMunicipais.blade.php ENDPATH**/ ?>