/**
 * Advertisement System Styles
 * Industry-standard ad styling with CLS prevention and responsive design
 */

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

.advertisement-container {
    position: relative;
    margin: 20px auto;
    text-align: center;
    overflow: hidden;
}

.ad-container {
    position: relative;
    background: #f5f5f5;
    border-radius: 4px;
    transition: background 0.3s ease;
}

/* CLS-Safe Containers (Prevent Layout Shift) */
.cls-safe {
    min-height: 90px; /* Default minimum height */
}

.cls-safe.ad-size-leaderboard {
    min-height: 90px;
    max-width: 728px;
}

.cls-safe.ad-size-billboard {
    min-height: 250px;
    max-width: 970px;
}

.cls-safe.ad-size-mpu {
    min-height: 250px;
    max-width: 300px;
}

.cls-safe.ad-size-skyscraper {
    min-height: 600px;
    max-width: 300px;
}

/* ============================================
   Ad Labels (Required by AdSense)
   ============================================ */

.ad-label {
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    font-weight: 500;
}

/* ============================================
   Lazy Loading Styles
   ============================================ */

.lazy-ad-image {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.lazy-ad-image.loaded {
    opacity: 1;
}

.ad-lazy-container {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* ============================================
   Sticky Bottom Ad
   ============================================ */

.sticky-bottom-ad {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 10px;
    text-align: center;
    transition: transform 0.3s ease;
}

.sticky-bottom-ad.hidden {
    transform: translateY(100%);
}

/* ============================================
   Sidebar Sticky Ad
   ============================================ */

.sidebar-sticky-ad {
    position: sticky;
    top: 20px;
    margin-bottom: 20px;
}

/* ============================================
   In-Article Ads
   ============================================ */

.in-article-ad {
    margin: 30px 0;
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    clear: both;
}

.in-article-ad-inserted {
    margin: 30px 0;
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablet */
@media (max-width: 992px) {
    .advertisement-container {
        margin: 15px auto;
    }
    
    .sidebar-sticky-ad {
        position: relative;
        top: 0;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .advertisement-container {
        margin: 10px auto;
        padding: 0 10px;
    }
    
    .cls-safe {
        min-height: 50px;
    }
    
    .in-article-ad,
    .in-article-ad-inserted {
        margin: 20px 0;
        padding: 15px 0;
    }
    
    .sidebar-sticky-ad {
        display: none; /* Hide desktop sidebar ads on mobile */
    }
    
    .sticky-bottom-ad {
        max-height: 60px;
    }
}

/* ============================================
   Ad Performance Indicators (Admin)
   ============================================ */

.ad-performance-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
}

.ad-performance-excellent {
    background: #28a745;
    color: #fff;
}

.ad-performance-good {
    background: #17a2b8;
    color: #fff;
}

.ad-performance-average {
    background: #ffc107;
    color: #000;
}

.ad-performance-poor {
    background: #dc3545;
    color: #fff;
}

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

.advertisement-container:focus-within {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* ============================================
   Print Styles (Hide ads when printing)
   ============================================ */

@media print {
    .advertisement-container,
    .sticky-bottom-ad,
    .sidebar-sticky-ad,
    .in-article-ad,
    .in-article-ad-inserted {
        display: none !important;
    }
}

