
(function() {
    // 1. Create the Aminos script element
    var script = document.createElement('script');
    script.src = 'https://platform.aminos.ai/w/chat_plugin.js';
    
    // 2. Find the script tag (Looking for your subdomain)
    // This checks for the data-bot-id specifically from your subdomain tag
    var currentScript = document.currentScript || 
                        document.querySelector('script[src*="assistant.rdwgroup.com"]');
    
    var botId = currentScript ? currentScript.getAttribute('data-bot-id') : null;
    
    if (!botId) {
        console.error("Aminos Proxy: Could not find data-bot-id. Make sure the script tag is correct.");
        return;
    }
    
    // 3. Set the bot ID and append
    script.setAttribute('data-bot-id', botId);
    document.head.appendChild(script);

    // 4. Inject your custom CSS
    function injectCustomCSS(css) {
        var style = document.createElement('style');
        style.textContent = css;
        document.head.appendChild(style);
    }

    var customCSS = '.sc-chat-window { width: 500px !important; }' +
        '.sc-message { width: 90% !important; }' +
        '#poweredBy img { max-width: 70% !important; padding-bottom: 5px !important; }' +
        '.sc-launcher, .sc-chat-window { border: 1px solid white !important; }';

    injectCustomCSS(customCSS);
    console.log("Aminos Proxy: Loaded for bot " + botId);
})();
