/* Mobile Ad Styling with Network Awareness */
@media (max-width: 768px) {
    /* Mobile ad containers */
    .mobile-ad-container {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 250px !important;
        margin: 10px 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        display: block !important;
        position: relative !important;
    }
    
    /* Google AdSense ads on mobile */
    .adsbygoogle {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 250px !important;
        display: block !important;
        margin: 0 auto !important;
        text-align: center !important;
        position: relative !important;
        z-index: 2 !important;
    }
    
    /* VDO.AI Video ads on mobile */
    #v-cricketaddictor-v2 {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 250px !important;
        display: block !important;
        margin: 0 auto !important;
        text-align: center !important;
        position: relative !important;
        z-index: 1 !important;
        overflow: hidden !important;
    }
    
    /* Ensure VDO.AI iframe doesn't overflow */
    #v-cricketaddictor-v2 iframe {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 250px !important;
        border: none !important;
        display: block !important;
    }
    
    /* Ensure ads don't overflow */
    .adsbygoogle iframe {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 250px !important;
        border: none !important;
    }
    
    /* Hide desktop ads on mobile */
    .desktop-ad-container {
        display: none !important;
    }
    
    /* Mobile-specific ad spacing */
    .mobile-ad-container + .mobile-ad-container {
        margin-top: 20px !important;
    }
    
    /* Ensure ads are visible */
    .mobile-ad-container:empty {
        min-height: 250px !important;
        background-color: #f5f5f5 !important;
        border: 1px dashed #ccc !important;
    }
    
    /* Mobile ad loading state */
    .mobile-ad-container.loading {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
    }
    
    /* Loading indicator styling */
    .ad-loading-indicator {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 1 !important;
        background: rgba(255, 255, 255, 0.9) !important;
        padding: 20px !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Fallback content styling */
    .ad-fallback {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 3 !important;
        background: rgba(255, 255, 255, 0.95) !important;
        padding: 20px !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
        text-align: center !important;
        min-width: 200px !important;
    }
    
    .ad-fallback p {
        margin-bottom: 10px !important;
        color: #666 !important;
        font-size: 14px !important;
    }
    
    .ad-fallback button {
        background: #007bff !important;
        color: white !important;
        border: none !important;
        padding: 8px 16px !important;
        border-radius: 4px !important;
        cursor: pointer !important;
        font-size: 12px !important;
    }
    
    .ad-fallback button:hover {
        background: #0056b3 !important;
    }
    
    /* Network-aware styling for slow connections */
    @media (prefers-reduced-data: reduce) {
        .mobile-ad-container {
            min-height: 200px !important;
        }
        
        .adsbygoogle {
            min-height: 200px !important;
        }
    }
    
    /* Slow network indicator */
    .slow-network .mobile-ad-container {
        opacity: 0.8 !important;
    }
    
    .slow-network .ad-loading-indicator {
        background: rgba(255, 193, 7, 0.9) !important;
    }
    
    @keyframes loading {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }
}

/* Tablet specific styling */
@media (min-width: 769px) and (max-width: 1024px) {
    .mobile-ad-container {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 250px !important;
    }
    
    .adsbygoogle {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 250px !important;
    }
}

/* Ensure ads work in AMP pages */
amp-ad {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 250px !important;
}

/* Mobile ad debugging */
.mobile-ad-debug {
    border: 2px solid red !important;
    background-color: rgba(255, 0, 0, 0.1) !important;
    padding: 10px !important;
    margin: 10px 0 !important;
}

.mobile-ad-debug::before {
    content: "Mobile Ad Debug: " attr(data-debug);
    color: red;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

/* Network status indicators */
.network-status {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 9999;
}

.network-status.slow {
    background: rgba(255, 193, 7, 0.9);
    color: black;
}

.network-status.offline {
    background: rgba(220, 53, 69, 0.9);
}

/* Ad error states */
.ad-error {
    border: 2px solid #dc3545 !important;
    background-color: rgba(220, 53, 69, 0.1) !important;
}

.ad-success {
    border: 2px solid #28a745 !important;
    background-color: rgba(40, 167, 69, 0.1) !important;
}

/* Responsive ad sizing for different screen sizes */
@media (max-width: 480px) {
    .mobile-ad-container {
        min-height: 200px !important;
    }
    
    .adsbygoogle {
        min-height: 200px !important;
    }
    
    .ad-fallback {
        min-width: 150px !important;
        padding: 15px !important;
    }
}

@media (max-width: 320px) {
    .mobile-ad-container {
        min-height: 180px !important;
    }
    
    .adsbygoogle {
        min-height: 180px !important;
    }
}
