window.productsData = [
    // 1. Mobile Devices
    // Smartphones
    { id: 'm1', name: 'Samsung Galaxy S24 Ultra', price: 1800000, category: 'Mobile Devices', subcategory: 'Smartphones', brand: 'Samsung', image: 'https://images.unsplash.com/photo-1610945415295-d9bbf067e59c?auto=format&fit=crop&w=800&q=80' },
    { id: 'm2', name: 'iPhone 15 Pro Max', price: 2100000, category: 'Mobile Devices', subcategory: 'Smartphones', brand: 'Apple', image: 'https://images.unsplash.com/photo-1695048133142-1a20484d2569?auto=format&fit=crop&w=800&q=80' },
    { id: 'm3', name: 'Xiaomi 13T Pro', price: 950000, category: 'Mobile Devices', subcategory: 'Smartphones', brand: 'Xiaomi', image: 'https://images.unsplash.com/photo-1598327105666-5b89351aff23?auto=format&fit=crop&w=800&q=80' },
    // Foldable
    { id: 'm4', name: 'Google Pixel Fold', price: 2500000, category: 'Mobile Devices', subcategory: 'Foldable Phones', brand: 'Google', image: 'https://images.unsplash.com/photo-1688649102473-099b9d16aa32?auto=format&fit=crop&w=800&q=80' },
    { id: 'm5', name: 'Samsung Galaxy Z Fold 5', price: 2300000, category: 'Mobile Devices', subcategory: 'Foldable Phones', brand: 'Samsung', image: 'https://images.unsplash.com/photo-1627845348873-4556aa529d20?auto=format&fit=crop&w=800&q=80' },

    // 2. Computers & Laptops
    // Laptops
    { id: 'c1', name: 'MacBook Pro 16 M3 Max', price: 4500000, category: 'Computers & Laptops', subcategory: 'Laptops', brand: 'Apple', image: 'https://images.unsplash.com/photo-1517336714731-489689fd1ca4?auto=format&fit=crop&w=800&q=80' },
    { id: 'c2', name: 'Dell XPS 15', price: 2800000, category: 'Computers & Laptops', subcategory: 'Laptops', brand: 'Dell', image: 'https://images.unsplash.com/photo-1593642632823-8f78536788c6?auto=format&fit=crop&w=800&q=80' },
    { id: 'c3', name: 'HP Spectre x360', price: 2200000, category: 'Computers & Laptops', subcategory: 'Laptops', brand: 'HP', image: 'https://images.unsplash.com/photo-1544731612-de7f96afe55f?auto=format&fit=crop&w=800&q=80' },
    // Desktops
    { id: 'c4', name: 'iMac 24-inch', price: 2100000, category: 'Computers & Laptops', subcategory: 'Desktop Computers', brand: 'Apple', image: 'https://images.unsplash.com/photo-1527443154391-507e9dc6c5cc?auto=format&fit=crop&w=800&q=80' },

    // 3. Tablets
    { id: 't1', name: 'iPad Pro 12.9 M2', price: 1600000, category: 'Tablets & E-Readers', subcategory: 'iPads', brand: 'Apple', image: 'https://images.unsplash.com/photo-1544244015-0df4b3ffc6b0?auto=format&fit=crop&w=800&q=80' },
    { id: 't2', name: 'Samsung Galaxy Tab S9 Ultra', price: 1400000, category: 'Tablets & E-Readers', subcategory: 'Android Tablets', brand: 'Samsung', image: 'https://images.unsplash.com/photo-1589739900243-4b52cd9b104e?auto=format&fit=crop&w=800&q=80' },

    // 4. Audio
    { id: 'a1', name: 'Sony WH-1000XM5', price: 450000, category: 'Audio Devices', subcategory: 'Headphones', brand: 'Sony', image: 'https://images.unsplash.com/photo-1618366712010-f4ae9c647dcb?auto=format&fit=crop&w=800&q=80', stock: 15, colors: ['Black', 'Silver'] },
    { id: 'a2', name: 'AirPods Pro 2', price: 350000, category: 'Audio Devices', subcategory: 'Earbuds', brand: 'Apple', image: 'https://images.unsplash.com/photo-1588423771073-b8903fbb85b5?auto=format&fit=crop&w=800&q=80', stock: 50, colors: ['White'] },
    { id: 'a3', name: 'JBL Charge 5', price: 180000, category: 'Audio Devices', subcategory: 'Bluetooth Speakers', brand: 'JBL', image: 'https://images.unsplash.com/photo-1608043152269-423dbba4e7e1?auto=format&fit=crop&w=800&q=80', stock: 20, colors: ['Black', 'Blue', 'Red', 'Camouflage'] },

    // 5. Gaming
    { id: 'g1', name: 'PlayStation 5 Slim', price: 750000, category: 'Gaming', subcategory: 'Gaming Consoles', brand: 'Sony', image: 'https://images.unsplash.com/photo-1606144042614-b2417e99c4e3?auto=format&fit=crop&w=800&q=80', stock: 5, colors: ['White'] },
    { id: 'g2', name: 'Xbox Series X', price: 720000, category: 'Gaming', subcategory: 'Gaming Consoles', brand: 'Microsoft', image: 'https://images.unsplash.com/photo-1621259182902-386d1a6e9752?auto=format&fit=crop&w=800&q=80', stock: 8, colors: ['Black'] },
    { id: 'g3', name: 'Meta Quest 3', price: 850000, category: 'Gaming', subcategory: 'VR Headsets', brand: 'Meta', image: 'https://images.unsplash.com/photo-1622979135225-d2ba269fb1bd?auto=format&fit=crop&w=800&q=80', stock: 12, colors: ['White'] },

    // 6. Wearables
    { id: 'w1', name: 'Apple Watch Ultra 2', price: 1200000, category: 'Wearables', subcategory: 'Smartwatches', brand: 'Apple', image: 'https://images.unsplash.com/photo-1579586337278-3befd40fd17a?auto=format&fit=crop&w=800&q=80', stock: 10, colors: ['Titanium'] },
    { id: 'w2', name: 'Samsung Galaxy Watch 6', price: 450000, category: 'Wearables', subcategory: 'Smartwatches', brand: 'Samsung', image: 'https://images.unsplash.com/photo-1544117519-31a4b719223d?auto=format&fit=crop&w=800&q=80', stock: 15, colors: ['Black', 'Silver', 'Gold'] },
    { id: 'w3', name: 'Oura Ring Gen 3', price: 550000, category: 'Wearables', subcategory: 'Smart Rings', brand: 'Oura', image: 'https://images.unsplash.com/photo-1605647540924-852290f6b0d5?auto=format&fit=crop&w=800&q=80', stock: 0, colors: ['Black', 'Gold', 'Silver'] }, // SOLD OUT TEST

    // 7. Cameras
    { id: 'cam1', name: 'Leica Q3', price: 6500000, category: 'Cameras & Imaging', subcategory: 'Digital Cameras', brand: 'Leica', image: 'https://images.unsplash.com/photo-1516035069371-29a1b244cc32?auto=format&fit=crop&w=800&q=80', stock: 2, colors: ['Black'] },
    { id: 'cam2', name: 'Sony A7 IV', price: 3200000, category: 'Cameras & Imaging', subcategory: 'Mirrorless Cameras', brand: 'Sony', image: 'https://images.unsplash.com/photo-1624138784181-29e5e6e2daf9?auto=format&fit=crop&w=800&q=80', stock: 5, colors: ['Black'] },
    { id: 'cam3', name: 'DJI Mini 4 Pro', price: 1100000, category: 'Cameras & Imaging', subcategory: 'Drones', brand: 'DJI', image: 'https://images.unsplash.com/photo-1579829366248-204fe8413f31?auto=format&fit=crop&w=800&q=80', stock: 8, colors: ['Grey'] },

    // 17. Services
    { id: 's1', name: 'Screen Repair (Premium)', price: 150000, category: 'Services', subcategory: 'Phone Repairs', brand: 'Ghadget', image: 'https://images.unsplash.com/photo-1581092160562-40aa08e78837?auto=format&fit=crop&w=800&q=80', stock: 999, colors: [] },
    { id: 's2', name: '2-Year Gadget Insurance', price: 200000, category: 'Services', subcategory: 'Gadget Insurance', brand: 'Ghadget', image: 'https://images.unsplash.com/photo-1454165804606-c3d57bc86b40?auto=format&fit=crop&w=800&q=80', stock: 999, colors: [] },

    // Special Deals Test Products
    { id: 'd1', name: 'iPhone 12 (Locked)', price: 150000, category: 'locked', subcategory: 'Smartphones', brand: 'Apple', image: 'https://images.unsplash.com/photo-1605236453806-6ff36851218e?auto=format&fit=crop&w=800&q=80', tags: ['locked'], stock: 1, colors: ['Blue'] },
    { id: 'd2', name: 'Samsung S10 (Nigeria Used)', price: 85000, category: 'nigeria-used', subcategory: 'Smartphones', brand: 'Samsung', image: 'https://images.unsplash.com/photo-1561263849-538964e7c60d?auto=format&fit=crop&w=800&q=80', tags: ['nigeria-used'], stock: 3, colors: ['Prism White', 'Prism Black'] },
    { id: 'd3', name: 'Infinix Hot 10', price: 45000, category: 'Mobile Devices', subcategory: 'Smartphones', brand: 'Infinix', image: 'https://images.unsplash.com/photo-1598327105666-5b89351aff23?auto=format&fit=crop&w=800&q=80', stock: 0, colors: ['Ocean Wave'] }, // SOLD OUT TEST
    { id: 'd4', name: 'Tecno Spark Go', price: 28000, category: 'Mobile Devices', subcategory: 'Smartphones', brand: 'Tecno', image: 'https://images.unsplash.com/photo-1565849904461-04a58ad377e0?auto=format&fit=crop&w=800&q=80', stock: 10, colors: ['Mystery White'] },
    { id: 'd5', name: 'Redmi Note 10', price: 95000, category: 'Mobile Devices', subcategory: 'Smartphones', brand: 'Xiaomi', image: 'https://images.unsplash.com/photo-1598327105666-5b89351aff23?auto=format&fit=crop&w=800&q=80', stock: 5, colors: ['Onyx Gray', 'Pebble White'] }
];

