/* Responsive Ad Styles - Mobile Friendly Across All Platforms */

/* Base Ad Container Styles */
.ad-wrapper, 
.ad-container,
.ad-banner,
.sidebar-ad,
.footer-ad,
.article-ad,
.live-header-ad,
.live-sidebar-ad,
.live-footer-ad,
.performance-header-ad,
.performance-sidebar-ad,
.performance-inline-ad,
.contact-header-ad,
.contact-sidebar-ad,
.category-header-ad,
.category-sidebar-ad,
.category-inline-ad,
.home-hero-ad,
.home-featured-ad,
.home-sidebar-ad,
.article-header-ad,
.article-inline-ad,
.article-footer-ad,
.article-sidebar-ad {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    margin: 10px 0;
    text-align: center;
}

/* Responsive Ad Container */
.ad-responsive {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    text-align: center;
    overflow: hidden;
}

/* Adsterra and Fixed Width Ads - Mobile Responsive */
@media (max-width: 768px) {
    /* Override fixed width ads on mobile */
    .ad-wrapper iframe,
    .ad-container iframe,
    .ad-banner iframe,
    .text-center iframe {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        min-height: 50px !important;
    }
    
    /* Specific Adsterra banner mobile adjustments */
    .container.my-3 iframe {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
    }
    
    /* Ensure ads don't overflow viewport */
    .ad-wrapper,
    .ad-container,
    .ad-banner {
        max-width: 100vw;
        overflow-x: hidden;
    }
}

/* Tablet Responsive Ads */
@media (min-width: 769px) and (max-width: 1024px) {
    .ad-wrapper,
    .ad-container {
        max-width: 728px;
        margin: 10px auto;
    }
    
    .sidebar-ad,
    .article-sidebar-ad {
        max-width: 300px;
    }
}

/* Desktop Ad Sizes */
@media (min-width: 1025px) {
    .ad-wrapper,
    .ad-container {
        max-width: 728px;
        margin: 10px auto;
    }
    
    .sidebar-ad,
    .article-sidebar-ad {
        max-width: 300px;
    }
    
    .home-hero-ad {
        max-width: 970px;
    }
}

/* Google AdSense Responsive Ads */
.adsbygoogle {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto;
}

/* Mobile-specific AdSense adjustments */
@media (max-width: 768px) {
    .adsbygoogle {
        min-height: 50px !important;
        max-height: 250px !important;
    }
    
    /* Full width responsive ads on mobile */
    ins.adsbygoogle[data-full-width-responsive="true"] {
        width: 100% !important;
        max-width: 100vw !important;
    }
}

/* Ad Placeholder Styling */
.ad-placeholder {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

@media (max-width: 768px) {
    .ad-placeholder {
        min-height: 50px;
        padding: 10px;
        font-size: 0.875rem;
    }
}

/* Ad Loading State */
.ad-loading {
    background: #f8f9fa;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ad-loading::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 3px solid #dee2e6;
    border-top-color: #dc3545;
    border-radius: 50%;
    animation: ad-spin 1s linear infinite;
}

@keyframes ad-spin {
    to { transform: rotate(360deg); }
}

/* Mobile-specific loading state */
@media (max-width: 768px) {
    .ad-loading {
        min-height: 50px;
    }
    
    .ad-loading::after {
        width: 20px;
        height: 20px;
    }
}

/* Ad Container Spacing */
.container .ad-wrapper,
.container .ad-container {
    margin: 15px 0;
}

@media (max-width: 768px) {
    .container .ad-wrapper,
    .container .ad-container {
        margin: 10px 0;
    }
}

/* Sidebar Ad Responsive */
.sidebar-ad {
    width: 100%;
    max-width: 300px;
    margin: 15px auto;
}

@media (max-width: 768px) {
    .sidebar-ad {
        max-width: 100%;
        margin: 10px 0;
    }
}

/* Footer Ad Responsive */
.footer-ad {
    width: 100%;
    max-width: 728px;
    margin: 20px auto;
}

@media (max-width: 768px) {
    .footer-ad {
        max-width: 100%;
        margin: 15px 0;
    }
}

/* Article Content Ad Responsive */
.article-ad {
    width: 100%;
    max-width: 100%;
    margin: 20px 0;
    clear: both;
}

@media (max-width: 768px) {
    .article-ad {
        margin: 15px 0;
    }
}

/* Header Banner Ad Responsive */
.header-banner-ad {
    width: 100%;
    max-width: 728px;
    margin: 10px auto;
}

@media (max-width: 768px) {
    .header-banner-ad {
        max-width: 100%;
        margin: 5px 0;
    }
}

/* Prevent ad overflow on small screens */
@media (max-width: 480px) {
    .ad-wrapper,
    .ad-container,
    .ad-banner,
    iframe {
        max-width: 100vw !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Ensure no horizontal scroll */
    body {
        overflow-x: hidden;
    }
    
    .container {
        padding: 0 10px;
    }
}

/* Ad Wrapper for different positions */
.ad-header-slot {
    width: 100%;
    max-width: 728px;
    margin: 10px auto;
    text-align: center;
}

@media (max-width: 768px) {
    .ad-header-slot {
        max-width: 100%;
        margin: 5px 0;
    }
}

.ad-sidebar-slot {
    width: 100%;
    max-width: 300px;
    margin: 15px auto;
}

@media (max-width: 768px) {
    .ad-sidebar-slot {
        max-width: 100%;
        margin: 10px 0;
    }
}

.ad-footer-slot {
    width: 100%;
    max-width: 728px;
    margin: 20px auto;
}

@media (max-width: 768px) {
    .ad-footer-slot {
        max-width: 100%;
        margin: 15px 0;
    }
}

/* Responsive Ad Images */
.ad-wrapper img,
.ad-container img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Ad Click Tracking Wrapper */
[data-ad-id] {
    display: block;
    width: 100%;
    max-width: 100%;
}

/* Mobile Ad Animation */
@media (max-width: 768px) {
    .ad-wrapper,
    .ad-container {
        transition: all 0.3s ease;
    }
    
    .ad-wrapper:hover,
    .ad-container:hover {
        transform: scale(1.02);
    }
}

/* Safe Area for Notch Phones */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .ad-wrapper,
        .ad-container {
            padding-left: max(0px, env(safe-area-inset-left));
            padding-right: max(0px, env(safe-area-inset-right));
        }
    }
}

/* Landscape Mobile Optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .ad-wrapper,
    .ad-container {
        max-height: 100px;
        overflow: hidden;
    }
    
    .adsbygoogle {
        max-height: 100px !important;
    }
}

/* High DPI Display Optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .ad-wrapper img,
    .ad-container img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Print Styles - Hide Ads */
@media print {
    .ad-wrapper,
    .ad-container,
    .ad-banner,
    .sidebar-ad,
    .footer-ad,
    .adsbygoogle {
        display: none !important;
    }
}

/* Dark Mode Ad Compatibility */
[data-theme="dark"] .ad-placeholder {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-color: #495057;
    color: #adb5bd;
}

/* Performance Optimization */
.ad-wrapper,
.ad-container {
    will-change: transform;
    contain: layout style paint;
}

/* Accessibility - Screen Reader Only */
.ad-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus States for Accessibility */
.ad-wrapper a:focus,
.ad-container a:focus {
    outline: 2px solid #dc3545;
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .ad-wrapper,
    .ad-container {
        transition: none;
    }
    
    .ad-loading::after {
        animation: none;
    }
}