/* Balloon Ads Styles */
.balloon-ad {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: visible;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  background: #fff;
  max-width: 400px;
}

.balloon-ad.banner {
  width: 300px;
  height: 250px;
}

.balloon-ad.video,
.balloon-ad.vast {
  width: 400px;
  height: 250px;
}

.balloon-ad.minimized {
  transform: scale(1);
  opacity: 1;
  cursor: pointer;
}

.balloon-ad.hidden {
  display: none;
}

.balloon-ad .ad-content {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 8px;
}

.balloon-ad .ad-banner,
.balloon-ad .ad-video,
.balloon-ad .ad-video-ima {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  border: none;
}

.balloon-ad .ad-video-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.balloon-ad .ad-ui-ima {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Allow interaction with IMA UI (including the original Skip Ad button) */
  pointer-events: auto;
  /* Ensure IMA UI is above custom elements */
  z-index: 15;
}

/* Ensure all IMA skip buttons are clickable */
.balloon-ad .ad-ui-ima .adsbygoogle-skipbutton,
.balloon-ad .ad-ui-ima .videoAdUiSkipButton,
.balloon-ad .ad-ui-ima [class*="skip"],
.balloon-ad .ad-ui-ima [class*="Skip"] {
  pointer-events: auto !important;
  z-index: 16 !important;
}

/* Custom styling for Google IMA SDK skip button - mobile responsive */
.balloon-ad .ad-ui-ima .videoAdUiSkipButton,
.balloon-ad .ad-ui-ima [class*="skip"],
.balloon-ad .ad-ui-ima [class*="Skip"] {
  font-size: 11px !important;
  padding: 3px 6px !important;
  min-width: auto !important;
  white-space: nowrap !important;
  border-radius: 3px !important;
  background: rgba(0, 0, 0, 0.8) !important;
  color: white !important;
  border: none !important;
  font-weight: 500 !important;
  line-height: 1.2 !important;
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
  .balloon-ad .ad-ui-ima .videoAdUiSkipButton,
  .balloon-ad .ad-ui-ima [class*="skip"],
  .balloon-ad .ad-ui-ima [class*="Skip"] {
    font-size: 10px !important;
    padding: 2px 5px !important;
    max-width: 60px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

/* Try to override IMA skip button text content */
.balloon-ad .ad-ui-ima .videoAdUiSkipButton::after,
.balloon-ad .ad-ui-ima [class*="skip"]::after,
.balloon-ad .ad-ui-ima [class*="Skip"]::after {
  content: "Bỏ qua" !important;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 500;
  border-radius: 3px;
  z-index: 1;
}

/* Hide original text */
.balloon-ad .ad-ui-ima .videoAdUiSkipButton,
.balloon-ad .ad-ui-ima [class*="skip"],
.balloon-ad .ad-ui-ima [class*="Skip"] {
  color: transparent !important;
  position: relative !important;
}

.balloon-ad .close-btn {
  position: absolute;
  top: -35px;
  right: 0px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 18;
}

.balloon-ad .close-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}

.balloon-ad .video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.balloon-ad .control-btn {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Mobile responsive control buttons */
@media (max-width: 768px) {
  .balloon-ad .control-btn {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .balloon-ad .controls {
    gap: 4px;
  }
}

.balloon-ad .control-btn:hover {
  background: white;
}

.balloon-ad .progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.balloon-ad .progress-fill {
  height: 100%;
  background: #ff6b6b;
  width: 0%;
  transition: width 0.1s ease;
}

.balloon-ad .skip-btn {
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  position: absolute;
  top: 5px;
  left: 5px;
}

.balloon-ad .skip-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}



/* VAST Control Bar */
.balloon-ad .vast-control-bar {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 17;
  pointer-events: auto;
}

.balloon-ad .vast-control-btn {
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  pointer-events: auto;
}

.balloon-ad .vast-control-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.balloon-ad .vast-control-btn:focus {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

/* Mobile responsive sizing */
@media (max-width: 480px) {
  .balloon-ad .vast-control-btn {
    width: 26px;
    height: 26px;
  }

  .balloon-ad .vast-control-btn svg {
    width: 26px;
    height: 26px;
  }
}

/* Icon visibility states for VAST controls */
.balloon-ad .vast-control-btn .icon--not-pressed {
  display: block;
}

.balloon-ad .vast-control-btn .icon--pressed {
  display: block;
}

.balloon-ad .mute-btn .icon--not-pressed {
  display: block;
}

.balloon-ad .mute-btn .icon--pressed {
  display: none;
}

.balloon-ad .mute-btn.muted .icon--not-pressed {
  display: none;
}

.balloon-ad .mute-btn.muted .icon--pressed {
  display: block;
}

.balloon-ad .play-pause-btn.playing .icon--not-pressed {
  display: none !important;
}

.balloon-ad .play-pause-btn.playing .icon--pressed {
  display: block !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .balloon-ad {
    bottom: 10px;
    right: 10px;
    max-width: calc(100vw - 20px);
  }

  .balloon-ad.banner {
    width: 300px;
    height: 250px;
  }

  .balloon-ad.video,
  .balloon-ad.vast {
    width: 66.67vw;
    height: calc(66.67vw * 9/16);
  }

  .balloon-ad .close-btn {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }
}

/* Animation for showing balloon ad */
@keyframes slideInFromBottom {
  from {
    transform: translateY(100%) translateX(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0) translateX(0);
    opacity: 1;
  }
}

.balloon-ad.show {
  animation: slideInFromBottom 0.3s ease-out;
}