<?php
// Ensure this path jumps up from public/user/ to the root for config
require_once __DIR__ . '/../../config/config.php';
@include_once __DIR__ . '/../includes/ad-display.php';

$settings_file = __DIR__ . '/../../config/site-settings.json';
$site_name = 'tipspac';
if (file_exists($settings_file)) {
    $loaded = json_decode(file_get_contents($settings_file), true);
    if (!empty($loaded['site_name'])) $site_name = $loaded['site_name'];
}

// ---------------------------------------------------------
// SESSION & TIER MANAGEMENT
// ---------------------------------------------------------
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

if (!isset($_SESSION['user_id'])) {
    header("Location: ../login-register.php?mode=login");
    exit;
}

$is_vip = (isset($_SESSION['user_tier']) && $_SESSION['user_tier'] === 'VIP');

// ---------------------------------------------------------
// DATE FILTERING LOGIC
// ---------------------------------------------------------
$view_day = $_GET['day'] ?? 'today';
$query = "SELECT * FROM admin_manual_tips";

if ($view_day === 'yesterday') {
    $query .= " WHERE match_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)";
} elseif ($view_day === 'upcoming') {
    $query .= " WHERE match_date > CURDATE()";
} elseif ($view_day === 'history') {
    $query .= " WHERE 1=1";
} else {
    $query .= " WHERE match_date = CURDATE()";
}

$query .= " ORDER BY match_date ASC, match_time ASC LIMIT 50";

try {
    $stmt = $pdo->query($query);
    $all_tips = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
    $all_tips = [];
}

$bankers = array_filter($all_tips, function($t) { return ($t['tip_type'] ?? 'BANKER') === 'BANKER'; });
$slip_of_the_day = array_filter($all_tips, function($t) { return ($t['tip_type'] ?? '') === 'SLIP'; });

$today_timestamp = strtotime(date('Y-m-d'));

// Helper functions
function getTrust($row) {
    $conf = isset($row['confidence']) ? (int)$row['confidence'] : 75;
    return number_format($conf / 10, 1);
}

function outcomeBadge($status) {
    if ($status === 'WON') {
        return '<span class="bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 px-3 py-1.5 rounded-lg text-[12px] font-black tracking-wider uppercase flex items-center gap-1"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg> Won</span>';
    } elseif ($status === 'LOST') {
        return '<span class="bg-rose-500/10 text-rose-400 border border-rose-500/20 px-3 py-1.5 rounded-lg text-[12px] font-black tracking-wider uppercase flex items-center gap-1"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg> Lost</span>';
    } else {
        return '<span class="bg-slate-800 text-slate-400 border border-slate-700 px-3 py-1.5 rounded-lg text-[12px] font-black tracking-wider uppercase flex items-center gap-1"><span class="w-2 h-2 rounded-full bg-slate-500 animate-pulse"></span> Pending</span>';
    }
}

