// CSS
var div = document.getElementsByClassName("google")[0];
if (div) {
div.innerHTML = `<style>
ins{z-index:999!important}
  .ad-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.2);
    border-top: 2px solid #ddd;
    transition: transform 0.5s ease;
    z-index: 2147483647;
  }
  .ad-header {
    text-align: center;
    background: #f1f1f1;
    cursor: pointer;
    padding: 0px;
  }
  .ad-header span {
    display: inline-block;
    transition: transform 0.3s;
  }
  .ad-container.active .ad-header span {
    transform: rotate(180deg);
  }
  .ad-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
  }
  .ad-container.active .ad-content {
    max-height: 300px;
  }
  .ad-content-inner {
    padding: 10px;
    display: flex;
    align-items: center;
    text-align:left;
  }
  .ad-content-inner img {
    width: 80px;
    height: auto;
    margin-right: 10px;
  }
  .ad-content-inner .text {
    font-size: 14px;
    line-height: 1.2;
  }
  .ad-content-inner .title {
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 5px;
  }
  .ad-content-inner .title2 {
    font-size: 13px;
    color: #666;
    margin: 0;
  }
</style>`;
}

// ads object
var ads = [];ads[1] = {
        href: 'https://amzn.to/41l8XcB',
        title: '90 L Large Storage Bags, 6 Pack Clothes Storage Bins Foldable Closet Organizers Storage Containers with Reinforced Handle for Clothing, Blanket, Comforters, Bed Sheets, Pillows and Toys (Gray)',
        title2: '43% Discount',
        img: `<img src="https://m.media-amazon.com/images/I/71tJDTdHNJL._AC_SL1500_.jpg" alt="rklm1">`
    };
ads[2] = {
        href: 'https://amzn.to/41l8XcB',
        title: 'Amazon Activewear Shop',
        title2: '**% Discount',
        img: `<img src="https://m.media-amazon.com/images/S/al-na-9d5791cf-3faf/6ff99f36-4675-4dbc-a724-c4d8885e9dae._CR0%2C0%2C3000%2C600_SX1500_.jpg" alt="rklm1">`
    };
ads[3] = {
        href: 'https://amzn.to/40JHeCp',
        title: '[Official Google TV]Smart Projector with WiFi 6 & Bluetooth',
        title2: '-46% Discount',
        img: `<img src="https://m.media-amazon.com/images/I/81wHCwl4fJL._AC_SL1500_.jpg" alt="rklm1">`
    };
ads[4] = {
        href: 'https://amzn.to/477jXhu',
        title: '2025 Upgraded Retro Gaming Console Stick, Classic Video Games Stick with 4K HDMI',
        title2: '-38% Discount',
        img: `<img src="https://m.media-amazon.com/images/I/81KH3sJAaJL._SL1500_.jpg" alt="rklm1">`
    };
ads[5] = {
        href: 'https://rklm.work/hostinger',
        title: 'Get exclusive discounts with this link – New or existing Hostinger user, it doesn’t matter!',
        title2: 'Special offer inside – Save big with this Hostinger link, no matter your account status!',
        img: `<img  alt="rklm2">`
    };
ads[6] = {
        href: 'https://amzn.to/3Hc3j5J',
        title: 'Super Console X2 Pro Retro Game Console Pre-Built-in 100000+Games, Retro Game Console with 65+ emulators,EmuELEC 4.5/Android 9.0，4K UHD Display',
        title2: '-17% Discount',
        img: `<img  src="https://m.media-amazon.com/images/I/71s+8T7cL1L._AC_SL1500_.jpg" alt="rklm3">`
    };
ads[7] = {
        href: 'https://rklm.work/hetzner',
        title: 'Get €20 credits for free: Cloud VPS HETZNER',
        title2: 'Only for new customers',
        img: `<img  src="https://www.hetzner.com/_resources/themes/hetzner/images/logo/hetzner-logo.svg" alt="rklm4">`
    };

var numAds = 7;
var dav = document.getElementById("googlecsf");

var current_ad = Math.floor(Math.random() * numAds) + 1;

function getCode(e) {
    var ad = ads[e];
    var html = "";
    html += `<div class="ad-container" id="adBox">
        <div class="ad-header" onclick="toggleAd()">
          <span>▲</span>
        </div>
        <div class="ad-content">
          <a target="_blank" href="${ad.href}" style="text-decoration:none;color:inherit;">
            <div class="ad-content-inner">
              ${ad.img}
              <div class="text">
                <p class="title">${ad.title}</p>
                <p class="title2">${ad.title2}</p>
              </div>
            </div>
          </a>
        </div>
      </div>`;
    return html;
};

var myCode = getCode(current_ad);

// r
setTimeout(function() {
    if (dav) dav.innerHTML += myCode;

    var adBox = document.getElementById("adBox");
    if (adBox) {
      // 1 sn 
      setTimeout(function() {
        adBox.classList.add("active");
      }, 1000);
    }
}, 2000);

// toggle
function toggleAd() {
  var adBox = document.getElementById("adBox");
  if (adBox) {
    adBox.classList.toggle("active");
  }
}
