/* Root: luôn ở cuối trang, cho phép click */
.sba-root{
  position: fixed; left:0; right:0; bottom:0;
  z-index: var(--sba-z, 999999);
}

/* Khung banner – Desktop: 2 cột (2 trên, 2 dưới) */
.sba-wrap{
  max-width: var(--sba-max-width, 1220px);
  margin: 0 auto;
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: auto;
  gap: var(--sba-gap, 10px);
  padding: 6px 8px;
  background: transparent;
  position: relative;      /* để sba-close bám đúng góc */
  justify-items: center;
  align-items: center;
}

/* Bỏ bọc để item vào trực tiếp grid */
.sba-row{ display: contents; }

/* Ảnh */
.sba-item img{
  max-height: var(--sba-max-height, 60px);
  height: auto; width: auto; display: block;
}
.sba-no-limit .sba-item img{ max-height:none; height:auto; }

/* Nút ĐÓNG – vuông, nhỏ gọn */
.sba-close{
  position: absolute;
  top: 6px; right: 6px;
  height: 26px; min-width: 52px; padding: 0 10px;
  border: 1px solid #e6e6e6; border-radius: 6px;
  background:#fff; color:#111; font-size:12px; font-weight:600; line-height:24px;
  text-align:center; cursor:pointer; z-index: 2147483646; /* rất cao để không bị che */
  pointer-events: auto;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.sba-close:hover{ background:#f3f4f6; border-color:#d1d5db; transform: translateY(-1px); }

/* Nút MỞ (Quảng cáo) – JS sẽ đổi state; ẩn khi đang open */
.sba-open{
  position: fixed; right:16px; bottom:16px;
  background: linear-gradient(135deg, #0066ff, #0033cc);
  color:#fff; font-size:15px; font-weight:600;
  border:none; border-radius:30px;
  padding:10px 20px; cursor:pointer;
  z-index: 2147483647; pointer-events:auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  transition: all .25s ease;
}
.sba-open:hover{ background: linear-gradient(135deg, #3385ff, #0044cc); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.sba-open::before{ content:"📢 "; }

/* Bảo đảm thuộc tính hidden có hiệu lực */
.sba-open[hidden]{ display:none !important; }

/* Điều khiển bằng data-state (an toàn với mọi theme) */
#sba-root[data-state="open"]  .sba-open{ display:none !important; }
#sba-root[data-state="closed"] .sba-open{ display:inline-flex !important; }
#sba-root[data-state="closed"] .sba-wrap{ display:none !important; }

/* ===== Mobile ===== */
@media (max-width: 768px){
  .sba-wrap{
    display:block !important;
    max-width:100% !important;
    padding:8px 10px;
  }
  .sba-row{ display:block !important; }
  .sba-item{ display:block; text-align:center; margin-top:0px; }
  .sba-item img{ max-width:92vw; height:auto; max-height:none !important; }

  .sba-close{
    top:8px; right:8px;
    height:28px; min-width:56px; font-size:13px; line-height:26px;
  }
  .sba-open{
    right:12px; bottom:12px;
    font-size:14px; padding:10px 14px; border-radius:14px;
  }
}
