/* ============================================
   AD SYSTEM STYLES
   Add this to your style.css or in <style> tag
   ============================================ */

/* Ad Container Base Styles */
.ad-container {
  display: none; /* Hidden by default */
  margin: 20px auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: all 0.3s ease;
}

/* Show ad when this class is added */
.ad-container.show {
  display: block;
  animation: fadeIn 0.5s ease;
}

/* Ad Label (small "Advertisement" text) */
.ad-label {
  font-size: 10px;
  color: var(--text);
  opacity: 0.4;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

/* Ad Content Area */
.ad-content {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  overflow: hidden;
}

/* After Results Ad (Horizontal Banner) */
#ad-after-results {
  max-width: 728px;
  margin: 24px auto;
}

#ad-after-results .ad-content {
  min-height: 90px;
}

/* Sidebar Ad (Vertical Banner) */
#ad-sidebar {
  position: fixed;
  right: 20px;
  top: 120px;
  width: 300px;
  max-width: 300px;
  z-index: 100;
  margin: 0;
}

#ad-sidebar .ad-content {
  min-height: 250px;
}

/* Fade In Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Design */
@media (max-width: 1200px) {
  /* Move sidebar ad below content on smaller screens */
  #ad-sidebar {
    position: static;
    width: 100%;
    max-width: 300px;
    margin: 20px auto;
    right: auto;
    top: auto;
  }
}

@media (max-width: 768px) {
  /* Stack ads vertically on mobile */
  .ad-container {
    margin: 16px 8px;
    padding: 12px;
  }
  
  #ad-after-results {
    max-width: 100%;
  }
  
  #ad-after-results .ad-content {
    min-height: 50px;
  }
  
  #ad-sidebar {
    width: 100%;
    max-width: 100%;
    margin: 16px 0;
  }
  
  #ad-sidebar .ad-content {
    min-height: 100px;
  }
}

/* Hide ads for paid users */
body[data-tier="basic"] .ad-container,
body[data-tier="pro"] .ad-container,
body[data-tier="elite"] .ad-container {
  display: none !important;
}

/* Optional: Ad hover effect */
.ad-container:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Placeholder ad styles (for testing) */
.ad-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Google AdSense styles */
.adsbygoogle {
  display: block;
  width: 100%;
  height: auto;
}

/* Loading state */
.ad-loading {
  opacity: 0.5;
  pointer-events: none;
}

.ad-loading::after {
  content: "Loading ad...";
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--text);
  opacity: 0.5;
  padding: 20px;
}

/* Ad error state */
.ad-error {
  opacity: 0.3;
}

.ad-error::after {
  content: "Ad failed to load";
  display: block;
  text-align: center;
  font-size: 11px;
  color: var(--text);
  opacity: 0.5;
}

/* Upgrade CTA in placeholder ads */
.ad-upgrade-cta {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.ad-upgrade-cta:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

/* Ad container for different screen sizes */
@media (min-width: 1400px) {
  /* Large desktop: sidebar stays on side */
  #ad-sidebar {
    right: calc((100vw - 1200px) / 2 - 320px);
  }
}

/* Print: hide all ads */
@media print {
  .ad-container {
    display: none !important;
  }
}
