/**
 * Google AdSense Styling for dbterd Documentation
 * Ensures ads integrate well with the Material theme
 */

/* Ad Container Base Styles */
.ad-container {
  max-width: 100%;
  overflow: hidden;
  margin: 20px auto;
  border-radius: 8px;
  transition: all 0.3s ease;
}

/* Header Ad Styling */
.ad-container:first-of-type {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dee2e6;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Mid-content Ad Styling */
.ad-container:nth-of-type(2) {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  position: relative;
}

.ad-container:nth-of-type(2)::before {
  content: 'Advertisement';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #6c757d;
  color: white;
  padding: 2px 8px;
  font-size: 10px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Footer Ad Styling */
.ad-container:last-of-type {
  background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
  border-top: 2px solid #dee2e6;
  margin-top: 40px;
}

/* Dark Mode Support */
[data-md-color-scheme="slate"] .ad-container {
  background: #1e1e1e !important;
  border-color: #333 !important;
  color: #fff;
}

[data-md-color-scheme="slate"] .ad-container:nth-of-type(2)::before {
  background: #444;
  color: #ccc;
}

/* Responsive Design */
@media (max-width: 768px) {
  .ad-container {
    margin: 15px 0;
    padding: 10px !important;
    border-radius: 6px;
  }

  .ad-container:nth-of-type(2)::before {
    font-size: 9px;
    padding: 1px 6px;
  }
}

@media (max-width: 480px) {
  .ad-container {
    margin: 10px 0;
    padding: 8px !important;
  }
}

/* AdSense Specific Styles */
.adsbygoogle {
  display: block !important;
  text-align: center;
  min-height: 250px; /* Prevent layout shift */
  background: transparent;
}

/* In-article ad adjustments */
.adsbygoogle[data-ad-layout="in-article"] {
  min-height: 200px;
}

/* Auto-relaxed ad adjustments */
.adsbygoogle[data-ad-format="autorelaxed"] {
  min-height: 300px;
}

/* Hover Effects */
.ad-container:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Loading State */
.ad-container.loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

/* Ad Blocker Message */
.ad-blocked {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  color: #856404;
  text-align: center;
  padding: 20px;
  border-radius: 8px;
  font-size: 14px;
}

.ad-blocked::before {
  content: '💡 ';
}

/* Fixed Right Bottom Ad */
.fixed-left-ad {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  width: 320px;
  background: transparent;
  border-radius: 8px;
  padding: 10px;
  transition: all 0.3s ease;
}

.fixed-ad-wrapper {
  position: relative;
  text-align: center;
}

.fixed-ad-label {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: #6c757d;
  color: white;
  padding: 1px 6px;
  font-size: 8px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Close button styles */
.ad-close-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: #6c757d;
  color: white;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ad-close-btn:hover {
  background: #5a6268;
  transform: scale(1.1);
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.ad-close-btn:active {
  transform: scale(0.95);
}

.left-sidebar-ad {
  display: block !important;
  width: 300px !important;
  height: 300px !important;
  margin: 0 auto;
  background: #f8f9fa;
  border-radius: 4px;
  aspect-ratio: 1 / 1 !important;
  min-width: 250px;
  min-height: 250px;
  max-width: 300px;
  max-height: 300px;
}

/* Dark Mode Fixed Left Ad */
[data-md-color-scheme="slate"] .fixed-left-ad {
  background: transparent !important;
}

[data-md-color-scheme="slate"] .fixed-ad-label {
  background: #4a5568;
  color: #e2e8f0;
}

[data-md-color-scheme="slate"] .left-sidebar-ad {
  background: #1a202c !important;
}

/* Hide on smaller screens to avoid layout conflicts */
@media (max-width: 1200px) {
  .fixed-left-ad {
    display: none;
  }
}

/* Adjust position for very large screens */
@media (min-width: 1400px) {
  .fixed-left-ad {
    right: 40px;
    width: 320px;
  }

  .left-sidebar-ad {
    width: 300px !important;
    height: 300px !important;
  }
}

/* Hover effect */
.fixed-left-ad:hover {
  transform: translateY(-5px) scale(1.05);
}

/* Print Styles - Hide ads when printing */
@media print {
  .ad-container,
  .adsbygoogle,
  .sidebar-ad-container,
  .fixed-left-ad {
    display: none !important;
  }
}