function timeAgo($timestamp) {
    if (empty($timestamp)) return 'Just now';
    $diff = time() - strtotime($timestamp);
    if ($diff < 60) return $diff . 's ago';
    if ($diff < 3600) return floor($diff / 60) . 'm ago';
    if ($diff < 86400) return floor($diff / 3600) . 'h ago';
    return date('M d', strtotime($timestamp));
}
?>
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Odds Database - <?php echo htmlspecialchars($site_name); ?></title>
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        ::-webkit-scrollbar { width: 6px; }
        ::-webkit-scrollbar-track { background: #020617; }
        ::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 10px; }
        ::-webkit-scrollbar-thumb:hover { background: #334155; }
        .hide-scroll::-webkit-scrollbar { display: none; }
        .hide-scroll { -ms-overflow-style: none; scrollbar-width: none; }

        /* MOBILE CARD LAYOUT */
        .match-card {
            background: rgba(15, 23, 42, 0.6);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(30, 41, 59, 0.5);
            border-radius: 1.25rem;
            padding: 1.25rem;
            margin-bottom: 0.75rem;
            transition: background 0.2s;
        }
        .match-card:hover {
            background: rgba(30, 41, 59, 0.4);
        }

        .match-card .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
        }
        .match-card .header .title {
            font-size: 11px;
            font-weight: 800;
            color: #fbbf24;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }
        .match-card .header .meta {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 10px;
            color: #94a3b8;
        }
        .match-card .header .meta .vip-badge {
            font-size: 8px;
            font-weight: 700;
            text-transform: uppercase;
            padding: 0.1rem 0.5rem;
            border-radius: 0.25rem;
            border: 1px solid;
        }
        .vip-badge.free {
            color: #34d399;
            border-color: rgba(52, 211, 153, 0.3);
            background: rgba(52, 211, 153, 0.1);
        }
        .vip-badge.vip {
            color: #f59e0b;
            border-color: rgba(245, 158, 11, 0.3);
            background: rgba(245, 158, 11, 0.1);
        }

        .match-card .teams {
            font-size: 20px;
            font-weight: 800;
            color: #f1f5f9;
            text-align: center;
            padding: 0.5rem 0;
            border-bottom: 1px solid rgba(30, 41, 59, 0.3);
            margin-bottom: 0.75rem;
        }
        .match-card .teams .vs {
            font-size: 12px;
            color: #64748b;
            margin: 0 0.5rem;
        }

        .match-card .details {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.75rem;
            margin-bottom: 0.75rem;
        }
        .match-card .details .item {
            display: flex;
            flex-direction: column;
        }
        .match-card .details .item .label {
            font-size: 9px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: #94a3b8;
            margin-bottom: 0.1rem;
        }
        .match-card .details .item .value {
            font-size: 14px;
            font-weight: 700;
            color: #f1f5f9;
        }
        .match-card .details .item .value .tip-badge {
            display: inline-block;
            background: rgba(16, 185, 129, 0.15);
            border: 1px solid rgba(16, 185, 129, 0.3);
            padding: 0.1rem 0.6rem;
            border-radius: 0.375rem;
            font-weight: 700;
            font-size: 13px;
            color: #34d399;
        }
        .match-card .details .item .trust-score {
            font-size: 18px;
            font-weight: 800;
            color: #34d399;
        }
        .match-card .details .item .trust-score .den {
            font-size: 12px;
            color: #64748b;
        }

        .match-card .footer {
            display: flex;
            justify-content: flex-start;
            border-top: 1px solid rgba(30, 41, 59, 0.3);
            padding-top: 0.75rem;
            font-size: 10px;
            color: #64748b;
        }

        /* DESKTOP GRID LAYOUT - 5 columns */
        @media (min-width: 1024px) {
            .match-card {
                display: grid;
                grid-template-columns: 1.8fr 1.8fr 1.5fr 1.5fr 1.2fr;
                gap: 0.5rem;
                padding: 0.75rem 1rem;
                border-radius: 0;
                background: transparent;
                backdrop-filter: none;
                border: none;
                border-bottom: 1px solid rgba(30, 41, 59, 0.5);
                margin-bottom: 0;
                align-items: center;
            }
            .match-card:hover {
                background: rgba(30, 41, 59, 0.15);
            }
            /* Hide mobile-only elements on desktop */
            .match-card .header,
            .match-card .teams,
            .match-card .details,
            .match-card .footer {
                display: contents;
            }
            .match-card .header .title,
            .match-card .header .meta,
            .match-card .teams .vs,
            .match-card .details .item .label,
            .match-card .footer .time-ago {
                display: none;
            }

            /* Desktop grid items */
            .match-card .desktop-date {
                display: flex;
                flex-direction: column;
            }
            .match-card .desktop-date .title {
                font-size: 10px;
                font-weight: 800;
                color: #fbbf24;
                text-transform: uppercase;
                letter-spacing: 0.05em;
            }
            .match-card .desktop-date .date-time {
                font-size: 10px;
                color: #94a3b8;
            }
            .match-card .desktop-match {
                font-size: 13px;
                font-weight: 700;
                color: #f1f5f9;
                display: flex;
                align-items: center;
                gap: 0.3rem;
                flex-wrap: wrap;
            }
            .match-card .desktop-match .vs {
                font-size: 9px;
                color: #64748b;
                font-weight: 600;
            }
            .match-card .desktop-prediction {
                font-size: 12px;
                font-weight: 700;
                color: #34d399;
                background: rgba(16, 185, 129, 0.1);
                border: 1px solid rgba(16, 185, 129, 0.2);
                padding: 0.15rem 0.6rem;
                border-radius: 0.375rem;
                display: inline-block;
                width: fit-content;
            }
            .match-card .desktop-status {
                display: flex;
                align-items: center;
            }
            .match-card .desktop-trust {
                font-size: 14px;
                font-weight: 800;
                color: #34d399;
                text-align: right;
            }
            .match-card .desktop-trust .den {
                font-size: 10px;
                color: #64748b;
            }
            .match-card .desktop-tier {
                display: none;
            }

            /* VIP Slip desktop styling */
            .match-card.vip-slip .desktop-prediction {
                color: #fbbf24;
                background: rgba(245, 158, 11, 0.1);
                border-color: rgba(245, 158, 11, 0.2);
            }
            .match-card.vip-slip .desktop-trust {
                color: #fbbf24;
            }
            .match-card.vip-slip .desktop-date .title {
                color: #fbbf24;
            }
        }

        @media (max-width: 1023px) {
            .match-card .desktop-date,
            .match-card .desktop-match,
            .match-card .desktop-prediction,
            .match-card .desktop-status,
            .match-card .desktop-trust,
            .match-card .desktop-tier {
                display: none;
            }
        }
    </style>
</head>
<body class="bg-[#020617] text-slate-300 font-sans antialiased min-h-screen relative overflow-x-hidden">

    <div class="fixed inset-0 z-0 pointer-events-none opacity-20 bg-cover bg-center bg-no-repeat" style="background-image: url('https://images.unsplash.com/photo-1579952363873-27f3bade9f55?q=80&w=2000&auto=format&fit=crop');"></div>
    <div class="fixed inset-0 z-0 bg-gradient-to-t from-[#020617] via-[#020617]/90 to-[#020617]/80 pointer-events-none"></div>
    <canvas id="neuralCanvas" class="fixed inset-0 w-full h-full pointer-events-none z-0 opacity-30"></canvas>

    <?php @include_once __DIR__ . '/includes/sidebar.php'; ?>

    <div class="relative z-10 flex flex-col min-h-screen md:pl-64 transition-all duration-300">
        
        <header class="md:hidden w-full border-b border-slate-800/60 bg-slate-950/80 backdrop-blur-md h-16 flex items-center justify-between px-4 sticky top-0 z-30">
            <div class="text-white font-black tracking-tighter text-lg flex items-center space-x-2">
                <span class="w-2 h-2 rounded-full bg-emerald-500 animate-pulse"></span>
                <span>tipspac <span class="text-emerald-400">Pro</span></span>
            </div>
            <button onclick="toggleSidebar()" class="text-slate-300 hover:text-white p-2 focus:outline-none">
                <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path></svg>
            </button>
        </header>

        <main class="flex-1 w-full max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 pt-8 pb-20 space-y-6">

            <div class="flex flex-col md:flex-row md:items-end justify-between space-y-4 md:space-y-0 border-b border-slate-800/60 pb-6">
                <div>
                    <div class="inline-flex items-center space-x-2 bg-emerald-500/10 border border-emerald-500/20 px-3 py-1 rounded-full text-[9px] font-bold tracking-widest uppercase text-emerald-400 mb-2">
                        <span class="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"></span>
                        <span>Neural System Database</span>
                    </div>
                    <h1 class="text-3xl md:text-4xl font-black text-white tracking-tight">Odds & Ledger <span class="text-cyan-400">Terminal</span></h1>
                    <p class="text-xs text-slate-400 mt-1 max-w-xl">Deep system tracking of highly probable match parameters.</p>
                </div>
            </div>

            <!-- Date navigation -->
            <div class="w-full pb-2">
                <div class="flex items-center justify-start md:justify-start space-x-2 overflow-x-auto hide-scroll py-1">
                    <a href="?day=yesterday" class="shrink-0 text-[9px] font-bold text-slate-500 hover:text-slate-300 uppercase tracking-wider px-4 py-2 transition bg-slate-900/40 rounded-xl border border-slate-800 <?php echo $view_day === 'yesterday' ? 'text-slate-950 bg-cyan-400 border-cyan-400 shadow' : ''; ?>"><?php echo date('d M', strtotime('-1 days')); ?></a>
                    <a href="?day=today" class="shrink-0 text-[9px] font-black text-white bg-gradient-to-r from-emerald-600 to-teal-600 shadow-lg shadow-emerald-500/25 uppercase tracking-widest px-6 py-2 rounded-xl transition <?php echo $view_day === 'today' ? 'ring-2 ring-white/20' : ''; ?>">Today, <?php echo date('d M'); ?></a>
                    <a href="?day=upcoming" class="shrink-0 text-[9px] font-bold text-slate-500 hover:text-slate-300 uppercase tracking-wider px-4 py-2 transition bg-slate-900/40 rounded-xl border border-slate-800 <?php echo $view_day === 'upcoming' ? 'text-slate-950 bg-emerald-400 border-emerald-400 shadow' : ''; ?>">Tomorrow</a>
                    <a href="?day=history" class="shrink-0 text-[9px] font-bold text-slate-500 hover:text-slate-300 uppercase tracking-wider px-4 py-2 transition bg-slate-900/40 rounded-xl border border-slate-800 <?php echo $view_day === 'history' ? 'text-slate-950 bg-cyan-400 border-cyan-400 shadow' : ''; ?>">History</a>
                </div>
            </div>

            <!-- Stats Cards -->
            <div class="grid grid-cols-1 md:grid-cols-3 gap-4 md:gap-6 pt-2">
                <div class="bg-slate-900/60 backdrop-blur-xl border border-slate-800/80 rounded-2xl p-5 flex flex-col items-center justify-center shadow-lg">
                    <span class="text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3">System Matches</span>
                    <div class="w-14 h-14 rounded-full bg-gradient-to-br from-emerald-500 to-teal-700 flex items-center justify-center text-sm font-black text-white shadow-lg shadow-emerald-500/20">
                        <?php echo count($bankers) + count($slip_of_the_day); ?>
                    </div>
                </div>
                <div class="bg-slate-900/60 backdrop-blur-xl border border-slate-800/80 rounded-2xl p-5 flex flex-col items-center justify-center shadow-lg">
                    <span class="text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3">Premium VIP</span>
                    <div class="w-14 h-14 rounded-full bg-gradient-to-br from-amber-500 to-orange-700 flex items-center justify-center text-sm font-black text-white shadow-lg shadow-amber-500/20">
                        <?php echo count($slip_of_the_day); ?>
                    </div>
                </div>
                <div class="bg-slate-900/60 backdrop-blur-xl border border-slate-800/80 rounded-2xl p-5 flex flex-col items-center justify-center shadow-lg">
                    <span class="text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3">AI Accuracy</span>
                    <div class="w-14 h-14 rounded-full bg-gradient-to-br from-emerald-500 to-teal-800 flex items-center justify-center text-sm font-black text-white shadow-lg shadow-emerald-500/20">
                        84%
                    </div>
                </div>
            </div>

            <!-- Tabs -->
            <div class="flex items-center space-x-6 border-b border-slate-800 pb-3 text-xs font-black tracking-[0.2em] uppercase mt-6">
                <button onclick="switchTab('bankers')" id="tab-bankers" class="tab-btn text-emerald-400 border-b-2 border-emerald-500 pb-3 -mb-3.5 focus:outline-none transition">Bankers</button>
                <button onclick="switchTab('slip')" id="tab-slip" class="tab-btn text-slate-500 hover:text-slate-300 pb-3 -mb-3.5 focus:outline-none transition">Slip of the Day</button>
            </div>

            <!-- ==================== BANKERS FEED ==================== -->
            <div id="feed-bankers" class="feed-container space-y-3 lg:space-y-0 bg-slate-900/60 backdrop-blur-xl border border-slate-800 rounded-2xl overflow-hidden shadow-2xl p-4 lg:p-0">
                
                <!-- Desktop header -->
                <div class="hidden lg:grid lg:grid-cols-5 gap-2 p-4 bg-slate-950/60 border-b border-slate-800/80 text-[8px] font-black tracking-[0.2em] uppercase text-slate-500 items-center">
                    <div>Date / Title</div>
                    <div>Match</div>
                    <div>Prediction</div>
                    <div>Status</div>
                    <div class="text-right">Trust Score</div>
                </div>

                <?php if (empty($bankers)): ?>
                    <div class="p-12 text-center text-xs font-bold tracking-widest text-slate-600 uppercase">Awaiting AI matrix generation...</div>
                <?php else: ?>
                    <?php foreach ($bankers as $b):
                        $is_vip_item = ($b['access_tier'] ?? 'FREE') === 'VIP';
                        $match_timestamp = strtotime($b['match_date']);
                        $is_future = $match_timestamp > $today_timestamp;
                        $trust = getTrust($b);
                        $time_ago = timeAgo($b['created_at'] ?? $b['match_date']);
                        $match_date_display = date('M d, Y', $match_timestamp);
                        $match_time_display = date('g:i A', $match_timestamp);
                    ?>
                        <?php if ($is_future): ?>
                            <!-- Future match - locked -->
                            <div class="match-card relative overflow-hidden bg-slate-900/40 border border-slate-700/30">
                                <div class="absolute inset-0 z-10 flex items-center justify-center pointer-events-none">
                                    <div class="bg-slate-900/80 backdrop-blur-sm border border-slate-700/50 px-4 py-2 rounded-xl flex items-center space-x-2 shadow-2xl">
                                        <span class="text-cyan-400 text-sm animate-pulse">⏳</span>
                                        <span class="text-[10px] font-black text-cyan-400 uppercase tracking-[0.2em]">Unlocks <?php echo date("l, M d", $match_timestamp); ?></span>
                                    </div>
                                </div>
                                <div class="opacity-30 blur-[3px] select-none pointer-events-none">
                                    <div class="header">
                                        <span class="title">MATCH EVENT</span>
                                        <span class="meta">--:-- <span class="vip-badge free">FREE</span></span>
                                    </div>
                                    <div class="teams">Team A <span class="vs">VS</span> Team B</div>
                                    <div class="details">
                                        <div class="item"><span class="label">Prediction</span><span class="value">-</span></div>
                                        <div class="item"><span class="label">Status</span><span class="value">🔒</span></div>
                                        <div class="item" style="grid-column: span 2;"><span class="label">Trust Score</span><span class="value trust-score">?<span class="den">/10</span></span></div>
                                    </div>
                                    <div class="footer"><span class="time-ago">--</span></div>
                                </div>
                            </div>
                        <?php else: ?>
                            <!-- Active match -->
                            <div class="match-card">
                                <!-- MOBILE VIEW -->
                                <div class="header">
                                    <span class="title"><?php echo htmlspecialchars($b['match_title'] ?? 'MATCH EVENT'); ?></span>
                                    <div class="meta">
                                        <span><?php echo date('H:i', $match_timestamp); ?></span>
                                        <span class="vip-badge <?php echo $is_vip_item ? 'vip' : 'free'; ?>"><?php echo $is_vip_item ? 'VIP' : 'FREE'; ?></span>
                                    </div>
                                </div>
                                <div class="teams">
                                    <?php echo htmlspecialchars($b['team_a']); ?>
                                    <span class="vs">VS</span>
                                    <?php echo htmlspecialchars($b['team_b']); ?>
                                </div>
                                <div class="details">
                                    <div class="item">
                                        <span class="label">Prediction</span>
                                        <span class="value"><span class="tip-badge"><?php echo htmlspecialchars($b['game_option']); ?></span></span>
                                    </div>
                                    <div class="item">
                                        <span class="label">Status</span>
                                        <span class="value"><?php echo outcomeBadge($b['outcome'] ?? 'PENDING'); ?></span>
                                    </div>
                                    <div class="item" style="grid-column: span 2;">
                                        <span class="label">Trust Score</span>
                                        <span class="value trust-score"><?php echo $trust; ?><span class="den"> /10</span></span>
                                    </div>
                                </div>
                                <div class="footer"><span class="time-ago">Posted <?php echo $time_ago; ?></span></div>

                                <!-- DESKTOP VIEW -->
                                <div class="desktop-date">
                                    <span class="title"><?php echo htmlspecialchars($b['match_title'] ?? 'MATCH EVENT'); ?></span>
                                    <span class="date-time"><?php echo $match_date_display; ?> • <?php echo $match_time_display; ?></span>
                                </div>
                                <div class="desktop-match">
                                    <span><?php echo htmlspecialchars($b['team_a']); ?></span>
                                    <span class="vs">VS</span>
                                    <span><?php echo htmlspecialchars($b['team_b']); ?></span>
                                </div>
                                <div class="desktop-prediction"><?php echo htmlspecialchars($b['game_option']); ?></div>
                                <div class="desktop-status"><?php echo outcomeBadge($b['outcome'] ?? 'PENDING'); ?></div>
                                <div class="desktop-trust"><?php echo $trust; ?><span class="den">/10</span></div>
                            </div>
                        <?php endif; ?>
                    <?php endforeach; ?>
                <?php endif; ?>
            </div>

            <!-- ==================== SLIP OF THE DAY FEED ==================== -->
            <div id="feed-slip" class="feed-container space-y-3 lg:space-y-0 bg-slate-900/60 backdrop-blur-xl border border-slate-800 rounded-2xl overflow-hidden shadow-2xl p-4 lg:p-0 hidden relative">
                
                <div class="hidden lg:grid lg:grid-cols-5 gap-2 p-4 bg-slate-950/60 border-b border-slate-800/80 text-[8px] font-black tracking-[0.2em] uppercase text-slate-500 items-center">
                    <div>Date / Title</div>
                    <div>Match</div>
                    <div>Prediction</div>
                    <div>Status</div>
                    <div class="text-right">Trust Score</div>
                </div>

                <?php if (!$is_vip): ?>
                    <?php 
                    $dummy_count = empty($slip_of_the_day) ? 3 : count($slip_of_the_day);
                    for ($i = 0; $i < $dummy_count; $i++): 
                    ?>
                        <div class="match-card relative overflow-hidden filter blur-[3px] opacity-30 select-none pointer-events-none">
                            <div class="header"><span class="title">LOCKED</span><span class="meta">--:--</span></div>
                            <div class="teams">Team A <span class="vs">VS</span> Team B</div>
                            <div class="details">
                                <div class="item"><span class="label">Prediction</span><span class="value">-</span></div>
                                <div class="item"><span class="label">Status</span><span class="value">🔒</span></div>
                                <div class="item" style="grid-column: span 2;"><span class="label">Trust Score</span><span class="value trust-score">?<span class="den">/10</span></span></div>
                            </div>
                            <div class="footer"><span class="time-ago">--</span></div>
                        </div>
                    <?php endfor; ?>

                    <div class="absolute inset-0 bg-slate-950/70 backdrop-blur-[6px] flex flex-col items-center justify-center z-10 p-6 text-center">
                        <div class="w-16 h-16 bg-gradient-to-br from-amber-400 to-orange-600 rounded-2xl flex items-center justify-center mx-auto text-3xl mb-4 shadow-[0_0_20px_rgba(245,158,11,0.3)] animate-pulse">👑</div>
                        <h4 class="text-white text-sm font-black uppercase tracking-widest mb-2">Premium Matrix Terminals Masked</h4>
                        <p class="text-[10px] text-slate-300 leading-relaxed font-medium max-w-md mb-6">Advanced Poisson distribution slips, correct scores, and high-yield pools are strictly restricted to active Neural Network subscribers.</p>
                        <a href="../pricing.php" class="inline-block bg-gradient-to-r from-amber-500 to-orange-500 text-slate-950 font-black px-6 py-4 rounded-xl text-[9px] tracking-widest uppercase hover:opacity-90 transition shadow-lg shadow-amber-500/20">Upgrade Terminal Tier</a>
                    </div>

                <?php else: ?>
                    <?php if (empty($slip_of_the_day)): ?>
                        <div class="p-12 text-center text-xs font-bold tracking-widest text-amber-600 uppercase">No active system combo slips deployed.</div>
                    <?php else: ?>
                        <?php foreach ($slip_of_the_day as $s):
                            $match_timestamp = strtotime($s['match_date']);
                            $is_future = $match_timestamp > $today_timestamp;
                            $trust = getTrust($s);
                            $time_ago = timeAgo($s['created_at'] ?? $s['match_date']);
                            $match_date_display = date('M d, Y', $match_timestamp);
                            $match_time_display = date('g:i A', $match_timestamp);
                        ?>
                            <?php if ($is_future): ?>
                                <div class="match-card relative overflow-hidden bg-amber-900/5 border border-amber-800/30">
                                    <div class="absolute inset-0 z-10 flex items-center justify-center pointer-events-none">
                                        <div class="bg-amber-950/80 backdrop-blur-sm border border-amber-700/50 px-4 py-2 rounded-xl flex items-center space-x-2 shadow-2xl">
                                            <span class="text-amber-500 text-sm animate-pulse">⏳</span>
                                            <span class="text-[10px] font-black text-amber-500 uppercase tracking-[0.2em]">Unlocks <?php echo date("l, M d", $match_timestamp); ?></span>
                                        </div>
                                    </div>
                                    <div class="opacity-30 blur-[3px] select-none pointer-events-none">
                                        <div class="header"><span class="title">VIP SLIP</span><span class="meta">--:-- <span class="vip-badge vip">VIP</span></span></div>
                                        <div class="teams">Team A <span class="vs">VS</span> Team B</div>
                                        <div class="details">
                                            <div class="item"><span class="label">Prediction</span><span class="value">-</span></div>
                                            <div class="item"><span class="label">Status</span><span class="value">🔒</span></div>
                                            <div class="item" style="grid-column: span 2;"><span class="label">Trust Score</span><span class="value trust-score">?<span class="den">/10</span></span></div>
                                        </div>
                                        <div class="footer"><span class="time-ago">--</span></div>
                                    </div>
                                </div>
                            <?php else: ?>
                                <div class="match-card border border-amber-900/30 vip-slip">
                                    <!-- MOBILE VIEW -->
                                    <div class="header">
                                        <span class="title" style="color: #fbbf24;"><?php echo htmlspecialchars($s['match_title'] ?? 'VIP SLIP'); ?></span>
                                        <div class="meta">
                                            <span><?php echo date('H:i', $match_timestamp); ?></span>
                                            <span class="vip-badge vip">VIP</span>
                                        </div>
                                    </div>
                                    <div class="teams">
                                        <span style="color: #f1f5f9;"><?php echo htmlspecialchars($s['team_a']); ?></span>
                                        <span class="vs" style="color: #f59e0b;">VS</span>
                                        <span style="color: #f1f5f9;"><?php echo htmlspecialchars($s['team_b']); ?></span>
                                    </div>
                                    <div class="details">
                                        <div class="item">
                                            <span class="label" style="color: #d97706;">Prediction</span>
                                            <span class="value"><span class="tip-badge" style="background:rgba(245,158,11,0.1);border-color:rgba(245,158,11,0.3);color:#fbbf24;"><?php echo htmlspecialchars($s['game_option']); ?></span></span>
                                        </div>
                                        <div class="item">
                                            <span class="label" style="color: #d97706;">Status</span>
                                            <span class="value"><?php echo outcomeBadge($s['outcome'] ?? 'PENDING'); ?></span>
                                        </div>
                                        <div class="item" style="grid-column: span 2;">
                                            <span class="label" style="color: #d97706;">Trust Score</span>
                                            <span class="value trust-score" style="color: #fbbf24;"><?php echo $trust; ?><span class="den" style="color: #b45309;"> /10</span></span>
                                        </div>
                                    </div>
                                    <div class="footer"><span class="time-ago">Posted <?php echo $time_ago; ?></span></div>

                                    <!-- DESKTOP VIEW -->
                                    <div class="desktop-date">
                                        <span class="title" style="color: #fbbf24;"><?php echo htmlspecialchars($s['match_title'] ?? 'VIP SLIP'); ?></span>
                                        <span class="date-time"><?php echo $match_date_display; ?> • <?php echo $match_time_display; ?></span>
                                    </div>
                                    <div class="desktop-match">
                                        <span><?php echo htmlspecialchars($s['team_a']); ?></span>
                                        <span class="vs">VS</span>
                                        <span><?php echo htmlspecialchars($s['team_b']); ?></span>
                                    </div>
                                    <div class="desktop-prediction"><?php echo htmlspecialchars($s['game_option']); ?></div>
                                    <div class="desktop-status"><?php echo outcomeBadge($s['outcome'] ?? 'PENDING'); ?></div>
                                    <div class="desktop-trust"><?php echo $trust; ?><span class="den">/10</span></div>
                                </div>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    <?php endif; ?>
                <?php endif; ?>
            </div>

            <div class="w-full flex justify-center py-4">
                <?php 
                if (function_exists('display_ad_slot')) {
                    display_ad_slot($pdo, 'in_content'); 
                }
                ?>
            </div>

        </main>
    </div>

    <script>
        function toggleSidebar() {
            const sidebar = document.getElementById('sidebar');
            const overlay = document.getElementById('sidebarOverlay');
            if(sidebar && overlay) {
                sidebar.classList.toggle('-translate-x-full');
                overlay.classList.toggle('hidden');
            }
        }

        function switchTab(tabName) {
            const btnBankers = document.getElementById('tab-bankers');
            const btnSlip = document.getElementById('tab-slip');
            const feedBankers = document.getElementById('feed-bankers');
            const feedSlip = document.getElementById('feed-slip');

            if(tabName === 'bankers') {
                btnBankers.className = "tab-btn text-emerald-400 border-b-2 border-emerald-500 pb-3 -mb-3.5 focus:outline-none transition";
                btnSlip.className = "tab-btn text-slate-500 hover:text-slate-300 pb-3 -mb-3.5 focus:outline-none transition";
                feedBankers.classList.remove('hidden');
                feedSlip.classList.add('hidden');
            } else {
                btnSlip.className = "tab-btn text-emerald-400 border-b-2 border-emerald-500 pb-3 -mb-3.5 focus:outline-none transition";
                btnBankers.className = "tab-btn text-slate-500 hover:text-slate-300 pb-3 -mb-3.5 focus:outline-none transition";
                feedSlip.classList.remove('hidden');
                feedBankers.classList.add('hidden');
            }
        }

        const canvas = document.getElementById("neuralCanvas");
        if(canvas) {
            const ctx = canvas.getContext("2d");
            let width, height;
            let particles = [];
            
            function initCanvas() {
                width = canvas.width = window.innerWidth;
                height = canvas.height = window.innerHeight;
                particles = [];
                for (let i = 0; i < (width * height) / 15000; i++) {
                    particles.push({
                        x: Math.random() * width, y: Math.random() * height,
                        vx: (Math.random() - 0.5) * 1.5, vy: (Math.random() - 0.5) * 1.5,
                        radius: Math.random() * 1.5 + 0.5
                    });
                }
            }

            function animateCanvas() {
                ctx.clearRect(0, 0, width, height);
                for (let i = 0; i < particles.length; i++) {
                    let p = particles[i];
                    p.x += p.vx; p.y += p.vy;
                    if (p.x < 0 || p.x > width) p.vx *= -1;
                    if (p.y < 0 || p.y > height) p.vy *= -1;
                    ctx.beginPath(); ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2);
                    ctx.fillStyle = "rgba(16, 185, 129, 0.2)"; ctx.fill();
                }
                requestAnimationFrame(animateCanvas);
            }
            window.addEventListener("resize", initCanvas);
            initCanvas(); animateCanvas();
        }
    </script>
</body>
</html>