/**
 * AdSense Styles for WHATZ4DINNER
 * Responsive ad container styling
 */

/* AdSense Container Base Styles */
.adsense-container {
    margin: 20px 0;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    padding: 10px;
    position: relative;
    overflow: hidden;
}

.adsense-container::before {
    content: 'Advertisement';
    position: absolute;
    top: 5px;
    left: 10px;
    font-size: 10px;
    color: #6c757d;
    font-weight: 500;
    z-index: 1;
}

/* Ad Container Placeholder Styles */
.adsense-top-banner::before {
    content: 'Advertisement';
    position: absolute;
    top: 5px;
    left: 10px;
    font-size: 10px;
    color: #6c757d;
    font-weight: 500;
    z-index: 1;
}

.adsense-sidebar::before,
.adsense-in-article::before,
.adsense-loading::before {
    content: 'Advertisement';
    position: absolute;
    top: 5px;
    left: 10px;
    font-size: 10px;
    color: #6c757d;
    font-weight: 500;
    z-index: 1;
}

/* Specific Ad Container Styles */
.adsense-top-banner {
    margin: 15px 0;
    min-height: 90px;
    max-width: 728px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    position: relative;
    overflow: hidden;
}

.adsense-sidebar {
    margin: 20px 0;
    min-height: 250px;
    max-width: 300px;
    width: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    position: relative;
    overflow: hidden;
    float: right;
    clear: right;
}

.adsense-in-article {
    margin: 30px 0;
    min-height: 250px;
    max-width: 300px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    position: relative;
    overflow: hidden;
}

.adsense-loading {
    margin: 20px 0;
    min-height: 250px;
    max-width: 300px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    position: relative;
    overflow: hidden;
    /* Hide loading ad initially to prevent white banner flash */
    display: none !important;
}

/* Only show loading ad when it has actual ad content */
.adsense-loading:has(.adsbygoogle) {
    display: block !important;
}

/* Fallback for browsers that don't support :has() */
.adsense-loading.loaded {
    display: block !important;
}

/* AdSense Responsive Styles */
.adsbygoogle {
    display: block !important;
    margin: 0 auto;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .adsense-container {
        margin: 10px 0;
        padding: 8px;
        min-height: 40px;
    }
    
    .adsense-top-banner {
        min-height: 50px;
        margin: 10px 0;
        max-width: 100%;
        padding: 10px;
    }
    
    .adsense-sidebar {
        float: none;
        clear: both;
        max-width: 100%;
        margin: 15px auto;
        min-height: 200px;
    }
    
    .adsense-in-article,
    .adsense-loading {
        min-height: 200px;
        margin: 15px 0;
        max-width: 100%;
    }
    
    .adsense-container::before {
        font-size: 9px;
        top: 3px;
        left: 8px;
    }
}

@media (max-width: 480px) {
    .adsense-container {
        margin: 8px 0;
        padding: 6px;
        border-radius: 6px;
    }
    
    .adsense-top-banner {
        min-height: 50px;
        margin: 8px 0;
        padding: 8px;
    }
    
    .adsense-sidebar {
        float: none;
        clear: both;
        margin: 12px auto;
        min-height: 180px;
        max-width: 100%;
    }
    
    .adsense-in-article,
    .adsense-loading {
        min-height: 180px;
        margin: 12px 0;
        max-width: 100%;
    }
}

/* Premium User Ad Hiding */
.premium-user .adsense-container {
    display: none !important;
}

/* Loading State */
.adsense-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 Container Hover Effects */
.adsense-container:hover {
    border-color: #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Integration with Existing Page Layout */
.hero-section + .adsense-top-banner {
    margin-top: 0;
}

.recommendations-section + .adsense-sidebar {
    margin-top: 0;
}

.quick-actions-section + .adsense-in-article {
    margin-top: 0;
}

/* AdSense Error Handling */
.adsense-container.error {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.adsense-container.error::after {
    content: 'Ad failed to load';
    position: absolute;
    bottom: 5px;
    right: 10px;
    font-size: 10px;
    color: #856404;
}

/* Accessibility Improvements */
.adsense-container:focus-within {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .adsense-container {
        display: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .adsense-container {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .adsense-container::before {
        color: #a0aec0;
    }
    
    .adsense-container:hover {
        border-color: #718096;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Performance Optimizations */
.adsense-container {
    contain: layout style paint;
    will-change: auto;
}

/* AdSense Auto Sizing */
.adsbygoogle[data-ad-status="unfilled"] {
    display: none !important;
}

.adsbygoogle[data-ad-status="error"] {
    display: none !important;
}