// Hierarchy Data
window.categoryHierarchy = {
    "Mobile Devices": ["Smartphones", "Feature Phones", "Foldable Phones", "Refurbished Phones", "Rugged Phones"],
    "Computers & Laptops": ["Laptops", "Desktop Computers", "All-in-One PCs", "Mini PCs", "Workstations"],
    "Tablets & E-Readers": ["Android Tablets", "iPads", "Windows Tablets", "E-Readers"],
    "Audio Devices": ["Headphones", "Earbuds", "Bluetooth Speakers", "Soundbars", "Home Theater"],
    "Gaming": ["Gaming Consoles", "Controllers", "Headsets", "Keyboards & Mouse", "VR Headsets"],
    "Wearables": ["Smartwatches", "Fitness Trackers", "Smart Rings", "Smart Glasses"],
    "Smart Home": ["Speakers", "Lighting", "Plugs", "Cameras", "Doorbells", "Thermostats"],
    "Accessories": ["Phone Cases", "Screen Protectors", "Chargers", "Power Banks", "Cables", "Keyboards", "Mice", "Monitors", "Bags"],
    "Imaging": ["Digital Cameras", "DSLR", "Mirrorless", "Action Cameras", "Drones"],
    "Office Electronics": ["Printers", "Scanners", "Projectors", "UPS", "Shredders"],
    "Networking": ["Routers", "Modems", "Extenders", "Switches"],
    "Storage": ["HDD", "SSD", "USB Drives", "Memory Cards", "NAS"],
    "Car Electronics": ["Dash Cams", "Chargers", "Trackers", "Audio", "Reverse Cams"],
    "Services": ["Phone Repairs", "Insurance", "Warranty", "Trade-In"]
};

