/* Ad Styling for yt2mp3.lol */

/* Ad Container Base */
.ad-container {
  margin: 24px auto;
  text-align: center;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  max-width: 100%;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  contain: layout style paint;
  will-change: auto;
}

.ad-container:hover {
  border-color: var(--border-2);
}

/* Fixed dimensions for different ad types - Desktop */
.ad-top-banner,
.ad-below-converter {
  min-height: 122px; /* 90px ad + 32px padding */
  height: 122px;
  max-height: 122px;
  width: 100%;
  max-width: 760px;
}

.ad-sidebar {
  min-height: 632px; /* 600px ad + 32px padding */
  height: 632px;
  max-height: 632px;
  width: 192px;
  max-width: 192px;
}

.ad-native {
  min-height: 282px; /* 250px ad + 32px padding */
  height: 282px;
  max-height: 282px;
  width: 100%;
  max-width: 760px;
}

/* Constrain ad wrapper inside container */
.adsterra-ad {
  max-width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.adsterra-ad iframe {
  max-width: 100%;
  display: block;
}

/* Ad Label */
.ad-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  opacity: 0.7;
}

/* Top Banner Ad */
.ad-top-banner {
  margin: 16px auto 24px;
}

/* Below Converter Ad */
.ad-below-converter {
  margin: 32px auto;
}

/* Sidebar Ad (Desktop Only) */
.ad-sidebar {
  display: none;
}

@media (min-width: 1200px) {
  .ad-sidebar {
    display: block;
    position: sticky;
    top: 80px;
    margin: 20px 0;
    min-height: 600px; /* Accommodate 160x600 skyscraper */
  }
  
  .content-with-sidebar {
    display: grid;
    grid-template-columns: 1fr 200px; /* Width for 160px skyscraper + padding */
    gap: 32px;
    max-width: 1240px;
    margin: 0 auto;
  }
}

/* In-Content Native Ads */
.ad-native {
  margin: 40px auto;
  background: transparent;
  border: none;
  padding: 0;
}

.ad-native .ad-label {
  text-align: left;
  margin-bottom: 12px;
}

/* Mobile Sticky Bottom Ad */
.ad-sticky-bottom {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  padding: 8px;
  text-align: center;
  transform: translateY(0);
  transition: transform 0.3s ease;
  min-height: 66px; /* Fixed height for 320x50 ad + 16px padding */
  height: 66px;
  max-height: 66px;
  overflow: hidden;
}

@media (max-width: 768px) {
  .ad-sticky-bottom {
    display: block;
  }
  
  /* Add padding to body to prevent content being hidden */
  body.has-sticky-ad {
    padding-bottom: 66px;
  }
}

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

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

.ad-close-btn svg {
  width: 12px;
  height: 12px;
}

/* Responsive Ad Sizes */
@media (max-width: 768px) {
  .ad-container {
    padding: 12px;
    margin: 16px auto;
    border-radius: 8px;
  }
  
  .ad-top-banner,
  .ad-below-converter {
    min-height: 274px; /* 250px ad + 24px padding for mobile 300x250 */
    height: 274px;
    max-height: 274px;
    max-width: 100%;
  }
  
  .ad-native {
    min-height: 274px; /* 250px ad + 24px padding */
    height: 274px;
    max-height: 274px;
    max-width: 100%;
  }
}

/* Loading State */
.ad-container.loading {
  min-height: 90px;
  background: linear-gradient(
    90deg,
    var(--card-2) 0%,
    var(--bg-2) 50%,
    var(--card-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Hide ads for supporters (optional) */
body.supporter .ad-container,
body.supporter .ad-sticky-bottom {
  display: none !important;
}

/* Accessibility */
.ad-container:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Dark theme adjustments */
html[data-theme="dark"] .ad-sticky-bottom {
  box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
}

html[data-theme="dark"] .ad-interstitial-overlay {
  background: rgba(0,0,0,0.9);
}

/* Print: hide ads */
@media print {
  .ad-container,
  .ad-sticky-bottom,
  .ad-interstitial-overlay {
    display: none !important;
  }
}
