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

<main class="main">
    <?= $this->insert('includes/aside_info') ?>
    <div class="content">
        <div class="h2-title h2-title-content flex-s-c">
            <span>Perfil da guild: <?= $data['name'] ?></span>
        </div>
        <div class="items-start gap-5">
            <div>
                <?php if ($guild = $data) : ?>
                    <div class="hero flex-s">
                        <div class="row">
                            <div class="heroLeft block-6">
                                <div class="heroLeft-img flex-c-c">
                                    <img src="<?= $guild['image'] ?>" alt="<?= $guild['name'] ?>">
                                </div>
                            </div>
                            <div class="heroRight block-6">
                                <div class="heroName">
                                    <?= $guild['name'] ?>
                                </div>
                                <div class="heroflex">
                                    <div class="flexBlock">
                                        <?= $guild['score'] ?> <span class="flexBlock-sp"><span>Score</span></span>
                                    </div>
                                    <div class="flexBlock">
                                        <a href="<?= __redirect("preview/char/{$guild['master']}") ?>"><?= $guild['master'] ?></a><span class="flexBlock-sp"><span>Master</span></span>
                                    </div>
                                </div><!--heroflex-->
                                <div class="heroflex">
                                    <div class="flexBlock">
                                        <?= $guild['members_count'] ?> <span class="flexBlock-sp"><span>Members</span></span>
                                    </div>
                                </div><!--heroflex-->
                            </div>
                        </div>
                    </div>

                    <div class="item-view">
                        <div class="mt-4">
                            <div class="heroInfo">
                                <div class="heroInfo-title">
                                    Members
                                </div>

                                <div class="table-scroll">
                                    <table>
                                        <thead>
                                            <tr>
                                                <td>NR</td>
                                                <td>CHARACTER NAME</td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php $cont = 0;
                                            foreach ($guild['members_list'] as $member) : $cont++; ?>
                                                <tr>
                                                    <td>#<?= $cont ?></td>
                                                    <td><a href="<?= __redirect("preview/char/{$member->name}") ?>"><?= $member->name ?></a></td>
                                                </tr>
                                            <?php endforeach; ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>

                        </div>
                    </div>
                <?php else : ?>
                    <div class="warning">Unable to load guild details</div>
                <?php endif; ?>

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