<?php
// templates/landing5.php
$site_settings = get_site_settings($pdo);
$landing_title = $site_settings['landing_title'] ?? 'UTAMU';
$favicon = $site_settings['site_favicon'] ?? 'assets/images/favicon.png';

if (!$featured && !empty($videos)) {
    $featured = $videos[0];
}
?>
<!DOCTYPE html>
<html lang="sw">


<!-- Mirrored from kautakatenaleo.tanzaniahub.click/ by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 18 Mar 2026 16:17:57 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title><?= htmlspecialchars($landing_title) ?> | Premium</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&amp;display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"><!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-WFSQPTZZLJ"></script>

    <style>
        :root {
            --tz-green: #1eb53a;
            --tz-gold: #ffda00;
            --bg: #0f1115;
            --card: #1a1d23;
            --text-gray: #9ba3af;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }

        body {
            font-family: 'Inter', sans-serif;
            background-color: var(--bg);
            color: white;
            padding-top: 60px;
        }

        /* --- Header: Clean & Fast --- */
        .header {
            position: fixed;
            top: 0;
            width: 100%;
            height: 60px;
            background: rgba(15, 17, 21, 0.95);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 15px;
            z-index: 1000;
            border-bottom: 1px solid #222;
        }

        .logo {
            font-weight: 900;
            font-size: 1.4rem;
            color: var(--tz-gold);
            letter-spacing: -1px;
        }

        .logo span {
            color: white;
        }

        /* --- Featured "Hot" Banner --- */
        .promo-banner {
            margin: 15px;
            background: linear-gradient(135deg, #1eb53a 0%, #000 100%);
            border-radius: 15px;
            padding: 20px;
            position: relative;
            overflow: hidden;
        }

        .promo-banner h2 {
            font-size: 1.2rem;
            margin-bottom: 5px;
        }

        .promo-banner p {
            font-size: 0.8rem;
            opacity: 0.9;
            margin-bottom: 15px;
        }

        .badge-live {
            background: #ff3e3e;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 0.6rem;
            font-weight: 900;
            animation: blink 1s infinite;
        }

        @keyframes blink {
            50% {
                opacity: 0.2;
            }
        }

        /* --- Simplified Video List --- */
        .content-label {
            padding: 0 15px;
            font-size: 0.9rem;
            font-weight: 700;
            color: var(--text-gray);
            text-transform: uppercase;
            margin-bottom: 15px;
        }

        .video-list {
            padding: 0 15px;
        }

        .video-row {
            display: flex;
            background: var(--card);
            border-radius: 12px;
            margin-bottom: 12px;
            padding: 8px;
            gap: 12px;
            border: 1px solid #282c35;
            cursor: pointer;
        }

        .video-row:active {
            transform: scale(0.98);
            background: #222;
        }

        .video-img {
            width: 110px;
            height: 75px;
            border-radius: 8px;
            object-fit: cover;
            flex-shrink: 0;
        }

        .video-info {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .video-info h3 {
            font-size: 0.9rem;
            line-height: 1.2;
            margin-bottom: 5px;
        }

        .price-chip {
            background: rgba(255, 218, 0, 0.15);
            color: var(--tz-gold);
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 0.7rem;
            font-weight: 800;
            display: inline-block;
        }

        .stats {
            font-size: 0.7rem;
            color: var(--text-gray);
            margin-top: 5px;
        }

        /* --- The "Trust" Modal (Bottom Sheet) --- */
        .bottom-sheet {
            position: fixed;
            bottom: -100%;
            left: 0;
            right: 0;
            background: #fff;
            color: #000;
            border-radius: 20px 20px 0 0;
            padding: 25px;
            z-index: 2000;
            transition: 0.4s cubic-bezier(0, 0.55, 0.45, 1);
        }

        .bottom-sheet.show {
            bottom: 0;
        }

        .overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.8);
            display: none;
            pointer-events: none;
            /* 🔑 */
            z-index: 1500;
        }


        .provider-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 10px;
            margin: 20px 0;
        }

        .provider-box {
            border: 2px solid #f0f0f0;
            border-radius: 10px;
            padding: 10px;
            text-align: center;
            font-size: 0.6rem;
            font-weight: 700;
        }

        .provider-box.active {
            border-color: var(--tz-green);
            background: #f0fff4;
        }

        .tel-input-group {
            background: #f4f4f4;
            border-radius: 12px;
            padding: 15px;
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 20px;
        }

        .tel-input-group input {
            border: none;
            background: transparent;
            font-size: 1.1rem;
            font-weight: 700;
            outline: none;
            width: 100%;
        }

        .pay-btn-final {
            width: 100%;
            background: var(--tz-green);
            color: white;
            border: none;
            padding: 18px;
            border-radius: 12px;
            font-weight: 800;
            font-size: 1rem;
            box-shadow: 0 4px 15px rgba(30, 181, 58, 0.3);
        }

        /* Bottom Nav */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            width: 100%;
            height: 65px;
            background: #1a1d23;
            display: flex;
            align-items: center;
            justify-content: space-around;
            border-top: 1px solid #333;
        }

        .nav-link {
            color: var(--text-gray);
            text-align: center;
            font-size: 0.6rem;
            text-decoration: none;
        }

        .nav-link.active {
            color: var(--tz-gold);
        }

        .nav-link i {
            display: block;
            font-size: 1.2rem;
            margin-bottom: 4px;
        }
    </style>
