/* Ad Container CSS - Responsive Ad Space Styles */

/* Base Ad Container Styles */
.ad-container {
    display: block;
    margin: 1rem auto;
    padding: 1rem;
    text-align: center;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Empty State Styling */
.ad-container:empty::before {
    content: "Advertisement";
    color: #6c757d;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.ad-container:not(:empty) {
    background-color: transparent;
    border: none;
    padding: 0;
}

/* Specific Ad Sizes - IAB Standard Sizes */

/* Header Banner - 728x90 (Leaderboard) */
.ad-header-banner {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    margin: 1rem auto 2rem auto;
}

.ad-header-banner:empty {
    height: 90px;
}

/* Sidebar Rectangle - 300x250 (Medium Rectangle) */
.ad-sidebar-rect {
    width: 100%;
    max-width: 300px;
    min-height: 250px;
    margin: 1rem;
    float: right;
    clear: right;
}

.ad-sidebar-rect:empty {
    height: 250px;
}

/* Footer Banner - 728x90 (Leaderboard) */
.ad-footer-banner {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    margin: 2rem auto 1rem auto;
}

.ad-footer-banner:empty {
    height: 90px;
}

/* Mobile Banner - 320x50 (Mobile Banner) */
.ad-mobile-banner {
    width: 100%;
    max-width: 320px;
    min-height: 50px;
    margin: 1rem auto;
}

.ad-mobile-banner:empty {
    height: 50px;
}

/* Large Rectangle - 336x280 */
.ad-large-rect {
    width: 100%;
    max-width: 336px;
    min-height: 280px;
    margin: 1rem auto;
}

.ad-large-rect:empty {
    height: 280px;
}

/* Responsive Behavior */
@media (max-width: 768px) {
    /* Hide large desktop ads on mobile */
    .ad-header-banner,
    .ad-footer-banner {
        display: none;
    }
    
    /* Show mobile-optimized ads */
    .ad-mobile-banner {
        display: block;
    }
    
    /* Adjust sidebar ads for mobile */
    .ad-sidebar-rect {
        float: none;
        clear: none;
        margin: 1rem auto;
        max-width: 300px;
    }
}

@media (max-width: 480px) {
    /* Further optimize for very small screens */
    .ad-sidebar-rect {
        max-width: 280px;
        min-height: 200px;
    }
    
    .ad-sidebar-rect:empty {
        height: 200px;
    }
    
    .ad-mobile-banner {
        max-width: 280px;
        min-height: 50px;
    }
    
    .ad-container {
        margin: 0.5rem auto;
        padding: 0.75rem;
    }
}

@media (min-width: 769px) {
    /* Show desktop ads on larger screens */
    .ad-header-banner,
    .ad-footer-banner {
        display: block;
    }
    
    /* Hide mobile ads on desktop */
    .ad-mobile-banner {
        display: none;
    }
}

/* Layout Integration */

/* Ensure ads don't break page layout */
.ad-container img,
.ad-container iframe,
.ad-container object {
    max-width: 100%;
    height: auto;
}

/* Prevent ads from overlapping content */
.content-with-sidebar-ad {
    margin-right: 320px;
}

@media (max-width: 768px) {
    .content-with-sidebar-ad {
        margin-right: 0;
    }
}

/* Accessibility and Performance */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .ad-container {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ad-container {
        background-color: #fff;
        border-color: #000;
    }
    
    .ad-container:empty::before {
        color: #000;
    }
}

/* Print styles - hide ads when printing */
@media print {
    .ad-container {
        display: none !important;
    }
}

/* Focus styles for keyboard navigation */
.ad-container a:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Loading states */
.ad-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 2s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Error states */
.ad-error {
    background-color: #ffeaa7;
    border-color: #fdcb6e;
    color: #e17055;
}

.ad-error::before {
    content: "Ad failed to load";
    font-size: 0.75rem;
}

/* Ad blocker detection styling */
.ad-blocked {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
}

.ad-blocked::before {
    content: "Ad blocked";
    font-size: 0.75rem;
    opacity: 0.5;
}