/* Google AdSense Styling for Dark Theme */

/* Ad Container Base Styling */
.adsense-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    margin: 1.5rem 0;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
}

/* Show container when ad is loaded */
.adsense-container[data-ad-loaded="true"] {
    opacity: 1;
    visibility: visible;
    animation: fadeIn 0.5s ease-in forwards;
}

.adsense-container:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Ad Label */
.ad-label {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* In-Feed Ad Styling */
.adsense-infeed {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.5rem;
}

/* Sidebar Ad Styling (Desktop) */
.adsense-sidebar {
    position: sticky;
    top: 80px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    margin-bottom: 2rem;
}

/* Banner Ad Styling */
.adsense-banner {
    width: 100%;
    max-width: 100%;
    margin: 2rem auto;
    text-align: center;
}

/* In-Article Ad Styling */
.adsense-article {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid rgba(13, 110, 253, 0.3);
    border-radius: 8px;
}

/* Dynamic Ad Visibility - Managed by JavaScript */
.adsense-container[data-ad-loaded="false"],
.adsense-container[style*="display: none"] {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* AdSense iframe styling */
.adsense-container ins {
    background: transparent;
}

.adsense-container iframe {
    max-width: 100%;
}

/* Loading State */
.adsense-container.loading::before {
    content: "";
    display: block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: rgba(13, 110, 253, 0.6);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive Ad Containers */
@media (max-width: 768px) {
    .adsense-container {
        padding: 0.75rem;
        margin: 1rem 0;
    }
    
    .adsense-sidebar {
        display: none;
    }
    
    .adsense-banner {
        margin: 1rem auto;
    }
}

/* Overlay/Anchor Ad Customization */
.adsbygoogle[data-ad-format="auto"][data-full-width-responsive="true"] {
    display: block;
}

/* Ensure ads blend with dark theme */
.adsbygoogle {
    background: transparent !important;
}

/* Ad Spacing in Story Grid */
.col-12.my-3 .adsense-container {
    width: 100%;
}

/* Story Page Ad Styling */
.story-content + .adsense-container,
.adsense-container + .story-content {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

/* Match Story Card Styling */
.adsense-infeed,
.adsense-article {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.adsense-infeed:hover,
.adsense-article:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

/* Ad Container Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Prevent Layout Shift */
.adsense-placeholder {
    min-height: 250px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.875rem;
}

/* Mobile Bottom Anchor Ad Space */
@media (max-width: 768px) {
    body {
        padding-bottom: 100px; /* Space for bottom anchor ads */
    }
}
