<?= $this->layout('_layout', ['title' => $title]); ?>


    
<main>
    <div class="topHomeBlocks flex-s">

        <?php if (plugin()->slider) :
            if ($sliders) : ?>
                <div class="newsSlider block-50">
                    <div class="swiper-container swiper-news">
                        <div class="swiper-wrapper">
                            <?php foreach ($sliders as $slider) : ?>
                                <div class="swiper-slide">
                                    <?php if ($slider['title']) : ?>
                                        <div class="swiper-news_info">
                                            <p><?= $slider['title'] ?></p>
                                        </div>
                                    <?php endif; ?>
                                    <img src="<?= __resources('slider/' . $slider['image']) ?>" alt="">
                                </div>
                            <?php endforeach; ?>
                        </div>
                        <div class="swiper-news-pagination">
                            <!-- Add Pagination -->
                            <div class="swiper-pagination"></div>
                            <!-- Add Arrows -->
                            <div class="swiper-button-next"></div>
                            <div class="swiper-button-prev"></div>
                        </div>
                    </div>
                </div>
                <div class="my-4"></div>
            <?php endif; ?>
        <?php endif; ?>
        <?php if (plugin()->notices) : ?>
            <div class="newsBlock block-50">
                
                <div class="h2-title flex-s-c">
                    <span>Last News</span> <a href="">All news</a>
                </div><!--h2-title-->
                <div class="body-news">
                <?php
                if ($posts) : foreach ($posts as $post) :?>
                                        <?php
                                        switch ($post['tag']) {
                                            case 'Avisos':
                                                $color = '#FFA500'; // Laranja para avisos
                                                break;
                                            case 'Promoção':
                                                $color = '#FF4500'; // Laranja avermelhado para promoção
                                                break;
                                            case 'Eventos':
                                                $color = '#1E90FF'; // Azul claro para eventos
                                                break;
                                            case 'Manutenção':
                                                $color = '#808080'; // Cinza para manutenção
                                                break;
                                            case 'Novidades':
                                                $color = '#32CD32'; // Verde para novidades
                                                break;
                                            default:
                                                $color = '#000000'; // Cor padrão (preto) caso nenhuma das tags seja encontrada
                                        }
                                        ?>

                        <div class="new-news-line-box">
                            <div class="new-news-tag" style="background:<?=$color?>">
                                <?= $post['tag'] ?>
                            </div>
                            <div class="new-news-title" style="width:70%;">
                                <a href="<?= $post['url'] ? $post['url'] : $post['redirect'] ?>" <?= $post['url'] ? 'target="_blank"' : '' ?>><?= $post['title'] ?></a> <sup style="color:<?= $color ?>"><?= dateBRL($post['created']) ?></sup>
                            </div>
                            
                        </div>
                    <?php endforeach;
                else : ?>
                    <p class="p-1 bg-yellow-300 text-sm rounded-full text-black text-center w-full">Não há notícias no momento</p>
                <?php endif; ?>
            </div><!--newsBlock-->
        <?php endif; ?>
    </div>

    </div><!--topHomeBlocks-->

    		<div class="newsBlock block-50" style="margin-top:20px; display:flex; width:100%; justify-content:space-between; align-items:center; flex-direction:row; flex-wrap:nowrap;">

<div class="body-news" style="margin:20px;">
		 <div class="h2-title flex-s-c">
                    <span>Informações</span> <a href=""></a>
                </div>
    <?php foreach (server as $key => $value): ?>
        <div class="new-news-line-box">
            <div class="new-news-tag" style="background: red"> <?= ucfirst(str_replace('_', ' ', $key)) ?> </div>
            <div class="new-news-title" style="width:70%;">
                <a href="#"><?= $value ?></a>
            </div>
        </div>
    <?php endforeach; ?>
	
</div><!--newsBlock--><!--newsBlock-->


