<?= $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>Auctions: <?= $auction->title ?></span>
        </div>

        <div class="flex-c-c align-start gap-10">
            <div class="my-characters-market auctions-info">
                <div>
                    <p class="name"><?= $auction->title ?></p>
                    <div>
                        <img src="<?= __resources('auctions/' . $auction->image) ?>" width="140">
                    </div>
                    <p class="name">Lance mínimo: <?= $auction->price ?> <?= $auction->coin_name ?></p>
                    <p class="name mt-4">Finaliza em: <?= date('d/m H:i', strtotime($auction->date)) ?></p>
                </div>

                <?php if (__login()) : ?>
                    <?php if ($auction->date > date('Y-m-d H:i:s', strtotime('now'))) : ?>
                        <br>
                        <div class="web-form">
                            <form action="<?= __redirect('auction/auth/auction/lance') ?>" method="post">
                                <div class="fields">
                                    <div class="fieldGroup">
                                        <input type="hidden" name="id_lance" value="<?= $auction->id ?>">
                                        <span>Digite seu lance:</span>
                                        <input class="py-1 px-3 rounded-full border border-neutral-300 block w-full focus:outline-none focus:bg focus:bg-neutral-100" type="number" name="price" placeholder="0">
                                    </div>
                                </div>

                                <button class="rounded-full py-1 px-4 bg-orange-500 text-white block mt-4 mx-auto text-sm border-2 border-orange-400 hover:bg-orange-700 transition ease-in-out duration-500" type="submit">Dar lance</button>
                            </form>
                        </div>
                    <?php else : ?>
                        <div class="warning"><em><strong>Auction</strong></em> completed</div>
                    <?php endif; ?>
                <?php else : ?>
                    <div class="warning">Log into your <em><strong>Account</strong></em> <br> to place a bid</div>
                <?php endif; ?>
            </div>

            <div class="w-full bg-neutral-200 p-1">
                <?php if ($lances) : ?>
                    <table class="border-collpase w-full">
                        <thead class="bg-neutral-900">
                            <tr>
                                <td>#</td>
                                <td>Nome:</td>
                                <td>Lance:</td>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $cont = 0;
                            foreach ($lances as $lance) : $cont++; ?>
                                <tr>
                                    <td width="80">#<?= $cont ?>º</td>
                                    <td width="130"><?= $lance->name ?></td>
                                    <td><?= $lance->price ?> <?= $auction->coin_name ?></td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                <?php
                else : ?>
                    <div class="warning">Does not contain <em><strong>auction bids</strong></em> at this time</div>
                <?php endif; ?>
            </div>
        </div>
    </div>
</main>