<div class='col-12 col-lg-6 mb-2'>
    <div class='card card-result-container bg-color-6 border-0 mb-3'>
        <div class='card-body px-2 py-2 px-lg-3 py-lg-3'>
            <div class='row no-gutters'>
                <div class='col-12 col-xl-auto'>
                    <div class='card card-result shadow bg-transparent border-0'>
                        <div class='card-header bg-color-1 border-0 px-2 py-3'>
                            <h5 class='text-white text-center text-uppercase mb-0'>
                                <span><?= $name ?></span>
                            </h5>
                        </div>
                        <div class='card-body bg-color-4 border-0 px-0 py-0'>
                            <div class='row no-gutters align-items-center'>
                                <div class='col-auto'>
                                    <div class='box-date bg-color-9 px-2 py-2 py-lg-3'>
                                        <?php
                                            $date = $result['draw_date'] ?? date('Y-m-d');
                                            $day = date('d', strtotime($date));
                                            $month = date('M', strtotime($date));
                                            $year = date('Y', strtotime($date));
                                        ?>
                                        <div class='row no-gutters align-items-center justify-content-center'>
                                            <div class='col-auto col-lg-12'><h5 class='text-black text-center text-uppercase mb-0'><span><?= $month ?></span></h5></div>
                                            <div class='col-auto col-lg-12'><h1 class='text-black text-center mb-0'><span><?= $day ?></span></h1></div>
                                            <div class='col-auto col-lg-12'><h3 class='text-black text-center mb-0'><span><?= $year ?></span></h3></div>
                                        </div>
                                    </div>
                                </div>
                                <div class='col d-flex align-items-center justify-content-center'>
                                    <div class='pool-result-winner'>
                                        <p class='text-white text-center mb-2'>
                                            <span>Draw Result #<?= $result['draw_number'] ?? '--' ?></span>
                                        </p>
                                        <h5 class='text-white text-center font-weight-bold my-2'>
                                            <span>1st Prize</span>
                                        </h5>
                                        <div class='box-winner px-2 py-0 px-lg-1 mb-0'>
                                            <div class='prize text-center py-1'>
                                                <?php if ($result && !empty($result['first_prize'])): ?>
                                                    <div class="prize-wrapper">
                                                        <?php foreach (str_split($result['first_prize']) as $digit): ?>
                                                            <div class="prize-block"><div class="prize-digit"><?= $digit ?></div></div>
                                                        <?php endforeach; ?>
                                                    </div>
                                                <?php else: ?>
                                                    <p class="text-center text-muted">No data available</p>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 2nd & 3rd Prize -->
                        <!-- Starter & Consolation Prize -->
                        <!-- (Bisa copy bagian ini dari yang sudah ada sebelumnya) -->

                    </div>
                </div>

                <!-- History -->
                <div class='col-12 col-xl ml-xl-3'>
                    <div class='card card-detail bg-color-2 border-0 my-3 mt-xl-0 w-lg-80'>
                        <div class='card-body px-3 py-3'>
                            <h5 class='text-white text-center text-uppercase mb-2'><span>History Result</span></h5>
                            <table class='table table-sm table-borderless table-striped text-center mb-0'>
                                <thead class='bg-color-1 text-white'><tr><th>Date</th><th>Result</th></tr></thead>
                                <tbody class='bg-light'>
                                    <?php foreach ($history as $row): ?>
                                        <tr>
                                            <td><?= $row['draw_date'] ?></td>
                                            <td>
                                                <div class='text-center prize-wrapper'>
                                                    <?php foreach (str_split($row['first_prize']) as $digit): ?>
                                                        <div class='prize-block d-inline-block winner'><div class='prize-digit'><span><?= $digit ?></span></div></div>
                                                    <?php endforeach; ?>
                                                </div>
                                            </td>
                                        </tr>
                                    <?php endforeach; ?>
                                </tbody>
                            </table>
                        </div>
                        <div class='card-footer border-0 px-0 py-0 mt-1'>
                            <div class='button-wrapper'>
                                <div class='row no-gutters justify-content-center'>
                                    <div class='col-auto'>
                                        <a href='market/<?= $slug ?>' class='btn btn-warning font-weight-bold'>View All Result</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div><!-- END history -->
            </div>
        </div>
    </div>
</div>