<div class="body-news" style="margin:20px;">
			 <div class="h2-title flex-s-c">
                    <span>Social</span> <a href=""></a>
                </div>
    <?php foreach (social as $key => $value): ?>
        <div class="new-news-line-box">
            <div class="new-news-tag" style="background: #3d06a5"> <?= ucfirst(str_replace('_', ' ', $key)) ?> </div>
            <div class="new-news-title" style="width:70%;">
                <a href="<?= $value ?>"><?= ucfirst(str_replace('_', ' ', $key)) ?></a>
            </div>
        </div>
    <?php endforeach; ?>
</div><!--newsBlock--><!--newsBlock-->


		</div>	
		
    <!-- End Stream -->
    
        <!--forumHome-->
        

		
		
<span class="line"></span>
        <div class="soc-home-box">
          <div class="h2-title flex-s-c">
            <span>Hall da Fama</span>
          </div>
          <div class="socHome2">
            <?= $this->insert('includes/top-resets') ?>
            <?= $this->insert('includes/top-resets-day') ?>
            <?= $this->insert('includes/top-resets-wek') ?>
            <?= $this->insert('includes/top-resets-mon') ?>
            <?= $this->insert('includes/top-pk') ?>
			<?= $this->insert('includes/top-donate') ?>
			
            </div>
        </div>
        
        
    <?php if (plugin()->market) :
        $this->insert('user/market/home', ['market' => $market]);
    endif; ?>


    


    <?php if (plugin()->castle_siege) :
        if ($castle_siege->guild) :

    ?>
    <span class="line"></span>
            <div>
                <div class="h2-title flex-s-c">
                    <span>Castle Siege</span>
                </div>

                <div class="castle_siege flex-c-c gap-20" style="background: url('<?= __files('images/bg-castle-siege.png') ?>'); background-size:cover; background-repeat: no-repat;">
                    <div class="guild">
                        <div>
                            <a href="<?= __redirect("preview/guild/{$castle_siege->guild}") ?>" class="preview" data-type="guild" data-name="<?= $castle_siege->guild  ?>">
                                <img src="<?= __guildmark($castle_siege->mark) ?>" width="103" height="103">
                            </a>
                            
                        </div>
                        <div style="margin-left:30px;">
                            <br>
                            <div>
                                <h3>Dona do Castelo: <a href="#" class="preview" data-type="guild" data-name="<?= $castle_siege->guild  ?>"> <?= $castle_siege->guild ?> </a></h3>
                            </div>
                            <div >
                                <!--<p>Próximo confronto: <br> <strong><?= $castle_siege->next_confront ?></strong></p>-->
                                <p style="color:white;">Próximo confronto:  <strong>Domingo às 19:00</strong> <sup style="color:white; font-size:10px; top:-9px; position:relative; background-color:#008300; padding:1px 6px; border-radius:10px;" id="countdown"></sup></p>
                                
                            </div>
                        </div>
                    </div>
                </div>

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

    


    <?= $this->start('modal_script') ?>
    <script>
        var swiper = new Swiper(".modalSlide", {
            loop: true,
            pagination: {
                el: ".swiper-pagination",
            },
            autoplay: {
                delay: 15000,
                disableOnInteraction: false,
            },
        });

        $(document).ready(function() {
            var store = localStorage.getItem('modal_status');
            var store_hours = localStorage.getItem('modal_hours');

            if (store != null && store_hours != null) {
                let now = Date.now(),
                    diff = (now - store_hours),
                    minutes = 10,
                    seconds = 60,
                    milliseconds = 1000,
                    delay = (minutes * seconds * milliseconds);

                if (diff >= delay) {
                    localStorage.removeItem('modal_status');
                    localStorage.removeItem('modal_hours');
                    $(".modal").addClass("active");
                }
            }

            if (store == null) {
                $(".modal").addClass("active");
            }
        });

        $(document).on("click", ".modal .closed-modal", function(e) {
            e.preventDefault();
            $(".modal").removeClass("active");
            localStorage.setItem('modal_status', 'no-active');
            localStorage.setItem('modal_hours', Date.now());
        });
    </script>
    <?= $this->stop(); ?>
</main>