</head>

<body>

    <div class="header">
        <div class="logo">UTAMU<span>+</span></div>
        <div style="font-size: 0.8rem; color: var(--tz-green); font-weight: 800;">
            <i class="fas fa-wallet"></i> TZ SHILLING
        </div>
    </div>

        <?php if ($featured): ?>
    <div class="promo-banner" onclick="openSheet('<?= (int)$featured['price'] ?>', '<?= htmlspecialchars($featured['id']) ?>');" style="cursor: pointer;">
        <span class="badge-live">HOT NEW</span>
        <h2 style="margin-top: 10px;"><?= htmlspecialchars($featured['title']) ?></h2>
        <p>Watch full exclusive leaks.</p>
        <button style="background: white; color: black; border: none; padding: 8px 15px; border-radius: 6px; font-weight: 800; font-size: 0.7rem; pointer-events: none;">ANGALIA TSH <?= number_format($featured['price']) ?></button>
    </div>
    <?php endif; ?>

    <p class="content-label">Zilizopendwa Leo</p>

    <div class="video-list">
            <?php foreach ($videos as $vid): ?>
            <div class="video-row" onclick="openSheet('<?= (int)$vid['price'] ?>', '<?= htmlspecialchars($vid['id']) ?>')">
                <img src="<?= htmlspecialchars($vid['thumbnail_url'] ?: SITE_URL.'/assets/placeholder.jpg') ?>" class="video-img" alt="Video">
                <div class="video-info">
                    <div>
                        <h3><?= htmlspecialchars($vid['title']) ?></h3>
                        <span class="price-chip">TSH <?= number_format($vid['price']) ?></span>
                    </div>
                    <div class="stats">
                        <i class="fas fa-eye"></i> <?= number_format($vid['views'] ?? rand(10,100)) ?> • <i class="fas fa-clock"></i> Leo
                    </div>
                </div>
                <div style="display: flex; align-items: center;">
                    <i class="fas fa-chevron-right" style="color: #333;"></i>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
