<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta name="description" content="WYZSTORE - Platform top up game terpercaya. Mobile Legends, Free Fire, PUBG, Valorant. Instan, Aman, 24 Jam.">
    <title>WYZSTORE - Top Up Game Instan & Terpercaya</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- SWIPER JS CSS ANIMATION -->
    <link href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <link rel="icon" type="image/png" href="{{ asset('images/logo.png') }}">
    <style>
        :root {
            --primary: #f39c12;    
            --primary-glow: rgba(243, 156, 18, 0.3);
            --bg: #0b0d0f;        
            --surface: #141619;    
            --border: rgba(255, 255, 255, 0.05); 
            --text-muted: #e2e8f0; /* Ultra-bright untuk visibilitas maksimal */
            --text-main: #ffffff;
            --text-heading: #ffffff;
            --nav-bg: rgba(11,13,15,0.9);
            --sidebar-bg: rgba(11,13,15,0.98);
        }

        /* LIGHT MODE CLASS OVERRIDE */
        body.light-mode {
            --bg: #f8fafc;
            --surface: #ffffff;
            --border: #e2e8f0;
            --text-main: #0f172a; 
            --text-heading: #0f172a; /* Menambah variabel yang tertinggal */
            --text-muted: #475569; 
            --nav-bg: rgba(255, 255, 255, 0.95);
            --sidebar-bg: rgba(255,255,255,0.98);
        }

        body { 
            font-family: 'Outfit', sans-serif; 
            background-color: var(--bg); 
            color: var(--text-main); 
            margin: 0; transition: background-color 0.3s, 
            color 0.3s; 
            }
        
        /* OVERRIDE BOOTSTRAP UTILITIES */
        .text-muted { 
            color: var(--text-muted) !important; 
        }
        .text-secondary { 
            color: var(--text-muted) !important; 
        }
        label { 
            color: var(--text-main); 
        }
        label.text-muted { 
            color: var(--text-muted) !important; 
        }
        .navbar-custom { 
            background: var(--nav-bg); backdrop-filter: blur(15px); 
            border-bottom: 1px solid var(--border); 
            padding: 16px 0; 
            position: sticky; 
            top: 0; z-index: 1000; 
        }
        .navbar-brand { 
            display: flex; 
            align-items: center; 
            gap: 15px; 
            font-weight: 800; 
            font-size: 1.7rem; 
            letter-spacing: -0.5px; 
            text-decoration: none !important; 
            line-height: 1;
        }
        .navbar-brand span {
            background: linear-gradient(135deg, var(--primary) 0%, var(--text-main) 50%, var(--primary) 100%);
            background-size: 200% auto;
            -webkit-background-clip: text; 
            -webkit-text-fill-color: transparent; 
            animation: text-slide 3s linear infinite;
            margin-top: 2px; /* Penyesuaian sejajar mata */
        }
        @keyframes text-slide {
            to { background-position: 200% center; }
        }
        .navbar-logo { 
            height: 48px; 
            width: auto; 
            object-fit: contain;
            filter: drop-shadow(0 0 8px var(--primary-glow)); 
            transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
        }
        .navbar-brand:hover .navbar-logo { 
            transform: rotate(-8deg) scale(1.1); 
            filter: drop-shadow(0 0 15px var(--primary)); 
        }

        /* NTPOINT STYLE SHINE ANIMATION */
        .navbar-brand {
            position: relative;
            overflow: hidden;
            border-radius: 8px; /* For clean shine edges */
            padding: 5px 10px;
        }
        .navbar-brand::after {
            content: '';
            position: absolute;
            top: -50%;
            left: -60%;
            width: 20%;
            height: 200%;
            background: rgba(255, 255, 255, 0.4);
            transform: rotate(30deg);
            transition: none;
            animation: shine-sweep 3s infinite;
            filter: blur(5px);
        }
        @keyframes shine-sweep {
            0% { left: -60%; opacity: 0; }
            10% { opacity: 0.5; }
            20% { left: 120%; opacity: 0; }
            100% { left: 120%; opacity: 0; }
        }

        .navbar-logo {
            z-index: 1;
            position: relative;
        }
        .navbar-brand span {
            z-index: 1;
            position: relative;
        }
        .nav-link { 
            color: var(--text-muted) !important; 
            font-weight: 600; 
            font-size: 0.95rem; 
            transition: 0.3s; 
        }
        .nav-link:hover { 
            color: var(--primary) !important; 
        }

        /* MOBILE MENU STYLES */
        .mobile-btn { 
            display: none; 
            background: none; 
            border: 1px solid var(--border); 
            color: var(--text-main); 
            padding: 6px 10px; 
            border-radius: 8px; 
            font-size: 1.2rem; 
        }
        .mobile-sidebar { 
            position: fixed; 
            top: 0; 
            right: -280px; 
            width: 280px; 
            height: 100%; 
            background: var(--sidebar-bg); 
            backdrop-filter: blur(10px); 
            z-index: 2000; 
            transition: 0.4s ease; 
            padding: 40px 25px; 
            border-left: 1px solid var(--border);
        }
        .mobile-sidebar.active { 
            right: 0; 
        }
        .sidebar-overlay { 
            position: fixed; 
            top: 0; 
            left: 0; 
            width: 100%; 
            height: 100%; 
            background: rgba(0,0,0,0.6); 
            z-index: 1999; 
            display: none; 
        }
        .sidebar-overlay.active { 
            display: block; 
        }
        .mobile-link { 
            display: block; 
            color: var(--text-main); 
            text-decoration: none; 
            font-size: 1.1rem; 
            font-weight: 700; 
            margin-bottom: 25px; 
            padding-bottom: 15px; 
            border-bottom: 1px solid var(--border); 
        }
        .mobile-link:hover { 
            color: var(--primary); 
        }

        @media (max-width: 768px) {
            .mobile-btn { display: block; }
        }

        /* HERO SWIPER "TAKAPEDIA" STYLE */
        .hero-section { 
            position: relative; 
            padding-top: 25px; 
            padding-bottom: 30px;
        }
        
        .hero-swiper {
            width: 100%;
            border-radius: 20px;
            overflow: hidden;
            box-shadow: 0 15px 40px rgba(0,0,0,0.5);
        }

        .swiper-slide {
            position: relative;
        }

        .swiper-slide img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            aspect-ratio: 21/9; /* Memanjangkan banner mirip Takapedia */
            pointer-events: none;
            display: block;
        }

        @media (max-width: 768px) {
            .hero-section { padding-top: 15px; }
            .swiper-slide img { aspect-ratio: 16/7; }
        }
        
        /* Tombol Navigasi Slider Modern */
        .swiper-button-next, .swiper-button-prev {
            background: rgba(11, 13, 15, 0.6);
            color: #fff !important;
            width: 45px !important;
            height: 45px !important;
            border-radius: 50%;
            backdrop-filter: blur(5px);
            transition: all 0.3s ease;
            transform: scale(0.8);
            opacity: 0; /* Sengaja sembunyi sebelum di hover */
        }
        .hero-swiper:hover .swiper-button-next, .hero-swiper:hover .swiper-button-prev { opacity: 1; transform: scale(1); }
        .swiper-button-next:after, .swiper-button-prev:after { font-size: 1.2rem !important; font-weight: bold; }
        .swiper-button-next:hover, .swiper-button-prev:hover { background: var(--primary); color: #0b0d0f !important;}
        
        /* Tag Label Unik "WYZSTORE" Khas */
        .wyzstore-tag-label {
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
            background: #fff;
            color: #141619;
            font-size: 0.8rem;
            font-weight: 800;
            padding: 12px 6px;
            border-radius: 8px 0 0 8px;
            writing-mode: vertical-rl;
            text-orientation: mixed;
            z-index: 10;
            box-shadow: -4px 0 15px rgba(0,0,0,0.6);
            letter-spacing: 1px;
            pointer-events: none;
        }
        
        .swiper-pagination-bullet { background: rgba(255,255,255,0.4) !important; width: 10px; height: 10px; }
        .swiper-pagination-bullet-active { background: var(--primary) !important; border-radius: 10px; width: 25px; transition: 0.3s; }

        /* GRID GAME "TAKAPEDIA" STYLE */
        .game-card {
            background: var(--surface); 
            border: 1px solid var(--border); 
            border-radius: 22px; /* Lebih bulat & modern */
            padding: 12px; 
            text-decoration: none; 
            color: var(--text-main); 
            display: block; 
            height: 100%; 
            transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
        }
    
        .game-card:hover { 
            transform: translateY(-10px) scale(1.03); 
            border-color: var(--primary); 
            box-shadow: 0 20px 40px rgba(0,0,0,0.6), 0 0 20px var(--primary-glow);
        }

        .game-img-wrap { 
            border-radius: 18px; 
            overflow: hidden; 
            margin-bottom: 14px; 
            aspect-ratio: 1/1; 
            position: relative;
        }

        .game-img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; }
        .game-card:hover .game-img { transform: scale(1.1); }

        .game-info h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 2px; text-align: center; }
        .game-info p { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin: 0; }

        /* HERO ELEMENTS */
        .hero-title, .hero-desc { display: none; }
        .btn-hero { 
            background: linear-gradient(135deg, #f39c12, #e67e22); 
            color: #fff; 
            border: none; 
            border-radius: 50px; 
            padding: 10px 25px; 
            font-weight: 800; 
            font-size: 1.1rem;
            text-decoration: none; 
            display: inline-block; 
            box-shadow: 0 10px 30px rgba(230, 126, 34, 0.4);
            transition: 0.3s;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-top: 150px;
            z-index: 5;
        }
        .btn-hero:hover { transform: translateY(-5px) scale(1.05); box-shadow: 0 15px 40px rgba(230, 126, 34, 0.6); color: #fff; }

        section { padding: 80px 0; }
        .section-title { margin-bottom: 40px; text-align: left; }
        .section-title h2 { color: var(--text-heading); font-weight: 800; font-size: 1.8rem; letter-spacing: -0.5px; position: relative; display: inline-block; transition: color 0.3s; }
        .section-title h2::after { content: ''; position: absolute; bottom: -10px; left: 0; width: 50px; height: 4px; background: var(--primary); border-radius: 10px; }
        .section-title.text-center h2::after { display: none; }
        .stat-num { color: var(--text-heading); font-weight: 800; transition: color 0.3s; }
        .section-subtitle { color: var(--text-muted); font-size: 1rem; margin-top: 15px; }

        /* DETAIL PAGE RESPONSIVE */
        .game-detail-banner { height: 200px; object-fit: cover; width: 100%; border-radius: 16px; margin-bottom: 20px; }
        .checkout-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 25px; margin-bottom: 20px; }
        .step-label { font-size: 0.85rem; font-weight: 800; color: var(--primary); text-transform: uppercase; margin-bottom: 15px; }
        .form-dark { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text-main); padding: 12px; width: 100%; }
        .item-card { 
            background: rgba(255,255,255,0.03); border: 1px solid var(--border); 
            color: var(--text-main); border-radius: 16px; padding: 16px; 
            text-align: center; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
            display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
            height: 100%; position: relative; overflow: hidden;
        }
        .item-card::before {
            content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
            background: radial-gradient(circle, rgba(243, 156, 18, 0.05) 0%, transparent 70%);
            opacity: 0; transition: 0.3s;
        }
        .item-card:hover { transform: translateY(-3px); border-color: rgba(243, 156, 18, 0.4); background: rgba(255,255,255,0.05); }
        .item-card:hover::before { opacity: 1; }
        .item-card.selected { border-color: var(--primary); background: rgba(243, 156, 18, 0.1); box-shadow: 0 0 20px rgba(243, 156, 18, 0.2); }
        .item-name { font-weight: 700; font-size: 0.85rem; line-height: 1.3; color: var(--text-main); z-index: 1; }
        .item-price { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; z-index: 1; }
        .item-card.selected .item-name { color: var(--primary); }
        .item-card.selected .item-price { color: var(--text-main); }
        body.light-mode .item-card { background: #fff; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }

        .btn-bayar { 
            width: 100%; background: var(--primary-gradient); border: none; color: #fff; 
            padding: 18px; border-radius: 16px; font-weight: 800; text-transform: uppercase;
            letter-spacing: 1px; box-shadow: 0 10px 25px var(--primary-glow);
            transition: all 0.3s;
        }
        .btn-bayar:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 15px 35px var(--primary-glow); filter: brightness(1.1); }
        .btn-bayar:disabled { background: linear-gradient(135deg, #2d3748, #1a202c); opacity: 0.7; box-shadow: none; }

        /* PROMO BANNER IN TOPUP PAGE */
        .topup-ad-banner {
            width: 100%;
            height: 220px; /* Sedikit lebih tinggi agar proporsional di desktop */
            border-radius: 22px;
            overflow: hidden;
            margin-bottom: 30px;
            box-shadow: 0 15px 35px rgba(0,0,0,0.4);
            border: 1px solid var(--border);
        }
        @media (max-width: 768px) {
            .topup-ad-banner { height: 140px; margin-bottom: 20px; }
        }
        .topup-ad-banner img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
            transition: 0.5s;
        }
        .topup-ad-banner:hover img {
            transform: scale(1.02);
        }

        /* SUMMARY BOX SIDEBAR */
        .order-summary { 
            background: var(--surface); border: 1px solid var(--border); 
            border-radius: 20px; padding: 24px; position: sticky; top: 90px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }

        /* SCROLL BAR TRANSAKSI TERBARU */
        .trx-feed { 
            max-height: 400px; 
            overflow-y: auto; 
            padding-right: 12px;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        .trx-feed::-webkit-scrollbar { 
            width: 6px; 
        }
        .trx-feed::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); border-radius: 10px; }
        .trx-feed::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }
        .trx-feed::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

        .trx-item {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 18px 24px;
            display: flex; align-items: center; justify-content: space-between;
            gap: 16px;
        }
        .trx-left { display: flex; align-items: center; gap: 14px; }
        .trx-icon { width: 42px; height: 42px; border-radius: 12px; background: rgba(92,63,246,0.15); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
        .trx-user { font-weight: 700; font-size: 0.95rem; margin: 0; }
        .trx-detail { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
        .trx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
        .trx-time { font-size: 0.8rem; color: var(--text-muted); }
        .trx-status { font-size: 0.75rem; font-weight: 700; padding: 3px 10px; border-radius: 50px; background: rgba(46,204,113,0.12); color: #2ecc71; text-transform: uppercase; }

        @keyframes fadeInScale { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
        .page-transition { animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1); }

        /* PAYMENT METHODS UI */
        .payment-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 15px; }
        .pay-card { 
            background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: 12px; padding: 15px; 
            text-align: center; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; 
            transition: all 0.3s;
        }
        .pay-card img { height: 26px; object-fit: contain; transition: 0.3s; }
        .pay-card:hover { border-color: rgba(243, 156, 18, 0.5); background: rgba(243, 156, 18, 0.05); }
        .pay-card span { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; padding-top: 4px; }
        .pay-card.active { border-color: var(--primary); background: rgba(243, 156, 18, 0.1); box-shadow: 0 4px 15px rgba(243, 156, 18, 0.2); }
        .pay-card.active img { transform: scale(1.05); }

        /* Payment Slider Animation */
        .pay-slider-container { overflow: hidden; white-space: nowrap; position: relative; padding: 5px 0; }
        .pay-slider { display: flex; gap: 40px; width: max-content; animation: pay-scroll 25s linear infinite; }
        .pay-slider:hover { animation-play-state: paused; }
        @keyframes pay-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
        .pay-logo { height: 22px; width: auto; object-fit: contain; }

        /* BOTTOM NAVIGATION (MOBILE APPS STYLE) */
        .mobile-bottom-nav { display: none; }

        @media (max-width: 768px) {
            .hero-title { font-size: 2.2rem; }
            section { padding: 40px 0; }
            .navbar-brand { font-size: 1.3rem; }
            
            /* HANCURKAN MENU KUNO, GANTI BOTTOM NAV */
            .mobile-btn { display: none !important; } 
            body { padding-bottom: 75px; } /* Jarak presisi untuk menu bawah */
            
            .mobile-bottom-nav {
                display: flex;
                position: fixed;
                bottom: 0px;
                left: 0;
                width: 100%;
                background: rgba(11, 13, 15, 0.98);
                backdrop-filter: blur(15px);
                border-top: 1px solid var(--border);
                z-index: 2000;
                padding: 12px 0;
                padding-bottom: env(safe-area-inset-bottom, 12px);
                justify-content: space-around;
                box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
            }
            .mobile-nav-item {
                display: flex; flex-direction: column; align-items: center;
                color: var(--text-muted); text-decoration: none; font-size: 0.7rem; font-weight: 700;
                transition: color 0.3s;
                letter-spacing: 0.5px;
            }
            .mobile-nav-item i { font-size: 1.25rem; margin-bottom: 4px; }
            .mobile-nav-item:hover, .mobile-nav-item.active { color: var(--primary); }
            
            /* Sembunyikan bottom nav saat tampilan detail (checkout) biar tidak semak */
            body.in-checkout .mobile-bottom-nav { display: none; } 
            
            /* RESET TOTAL AGAR SANGAT PENDEK & RAMPING */
            body { padding-bottom: 60px !important; }
            footer { padding: 15px 0 0 0 !important; }
            footer .row { --bs-gutter-y: 0 !important; margin-bottom: 0 !important; }
            .footer-heading { margin-bottom: 10px !important; font-size: 1rem !important; }
            .footer-link { margin-bottom: 5px !important; font-size: 0.85rem !important; }
            .footer-copy { margin: 0 !important; padding: 5px 0 !important; border-top: none !important; }
            .footer-copy .container { padding: 0 !important; }
            
            /* LOGIKA JARAK DINAMIS */
            body.in-checkout { padding-bottom: 0 !important; } /* Rapat jika belum pilih produk */
            body.in-checkout.has-item-selected { padding-bottom: 85px !important; } /* Baru muncul ruang jika tombol bayar ada */
            .order-summary { 
                display: none !important; 
            }
            body.has-item-selected .order-summary {
                display: block !important;
                position: fixed !important; 
                bottom: 0; 
                left: 0;
                width: 100%;
                z-index: 1050;
                margin: 0; padding: 12px 20px 8px; 
                background: rgba(15, 23, 42, 0.98); 
                backdrop-filter: blur(15px); 
                border-top: 1px solid rgba(255,255,255,0.1); 
                border-radius: 20px 20px 0 0; 
                box-shadow: 0 -10px 40px rgba(0,0,0,0.8); 
                animation: slideUpMobile 0.3s ease-out;
            }
            .btn-close-summary {
                position: absolute; top: -15px; right: 15px;
                background: var(--primary); border: 2px solid var(--surface);
                color: #000; width: 32px; height: 32px;
                border-radius: 50%; display: flex; align-items: center;
                justify-content: center; font-size: 20px; font-weight: bold; line-height: 1;
                cursor: pointer; z-index: 2000;
                box-shadow: 0 4px 10px rgba(0,0,0,0.3);
            }
            @keyframes slideUpMobile {
                from { transform: translateY(100%); }
                to { transform: translateY(0); }
            }
            .order-summary h5 { 
                display: none; }
            .hide-mobile-summary { 
                display: none !important; }
            .total-row-mobile { 
                display: flex; 
                justify-content: space-between; 
                align-items: center; margin-bottom: 12px; 
                padding: 0 !important; 
                border:none; }
            .total-row-mobile .total-label { 
                font-size: 0.9rem; 
                color: var(--text-muted); }
            .order-summary .invoice-total { 
                font-size: 1.35rem; 
                color: #fff !important; 
                text-shadow: 0 2px 10px rgba(92,63,246,0.5); }
            .game-detail-banner { 
                height: 160px; }
            .btn-bayar { 
                font-size: 1rem; 
                padding: 14px; 
                box-shadow: 0 4px 20px rgba(92,63,246,0.4); }
        }

        /* PREMIUM FOOTER STYLES */
        footer { 
            background: rgba(10, 12, 16, 0.95); 
            border-top: 1px solid var(--border); 
            padding: 40px 0 20px; 
            margin-top: 0;
        }
        .footer-brand { 
            display: flex;
            align-items: center;
            gap: 12px;
            font-size: 1.8rem; 
            font-weight: 800; 
            margin-bottom: 20px; 
            text-decoration: none !important;
        }
        .footer-brand span {
            background: linear-gradient(135deg, #fff, var(--primary)); 
            -webkit-background-clip: text; 
            -webkit-text-fill-color: transparent; 
        }
        .footer-logo { 
            height: 45px; 
            width: auto; }
        .footer-text { 
            color: var(--text-muted); 
            font-size: 0.95rem; 
            line-height: 1.8; 
            max-width: 350px; }
        .footer-heading { 
            font-weight: 700; 
            font-size: 1.1rem; 
            color: var(--text-main); 
            margin-bottom: 25px; 
            position: relative; }
        .footer-heading::after { content: ''; position: absolute; bottom: -8px; left: 0; width: 35px; height: 3px; background: var(--primary); border-radius: 10px; }
        .footer-link { display: block; color: var(--text-muted); text-decoration: none; font-size: 0.95rem; margin-bottom: 12px; transition: all 0.3s; }
        .footer-link:hover { color: var(--primary); padding-left: 5px; }
        .social-circle { 
            width: 40px; height: 40px; 
            border-radius: 50%; 
            background: rgba(255,255,255,0.05); 
            display: flex; align-items: center; justify-content: center; 
            color: #fff; text-decoration: none; 
            transition: all 0.3s; border: 1px solid var(--border);
        }
        .social-circle:hover { background: var(--primary); transform: translateY(-5px); box-shadow: 0 5px 15px var(--primary-glow); border-color: transparent; }
        .footer-copy { 
            text-align: center; 
            color: var(--text-muted); 
            font-size: 0.8rem; 
            margin-top: 20px; 
            padding: 15px 0; 
            border-top: 1px solid var(--border); 
            letter-spacing: 1px; 
            text-transform: uppercase;
            font-weight: 600;
            opacity: 0.8;
        }
        .cs-menu-item { font-weight: 700; }
        #tiktokCsLink { color: #fff; }
        body.light-mode #tiktokCsLink { color: #0f172a; }
        body.light-mode .cs-menu { background: #fff; border-color: #e2e8f0; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }

        /* PROMO BANNER IN TOPUP PAGE */
        /* PROMO BANNER IN TOPUP PAGE */
        .topup-ad-banner {
            width: 100%;
            height: 250px; /* Tinggi dikurangi agar tidak terlalu panjang */
            overflow: hidden;
            margin-bottom: 30px;
            background: #000;
        }
        @media (max-width: 768px) {
            .topup-ad-banner { height: 140px; margin-bottom: 20px; }
        }
        .checkout-section-wrap { padding: 60px 0; }
        @media (max-width: 768px) {
            .checkout-section-wrap { padding: 20px 0 !important; }
        }
        .topup-ad-banner img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            object-position: center;
            display: block;
        }
        body.light-mode .game-card:hover { box-shadow: 0 15px 30px rgba(0,0,0,0.08), 0 0 15px rgba(243, 156, 18, 0.2); }
        body.light-mode .form-dark { color: var(--text-main); background: #fff; border-color: rgba(0,0,0,0.1); }
        body.light-mode .checkout-card { box-shadow: 0 5px 15px rgba(0,0,0,0.02); }
        body.light-mode .pay-card { background: rgba(0,0,0,0.01); }
        body.light-mode .pay-card span { color: var(--text-main); }
        body.light-mode .pay-card.active { background: rgba(243, 156, 18, 0.1); border-color: var(--primary); }
        body.light-mode .order-summary { box-shadow: 0 15px 35px rgba(0,0,0,0.05); background: #ffffff; }
        body.light-mode .order-summary h5 { color: var(--text-heading); }
        body.light-mode .invoice-row span { color: var(--text-muted); }
        body.light-mode .invoice-row strong { color: var(--text-heading); }
        body.light-mode .invoice-total { color: var(--text-heading) !important; text-shadow: none; }
        body.light-mode .btn-bayar { color: #fff !important; background: var(--primary) !important; }
        body.light-mode footer { background: #ffffff; border-top-color: rgba(0,0,0,0.05); }
        body.light-mode .footer-heading { color: #111827; }
        body.light-mode .footer-brand { background: linear-gradient(135deg, #111827, var(--primary)); -webkit-background-clip: text; }
        body.light-mode .social-circle { background: rgba(0,0,0,0.03); color: #111827; border-color: rgba(0,0,0,0.08); }
        body.light-mode .social-circle:hover { color: #fff; background: var(--primary); border-color: transparent;}
        body.light-mode .custom-modal .modal-content-custom { color: #111827; }
        body.light-mode .custom-modal .btn-close-custom { color: #111827; }
        body.light-mode .trx-item { color: var(--text-main); box-shadow: 0 5px 15px rgba(0,0,0,0.02); background: #ffffff; }
        body.light-mode .nick-box { background: rgba(46, 204, 113, 0.08) !important; }
        body.light-mode #nickText { color: #111827 !important; }
        body.light-mode .stat-num { color: #111827; }
        body.light-mode .stat-label { color: var(--text-muted); }




        .footer-banner-full {
            width: 100%;
            background: var(--bg);
            margin-top: 0;
            overflow: hidden;
            position: relative;
        }
        @media (max-width: 768px) {
            .footer-banner-full { margin-top: -15px !important; }
        }
        .footer-banner-wrapper {
            width: 100%;
            position: relative;
            background: var(--bg);
            display: flex;
            justify-content: center;
        }

        .footer-promo-image {
            width: 100%;
            max-width: 100vw;
            height: auto;
            display: block;
            object-fit: cover;
        }

        /* Default (Dark Mode) Styles */
        .footer-promo-image.dark-banner {
            mask-image: radial-gradient(ellipse 90% 80% at center, black 10%, transparent 100%);
            -webkit-mask-image: radial-gradient(ellipse 90% 80% at center, black 10%, transparent 100%);
            opacity: 0.9;
            filter: brightness(1.1) contrast(1.05);
        }

        .footer-promo-image.light-banner { display: none; }
        
        body.light-mode .footer-promo-image.dark-banner { display: none; }
        body.light-mode .footer-promo-image.light-banner { 
            display: block; 
            /* Memastikan tidak ada efek apapun di mode light */
            mask-image: none !important;
            -webkit-mask-image: none !important;
            opacity: 1 !important;
            filter: none !important;
        }
        
        .banner-glow {
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            background: radial-gradient(circle at center, transparent 30%, var(--bg) 100%);
            pointer-events: none;
        }
        
        body.light-mode .banner-glow {
            display: none;
        }

        /* ARTICLE CARDS - NTPEDIA STYLE */
        .article-card { 
            background: var(--surface); 
            border: 1px solid var(--border); 
            border-radius: 24px; 
            overflow: hidden; 
            height: 100%; 
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); 
            cursor: pointer;
            position: relative;
        }
        .article-card:hover { transform: translateY(-10px); border-color: var(--primary); box-shadow: 0 20px 40px rgba(0,0,0,0.6); }
        
        .art-img-wrap {
            position: relative;
            width: 100%;
            height: auto; /* Membiarkan gambar menentukan tinggi secara alami */
            overflow: hidden;
            background-color: transparent;
        }

        .art-img-main {
            width: 100%;
            height: auto;
            display: block;
            z-index: 2;
            transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .article-card:hover .art-img-main { transform: scale(1.1); }
        
        .art-img-gradient {
            position: absolute;
            bottom: 0; left: 0; width: 100%; height: 80%;
            background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
            z-index: 3;
        }
        .art-title-overlay {
            position: absolute;
            bottom: 15px; left: 18px; right: 18px;
            z-index: 4;
            color: #fff;
            font-weight: 800;
            font-size: 1.05rem;
            line-height: 1.3;
            margin: 0;
            display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
            text-shadow: 0 2px 4px rgba(0,0,0,0.5);
        }
        .art-badge-top {
            position: absolute;
            top: 15px; left: 15px;
            z-index: 5;
            background: var(--primary);
            color: #000;
            font-size: 0.6rem;
            font-weight: 900;
            padding: 4px 10px;
            border-radius: 50px;
            text-transform: uppercase;
        }
        .art-body { padding: 18px 20px; }
        .art-footer-brand { 
            color: var(--primary); 
            font-size: 0.7rem; 
            font-weight: 900; 
            text-transform: uppercase; 
            margin-bottom: 5px;
            letter-spacing: 1px;
        }
        .art-text-short { 
            font-size: 0.8rem; 
            color: var(--text-muted); 
            line-height: 1.4; 
            margin: 0;
            display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
        }
        body.light-mode .article-card { background: #fff; border-color: rgba(0,0,0,0.05); }
        body.light-mode .art-title-overlay { color: #fff; } /* Tetap putih karena di atas gradasi hitam */
        
        .modal-content { transition: all 0.3s ease; }

        /* Modal Art View Premium */
        #artViewImage {
            width: 100%; 
            height: 400px; /* Kembali ke ukuran normal yang megah */
            position: relative; 
            overflow: hidden;
            background-color: #000;
        }
        @media (max-width: 768px) { #artViewImage { height: 220px; } }

        
        .art-view-main {
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            z-index: 2;
        }

        .art-view-overlay {
            display: none;
        }
        /* Title sekarang di dalam modal-body, bukan overlay */




        .modal-reader {
            background: rgba(20, 22, 25, 0.8) !important;
            backdrop-filter: blur(20px);
            border: 1px solid rgba(255,255,255,0.08) !important;
            border-radius: 30px !important;
        }
        body.light-mode .modal-reader {
            background: rgba(255, 255, 255, 0.9) !important;
            border-color: rgba(0,0,0,0.05) !important;
        }

        .art-reader-title {
            font-family: 'Outfit', sans-serif; font-size: 2.2rem; font-weight: 800;
            line-height: 1.2; letter-spacing: -1px; color: var(--text-main);
        }
        body.light-mode .art-reader-title {
            background: linear-gradient(135deg, #111827, #4b5563);
            -webkit-background-clip: text;
        }
        @media (max-width: 768px) { .art-reader-title { font-size: 1.8rem; } }

        .art-reader-content {
            font-size: 1.1rem;
            line-height: 1.8;
            color: var(--text-main);
            opacity: 0.9;
            text-align: justify;
        }
        .art-reader-content p { margin-bottom: 1.5rem; }

        .art-reader-meta {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 1px solid var(--border);
        }

        .btn-close-reader {
            width: 45px; height: 45px;
            background: rgba(255,255,255,0.1);
            border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            color: #fff; border: none; font-size: 20px;
            transition: 0.3s; z-index: 100;
            backdrop-filter: blur(5px);
        }
        .btn-close-reader:hover { background: var(--primary); transform: rotate(90deg); color: #000; }

        /* HOW TO SECTION PREMIUM */
        .how-card {
            background: rgba(255, 255, 255, 0.02);
            border: 1px solid var(--border);
            border-radius: 24px;
            padding: 40px 25px;
            text-align: center;
            transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            height: 100%;
            position: relative;
            overflow: hidden;
            z-index: 1;
        }
        .how-card::before {
            content: '';
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background: radial-gradient(circle at top right, var(--primary-glow), transparent 70%);
            opacity: 0; transition: 0.4s; z-index: -1;
        }
        .how-card:hover {
            transform: translateY(-12px);
            border-color: var(--primary);
            box-shadow: 0 20px 40px rgba(0,0,0,0.4), 0 0 20px var(--primary-glow);
            background: rgba(255, 255, 255, 0.04);
        }
        .how-card:hover::before { opacity: 1; }

        .how-step-wrap {
            width: 55px; height: 55px;
            background: var(--surface);
            border: 2px solid var(--border);
            border-radius: 16px;
            display: flex; align-items: center; justify-content: center;
            margin: 0 auto 30px;
            position: relative;
            font-weight: 800; font-size: 1.1rem; color: var(--primary);
            box-shadow: 0 10px 20px rgba(0,0,0,0.2);
            transition: 0.4s;
        }
        .how-card:hover .how-step-wrap {
            background: var(--primary);
            color: #000;
            border-color: var(--primary);
            transform: rotate(10deg) scale(1.1);
            box-shadow: 0 0 20px var(--primary-glow);
        }
        .how-card h3 {
            font-size: 1.25rem; font-weight: 800; margin-bottom: 15px; color: #fff;
            letter-spacing: -0.5px;
        }
        .how-card p {
            font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; margin: 0;
        }
        .how-icon-bg {
            position: absolute;
            bottom: -20px; right: -15px;
            font-size: 5rem; color: #fff;
            opacity: 0.02;
            transition: 0.5s;
            transform: rotate(-15deg);
            pointer-events: none;
        }
        .how-card:hover .how-icon-bg {
            opacity: 0.07;
            transform: rotate(0deg) scale(1.2);
            color: var(--primary);
        }
        body.light-mode .how-card { background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,0.03); }
        body.light-mode .how-card h3 { color: #111827; }
        body.light-mode .how-step-wrap { background: #f3f4f6; }



        /* INVOICE STYLING */
        .invoice-card { 
            background: #fff; color: #111827; border-radius: 0; padding: 40px; 
            box-shadow: 0 0 50px rgba(0,0,0,0.1); position: relative; 
            max-width: 500px; margin: 0 auto; font-family: 'Courier New', Courier, monospace;
        }
        .invoice-header { text-align: center; border-bottom: 2px dashed #e5e7eb; padding-bottom: 20px; margin-bottom: 25px; }
        .invoice-item { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 0.9rem; }
        .invoice-total { border-top: 2px dashed #e5e7eb; padding-top: 15px; margin-top: 20px; font-weight: bold; font-size: 1.1rem; }
        .invoice-qr { width: 100px; height: 100px; margin: 20px auto; background: #f3f4f6; display: flex; align-items: center; justify-content: center; border-radius: 10px; }
        .invoice-footer { text-align: center; font-size: 0.8rem; color: #6b7280; margin-top: 30px; }

        /* THEME TOGGLE BTN */
        .theme-toggle { background: none; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; padding: 6px 14px; border-radius: 50px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.85rem; transition: 0.3s; margin-left: auto; }
        .theme-toggle:hover { color: var(--primary); border-color: var(--primary); }

        /* METEOR ANIMATION */
        .hero-section {
            overflow: hidden; /* Agar meteor tidak keluar jalur */
        }
        .meteor-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 0;
        }
        .meteor {
            position: absolute;
            width: 3px;
            height: 130px;
            background: linear-gradient(to bottom, var(--primary), transparent);
            transform: rotate(-45deg);
            opacity: 0;
            box-shadow: 0 0 10px var(--primary);
            animation: meteor-animation linear infinite;
        }
        @keyframes meteor-animation {
            0% { transform: rotate(-45deg) translateY(-200px); opacity: 0; }
            10% { opacity: 1; }
            90% { opacity: 0.8; }
            100% { transform: rotate(-45deg) translateY(1200px); opacity: 0; }
        }
        /* PRELOADER */
        #preloader {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: var(--bg); display: flex; flex-direction: column;
            justify-content: center; align-items: center; z-index: 9999;
            transition: opacity 0.5s ease;
        }
        .preloader-logo {
            width: 120px; height: auto; margin-bottom: 25px;
            animation: pulse-glow 1.5s infinite alternate;
        }
        .loading-bar-container {
            width: 200px; height: 3px; background: rgba(255,255,255,0.05);
            border-radius: 10px; overflow: hidden; position: relative;
        }
        .loading-bar {
            width: 0%; height: 100%; background: var(--primary);
            box-shadow: 0 0 15px var(--primary);
            animation: loading-anim 1.5s ease-in-out forwards;
        }
        @keyframes loading-anim {
            0% { width: 0%; }
            100% { width: 100%; }
        }
        @keyframes pulse-glow {
            from { filter: drop-shadow(0 0 5px var(--primary-glow)); transform: scale(1); }
            to { filter: drop-shadow(0 0 20px var(--primary)); transform: scale(1.05); }
        }

        /* WELCOME MODAL */
        .welcome-modal {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.85); display: none; justify-content: center;
            align-items: center; z-index: 9000; backdrop-filter: blur(8px);
        }
        .welcome-content {
            background: var(--surface); border: 1px solid var(--border);
            width: 90%; max-width: 500px; border-radius: 20px;
            overflow: hidden; position: relative; animation: zoom-in 0.3s ease;
        }
        .welcome-img { width: 100%; display: block; border-bottom: 3px solid var(--primary); }
        .welcome-body { padding: 30px; text-align: center; }
        .welcome-close { 
            position: absolute; top: 15px; right: 15px; background: rgba(255,255,255,0.1);
            color: #fff; border: none; width: 35px; height: 35px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center; cursor: pointer;
            transition: 0.3s;
        }
        .welcome-close:hover { background: var(--primary); transform: rotate(90deg); }
        @keyframes zoom-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
        /* SKELETON LOADER FOR TRX FEED */
        .skeleton-trx {
            height: 60px; background: rgba(255,255,255,0.03); 
            border-radius: 12px; margin-bottom: 12px; position: relative; overflow: hidden;
        }
        .skeleton-trx::after {
            content: ''; position: absolute; top: 0; left: -100%; width: 50%; height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
            animation: skeleton-shine 1.5s infinite;
        }
        @keyframes skeleton-shine {
            0% { left: -100%; }
            100% { left: 100%; }
        }
        /* CS FLOATING BUTTON */
        .cs-fab {
            position: fixed; bottom: 30px; right: 30px; z-index: 9999;
            width: 60px; height: 60px; background: var(--primary);
            border-radius: 50%; display: flex; align-items: center; justify-content: center;
            color: white; font-size: 1.5rem; cursor: pointer;
            box-shadow: 0 10px 25px var(--primary-glow); transition: all 0.3s;
            animation: pulse-cs 2s infinite;
        }
        .cs-fab:hover { transform: scale(1.1) rotate(15deg); }
        .cs-menu {
            position: fixed; bottom: 100px; right: 30px; z-index: 9999;
            background: var(--surface); border: 1px solid var(--border);
            border-radius: 1.5rem; padding: 1rem; width: 220px;
            display: none; flex-direction: column; gap: 10px;
            box-shadow: 0 15px 40px rgba(0,0,0,0.4); animation: slide-up-cs 0.3s ease;
        }
        .cs-menu-item {
            display: flex; align-items: center; gap: 12px;
            color: #fff; text-decoration: none; padding: 12px;
            border-radius: 12px; background: rgba(255,255,255,0.03); transition: 0.2s;
            font-size: 0.9rem; font-weight: 600;
        }
        .cs-menu-item:hover { background: rgba(255,255,255,0.08); transform: translateX(5px); }
        .cs-menu-item i { width: 20px; text-align: center; }
        @keyframes pulse-cs { 0% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0.4); } 70% { box-shadow: 0 0 0 15px rgba(243, 156, 18, 0); } 100% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0); } }
        @keyframes slide-up-cs { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

        @media (max-width: 768px) {
            .cs-fab { display: none !important; }
            .cs-menu { display: none !important; }
        }

        /* ===== PRODUCT CATEGORY TABS ===== */
        .cat-tabs-wrapper {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
            margin-bottom: 20px;
            padding-bottom: 2px;
        }
        .cat-tabs-wrapper::-webkit-scrollbar { display: none; }
        .cat-tabs {
            display: flex;
            gap: 8px;
            white-space: nowrap;
            padding: 4px 2px;
        }
        .cat-tab {
            background: rgba(255,255,255,0.04);
            border: 1px solid var(--border);
            color: var(--text-muted);
            border-radius: 50px;
            padding: 7px 18px;
            font-size: 0.8rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.25s;
            white-space: nowrap;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            letter-spacing: 0.3px;
        }
        .cat-tab:hover {
            border-color: rgba(243,156,18,0.5);
            color: var(--primary);
            background: rgba(243,156,18,0.06);
        }
        .cat-tab.active {
            background: var(--primary);
            border-color: var(--primary);
            color: #0b0d0f;
            box-shadow: 0 4px 15px rgba(243,156,18,0.35);
        }
        .cat-tab .tab-badge {
            background: rgba(0,0,0,0.2);
            border-radius: 50px;
            padding: 1px 7px;
            font-size: 0.7rem;
            font-weight: 800;
        }
        .cat-tab.active .tab-badge {
            background: rgba(0,0,0,0.25);
        }
        /* Product grid animation when filtering */
        @keyframes fadeSlideIn {
            from { opacity: 0; transform: translateY(8px); }
            to   { opacity: 1; transform: translateY(0); }
        }
        .item-card-wrap {
            animation: fadeSlideIn 0.25s ease both;
        }
        /* Category icon colors */
        .cat-icon-all        { color: #f39c12; }
        .cat-icon-diamond    { color: #5ce1e6; }
        .cat-icon-special    { color: #d63384; }
        .cat-icon-weekly     { color: #198754; }
        .cat-icon-first      { color: #ffc107; }
        .cat-icon-starlight  { color: #c77dff; }
        .cat-icon-battlepass { color: #e55039; }
        .cat-icon-twilight   { color: #7986cb; }
        .cat-icon-sub        { color: #17a2b8; }
        .cat-icon-id         { color: #e74c3c; }
        .cat-icon-brazil     { color: #27ae60; }
        .cat-icon-india      { color: #ff9a3c; }
        .cat-icon-token      { color: #f1c40f; }
        .cat-icon-voucher    { color: #6c757d; }
        .cat-icon-pass       { color: #00b4d8; }
        /* Empty state */
        .empty-cat {
            grid-column: 1 / -1;
            text-align: center;
            padding: 40px 20px;
            color: var(--text-muted);
            font-size: 0.9rem;
        }
        body.light-mode .cat-tab {
            background: rgba(0,0,0,0.03);
            border-color: rgba(0,0,0,0.1);
            color: #6b7280;
        }
        body.light-mode .cat-tab.active { color: #0b0d0f; }
        /* Custom Notice Styling */
        .topup-notice {
            background: rgba(243, 156, 18, 0.1);
            border: 1px solid rgba(243, 156, 18, 0.3);
            border-radius: 15px;
            padding: 15px 20px;
            margin-bottom: 25px;
            display: flex;
            align-items: center;
            gap: 15px;
        }
        .topup-notice i {
            font-size: 1.5rem;
            color: var(--primary);
            filter: drop-shadow(0 0 8px var(--primary-glow));
        }
        .topup-notice p {
            margin: 0;
            font-size: 0.85rem;
            color: var(--text-main);
            line-height: 1.5;
        }
        body.light-mode .topup-notice {
            background: rgba(243, 156, 18, 0.05);
            border-color: rgba(243, 156, 18, 0.2);
        }
    </style>
    <!-- Midtrans Snap.js -->
    <script type="text/javascript" src="{{ config('midtrans.is_production') ? 'https://app.midtrans.com/snap/snap.js' : 'https://app.sandbox.midtrans.com/snap/snap.js' }}" data-client-key="{{ config('midtrans.client_key') }}"></script>
</head>
<body onscroll="onScroll()">
    <!-- PRELOADER -->
    <div id="preloader">
        <img src="{{ asset('images/logo.png') }}" alt="WYZSTORE Logo" class="preloader-logo">
        <div class="loading-bar-container">
            <div class="loading-bar"></div>
        </div>
        <p class="text-muted mt-3 small fw-bold" style="letter-spacing: 2px;">LOADING...</p>
    </div>

    <!-- WELCOME POPUP -->
    <div id="welcomeModal" class="welcome-modal">
        <div class="welcome-content">
            <button class="welcome-close" onclick="closeWelcome()">&times;</button>
            <img src="https://images.unsplash.com/photo-1511512578047-dfb367046420?q=80&w=1000&auto=format&fit=crop" class="welcome-img" alt="Promo">
            <div class="welcome-body text-center">
                <h4 class="fw-bold mb-2">Verifikasi Keamanan</h4>
                <p class="text-muted small mb-4">Silakan hitung penjumlahan di bawah untuk melanjutkan ke WYZSTORE.</p>
                
                <div class="d-flex align-items-center justify-content-center gap-3 mb-4">
                    <span class="badge bg-primary px-4 py-3" style="font-size: 1.5rem; border-radius: 12px; box-shadow: 0 5px 15px var(--primary-glow);">{{ $captcha_question }}</span>
                    <input type="number" id="welcomeCaptcha" class="form-dark m-0 text-center" style="width: 100px; font-size: 1.5rem; height: 60px;" placeholder="?">
                </div>

                <div id="welcomeError" class="text-danger small mb-3" style="display:none;">Jawaban salah, silakan coba lagi!</div>
                
                <button class="btn btn-primary w-100 py-3 fw-bold" onclick="verifyWelcome()">LANJUT KE STORE</button>
            </div>
        </div>
    </div>

<!-- ========== BOTTOM APP NAV (KHUSUS HP) ========== -->
<div class="mobile-bottom-nav">
    <a href="#" onclick="showHome(); window.scrollTo({top: 0, behavior: 'smooth'}); return false;" class="mobile-nav-item active">
        <i class="fas fa-home"></i>
        <span>Beranda</span>
    </a>
    <a href="/articles" class="mobile-nav-item">
        <i class="fas fa-newspaper"></i>
        <span>Berita</span>
    </a>
    <a href="#games" onclick="showHome(); document.getElementById('games').scrollIntoView();" class="mobile-nav-item">
        <i class="fas fa-gamepad"></i>
        <span>Game</span>
    </a>
    <a href="javascript:void(0)" onclick="openTrackModal()" class="mobile-nav-item">
        <i class="fas fa-search-location"></i>
        <span>Lacak</span>
    </a>
    <a href="https://wa.me/{{ env('WA_ADMIN_PHONE') }}" class="mobile-nav-item">
        <i class="fas fa-headset"></i>
        <span>Bantuan</span>
    </a>
</div>

<!-- ========== NAVBAR ========== -->
<div class="sidebar-overlay" id="sbOverlay" onclick="togMenu()"></div>
<div class="mobile-sidebar" id="mobSidebar">
    <div class="d-flex justify-content-between align-items-center mb-5">
        <div class="d-flex align-items-center gap-2">
            <img src="{{ asset('images/logo.png') }}" alt="Logo" style="height: 30px; width: auto;">
            <span class="fw-bold text-primary">WYZSTORE MENU</span>
        </div>
        <button class="btn btn-sm btn-outline-light rounded-circle" onclick="togMenu()">&times;</button>
    </div>
    <a href="/" class="mobile-link" onclick="togMenu()">Home</a>
    <a href="/articles" class="mobile-link" onclick="togMenu()">Articles</a>
    <a href="#games" class="mobile-link" onclick="togMenu()">Games</a>
    <a href="#how-to" class="mobile-link" onclick="togMenu()">Cara Top Up</a>
    <a href="javascript:void(0)" onclick="openTrackModal()" class="footer-link">Cek Transaksi</a>
</div>

<nav class="navbar-custom">
    <div class="container d-flex align-items-center justify-content-between">
        <a href="/" class="navbar-brand">
            <img src="{{ asset('images/logo.png') }}" alt="WYZSTORE Logo" class="navbar-logo">
            <span>WYZSTORE</span>
        </a>
        <div class="d-flex align-items-center gap-2 gap-md-4">
            <div class="d-none d-md-flex gap-4 me-3">
                <a href="/" class="nav-link">Beranda</a>
                <a href="/articles" class="nav-link">Artikel</a>
                <a href="#games" class="nav-link">Game</a>
                <a href="#how-to" class="nav-link">Cara Top Up</a>
                <a href="javascript:void(0)" onclick="openTrackModal()" class="footer-link nav-link m-0">Cek Transaksi</a>
            </div>
            <button class="theme-toggle" id="themeBtnDesktop" aria-label="Toggle Theme" onclick="toggleTheme()">
                <i class="fas fa-moon"></i> <span class="d-none d-sm-inline">Dark</span>
            </button>
            <button class="mobile-btn" onclick="togMenu()"><i class="fas fa-bars"></i></button>
        </div>
    </div>
</nav>

<!-- ========== HOME PAGE ========== -->
<div id="homePage">
    <!-- HERO SWIPER (TAKAPEDIA STYLE) -->
    <section class="hero-section">
        <!-- Meteor Animation Background -->
        <div class="meteor-container" id="meteorContainer"></div>
        <div class="container position-relative">
            <!-- Container Swiper -->
            <div class="swiper hero-swiper">
                <div class="swiper-wrapper">
                    @forelse($banners as $banner)
                    <div class="swiper-slide">
                        @if($banner->target_url)
                            <a href="{{ Str::startsWith($banner->target_url, 'article:') ? 'javascript:void(0)' : $banner->target_url }}" 
                               class="d-block w-100 h-100" 
                               @if(Str::startsWith($banner->target_url, 'article:')) onclick="handleBannerArticle('{{ substr($banner->target_url, 8) }}')" @endif>
                                <img src="{{ \Illuminate\Support\Str::startsWith($banner->image_url, ['http', '/']) ? $banner->image_url : asset('storage/' . $banner->image_url) }}" alt="{{ $banner->title ?? 'Promo WYZSTORE' }}">
                            </a>
                        @else
                            <img src="{{ \Illuminate\Support\Str::startsWith($banner->image_url, ['http', '/']) ? $banner->image_url : asset('storage/' . $banner->image_url) }}" alt="{{ $banner->title ?? 'Promo WYZSTORE' }}">
                        @endif
                    </div>
                    @empty
                    <!-- GAMBAR CADANGAN (Tampil jika Admin mengosongkan banner) -->
                    <div class="swiper-slide">
                        <a href="#games">
                            <img src="https://images.unsplash.com/photo-1542751371-adc38448a05e?q=80&w=2070&auto=format&fit=crop" alt="Promo WYZSTORE 1">
                        </a>
                    </div>
                    <div class="swiper-slide">
                        <a href="#games">
                            <img src="https://images.unsplash.com/photo-1538481199705-c710c4e965fc?q=80&w=2000&auto=format&fit=crop" alt="Promo WYZSTORE 2">
                        </a>
                    </div>
                    @endforelse

                    @if(isset($featured_articles))
                        @foreach($featured_articles as $f_article)
                        <div class="swiper-slide">
                            <a href="/article/{{ $f_article->id }}" class="d-block w-100 h-100 position-relative">
                                <img src="{{ \Illuminate\Support\Str::startsWith($f_article->image_url, ['http', '/']) ? $f_article->image_url : asset('storage/' . $f_article->image_url) }}" alt="{{ $f_article->title }}">
                                <div class="position-absolute bottom-0 start-0 w-100 p-4" style="background: linear-gradient(transparent, rgba(0,0,0,0.8));">
                                    <span class="badge bg-primary mb-2 px-3 py-2" style="font-size: 0.8rem;">{{ $f_article->category }}</span>
                                    <h3 class="text-white fw-bold mb-0 text-truncate" style="text-shadow: 0 2px 4px rgba(0,0,0,0.5);">{{ $f_article->title }}</h3>
                                </div>
                            </a>
                        </div>
                        @endforeach
                    @endif
                </div>
                
                <!-- Tag Khas Samping -->
                <!-- <div class="wyzstore-tag-label">WYZSTORE</div> -->
                <!-- Panah Navigasi -->
                <div class="swiper-button-next"></div>
                <div class="swiper-button-prev"></div>
                <!-- Titik Pagination Bawah -->
                <div class="swiper-pagination"></div>
            </div>
        </div>
    </section>

    <!-- GAME LIST -->
    <section id="games" class="container">
        <div class="section-title"> <h2>Daftar Game</h2></div>
        <p class="section-subtitle">Pilih game favoritmu dan top up sekarang!</p>
        <div class="row g-4">
            @foreach($games as $game)
            <div class="col-6 col-md-4 col-lg-2">
                <a class="game-card" href="#" onclick="openGame({{ $game->id }}, '{{ $game->name }}', '{{ $game->image_url }}')">
                    <div class="game-img-wrap">
                        <img class="game-img" src="{{ $game->image_url }}">
                        <div class="game-overlay"><button class="btn-topup">Top Up</button></div>
                        @if($game->badge_text)
                            <div class="position-absolute top-0 start-0 m-2 badge bg-primary">{{ $game->badge_text }}</div>
                        @endif
                    </div>
                    <div class="game-info"><h3>{{ $game->name }}</h3><p>Otomatis</p></div>
                </a>
            </div>
            @endforeach
        </div>
    </section>

    <!-- HOW TO -->
    <section id="how-to" style="background: var(--surface); position: relative; overflow: hidden;">
        <!-- Tambahan dekorasi latar belakang -->
        <div class="position-absolute top-0 start-0 w-100 h-100" style="background: radial-gradient(circle at 50% 50%, rgba(243, 156, 18, 0.03) 0%, transparent 70%); pointer-events: none;"></div>
        
        <div class="container position-relative">
            <div class="section-title text-center mb-5">
                <h2 class="d-block mx-auto text-center">Cara Top Up</h2>
                <div class="mx-auto mt-3" style="width: 60px; height: 4px; background: var(--primary); border-radius: 10px;"></div>
            </div>
            <p class="text-center text-muted mb-5">Selesaikan pesananmu hanya dalam hitungan detik dengan 4 langkah mudah!</p>
            
            <div class="row g-4">
                <div class="col-md-3">
                    <div class="how-card">
                        <div class="how-step-wrap">01</div>
                        <h3 class="fw-bold" style="color: var(--text-main);">Pilih Game</h3>
                        <p style="color: var(--text-muted);">Pilih game favorit kamu yang ingin di top up nominalnya.</p>
                        <i class="fas fa-gamepad how-icon-bg"></i>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="how-card">
                        <div class="how-step-wrap">02</div>
                        <h3 class="fw-bold" style="color: var(--text-main);">Masukkan ID</h3>
                        <p style="color: var(--text-muted);">Masukkan User ID & Zone ID akun game kamu dengan benar.</p>
                        <i class="fas fa-user-tag how-icon-bg"></i>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="how-card">
                        <div class="how-step-wrap">03</div>
                        <h3 class="fw-bold" style="color: var(--text-main);">Pilih Nominal</h3>
                        <p style="color: var(--text-muted);">Tentukan jumlah item atau nominal top up yang kamu inginkan.</p>
                        <i class="fas fa-gem how-icon-bg"></i>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="how-card">
                        <div class="how-step-wrap">04</div>
                        <h3 class="fw-bold" style="color: var(--text-main);">Bayar & Selesai</h3>
                        <p style="color: var(--text-muted);">Pilih metode pembayaran favoritmu dan item langsung masuk!</p>
                        <i class="fas fa-wallet how-icon-bg"></i>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- ARTICLE SECTION -->
    <section class="container mb-5 py-5">
        <div class="d-flex justify-content-between align-items-end mb-4">
            <div>
                <h2 class="fw-bold mb-1"><i class="fas fa-newspaper text-primary me-2"></i> Berita & Esport</h2>
                <p class="text-muted small mb-0">Update info terkini seputar dunia game & industri esport.</p>
            </div>
        </div>
        <div class="row g-4" id="articleList">
            <div class="col-12 text-center py-4 text-muted">Memuat berita...</div>
        </div>
        
        <!-- Tombol Lihat Semua Artikel -->
        <div class="text-center mt-5">
            <a href="/articles" class="btn btn-outline-primary rounded-pill px-5 py-2 fw-bold" style="border-width: 2px;">
                Cari Artikel Terkait <i class="fas fa-arrow-right ms-2"></i>
            </a>
        </div>
    </section>

    <!-- STATS BAR -->
    <div class="stats-bar">
        <div class="container"><div class="row g-3 text-center">
            <div class="col-6 col-md-3 stat-item">
                <div class="stat-num">{{ $homepage['stat_1_num'] ?? '50k+' }}</div>
                <div class="stat-label">{{ $homepage['stat_1_label'] ?? 'Transaksi Sukses' }}</div>
            </div>
            <div class="col-6 col-md-3 stat-item">
                <div class="stat-num">{{ $homepage['stat_2_num'] ?? '99.9%' }}</div>
                <div class="stat-label">{{ $homepage['stat_2_label'] ?? 'Uptime Berjalan' }}</div>
            </div>
            <div class="col-6 col-md-3 stat-item">
                <div class="stat-num">{{ $homepage['stat_3_num'] ?? '< 5 Detik' }}</div>
                <div class="stat-label">{{ $homepage['stat_3_label'] ?? 'Rata-rata Proses' }}</div>
            </div>
            <div class="col-6 col-md-3 stat-item">
                <div class="stat-num">{{ $homepage['stat_4_num'] ?? '24 / 7' }}</div>
                <div class="stat-label">{{ $homepage['stat_4_label'] ?? 'Layanan Aktif' }}</div>
            </div>
        </div></div>
    </div>

    <!-- RECENT TRX -->
    <section class="container">
        <div class="section-title"><span class="section-icon"></span><h2>Transaksi Terbaru</h2></div>
        <div class="trx-feed" id="trxFeed"><div class="text-center py-4 text-muted">Memuat data dari MySQL...</div></div>
    </section>
</div>

<!-- ========== GAME DETAIL PAGE ========== -->
<div id="gameDetailPage" style="display:none;">
    <!-- Promo Banner Topup - Full Screen Width -->
    <!-- <div class="topup-ad-banner">
        <img src="{{ asset('images/wyzstore-banner.png') }}" alt="Promo WYZSTORE">
    </div> -->

    <div class="container pb-5">
        <button class="btn btn-outline-light btn-sm mb-4" onclick="showHome()">← Kembali</button>
        
        <!-- Notification Box -->
        <div class="topup-notice page-transition">
            <i class="fas fa-info-circle"></i>
            <p>
                <strong>Informasi Penting:</strong> Harap selalu cek bukti transaksi Anda pada bagian bawah halaman setiap kali melakukan top up. Simpan atau screenshot bukti pembayaran untuk memudahkan proses bantuan jika terjadi kendala.
            </p>
        </div>
        
        <div class="row g-4">
        <div class="col-lg-3">
            <div class="checkout-card p-4">
                <img id="gdCover" class="w-100 rounded-4 mb-4 shadow-lg" src="">
                <h2 id="gdTitle" class="fw-bold mb-2 text-white"></h2>
                <div class="badge bg-primary px-3 py-2 mb-4">Otomatis ⚡</div>
                
                <h6 class="fw-bold text-white mb-2">Tentang Game</h6>
                <p class="text-muted small" id="gdDesc">Top up voucher game favoritmu hanya di WYZSTORE. Proses instan, harga murah, dan terpercaya. Layanan aktif 24 jam nonstop.</p>
                
                <hr class="border-secondary opacity-25">
                <div class="d-flex align-items-center gap-2 mb-2">
                    <i class="fas fa-shield-alt text-primary"></i>
                    <span class="small text-muted">Layanan Terenkripsi</span>
                </div>
            </div>
        </div>

        <div class="col-lg-5">
            <div class="checkout-card">
                <div class="step-label">Langkah 1 — Masukkan ID Akun</div>
                <div class="row g-3">
                    <div class="col-md-5">
                        <input type="text" id="inputUserId" class="form-dark" placeholder="Contoh: 12345678 (User ID)">
                    </div>
                    <div class="col-md-3" id="zoneInputWrapper" style="display:none;">
                        <input type="text" id="inputZoneId" class="form-dark" placeholder="Contoh: 1234 (Zone)">
                    </div>
                    <div class="col-md-3" id="serverSelectWrapper" style="display:none;">
                        <select id="inputServer" class="form-dark">
                            <option value="">Pilih Server</option>
                            <option value="Asia">Asia</option>
                            <option value="America">America</option>
                            <option value="Europe">Europe</option>
                        </select>
                    </div>
                    <div class="col-md-4">
                        <button class="btn btn-primary w-100" onclick="checkNickname()" id="btnCek" style="height:48px;">Cek Nickname</button>
                    </div>
                </div>
                <div class="nick-box" id="nickBox" style="display:none; padding:12px; background:rgba(46, 204, 113, 0.15); border:1px solid #2ecc71; border-radius:10px; margin-top:20px; color:#2ecc71;">✅ Nickname Berhasil Ditemukan: <br><strong id="nickText" class="fs-5"></strong></div>
                
                <div id="manualNickWrapper" style="display:none; padding:15px; background:rgba(231, 76, 60, 0.15); border:1px solid #e74c3c; border-radius:10px; margin-top:20px;">
                    <label class="text-danger small fw-bold mb-2"><i class="fas fa-exclamation-triangle"></i> Pencarian nama gagal. Silakan ketik nama Game Anda di sini:</label>
                    <input type="text" id="manualNickInput" class="form-dark w-100" placeholder="Ketik nama asli kamu (misal: SangPemimpi)" oninput="checkReady()">
                </div>
            </div>

            <div class="checkout-card">
                <div class="step-label">Langkah 2 — Pilih Nominal</div>
                <div class="cat-tabs-wrapper" id="catTabsWrapper" style="display:none;">
                    <div class="cat-tabs" id="catTabs"></div>
                </div>
                <div class="row g-3" id="itemGrid">
                    <div class="col-12 text-center py-4 text-muted">Memuat produk...</div>
                </div>
            </div>

            <div class="checkout-card">
                <div class="step-label">Langkah 3 — Pembayaran & Kontak</div>
                <div class="mb-4">
                    <label class="small text-muted mb-2 fw-bold">Pilih Pembayaran</label>
                    <div class="payment-grid">
                        <div class="pay-card active" onclick="selPay(this)">
                            <img src="https://upload.wikimedia.org/wikipedia/commons/e/e1/QRIS_logo.svg" alt="QRIS">
                            <span>Scan QRIS</span>
                        </div>
                        <div class="pay-card" onclick="selPay(this)">
                            <img src="https://upload.wikimedia.org/wikipedia/commons/8/86/Gopay_logo.svg" alt="Gopay">
                            <span>Gopay</span>
                        </div>
                        <div class="pay-card" onclick="selPay(this)">
                            <img src="https://upload.wikimedia.org/wikipedia/commons/e/eb/Logo_ovo_purple.svg" alt="OVO">
                            <span>OVO Wallet</span>
                        </div>
                        <div class="pay-card" onclick="selPay(this)">
                            <img src="https://upload.wikimedia.org/wikipedia/commons/7/72/Logo_dana_blue.svg" alt="DANA">
                            <span>DANA</span>
                        </div>
                    </div>
                </div>
                <div class="mt-4 pt-3" style="border-top: 1px dashed rgba(255,255,255,0.1);">
                    <label class="small text-muted mb-2 fw-bold">Nomor WhatsApp</label>
                    <input type="text" id="inputWa" class="form-dark" placeholder="08123456xxxx">
                </div>
            </div>

            <div class="checkout-card">
                <div class="step-label">Langkah 4 — Data Kontak & Promo</div>
                <div class="row g-3 mb-3">
                    <div class="col-md-6">
                        <label class="small text-muted mb-2">Nama Lengkap</label>
                        <input type="text" id="inputName" class="form-dark" placeholder="Nama Anda" oninput="checkReady()">
                    </div>
                    <div class="col-md-6">
                        <label class="small text-muted mb-2">Email (Opsional)</label>
                        <input type="email" id="inputEmail" class="form-dark" placeholder="nama@email.com" oninput="checkReady()">
                    </div>
                </div>
                <div class="d-flex gap-2">
                    <input type="text" id="inputPromo" class="form-dark" placeholder="Kode promo...">
                    <button class="btn btn-outline-primary px-4" onclick="applyPromo()">Apply</button>
                </div>
            </div>
        </div>

        <div class="col-lg-4">
            <div class="checkout-card order-summary">
                <button class="btn-close-summary d-lg-none" onclick="resetSelection()">&times;</button>
                <h5 class="fw-bold mb-4" style="color: var(--text-main);">Ringkasan Pesanan</h5>
                <div class="invoice-row d-flex justify-content-between mb-2"><span style="color: var(--text-muted);">Game</span><strong id="summGame" style="color: var(--text-main);">-</strong></div>
                <div class="invoice-row d-flex justify-content-between mb-2"><span style="color: var(--text-muted);">Item</span><strong id="summItem" style="color: var(--text-main);">-</strong></div>
                <div class="invoice-row d-flex justify-content-between mb-4 pt-3 border-top border-secondary">
                    <span class="fw-bold">Total Bayar</span>
                    <span class="invoice-total fs-4 text-primary fw-bold" id="summTotal">Rp 0</span>
                </div>
                
                <button class="btn-bayar w-100 mt-2" id="btnBayar" onclick="doCheckout()" disabled>
                    <i class="fas fa-lock me-2"></i> Bayar Sekarang
                </button>
            </div>
        </div>
        </div>
    </div>
</div>
<!-- ========== FOOTER ========== -->
<!--  -->
<!-- ========== MODAL TRACK ORDER ========== -->
<div id="modalTrack" class="custom-modal">
    <div class="modal-content-custom">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h5 class="mb-0">Cek Status Pesanan</h5>
            <button class="btn-close-custom" onclick="closeTrackModal()">&times;</button>
        </div>
        <div class="mb-4">
            <label class="small text-muted mb-2">Order ID (Contoh: TRX-XXXXX)</label>
            <div class="input-group">
                <input type="text" id="trackOrderId" class="form-dark flex-grow-1" placeholder="TRX-...">
                <button class="btn btn-primary" onclick="trackOrder()" id="btnTrack" style="border-radius: 0 10px 10px 0;">Cek</button>
            </div>
        </div>

        <!-- FITUR LUPA ID -->
        <div class="p-3 rounded-4 mb-4" style="background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);">
            <p class="small text-white fw-bold mb-2"><i class="fas fa-history me-2 text-primary"></i> Temukan ID Pesanan</p>
            
            <!-- Tombol Pesanan Terakhir -->
            <div id="lastOrderShortcut" style="display:none;" class="mb-3">
                <div class="d-flex gap-2">
                    <button class="btn btn-sm btn-outline-light flex-grow-1 text-start d-flex justify-content-between align-items-center" onclick="useLastOrder()">
                        <span><i class="fas fa-clock-rotate-left me-2"></i> Riwayat Terakhir</span>
                        <strong id="lastOrderIdDisplay" class="text-primary"></strong>
                    </button>
                    <button class="btn btn-sm btn-outline-danger" onclick="clearLastOrder()" title="Hapus Riwayat">
                        <i class="fas fa-trash-alt"></i>
                    </button>
                </div>
                <div class="small text-muted mt-1" style="font-size: 0.7rem;"><i class="fas fa-info-circle me-1"></i>Riwayat ini hanya tersimpan di perangkat Anda. Hapus jika menggunakan perangkat umum.</div>
            </div>

            <label class="small text-muted mb-2">Lupa ID? Cari dengan No. WhatsApp</label>
            <div class="input-group">
                <input type="text" id="trackWa" class="form-dark flex-grow-1" placeholder="08xxxxxx">
                <button class="btn btn-outline-primary" onclick="findOrdersByWa()" id="btnFindWa" style="border-radius: 0 10px 10px 0;">Cari</button>
            </div>
            <div id="waSearchResult" class="mt-3 small" style="display:none;"></div>
        </div>

        <div id="trackResult" style="display:none; margin-bottom: 20px;">
            <hr class="border-secondary opacity-25">
            <div class="p-3 rounded-4" style="background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05);">
                <div class="d-flex justify-content-between mb-2"><span>Game</span><strong id="trGame"></strong></div>
                <div class="d-flex justify-content-between mb-2"><span>Item</span><strong id="trItem"></strong></div>
                <div class="d-flex justify-content-between mb-2"><span>Status</span><span id="trStatus"></span></div>
                <div class="d-flex justify-content-between pt-2 border-top border-secondary opacity-50"><span>SN / Keterangan</span><small id="trSn" class="text-secondary"></small></div>

                <div class="text-center mt-4 pt-3" style="border-top: 1px dashed rgba(255,255,255,0.1);">
                    <button class="btn btn-primary w-100 rounded-pill py-2 fw-bold shadow-sm" onclick="showInvoice()">
                        <i class="fas fa-file-invoice me-2"></i> Lihat Nota / Invoice
                    </button>
                    <p class="small text-muted mt-2 mb-0">Klik untuk cetak atau simpan invoice.</p>
                </div>
            </div>
            <div style="height: 10px;"></div>
        </div>
    </div>
</div>

<style>
.custom-modal { position: fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.85); display:none; z-index:10000; align-items:center; justify-content:center; backdrop-filter:blur(5px); padding: 20px; }
.modal-content-custom { background:var(--surface); border:1px solid var(--border); border-radius:1.5rem; width:90%; max-width:450px; padding:2rem; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); max-height: 90vh; overflow-y: auto; }
.btn-close-custom { background:none; border:none; color:white; font-size:1.5rem; line-height:1; cursor:pointer; }
.badge-status { padding: 4px 10px; border-radius: 50px; font-size: 0.75rem; font-weight: 700; }
</style>

    <!-- FOOTER PROMO BANNER FULL WIDTH -->
    <div class="footer-banner-full">
        <div class="footer-banner-wrapper">
            <!-- Gambar Dark Mode -->
            <img src="{{ asset('images/footer-banner.png') }}" alt="WYZSTORE Promo" class="footer-promo-image dark-banner">
            <!-- Gambar Light Mode -->
            <img src="{{ asset('images/bg-light.png') }}" alt="WYZSTORE Promo" class="footer-promo-image light-banner">
            <div class="banner-glow"></div>
        </div>
    </div>

<footer>
    <div class="container">
        <div class="row g-4">
            <div class="col-lg-4 col-md-6 mb-3">
                <a href="/" class="footer-brand mb-2 d-inline-flex align-items-center gap-2">
                    <img src="{{ $homepage['logo_url'] ?? asset('images/logo.png') }}" alt="Logo" class="navbar-logo">
                    <span>WYZSTORE</span>
                </a>
                <p class="text-muted small mb-3" style="max-width: 300px;">Solusi top up game tercepat, termurah, dan terpercaya di Indonesia. Otomatis masuk dalam hitungan detik 24 jam nonstop.</p>
                <div class="d-flex gap-3 mb-3">
                    <a href="{{ $homepage['wa_link'] ?? '#' }}" class="social-circle"><i class="fab fa-whatsapp"></i></a>
                    <a href="{{ $homepage['ig_link'] ?? '#' }}" class="social-circle"><i class="fab fa-instagram"></i></a>
                    <a href="{{ $homepage['tiktok_link'] ?? '#' }}" class="social-circle"><i class="fab fa-tiktok"></i></a>
                </div>
            </div>
            <div class="col-6 col-lg-2 mb-3">
                <h5 class="footer-heading">Navigasi</h5>
                <a href="/" class="footer-link">Home</a>
                <a href="/#games" class="footer-link">Daftar Game</a>
                <a href="javascript:void(0)" onclick="openTrackModal()" class="footer-link nav-link m-0">Cek Transaksi</a>
            </div>
            <div class="col-6 col-lg-3 mb-3">
                <h5 class="footer-heading">Bantuan</h5>
                <a href="https://wa.me/{{ env('WA_ADMIN_PHONE') }}" class="footer-link">Hubungi Kami</a>
                <a href="/#how-to" class="footer-link">Metode Pembayaran</a>
                <a href="#" class="footer-link">Syarat & Ketentuan</a>
            </div>
            <div class="col-12 col-lg-3 mb-3">
                <h5 class="footer-heading">Metode Pembayaran</h5>
                <div class="pay-slider-container">
                    <div class="pay-slider">
                        @php
                            $logos = isset($homepage['pay_logos']) && !empty($homepage['pay_logos']) 
                                ? explode(',', $homepage['pay_logos']) 
                                : [
                                    'https://upload.wikimedia.org/wikipedia/commons/e/e1/QRIS_logo.svg',
                                    'https://upload.wikimedia.org/wikipedia/commons/7/72/Logo_dana_blue.svg',
                                    'https://upload.wikimedia.org/wikipedia/commons/8/86/Gopay_logo.svg',
                                    'https://upload.wikimedia.org/wikipedia/commons/e/eb/Logo_ovo_purple.svg',
                                    'https://upload.wikimedia.org/wikipedia/commons/9/9d/Logo_Indomaret.png'
                                ];
                        @endphp

                        @foreach($logos as $logo)
                            <img src="{{ trim($logo) }}" class="pay-logo">
                        @endforeach
                        
                        {{-- Duplikasi untuk marquee seamless --}}
                        @foreach($logos as $logo)
                            <img src="{{ trim($logo) }}" class="pay-logo">
                        @endforeach
                    </div>
                </div>
            </div>
        </div>
        <div class="footer-copy">
            <div class="container">
                <div class="mb-2">&copy; 2025 <span class="text-primary">WYZSTORE</span>. ALL RIGHTS RESERVED.</div>
                <div style="font-size: 0.65rem; opacity: 0.6; letter-spacing: 2px;">POWERED BY GER</div>
            </div>
        </div>
    </div>
</footer>

<!-- ARTICLE VIEW MODAL -->
<div class="modal fade" id="modalArticle" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable">
        <div class="modal-content border-0 modal-reader">
            <div id="artViewImage">
                <div class="art-view-main" id="artViewMain"></div>
                <div class="art-view-overlay"></div>
                <button type="button" class="btn-close-reader position-absolute top-0 end-0 m-4" data-bs-dismiss="modal">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <div class="modal-body p-4 p-md-5 pt-md-4">
                <div class="art-reader-meta mb-3">
                    <span id="artViewCategory" class="badge bg-primary px-3 py-2 rounded-pill small fw-bold shadow-sm">CATEGORY</span>
                    <span class="text-muted small"><i class="far fa-calendar-alt me-1"></i> <span id="artViewDate">DATE</span></span>
                </div>
                
                <h1 id="artViewTitle" class="art-reader-title mb-4">Article Title</h1>
                
                <div id="artViewContent" class="art-reader-content">
                    <!-- Konten akan diisi via JS -->
                </div>


                <div class="mt-5 pt-4 border-top border-secondary border-opacity-10 text-center">
                    <p class="text-muted small mb-3">Bagikan artikel ini:</p>
                    <div class="d-flex justify-content-center gap-3">
                        <a href="https://wa.me/?text={{ urlencode($article->title ?? 'WYZPEDIA') . ' ' . url()->current() }}" target="_blank" class="social-circle"><i class="fab fa-whatsapp"></i></a>
                        <a href="#" class="social-circle"><i class="fab fa-instagram"></i></a>
                        <a href="#" class="social-circle"><i class="fab fa-tiktok"></i></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
let S = { game: '', nick: null, item: null, price: 0, sku: null, promo: null, discount: 0 };
window.loadedArticles = [];
const rp = (v) => 'Rp ' + Math.floor(v||0).toLocaleString('id-ID');
const allGames = @json($games);

function showHome() {
    document.body.classList.remove('in-checkout');
    document.getElementById('homePage').classList.add('page-transition');
    document.getElementById('homePage').style.display = '';
    document.getElementById('gameDetailPage').style.display = 'none';
}

function selPay(el) {
    document.querySelectorAll('.pay-card').forEach(c => c.classList.remove('active'));
    el.classList.add('active');
}

async function openGame(id, name, img, targetSku = null) {
    S.game = name;
    S.item = null; S.price = 0; S.sku = null; S.nick = null; // reset selection
    document.body.classList.remove('has-item-selected');
    
    const cover = document.getElementById('gdCover');
    const title = document.getElementById('gdTitle');
    if (cover) cover.src = img;
    const gameInfo = allGames.find(g => g.id == id);
    const fullDesc = gameInfo && gameInfo.description ? gameInfo.description : 'Top up voucher game favoritmu hanya di WYZSTORE. Proses instan, harga murah, dan terpercaya. Layanan aktif 24 jam nonstop.';
    
    const descEl = document.getElementById('gdDesc');
    if (descEl) {
        if (fullDesc.length > 150) {
            descEl.innerHTML = `<span id="descShort">${fullDesc.substring(0, 150)}...</span><span id="descFull" style="display:none;">${fullDesc}</span> <a href="javascript:void(0)" onclick="toggleReadMore()" id="btnReadMore" class="text-primary small fw-bold">Baca Selengkapnya</a>`;
        } else {
            descEl.innerText = fullDesc;
        }
    }

    document.getElementById('summGame').innerText = name;
    document.getElementById('summItem').innerText = '-';
    document.getElementById('summTotal').innerText = 'Rp 0';
    document.getElementById('nickBox').style.display = 'none';
    document.getElementById('manualNickWrapper').style.display = 'none';
    document.getElementById('manualNickInput').value = '';
    checkReady();

    // Logic for Zone vs Server Select
    const gl = name.toLowerCase();
    const needsZone = gl.includes('legend') || gl.includes('ragnarok') || gl.includes('dragon nest');
    const needsServer = gl.includes('genshin') || gl.includes('star rail') || gl.includes('tower of fantasy');

    document.getElementById('zoneInputWrapper').style.display = needsZone ? 'block' : 'none';
    document.getElementById('serverSelectWrapper').style.display = needsServer ? 'block' : 'none';
    
    // Adjust visual size for ID input
    document.getElementById('inputUserId').parentElement.className = (needsZone || needsServer) ? 'col-md-5' : 'col-md-8';

    document.body.classList.add('in-checkout');
    document.getElementById('homePage').style.display = 'none';
    
    const gdPage = document.getElementById('gameDetailPage');
    gdPage.style.display = '';
    gdPage.classList.remove('page-transition');
    void gdPage.offsetWidth; // trigger reflow for animation restart
    gdPage.classList.add('page-transition');
    
    const grid = document.getElementById('itemGrid');
    const catTabsWrapper = document.getElementById('catTabsWrapper');
    const catTabsEl = document.getElementById('catTabs');
    grid.innerHTML = '<div class="col-12 text-center py-4"><div class="spinner-border text-primary"></div> Memuat produk...</div>';
    catTabsWrapper.style.display = 'none';
    catTabsEl.innerHTML = '';

    try {
        const res = await fetch(`/api/products/game/${id}`);
        const products = await res.json();

        if (products.length === 0) {
            grid.innerHTML = '<div class="col-12 text-center py-4 text-muted">Belum ada produk untuk game ini.</div>';
            return;
        }

        // ---- Build category list (preserve order appearance) ----
        const CAT_ICONS = {
            'Diamond':    { icon: 'fas fa-gem',             cls: 'cat-icon-diamond'    },
            'Special':    { icon: 'fas fa-star',            cls: 'cat-icon-special'    },
            'Weekly Pass':{ icon: 'fas fa-calendar-week',   cls: 'cat-icon-weekly'     },
            'First Topup':{ icon: 'fas fa-bolt',            cls: 'cat-icon-first'      },
            'Starlight':  { icon: 'fas fa-moon',            cls: 'cat-icon-starlight'  },
            'Battle Pass':{ icon: 'fas fa-shield-alt',      cls: 'cat-icon-battlepass' },
            'Twilight Pass':{ icon: 'fas fa-cloud-moon',   cls: 'cat-icon-twilight'   },
            'Subscription':{ icon: 'fas fa-sync-alt',      cls: 'cat-icon-sub'        },
            'Indonesia':  { icon: 'fas fa-flag',            cls: 'cat-icon-id'         },
            'Brazil':     { icon: 'fas fa-globe-americas',  cls: 'cat-icon-brazil'     },
            'India':      { icon: 'fas fa-globe-asia',      cls: 'cat-icon-india'      },
            'Token':      { icon: 'fas fa-coins',           cls: 'cat-icon-token'      },
            'Voucher':    { icon: 'fas fa-ticket-alt',      cls: 'cat-icon-voucher'    },
            'Pass':       { icon: 'fas fa-id-badge',        cls: 'cat-icon-pass'       },
        };

        // collect unique categories in product order
        const seenCats = [];
        products.forEach(p => {
            const cat = p.sub_category || 'Diamond';
            if (!seenCats.includes(cat)) seenCats.push(cat);
        });

        // Render tabs only when > 1 category exists
        if (seenCats.length > 1) {
            catTabsWrapper.style.display = '';
            const tabs = ['Semua', ...seenCats];
            catTabsEl.innerHTML = tabs.map((cat, i) => {
                const count = cat === 'Semua' ? products.length : products.filter(p => (p.sub_category || 'Diamond') === cat).length;
                const info = CAT_ICONS[cat] || { icon: 'fas fa-cube', cls: 'cat-icon-diamond' };
                return `<button class="cat-tab ${i === 0 ? 'active' : ''}" onclick="filterCat('${cat}', this)">
                    <i class="${info.icon} ${info.cls}"></i>
                    ${cat}
                    <span class="tab-badge">${count}</span>
                </button>`;
            }).join('');
        }

        // Store products globally for filter
        window._currentProducts = products;

        // Render function
        window.renderProductGrid = function(filterCatName) {
            const toShow = (!filterCatName || filterCatName === 'Semua')
                ? products
                : products.filter(p => (p.sub_category || 'Diamond') === filterCatName);

            if (toShow.length === 0) {
                grid.innerHTML = `<div class="col-12 empty-cat"><i class="fas fa-box-open fa-2x mb-3 d-block"></i>Tidak ada produk di kategori ini.</div>`;
                return;
            }

            grid.innerHTML = toShow.map((p, idx) => {
                const cat = p.sub_category || 'Diamond';
                const info = CAT_ICONS[cat] || { icon: 'fas fa-gem', cls: 'cat-icon-diamond' };
                const delay = (idx % 12) * 30;
                return `<div class="col-6 col-md-4 item-card-wrap" style="animation-delay:${delay}ms">
                    <div class="item-card ${targetSku && p.sku_code == targetSku ? 'selected' : ''}" id="sku-${p.sku_code}" onclick="selectItem(this, '${p.name.replace(/'/g, "\\'").replace(/"/g, '&quot;')}', ${p.price}, '${p.sku_code}')">
                        <div class="item-icon"><i class="${info.icon} ${info.cls}"></i></div>
                        <div class="item-name">${p.name}</div>
                        <div class="item-price">${rp(p.price)}</div>
                    </div>
                </div>`;
            }).join('');

            if (targetSku) {
                const el = document.getElementById(`sku-${targetSku}`);
                if (el) el.click();
            }
        };

        window.filterCat = function(catName, btn) {
            document.querySelectorAll('.cat-tab').forEach(t => t.classList.remove('active'));
            if (btn) btn.classList.add('active');
            window.renderProductGrid(catName);
        };

        // Initial render — show all
        window.renderProductGrid('Semua');

    } catch(e) { grid.innerHTML = '<div class="col-12 text-center py-4 text-danger">Gagal memuat produk.</div>'; }
}

async function checkNickname() {
    const uid = document.getElementById('inputUserId').value.trim();
    const zoneId = document.getElementById('inputZoneId').value.trim();
    const serverVal = document.getElementById('inputServer').value;
    
    // Choose which one is relevant
    const zid = (document.getElementById('zoneInputWrapper').style.display !== 'none') ? zoneId : serverVal;
    
    if (!uid) return;
    
    document.getElementById('nickBox').style.display = 'none';
    const btn = document.getElementById('btnCek');
    btn.disabled = true; btn.innerText = 'Checking...';
    try {
        const res = await fetch('/api/topup/validate-nickname', {
            method: 'POST',
            headers: {'Content-Type': 'application/json'},
            body: JSON.stringify({ user_id: uid, zone_id: zid, game: S.game })
        });
        const data = await res.json();
        if (data.success) {
            S.nick = data.nickname;
            document.getElementById('nickText').innerText = data.nickname;
            document.getElementById('nickBox').style.display = 'block';
            document.getElementById('manualNickWrapper').style.display = 'none';
            checkReady();
        } else {
            // Meleset! Aktifkan Kotak Manual (Sistem Fail-Safe)
            S.nick = null;
            document.getElementById('nickBox').style.display = 'none';
            document.getElementById('manualNickWrapper').style.display = 'block';
            checkReady();
            alert(data.message || 'Nama tidak ditemukan, silakan masukkan nama secara manual.');
        }
    } catch(e) { 
        // Penuh/Tumbang! Aktifkan Kotak Manual
        S.nick = null;
        document.getElementById('nickBox').style.display = 'none';
        document.getElementById('manualNickWrapper').style.display = 'block';
        checkReady();
    }
    finally { btn.innerText = 'Cek Nickname'; btn.disabled = false; }
}

function selectItem(el, name, price, sku) {
    document.querySelectorAll('.item-card').forEach(c => c.classList.remove('selected'));
    el.classList.add('selected');
    S.item = name; S.price = price; S.sku = sku;
    document.getElementById('summItem').innerText = name;
    recalculateTotal();
    checkReady();
}

function resetSelection() {
    S.item = null; S.price = 0; S.sku = null;
    document.querySelectorAll('.item-card').forEach(c => c.classList.remove('selected'));
    document.getElementById('summItem').innerText = '-';
    recalculateTotal();
    checkReady();
}

function recalculateTotal() {
    let finalPrice = S.price;
    if (S.promo) {
        if (S.promo.type === 'percent') {
            S.discount = (S.price * S.promo.amount) / 100;
        } else {
            S.discount = S.promo.amount;
        }
        finalPrice = S.price - S.discount;
        if (finalPrice < 0) finalPrice = 0;

        const row = document.getElementById('summPromoRow');
        if (row) row.style.display = 'flex';
        const span = document.getElementById('summPromo');
        if (span) span.innerText = '- ' + rp(S.discount);
    } else {
        const row = document.getElementById('summPromoRow');
        if (row) row.style.display = 'none';
        S.discount = 0;
    }
    document.getElementById('summTotal').innerText = rp(finalPrice);
}

async function applyPromo() {
    const code = document.getElementById('inputPromo').value.trim();
    const msg = document.getElementById('promoMsg');
    const btn = document.getElementById('btnPromo');

    if (!code) return;
    if (!S.price) {
        msg.style.display = 'block';
        msg.className = 'small mt-2 text-danger';
        msg.innerText = 'Pilih produk terlebih dahulu!';
        return;
    }

    btn.disabled = true;
    btn.innerText = '...';

    try {
        const res = await fetch('/api/promos/check', {
            method: 'POST',
            headers: { 
                'Content-Type': 'application/json',
                'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
            },
            body: JSON.stringify({ code })
        });
        const data = await res.json();

        if (data.success) {
            S.promo = { code: data.code, amount: data.discount_amount, type: data.type };
            msg.style.display = 'block';
            msg.className = 'small mt-2 text-success';
            msg.innerText = 'Kode promo berhasil digunakan!';
            recalculateTotal();
        } else {
            msg.style.display = 'block';
            msg.className = 'small mt-2 text-danger';
            msg.innerText = data.message || 'Kode tidak valid.';
            S.promo = null;
            recalculateTotal();
        }
    } catch(e) { 
        msg.style.display = 'block';
        msg.className = 'small mt-2 text-danger';
        msg.innerText = 'Gagal memverifikasi promo.';
    } finally {
        btn.disabled = false;
        btn.innerText = 'Terapkan';
    }
}

function checkReady() {
    const wa = document.getElementById('inputWa').value.trim();
    const name = document.getElementById('inputName').value.trim();
    const manualNick = document.getElementById('manualNickInput').value.trim();
    const userId = document.getElementById('inputUserId').value.trim();
    
    // Requirements: Game, Product, WA, Name, and UserID
    const isReady = !!(S.game && S.item && wa && name && userId);
    
    // Munculkan bar pembayaran di HP hanya jika data sudah lengkap
    if (isReady) {
        document.body.classList.add('has-item-selected');
    } else {
        document.body.classList.remove('has-item-selected');
    }

    const btn = document.getElementById('btnBayar');
    btn.disabled = !isReady;
    
    if (isReady) {
        btn.innerHTML = '<i class="fas fa-rocket me-2"></i> Bayar Sekarang';
        btn.style.opacity = '1';
    } else {
        btn.innerHTML = '<i class="fas fa-lock me-2 text-white-50"></i> Bayar Sekarang';
        btn.style.opacity = '0.6';
    }
}
document.getElementById('inputWa').addEventListener('input', checkReady);
document.getElementById('inputName').addEventListener('input', checkReady);
document.getElementById('inputEmail').addEventListener('input', checkReady);
document.getElementById('inputUserId').addEventListener('input', checkReady);
document.getElementById('inputZoneId').addEventListener('input', checkReady);
document.getElementById('manualNickInput').addEventListener('input', checkReady);

async function doCheckout() {
    const btn = document.getElementById('btnBayar');
    const wa = document.getElementById('inputWa').value;
    const name = document.getElementById('inputName').value;
    const email = document.getElementById('inputEmail').value;
    
    if (!wa || wa.length < 10) { alert('Silakan isi nomor WhatsApp (minimal 10 digit).'); return; }
    if (!name) { alert('Silakan isi nama lengkap Anda.'); return; }

    btn.disabled = true; btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Memproses...';
    
    const manualNick = document.getElementById('manualNickInput').value.trim();
    const userId = document.getElementById('inputUserId').value.trim();
    const finalNick = S.nick || manualNick || userId || "Player";
    
    const selectedPayEl = document.querySelector('.pay-card.selected');
    const selectedPayment = selectedPayEl ? selectedPayEl.querySelector('span').innerText : 'Midtrans';

    try {
        const res = await fetch('/api/topup/checkout', {
            method: 'POST',
            headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
            body: JSON.stringify({
                user_id: document.getElementById('inputUserId').value,
                zone_id: (document.getElementById('zoneInputWrapper').style.display !== 'none') 
                          ? document.getElementById('inputZoneId').value 
                          : document.getElementById('inputServer').value,
                game: S.game, nickname: finalNick, product: S.item, product_sku: S.sku, 
                price: S.price - S.discount,
                payment_method: selectedPayment,
                customer_whatsapp: wa,
                customer_name: name,
                customer_email: email,
                promo_code: S.promo ? S.promo.code : null
            })
        });
        const data = await res.json();
        if (data.snap_token) {
            // SIMPAN ID KE LOCALSTORAGE AGAR TIDAK LUPA
            localStorage.setItem('last_order_id', data.order_id);
            
            window.snap.pay(data.snap_token, {
                onSuccess: function() { alert('Sukses!'); location.reload(); },
                onPending: function() { alert('Menunggu pembayaran...'); location.reload(); },
                onClose: function() { btn.disabled = false; btn.innerHTML = 'Lakukan Pembayaran →'; }
            });
        } else {
            alert(data.error || data.message || 'Gagal memproses pesanan.');
            btn.disabled = false; btn.innerHTML = 'Lakukan Pembayaran →';
        }
    } catch(e) { 
        console.error(e);
        alert('Terjadi kesalahan jaringan atau sistem.'); 
        btn.disabled = false; btn.innerHTML = 'Lakukan Pembayaran →'; 
    }
}

function openTrackModal() { 
    document.getElementById('modalTrack').style.display='flex'; 
    const last = localStorage.getItem('last_order_id');
    if (last) {
        document.getElementById('lastOrderShortcut').style.display = 'block';
        document.getElementById('lastOrderIdDisplay').innerText = last;
    } else {
        document.getElementById('lastOrderShortcut').style.display = 'none';
    }
}
function clearLastOrder() {
    localStorage.removeItem('last_order_id');
    document.getElementById('lastOrderShortcut').style.display = 'none';
    alert('Riwayat pesanan terakhir di perangkat ini telah dihapus.');
}
function useLastOrder() {
    const last = localStorage.getItem('last_order_id');
    if (last) {
        document.getElementById('trackOrderId').value = last;
        trackOrder();
    }
}

async function findOrdersByWa() {
    const wa = document.getElementById('trackWa').value.trim();
    if (!wa) return;
    const resDiv = document.getElementById('waSearchResult');
    const btn = document.getElementById('btnFindWa');
    
    btn.disabled = true;
    resDiv.innerHTML = '<div class="spinner-border spinner-border-sm text-primary"></div> Mencari...';
    resDiv.style.display = 'block';

    try {
        const res = await fetch(`/api/topup/find-by-wa/${wa}`);
        const data = await res.json();
        
        if (data.length === 0) {
            resDiv.innerHTML = '<span class="text-danger">Tidak ditemukan pesanan untuk nomor ini.</span>';
        } else {
            resDiv.innerHTML = '<p class="mb-2 text-white-50">Pesanan Terbaru Anda:</p>';
            data.forEach(t => {
                resDiv.innerHTML += `
                    <div class="d-flex justify-content-between align-items-center mb-1 p-2 bg-dark rounded">
                        <span class="text-primary font-monospace">${t.order_id}</span>
                        <button class="btn btn-xs btn-primary py-0" onclick="document.getElementById('trackOrderId').value='${t.order_id}';trackOrder();">Pilih</button>
                    </div>
                `;
            });
        }
    } catch(e) { resDiv.innerHTML = 'Error mencari data.'; }
    finally { btn.disabled = false; }
}

function closeTrackModal() { document.getElementById('modalTrack').style.display='none'; }

async function trackOrder() {
    const oid = document.getElementById('trackOrderId').value.trim();
    if (!oid) return;
    const btn = document.getElementById('btnTrack');
    btn.disabled = true; btn.innerText = 'Mencari...';
    try {
        const res = await fetch(`/api/topup/${oid}`);
        const data = await res.json();
        if (data.error) { alert('Pesanan tidak ditemukan'); return; }
        
        document.getElementById('trGame').innerText = data.game;
        document.getElementById('trItem').innerText = data.product;
        
        let sColor = '#ffc107'; // yellow
        if (data.status === 'SUCCESS') sColor = '#2ecc71';
        if (data.status === 'FAILED') sColor = '#e74c3c';
        
        document.getElementById('trStatus').innerHTML = `<span class="badge-status" style="background:${sColor}">${data.status}</span>`;
        document.getElementById('trSn').innerText = data.sn || '-';
        
        // Simpan data untuk invoice
        window.currentTrx = data;
        
        // Modal & Button will be shown below

        document.getElementById('trackResult').style.display = 'block';
    } catch(e) { alert('Gagal memuat data'); }
    finally { btn.innerText = 'Cek Sekarang'; btn.disabled = false; }
}

function showInvoice() {
    closeTrackModal(); // Tutup modal tracking agar nota bisa diklik

    const t = window.currentTrx;
    if (!t) return;
    
    document.getElementById('invId').innerText = t.order_id;
    document.getElementById('invName').innerText = t.customer_name || '-';
    document.getElementById('invDate').innerText = new Date(t.created_at).toLocaleString('id-ID');
    document.getElementById('invGame').innerText = t.game;
    document.getElementById('invItem').innerText = t.product;
    document.getElementById('invMethod').innerText = t.payment_method;
    
    // Status Berwarna
    const stEl = document.getElementById('invStatus');
    stEl.innerText = t.status === 'SUCCESS' ? 'LUNAS (BERHASIL)' : (t.status === 'PAID' ? 'LUNAS' : 'BELUM BAYAR');
    stEl.style.color = (t.status === 'SUCCESS' || t.status === 'PAID') ? '#2ecc71' : '#e67e22';

    document.getElementById('invTotal').innerText = rp(t.price);
    document.getElementById('invSn').innerText = t.sn || 'Sedang diproses...';
    
    new bootstrap.Modal(document.getElementById('modalInvoice')).show();
}

async function loadRecentTransactions() {
    const feed = document.getElementById('trxFeed');
    if(!feed) return;
    try {
        const res = await fetch('/api/topup/feed');
        const data = await res.json();
        if (data.length === 0) { 
            feed.innerHTML = '<div class="text-center py-4 text-muted">Belum ada transaksi hari ini.</div>'; 
            return; 
        }
        feed.innerHTML = data.map((t, idx) => {
            let wa = t.customer_whatsapp || '0812';
            let formattedWa = wa.substring(0, 4) + '****' + wa.substring(wa.length - 2);
            const times = ['Baru saja', '1 mnt lalu', '2 mnt lalu', '5 mnt lalu', '10 mnt lalu'];
            const time = times[Math.floor(Math.random() * (idx + 1))] || 'Baru saja';
            return `
                <div class="trx-item" style="animation-delay: ${idx * 0.1}s">
                    <div class="trx-left">
                        <div class="trx-icon">${idx % 2 === 0 ? '🎁' : '⚡'}</div>
                        <div>
                            <p class="trx-user">${formattedWa}</p>
                            <p class="trx-detail">${t.product} - ${t.game}</p>
                        </div>
                    </div>
                    <div class="trx-right text-end">
                        <span class="trx-time">${time}</span>
                        <span class="trx-status status-${t.status.toLowerCase()}">${t.status}</span>
                    </div>
                </div>
            `;
        }).join('');
    } catch(e) { console.error(e); }
}

async function loadPublishedArticles() {
    const list = document.getElementById('articleList');
    if (!list) return;

    try {
        const res = await fetch('/api/articles/published');
        const data = await res.json();
        window.loadedArticles = data;
        
        if (data.length === 0) {
            list.innerHTML = '<div class="col-12 text-center py-4 text-muted">Belum ada berita.</div>';
            return;
        }

        list.innerHTML = data.map((a, idx) => {
            const imgUrl = a.image_url ? (a.image_url.startsWith('http') ? a.image_url : '/storage/'+a.image_url) : 'https://placehold.co/600x400';
            return `
                <div class="col-md-6 col-lg-4">
                    <a href="/article/${a.id}" class="article-card text-decoration-none">
                        <div class="art-img-wrap">
                            <img src="${imgUrl}" alt="${a.title}" class="art-img-main">
                            <span class="art-badge-top">${a.category}</span>
                            <h5 class="art-title-overlay">${a.title}</h5>
                        </div>
                        <div class="art-body">
                            <div class="art-footer-brand">WYZPEDIA</div>
                            <p class="art-text-short">${a.title}: ${a.content.substring(0, 80)}...</p>
                            <div class="mt-3 text-end">
                                <span class="small text-primary fw-bold">Baca Selengkapnya <i class="fas fa-arrow-right ms-1"></i></span>
                            </div>
                        </div>
                    </a>
                </div>
            `;
        }).join('');
    } catch(e) { console.error(e); }
}

function viewArticle(p) {
    let a = (typeof p === 'number') ? window.loadedArticles[p] : p;
    if (!a) return;
    
    const imgUrl = a.image_url ? (a.image_url.startsWith('http') ? a.image_url : '/storage/'+a.image_url) : 'https://placehold.co/600x400';
    document.getElementById('artViewMain').style.backgroundImage = `url('${imgUrl}')`;
    document.getElementById('artViewCategory').innerText = a.category;
    document.getElementById('artViewDate').innerText = new Date(a.created_at).toLocaleDateString('id-ID', { day: 'numeric', month: 'long', year: 'numeric' });
    document.getElementById('artViewTitle').innerText = a.title;
    
    // Format konten agar lebih rapi dengan paragraf
    const formattedContent = a.content.split('\n').map(p => p.trim() ? `<p>${p}</p>` : '').join('');
    document.getElementById('artViewContent').innerHTML = formattedContent;
    
    new bootstrap.Modal(document.getElementById('modalArticle')).show();
}

async function handleBannerArticle(id) {
    try {
        const res = await fetch(`/api/articles/${id}`);
        const data = await res.json();
        if (data && data.id) {
            viewArticle(data);
        }
    } catch(e) { console.error(e); }
}

document.addEventListener('DOMContentLoaded', () => {
    loadRecentTransactions();
    loadPublishedArticles();
});

function togMenu() {
    document.getElementById('mobSidebar').classList.toggle('active');
    document.getElementById('sbOverlay').classList.toggle('active');
}

function toggleTheme() {
    document.body.classList.toggle('light-mode');
    const isLight = document.body.classList.contains('light-mode');
    localStorage.setItem('theme', isLight ? 'light' : 'dark');
    updateThemeUI(isLight);
}

function updateThemeUI(isLight) {
    const btn = document.getElementById('themeBtnDesktop');
    if(!btn) return;
    const icon = btn.querySelector('i');
    const text = btn.querySelector('span');
    if(isLight) {
        icon.className = 'fas fa-sun';
        text.innerText = 'Light';
    } else {
        icon.className = 'fas fa-moon';
        text.innerText = 'Dark';
    }
}

// INIT THEME
if(localStorage.getItem('theme') === 'light') {
    document.body.classList.add('light-mode');
    updateThemeUI(true);
}

// METEOR GENERATOR
function createMeteors() {
    const container = document.getElementById('meteorContainer');
    if (!container) return;
    const count = 45; // Meningkatkan jumlah meteor
    for (let i = 0; i < count; i++) {
        const meteor = document.createElement('div');
        meteor.className = 'meteor';
        
        // Randomize posisi dan durasi
        const left = Math.random() * 110; 
        const top = Math.random() * 30 - 20; 
        const duration = 2 + Math.random() * 4;
        const delay = Math.random() * 15;
        const opacity = 0.3 + Math.random() * 0.7;
        
        meteor.style.left = left + '%';
        meteor.style.top = top + '%';
        meteor.style.animationDuration = duration + 's';
        meteor.style.animationDelay = delay + 's';
        meteor.style.opacity = opacity;
        
        container.appendChild(meteor);
    }
}

// WELCOME & PRELOADER
function closeWelcome() {
    document.getElementById('welcomeModal').style.display = 'none';
}

async function verifyWelcome() {
    const ans = document.getElementById('welcomeCaptcha').value;
    const btn = document.querySelector('.welcome-body .btn-primary');
    const error = document.getElementById('welcomeError');
    
    btn.disabled = true; btn.innerText = 'Memverifikasi...';
    error.style.display = 'none';

    try {
        const res = await fetch('/api/topup/verify-captcha', {
            method: 'POST',
            headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
            body: JSON.stringify({ answer: ans })
        });
        const data = await res.json();

        if (data.success) {
            closeWelcome();
        } else {
            throw new Error(data.message || 'Jawaban salah');
        }
    } catch(err) {
        error.style.display = 'block';
        error.innerText = err.message;
        document.getElementById('welcomeCaptcha').value = '';
        document.getElementById('welcomeCaptcha').focus();
    } finally {
        btn.disabled = false; btn.innerText = 'LANJUT KE STORE';
    }
}

window.addEventListener('load', () => {
    // Hide Preloader
    const pre = document.getElementById('preloader');
    if (pre) {
        pre.style.opacity = '0';
        setTimeout(() => { pre.style.display = 'none'; }, 500);
    }

    // Always Show Welcome Popup every load
    setTimeout(() => {
        const modal = document.getElementById('welcomeModal');
        if (modal) modal.style.display = 'flex';
    }, 1200);

    createMeteors();
    handleDeepLinks();
    
    // Auto-refresh transaksi terbaru setiap 10 detik (Real-time)
    setInterval(loadRecentTransactions, 10000);

    // AUTO SHOW INVOICE IF FROM LINK
    @if(isset($auto_invoice))
        window.currentTrx = @json($auto_invoice);
        setTimeout(() => showInvoice(), 1500);
    @endif
});

function toggleCS() {
    const menu = document.getElementById('csMenu');
    menu.style.display = (menu.style.display === 'flex') ? 'none' : 'flex';
}

function toggleReadMore() {
    const s = document.getElementById('descShort');
    const f = document.getElementById('descFull');
    const b = document.getElementById('btnReadMore');
    if (f.style.display === 'none') {
        f.style.display = 'inline';
        s.style.display = 'none';
        b.innerText = ' Sembunyikan';
    } else {
        f.style.display = 'none';
        s.style.display = 'inline';
        b.innerText = ' Baca Selengkapnya';
    }
}

// DEEP LINK HANDLER (Auto-open game from URL like ?game=1)
function handleDeepLinks() {
    const params = new URLSearchParams(window.location.search);
    const gameId = params.get('game');
    const sku = params.get('sku');

    if (gameId) {
        const game = allGames.find(g => g.id == gameId);
        if (game) {
            openGame(game.id, game.name, game.image_url, sku);
        }
    }
}

// SCROLL HANDLER
function onScroll() {
    const nav = document.querySelector('.navbar-custom');
    if (window.scrollY > 20) {
        nav.style.boxShadow = '0 10px 30px rgba(0,0,0,0.3)';
    } else {
        nav.style.boxShadow = 'none';
    }
}

</script>
<script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
<script>
    // Inisialisasi Mesin Animasi Slider Modern
    var swiper = new Swiper('.hero-swiper', {
      effect: 'slide',           // Efek geser
      loop: true,                // Mengulang dari awal jika sudah sampai slide terakhir
      autoplay: { 
          delay: 3500,           // Pindah otomatis setiap 3.5 detik
          disableOnInteraction: false // Tetap jalan meskipun user baru saja mengusap layar
      },
      pagination: { 
          el: '.swiper-pagination', 
          clickable: true 
      },
      navigation: { 
          nextEl: '.swiper-button-next', 
          prevEl: '.swiper-button-prev' 
      },
      spaceBetween: 20
    });
</script>

    <!-- CS FLOATING BUTTON -->
    <div class="cs-menu" id="csMenu">
        <div class="fw-bold mb-2 small px-2" style="color: var(--text-main);">Hubungi Layanan CS</div>
        <a href="https://wa.me/{{ env('WA_ADMIN_PHONE') }}" target="_blank" class="cs-menu-item" style="color:#2ecc71;">
            <i class="fab fa-whatsapp"></i> WhatsApp
        </a>
        <a href="{{ $homepage['ig_link'] ?? '#' }}" target="_blank" class="cs-menu-item" style="color:#e1306c;">
            <i class="fab fa-instagram"></i> Instagram
        </a>
        <a href="{{ $homepage['tiktok_link'] ?? '#' }}" target="_blank" class="cs-menu-item" id="tiktokCsLink">
            <i class="fab fa-tiktok"></i> TikTok
        </a>
    </div>
    <div class="cs-fab" onclick="toggleCS()" title="Hubungi CS">
        <i class="fas fa-headset"></i>
    </div>

<!-- INVOICE MODAL -->
<div class="modal fade" id="modalInvoice" tabindex="-1" aria-hidden="true" style="z-index: 10550;">
    <div class="modal-dialog modal-dialog-centered" style="z-index: 10555;">
        <div class="modal-content border-0 bg-transparent">
            <div class="invoice-card" id="printableInvoice">
                <div class="invoice-header">
                    <h4 class="fw-bold mb-1">WYZSTORE</h4>
                    <p class="small text-muted mb-0">Terima Kasih Atas Pesanan Anda!</p>
                </div>
                <div class="invoice-item"><span>No. Invoice</span> <strong id="invId">-</strong></div>
                <div class="invoice-item"><span>Pelanggan</span> <span id="invName">-</span></div>
                <div class="invoice-item"><span>Tanggal</span> <span id="invDate">-</span></div>
                <hr class="my-3 opacity-10">
                <div class="invoice-item"><span>Layanan</span> <strong id="invGame">-</strong></div>
                <div class="invoice-item"><span>Produk</span> <span id="invItem">-</span></div>
                <div class="invoice-item"><span>Metode</span> <span id="invMethod">-</span></div>
                <div class="invoice-item"><span>Pembayaran</span> <strong id="invStatus" class="ms-auto">-</strong></div>
                <div class="invoice-total">
                    <div class="d-flex justify-content-between">
                        <span>TOTAL BAYAR</span>
                        <span id="invTotal">-</span>
                    </div>
                </div>
                <div class="mt-3 p-3 bg-light rounded small" style="word-break: break-all;">
                    <span class="text-muted d-block mb-1">SN / Voucher:</span>
                    <strong id="invSn">-</strong>
                </div>
                <div class="invoice-footer">
                    <p class="mb-0">Simpan invoice ini sebagai bukti sah.</p>
                    <p class="fw-bold">@WYZSTORE - Game Instan</p>
                </div>
            </div>
            <div class="text-center mt-3 no-print">
                <button class="btn btn-primary rounded-pill px-4" onclick="window.print()">
                    <i class="fas fa-print me-2"></i> Cetak Invoice
                </button>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
