/**
 * AdSense Pro - Ad Container Styles
 * CLS-safe containers with premium glassmorphism design
 */

/* ============================================
   Ad Container Base Styles
   ============================================ */

.ad-container {
    position: relative;
    width: 100%;
    margin: 2rem auto;
    padding: 0;
    overflow: hidden;
    
    /* CLS Prevention - always reserve space */
    min-height: 90px;
    
    /* Premium glassmorphism container */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    
    /* Smooth transitions */
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.ad-container:hover {
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ad-container.ad-loaded {
    background: transparent;
    backdrop-filter: none;
    border-color: transparent;
    box-shadow: none;
}

/* ============================================
   Skeleton Loading Animation
   ============================================ */

.ad-skeleton {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        90deg,
        rgba(243, 244, 246, 0.8) 0%,
        rgba(229, 231, 235, 0.8) 50%,
        rgba(243, 244, 246, 0.8) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 16px;
    transition: opacity 0.3s ease;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ad-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(107, 114, 128, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
}

/* ============================================
   Ad Slot Specific Styles
   ============================================ */

/* Header Ad */
.ad-container[data-ad-slot="header-ad"] {
    max-width: 728px;
    min-height: 90px;
    margin: 1rem auto;
}

/* In-Content Ads */
.ad-container[data-ad-slot^="in-content"] {
    max-width: 100%;
    min-height: 250px;
    margin: 3rem auto;
    padding: 1rem;
}

/* Sidebar Sticky Ad */
.ad-container[data-ad-slot="sidebar-sticky"] {
    width: 300px;
    min-height: 250px;
    margin: 0;
}

/* Footer Ad */
.ad-container[data-ad-slot="footer-ad"] {
    max-width: 728px;
    min-height: 90px;
    margin: 2rem auto;
}

/* ============================================
   Sticky Ad Wrapper
   ============================================ */

.ad-sticky-wrapper {
    position: relative;
    width: 300px;
    min-height: 600px;
}

.ad-sticky-wrapper .ad-container {
    transition: none; /* Prevent jank during scroll */
}

/* ============================================
   Responsive Styles
   ============================================ */

/* Tablet */
@media (max-width: 1023px) {
    .ad-container[data-ad-slot="sidebar-sticky"] {
        display: none !important;
    }
    
    .ad-sticky-wrapper {
        display: none !important;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .ad-container {
        margin: 1.5rem auto;
        border-radius: 12px;
    }
    
    .ad-container[data-ad-slot="header-ad"],
    .ad-container[data-ad-slot="footer-ad"] {
        max-width: 100%;
        min-height: 100px;
    }
    
    .ad-container[data-ad-slot^="in-content"] {
        min-height: 200px;
        padding: 0.5rem;
        margin: 2rem auto;
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */

@media (prefers-color-scheme: dark) {
    .ad-container {
        background: rgba(30, 41, 59, 0.6);
        border-color: rgba(71, 85, 105, 0.3);
    }
    
    .ad-skeleton {
        background: linear-gradient(
            90deg,
            rgba(51, 65, 85, 0.8) 0%,
            rgba(71, 85, 105, 0.8) 50%,
            rgba(51, 65, 85, 0.8) 100%
        );
        background-size: 200% 100%;
    }
    
    .ad-label {
        color: rgba(148, 163, 184, 0.6);
        background: rgba(30, 41, 59, 0.8);
    }
}

/* Dark mode class override */
.dark .ad-container,
[data-theme="dark"] .ad-container {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(71, 85, 105, 0.3);
}

/* ============================================
   AdSense Unit Styling
   ============================================ */

.ad-container .adsbygoogle {
    display: block;
    width: 100%;
    height: auto;
}

/* Prevent AdSense overflow */
.ad-container ins.adsbygoogle {
    max-width: 100% !important;
}

/* ============================================
   Page Type Specific Adjustments
   ============================================ */

/* Article pages - more prominent in-content ads */
.page-type-article .ad-container[data-ad-slot^="in-content"] {
    max-width: 100%;
    background: linear-gradient(135deg, rgba(243, 244, 246, 0.9) 0%, rgba(249, 250, 251, 0.9) 100%);
    border: 1px solid rgba(229, 231, 235, 0.5);
}

/* Homepage - subtle header ad */
.page-type-homepage .ad-container[data-ad-slot="header-ad"] {
    background: transparent;
    box-shadow: none;
    border: none;
}

/* Tool pages - minimal ad styling */
.page-type-tool .ad-container {
    background: rgba(249, 250, 251, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* ============================================
   Animation States
   ============================================ */

.ad-container.ad-loading {
    opacity: 0.7;
}

.ad-container.ad-error {
    opacity: 0.5;
    pointer-events: none;
}

.ad-container.ad-refreshing::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.5);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

/* ============================================
   Accessibility
   ============================================ */

.ad-container:focus-within {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Screen reader only label */
.ad-container::before {
    content: 'Advertisement';
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