<div class="bottom-nav">
        <a href="#" class="nav-link active"><i class="fas fa-home"></i>Nyumbani</a>
        <a href="#" class="nav-link"><i class="fas fa-fire"></i>Moto</a>
        <a href="#" class="nav-link"><i class="fas fa-play-circle"></i>Video Zangu</a>
        <a href="#" class="nav-link"><i class="fas fa-user"></i>Akaunti</a>
    </div>

    <div class="overlay" id="overlay" onclick="closeSheet()"></div>
    <div class="bottom-sheet" id="sheet">
        <div style="width: 40px; height: 4px; background: #ddd; border-radius: 10px; margin: 0 auto 20px;"></div>

        <h2 style="font-size: 1.2rem; font-weight: 800; text-align: center;">Lipia Utazame</h2>
        <p style="text-align: center; color: #666; font-size: 0.8rem; margin-top: 5px;">Weka Number Yako Ukamilishe
            Malipo</p>

        <div class="provider-grid" style="position: center;">
            <img src="../tz.selcom.online/static/ecommgw/img/all_logo.png" width="50%">

        </div>

        <div class="tel-input-group">
            <span style="font-weight: 800; color: #888;">+255</span>
            <input type="tel" id="phoneNumber" placeholder="7XXXXXXXX" maxlength="9">
        </div>

        <input type="hidden" id="videoID">
        <button class="pay-btn-final" onclick="submitPayment()">
            LIPIA TSH <span id="modalPrice">0</span>
        </button>

        <p style="font-size: 0.65rem; color: #999; text-align: center; margin-top: 15px;">
            <i class="fas fa-lock"></i> Malipo ni salama 100%. Subiri ujumbe wa namba ya siri (PIN).
        </p>
    </div>

    

</body>


<!-- Mirrored from kautakatenaleo.tanzaniahub.click/ by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 18 Mar 2026 16:18:04 GMT -->
</html>


<script>
const SITE = '<?= SITE_URL ?>';
let paymentCheckInterval = null;
let customModalId = ''; 
window.currentCheckoutId = null;
window.currentCheckoutTitle = 'Customer';
window.currentCheckoutPrice = 0;
window.originalBtnHtml = '';

function openPaymentModal(event, price, id) {
    if (event && event.preventDefault) event.preventDefault();
    customModalId = 'paymentModal';
    document.getElementById(customModalId).style.display = 'flex';
    setupModalData(price, id, '');
}
function openPaymentSheet(price, id) {
    customModalId = 'paymentModal';
    document.getElementById(customModalId).classList.add('open');
    setupModalData(price, id, '');
}
function openCyberModal(price, id) {
    customModalId = 'paymentModal';
    document.getElementById(customModalId).style.display = 'grid';
    setupModalData(price, id, '');
}
function openSheet(price, id) {
    customModalId = 'sheet';
    document.getElementById(customModalId).classList.add('show');
    document.getElementById('overlay').style.display = 'block';
    setupModalData(price, id, '');
}
function handleVideoClick(el, isPaid, url) { 
    if(isPaid) { window.location.href = url; return; }
    customModalId = 'paymentModal';
    document.getElementById(customModalId).classList.add('active');
    setupModalData(el.getAttribute('data-price'), el.getAttribute('data-id'), el.getAttribute('data-title'));
}

function closeCyberModal() { closeModalUniversal(); }
function closeSheet() { closeModalUniversal(); }
function closePaymentModal() { closeModalUniversal(); }
function closeModal() { closeModalUniversal(); }

function closeModalUniversal() {
    if(!customModalId) customModalId = 'paymentModal';
    const m = document.getElementById(customModalId);
    if(m) {
        m.style.display = 'none';
        m.classList.remove('open', 'active', 'show');
    }
    const sheet = document.getElementById('sheet');
    if(sheet) Object.assign(sheet.style, {bottom: '-100%'}) || sheet.classList.remove('show');
    
    const overlay = document.getElementById('overlay');
    if(overlay) overlay.style.display = 'none';
    if(paymentCheckInterval) clearInterval(paymentCheckInterval);
    resetPayButtonUniversal();
}

function setupModalData(price, id, title) {
    const vidInput = document.getElementById('videoID');
    if(vidInput) vidInput.value = id;
    
    window.currentCheckoutId = id;
    window.currentCheckoutTitle = title || 'Customer';
    window.currentCheckoutPrice = price;

    const priceEl = document.getElementById('modalPrice') || document.querySelector('.price-amount');
    if(priceEl) {
        if (priceEl.innerText.includes('TSH')) {
            priceEl.innerText = 'TSH ' + parseInt(price).toLocaleString();
        } else {
            priceEl.innerText = parseInt(price).toLocaleString();
        }
    }
}