// Helper for filtering
window.categoriesList = [
    "Mobile Devices", "Computers & Laptops", "Tablets & E-Readers",
    "Audio Devices", "Gaming", "Wearables", "Smart Home Devices",
    "Mobile Accessories", "Computer Accessories", "Cameras & Imaging",
    "Office Electronics", "Networking Devices", "Storage Devices",
    "Car Electronics", "Health & Personal Tech", "DIY & Components",
    "Services", "Deals"
];

// --- PRODUCTION DATA ENRICHMENT ---
// Automatically add locations to all products so Map/Directions work
(function enrichData() {
    if (Array.isArray(window.productsData)) {
        window.productsData.forEach(p => {
            // Assign random location around Abuja Wuse 2
            // center: 9.0765, 7.3986
            // spread: +/- 0.02
            if (!p.location) {
                p.location = {
                    lat: 9.0765 + (Math.random() * 0.04 - 0.02),
                    lng: 7.3986 + (Math.random() * 0.04 - 0.02),
                    address: "Wuse 2, Abuja"
                };
            }
            // Ensure seller info
            if (!p.sellerPhone) p.sellerPhone = "+2348000000000";
            if (!p.sellerName) p.sellerName = "Verified Merchant";
            if (!p.whatsapp) p.whatsapp = "2348000000000";
        });
    }
})();
