<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
        xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0"
        xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
    
    <!-- Homepage -->
    <url>
        <loc>https://awaismart.com/</loc>
        <lastmod>2026-09-01</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>

    <!-- Shop -->
    <url>
        <loc>https://awaismart.com/shop.php</loc>
        <lastmod>2026-09-01</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.9</priority>
    </url>

    <!-- Categories -->
    <?php
    require_once __DIR__ . '/includes/db.php';
    $categories = getCategories();
    foreach($categories as $cat) { ?>
    <url>
        <loc>https://awaismart.com/category.php?id=<?php echo $cat['id']; ?></loc>
        <lastmod>2026-09-01</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.8</priority>
    </url>
    <?php } ?>

    <!-- Subcategories -->
    <?php
    $subcats_sql = "SELECT * FROM subCategory";
    $subcats_result = mysqli_query($conn, $subcats_sql);
    while($subcat = mysqli_fetch_assoc($subcats_result)) { ?>
    <url>
        <loc>https://awaismart.com/subcategory.php?id=<?php echo $subcat['id']; ?></loc>
        <lastmod>2026-09-01</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.7</priority>
    </url>
    <?php } ?>

    <!-- Products -->
    <?php
    $products_sql = "SELECT id, updated_at FROM products ORDER BY id DESC";
    $products_result = mysqli_query($conn, $products_sql);
    while($product = mysqli_fetch_assoc($products_result)) { ?>
    <url>
        <loc>https://awaismart.com/product-details.php?id=<?php echo $product['id']; ?></loc>
        <lastmod><?php echo date('Y-m-d', strtotime($product['updated_at'] ?? 'now')); ?></lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.6</priority>
    </url>
    <?php } ?>

    <!-- Static Pages -->
    <url>
        <loc>https://awaismart.com/about.php</loc>
        <lastmod>2026-09-01</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.5</priority>
    </url>
    <url>
        <loc>https://awaismart.com/contact.php</loc>
        <lastmod>2026-09-01</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.5</priority>
    </url>
    <url>
        <loc>https://awaismart.com/cart.php</loc>
        <lastmod>2026-09-01</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.4</priority>
    </url>
    <url>
        <loc>https://awaismart.com/checkout.php</loc>
        <lastmod>2026-09-01</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.4</priority>
    </url>

</urlset>