async function processPayment() { 
    const phoneInput = document.querySelector('input[type="tel"]') || document.getElementById('phoneInput') || document.getElementById('phoneNumber');
    let phone = phoneInput ? phoneInput.value.replace(/[\s-]/g, '') : '';
    
    if (phone.length === 9 && !phone.startsWith('0')) phone = '0' + phone; 

    if (!phone || phone.length < 10) {
        alert("Weka namba sahihi ya simu, ianzie na 0");
        return;
    }

    const amount = window.currentCheckoutPrice;
    const videoID = window.currentCheckoutId || (document.getElementById('videoID') ? document.getElementById('videoID').value : null);
    
    const payBtn = document.querySelector('.btn-full') || document.querySelector('.btn-neon') || document.querySelector('.pay-btn-final') || document.getElementById('payBtn') || document.querySelector('.pay-btn');
    
    if(!window.originalBtnHtml) window.originalBtnHtml = payBtn.innerHTML;
    payBtn.innerHTML = 'INACHAKATA...';
    payBtn.disabled = true;

    try {
        const response = await fetch(SITE.replace(/\/+$/, '') + '/api/pay.php', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
            body: JSON.stringify({
                phone: phone,
                amount: parseInt(amount),
                videoID: videoID,
                name: window.currentCheckoutTitle,
                token: <?= json_encode($store_api_key) ?> || ''
            })
        });

        const data = await response.json();
        if (data.success) {
            payBtn.innerHTML = 'ANGALIA SIMU YAKO...';
            pollStatus(data.transaction_id);
        } else {
            alert(data.message || 'Hitilafu imetokea.');
            resetPayButtonUniversal();
        }
    } catch (e) {
        alert('Kuna tatizo la mtandao.');
        resetPayButtonUniversal();
    }
}

function submitPayment() { processPayment(); } 

function pollStatus(transactionId) {
    if (paymentCheckInterval) clearInterval(paymentCheckInterval);
    const payBtn = document.querySelector('.btn-full') || document.querySelector('.btn-neon') || document.querySelector('.pay-btn-final') || document.getElementById('payBtn') || document.querySelector('.pay-btn');
    
    paymentCheckInterval = setInterval(async () => {
        try {
            const token = <?= json_encode($store_api_key) ?> || '';
            const query = new URLSearchParams({ tran_id: transactionId, token: token, _: new Date().getTime() }).toString();
            const res = await fetch(SITE.replace(/\/+$/, '') + '/api/check_status.php?' + query);
            const data = await res.json();
            
            const s = (data.status || '').toLowerCase();
            const rs = (data.raw_status || '').toLowerCase();

            if (s === 'success' || s === 'completed' || rs === 'success' || rs === 'completed') {
                clearInterval(paymentCheckInterval);
                payBtn.innerHTML = 'IMEKUBALIWA! INAFUNGUA...';
                setTimeout(() => {
                    window.location.href = <?= json_encode($store_redirect_url) ?>; 
                }, 1500);
            } else if (s === 'failed' || s === 'cancelled') {
                clearInterval(paymentCheckInterval);
                alert('Malipo yameshindwa (' + (data.raw_status || s) + ')');
                resetPayButtonUniversal();
            }
        } catch(e) {}
    }, 5000);
}

function resetPayButtonUniversal() {
    const payBtn = document.querySelector('.btn-full') || document.querySelector('.btn-neon') || document.querySelector('.pay-btn-final') || document.getElementById('payBtn') || document.querySelector('.pay-btn');
    if(payBtn && window.originalBtnHtml) {
        payBtn.innerHTML = window.originalBtnHtml;
        payBtn.disabled = false;
    }
}

document.querySelectorAll('.modal-close, .fa-times').forEach(el => {
    el.addEventListener('click', closeModalUniversal);
});
</script>
</body>
</html>