document.addEventListener("DOMContentLoaded", function () {

    const widget = document.getElementById("amazon-widget");
    if (!widget) return;

    const page = (document.title + " " + location.pathname).toLowerCase();

    let books = [];

    // SSC BOOKS
    if(page.includes("ssc")){

        books = [

            {
                title:"Arihant SSC GD Constable Exam 2026",
                author:"Arihant",
                image:"https://m.media-amazon.com/images/I/81tnAZmby2L._SL1500_.jpg",
                price:"₹263",
                link:"https://www.amazon.in/dp/B0BSVHRD8"
            },

            {
                title:"Test Book",
                author:"Test Author",
                image:"https://picsum.photos/300/400",
                price:"₹100",
                link:"https://google.com"
            }

        ];

    }

    // DEFAULT BOOK
    else{

        books=[

            {
                title:"General Competitive Exam Book",
                author:"Arihant",
                image:"https://picsum.photos/300/400",
                price:"₹399",
                link:"https://google.com"
            }

        ];

    }

    let html='<div class="aw-grid">';

    books.forEach(book=>{

        html+=`

        <div class="aw-card">

            <img src="${book.image}" style="width:100%;height:260px;object-fit:cover;">

            <h3>${book.title}</h3>

            <p>${book.author}</p>

            <strong>${book.price}</strong>

            <br><br>

            <a href="${book.link}" target="_blank">
                Buy Now
            </a>

        </div>

        `;

    });

    html+='</div>';

    widget.innerHTML=html;

});