<div class="ads">
    <?= $settings['dashboard_top_ad'] ?>
</div>

<style>
.lb-banner{
    display:flex;align-items:center;justify-content:center;gap:10px;
    background:linear-gradient(135deg, rgba(139,92,246,.16), rgba(245,72,139,.12));
    border:1px solid var(--line);border-radius:16px;padding:14px 18px;margin-bottom:22px;
    color:var(--text);font-weight:600;font-size:13.5px;text-align:center;
}
.lb-banner i{color:#FFB23C;font-size:15px;}
.lb-banner b{font-family:var(--font-mono);color:#fff;}

.lb-card{
    background:var(--surface);border:1px solid var(--line);border-radius:18px;
    border-top:3px solid transparent;height:100%;overflow:hidden;
}
.lb-card.acc-violet{border-top-color:#8B5CF6;}
.lb-card.acc-pink{border-top-color:#F5488B;}
.lb-card.acc-mint{border-top-color:#22E3A5;}
.lb-card.acc-amber{border-top-color:#FFB23C;}
.lb-card.acc-blue{border-top-color:#3C8CFF;}
.lb-card.acc-orange{border-top-color:#FF7A3C;}

.lb-card .card-body{padding:22px;}
.lb-card-title{
    font-family:var(--font-display);letter-spacing:.03em;font-size:19px;color:var(--text);
    display:flex;align-items:center;justify-content:center;gap:10px;margin-bottom:6px;
}
.lb-icon{
    width:32px;height:32px;border-radius:10px;display:flex;align-items:center;justify-content:center;
    font-size:14px;color:#fff;flex-shrink:0;
}
.lb-icon.violet{background:linear-gradient(135deg,#8B5CF6,#5B21B6);box-shadow:0 6px 14px -4px rgba(139,92,246,.6);}
.lb-icon.pink{background:linear-gradient(135deg,#F5488B,#B91C5C);box-shadow:0 6px 14px -4px rgba(245,72,139,.6);}
.lb-icon.mint{background:linear-gradient(135deg,#22E3A5,#0E9E71);box-shadow:0 6px 14px -4px rgba(34,227,165,.6);}
.lb-icon.amber{background:linear-gradient(135deg,#FFC93C,#FF7A3C);box-shadow:0 6px 14px -4px rgba(255,178,60,.6);}
.lb-icon.blue{background:linear-gradient(135deg,#3C8CFF,#2563EB);box-shadow:0 6px 14px -4px rgba(60,140,255,.6);}
.lb-icon.orange{background:linear-gradient(135deg,#FF9A3C,#E05A1C);box-shadow:0 6px 14px -4px rgba(255,122,60,.6);}

.lb-subtitle{color:var(--text-dim);font-size:13px;margin-bottom:18px;}
.lb-subtitle b{color:var(--text);font-family:var(--font-mono);}

.lb-card .table-responsive{margin:0;}
.lb-table{width:100%;border-collapse:collapse;color:var(--text);margin:0;background:transparent !important;}
.lb-table thead th{
    background:transparent !important;color:var(--text-dim) !important;font-size:11px;
    text-transform:uppercase;letter-spacing:.05em;border-bottom:1px solid var(--line) !important;
    border-top:none !important;padding:10px 8px;font-weight:700;text-align:center;
}
.lb-table tbody tr{background:transparent !important;transition:background .15s ease;}
.lb-table tbody tr:hover{background:var(--surface-2) !important;}
.lb-table tbody td,.lb-table tbody th{
    padding:10px 8px;border-bottom:1px solid var(--line) !important;border-top:none !important;
    font-size:13.5px;vertical-align:middle;text-align:center;
}
.lb-table tbody tr:last-child td,.lb-table tbody tr:last-child th{border-bottom:none !important;}

.lb-rank{
    display:inline-flex;align-items:center;justify-content:center;
    width:26px;height:26px;border-radius:50%;font-weight:700;font-size:12px;
    background:var(--surface-3);color:var(--text-dim);
}
.lb-rank.top-1{background:linear-gradient(135deg,#FFD65C,#FF9F1C);color:#2a1a00;box-shadow:0 0 12px rgba(255,193,58,.5);}
.lb-rank.top-2{background:linear-gradient(135deg,#E7ECF7,#A9B4C6);color:#1a1f2e;box-shadow:0 0 10px rgba(200,210,230,.35);}
.lb-rank.top-3{background:linear-gradient(135deg,#E2A76F,#B8703A);color:#2a1503;box-shadow:0 0 10px rgba(200,140,80,.35);}

.username-rank{font-weight:700;color:var(--text) !important;}

.lb-reward{
    display:inline-flex;align-items:center;padding:3px 10px;border-radius:999px;
    background:rgba(255,178,60,.16);color:#FFB23C;
    font-family:var(--font-mono);font-size:12px;font-weight:700;white-space:nowrap;
}
</style>

<div class="lb-banner">
    <i class="fas fa-clock"></i>
    Weekly Leaderboard Resets In <b><?= timespan(time(), $settings["leaderboard_date"], 2) ?></b> · updated every 10 minutes
</div>

<div class="row">
    <div class="col-12 col-md-6 col-lg-6 order-md-1 mb-4 text-center">
        <div class="card lb-card acc-violet">
            <div class="card-body text-center">
                <h4 class="lb-card-title"><span class="lb-icon violet"><i class="fas fa-layer-group"></i></span> Level leaderboard</h4>
                <p class="lb-subtitle">Top 20 highest level users!</p>
                <div class="table-responsive">
                    <table class="table lb-table text-center">
                        <thead>
                            <tr>
                                <th scope="col">#</th>
                                <th scope="col">Username</th>
                                <th scope="col">Level</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $rank = 1;
                            foreach ($topLevel as $u) {
                                $rankNum = $rank++;
                                $rankClass = $rankNum <= 3 ? ' top-' . $rankNum : '';
                                echo '<tr><td><span class="lb-rank' . $rankClass . '">' . $rankNum . '</span></td><td class="username-rank">' . $u["username"] . '</td><td>' . $u["level"] . '</td></tr>';
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <?php if ($settings['activity_contest_reward'] != "") {
        $rewards = explode('|', $settings['activity_contest_reward'])
    ?>
        <div class="col-12 col-md-6 col-lg-6 order-md-1 mb-4 text-center">
            <div class="card lb-card acc-pink">
                <div class="card-body text-center">
                    <h4 class="lb-card-title"><span class="lb-icon pink"><i class="fas fa-fire"></i></span> Activity contest leaderboard</h4>
                    <p class="lb-subtitle">Top 20 claimers of this week! Your exp earned this week: <b><?= $user['claims'] ?></b></p>
                    <div class="table-responsive">
                        <table class="table lb-table text-center">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Username</th>
                                    <th scope="col">Level</th>
                                    <th scope="col">Exp</th>
                                    <th scope="col">Reward</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $rank = 0;
                                foreach ($topClaimer as $u) {
                                    $reward = $rank < count($rewards) ? $rewards[$rank] : 0;
                                    $rankNum = ++$rank;
                                    $rankClass = $rankNum <= 3 ? ' top-' . $rankNum : '';
                                    echo '<tr><td><span class="lb-rank' . $rankClass . '">' . $rankNum . '</span></td><td class="username-rank">' . $u["username"] . '</td><td>' . $u["level"] . '</td><td>' . $u["claims"] . '</td><td><span class="lb-reward">' . $reward . ' USD</span></td></tr>';
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    <?php } ?>
    <?php if ($settings['referral_contest_reward'] != "") {
        $rewards = explode('|', $settings['referral_contest_reward'])
    ?>
        <div class="col-12 col-md-6 col-lg-6 order-md-1 mb-4 text-center">
            <div class="card lb-card acc-mint">
                <div class="card-body text-center">
                    <h4 class="lb-card-title"><span class="lb-icon mint"><i class="fas fa-share-alt"></i></span> Referral contest leaderboard</h4>
                    <p class="lb-subtitle">Top 20 users of referral contest! Your referrals this week: <b><?= $user['ref_count'] ?></b></p>
                    <div class="table-responsive">
                        <table class="table lb-table text-center">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Username</th>
                                    <th scope="col">Level</th>
                                    <th scope="col">Referral</th>
                                    <th scope="col">Reward</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $rank = 0;
                                foreach ($topReferral as $u) {
                                    $reward = $rank < count($rewards) ? $rewards[$rank] : 0;
                                    $rankNum = ++$rank;
                                    $rankClass = $rankNum <= 3 ? ' top-' . $rankNum : '';
                                    echo '<tr><td><span class="lb-rank' . $rankClass . '">' . $rankNum . '</span></td><td class="username-rank">' . $u["username"] . '</td><td>' . $u["level"] . '</td><td>' . $u["ref_count"] . '</td><td><span class="lb-reward">' . $reward . ' USD</span></td></tr>';
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    <?php } ?>
    <?php if ($settings['faucet_contest_reward'] != "") {
        $rewards = explode('|', $settings['faucet_contest_reward'])
    ?>
        <div class="col-12 col-md-6 col-lg-6 order-md-1 mb-4 text-center">
            <div class="card lb-card acc-amber">
                <div class="card-body text-center">
                    <h4 class="lb-card-title"><span class="lb-icon amber"><i class="fas fa-tint"></i></span> Faucet contest leaderboard</h4>
                    <p class="lb-subtitle">Top 20 users of faucet contest! Your faucet claim this week: <b><?= $user['faucet_count_tmp'] ?></b></p>
                    <div class="table-responsive">
                        <table class="table lb-table text-center">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Username</th>
                                    <th scope="col">Level</th>
                                    <th scope="col">Claims</th>
                                    <th scope="col">Reward</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $rank = 0;
                                foreach ($topFaucet as $u) {
                                    $reward = $rank < count($rewards) ? $rewards[$rank] : 0;
                                    $rankNum = ++$rank;
                                    $rankClass = $rankNum <= 3 ? ' top-' . $rankNum : '';
                                    echo '<tr><td><span class="lb-rank' . $rankClass . '">' . $rankNum . '</span></td><td class="username-rank">' . $u["username"] . '</td><td>' . $u["level"] . '</td><td>' . $u["faucet_count_tmp"] . '</td><td><span class="lb-reward">' . $reward . ' USD</span></td></tr>';
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    <?php } ?>
    <?php if ($settings['shortlink_contest_reward'] != "") {
        $rewards = explode('|', $settings['shortlink_contest_reward'])
    ?>
        <div class="col-12 col-md-6 col-lg-6 order-md-1 mb-4 text-center">
            <div class="card lb-card acc-blue">
                <div class="card-body text-center">
                    <h4 class="lb-card-title"><span class="lb-icon blue"><i class="fas fa-link"></i></span> Shortlink contest leaderboard</h4>
                    <p class="lb-subtitle">Top 20 users of shortlink contest! Your shortlink claim this week: <b><?= $user['shortlink_count_tmp'] ?></b></p>
                    <div class="table-responsive">
                        <table class="table lb-table text-center">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Username</th>
                                    <th scope="col">Level</th>
                                    <th scope="col">Claims</th>
                                    <th scope="col">Reward</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $rank = 0;
                                foreach ($topShortlink as $u) {
                                    $reward = $rank < count($rewards) ? $rewards[$rank] : 0;
                                    $rankNum = ++$rank;
                                    $rankClass = $rankNum <= 3 ? ' top-' . $rankNum : '';
                                    echo '<tr><td><span class="lb-rank' . $rankClass . '">' . $rankNum . '</span></td><td class="username-rank">' . $u["username"] . '</td><td>' . $u["level"] . '</td><td>' . $u["shortlink_count_tmp"] . '</td><td><span class="lb-reward">' . $reward . ' USD</span></td></tr>';
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    <?php } ?>
    <?php if ($settings['offerwall_contest_reward'] != "") {
        $rewards = explode('|', $settings['offerwall_contest_reward'])
    ?>
        <div class="col-12 col-md-6 col-lg-6 order-md-1 mb-4 text-center">
            <div class="card lb-card acc-orange">
                <div class="card-body text-center">
                    <h4 class="lb-card-title"><span class="lb-icon orange"><i class="fas fa-window-restore"></i></span> Offerwall contest leaderboard</h4>
                    <p class="lb-subtitle">Top 20 users of offerwall contest! Your offerwall claim this week: <b><?= $user['offerwall_count_tmp'] ?></b></p>
                    <div class="table-responsive">
                        <table class="table lb-table text-center">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Username</th>
                                    <th scope="col">Level</th>
                                    <th scope="col">Claims</th>
                                    <th scope="col">Reward</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $rank = 0;
                                foreach ($topOfferwall as $u) {
                                    $reward = $rank < count($rewards) ? $rewards[$rank] : 0;
                                    $rankNum = ++$rank;
                                    $rankClass = $rankNum <= 3 ? ' top-' . $rankNum : '';
                                    echo '<tr><td><span class="lb-rank' . $rankClass . '">' . $rankNum . '</span></td><td class="username-rank">' . $u["username"] . '</td><td>' . $u["level"] . '</td><td>' . $u["offerwall_count_tmp"] . '</td><td><span class="lb-reward">' . $reward . ' USD</span></td></tr>';
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    <?php } ?>
</div>