<?= $this->layout('_theme', ['title' => $title, 'subtitle' => "Ticket - " . $ticket_info->subject]); ?>

<div class="p-3 bg-neutral-200/80">
    <section>
        <aside>
            <?php if ($ticket_info->image) : ?>
                <center>
                    <div class="image">
                        <img src="<?= __resources('ticket/' . $ticket_info->image) ?>" alt="Imagem Ticket" class="w-max object-contain">
                    </div>
                </center>
            <?php endif; ?>
            <div class="p-2 bg-neutral-300 my-2 rounded-lg border border-neutral-400 text-sm shadow drop-shadow-lg">
                <?= $ticket_info->message ?>
            </div>
        </aside>
        <p class="text-center p-1 text-neutral-900 font-semibold text-xs">Criado por: <?= $ticket_info->name ?> | <?= date('d/m/y H:i', strtotime($ticket_info->date)) ?></p>
    </section>
</div>

<div class="my-4"></div>

<div class="p-1 text-neutral-900 uppercase font-semibold bg-neutral-200/50 rounded-sm">
    <h4> Respostas:</h4>
</div>

<div class="post-comments ticket-comments">
    <?php if ($tickets_answered) : foreach ($tickets_answered as $answered) : ?>
            <div class="p-2 bg-neutral-200/60 my-4">
                <div class="p-2 bg-neutral-200 my-2 rounded-lg border border-neutral-300 text-sm shadow drop-shadow-lg">
                    <?= $answered->message ?>
                </div>
                <p class="text-center p-1 text-neutral-900 font-semibold text-xs">Respondido por: <?= $answered->name ?> | <?= date('d/m/y H:i', strtotime($answered->date)) ?> </p>
            </div>
        <?php endforeach;
    else : ?>
        <div class="p-1 bg-yellow-300 text-sm rounded-full text-black text-center w-full">Não há respostas no momento</div>
    <?php endif; ?>
</div>

<div class="p-2 bg-neutral-200 mt-4">
    <form action="<?= __redirect("administration/auth/ticket/new/to/respond/{$ticket_info->id}") ?>" method="post">
        <?= __csrf(); ?>
        <input type="hidden" name="id_ticket" value="<?= $ticket_info->id ?>">
        <div>
            <p class="px-1 py-3 text-sm">Mensagem <sup class="text-red-500">*</sup></p>
            <textarea class="py-1 px-3 rounded-lg border border-neutral-300 block w-full focus:outline-none focus:bg focus:bg-neutral-100" cols="30" rows="4" name="message" required minlength="10" maxlength="1000" placeholder="Digite aqui sua resposta"></textarea>
        </div>

        <button class="rounded-lg py-3 px-6 bg-sky-500 text-white block mt-4 mx-auto text-sm border-2 border-sky-400 hover:bg-sky-700 transition ease-in-out duration-500" type="submit">Enviar</button>
    </form>
</div>