/**
 * Sidebar Ads CSS for Maritime Executive
 * 
 * Improves ad loading experience and visual consistency
 */

/* Sidebar ad containers */
.sidebar .add {
    margin-bottom: 20px;
    min-height: 250px;
    position: relative;
    transition: opacity 0.3s ease-in-out;
}

/* Ad slot styling */
.sidebar-ad-slot {
    min-height: 250px;
    width: 300px;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    transition: all 0.3s ease-in-out;
}

/* Loading state */
.sidebar-ad-slot.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e5e5e5 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: ad-shimmer 1.5s infinite;
}

/* Loaded state */
.sidebar-ad-slot.loaded {
    background: transparent;
    border: none;
    animation: none;
}

/* Failed state */
.sidebar-ad-slot.failed {
    background: #f8f8f8;
    border: 1px dashed #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    animation: none;
}

.sidebar-ad-slot.failed::before {
    content: "Ad space";
}

/* Shimmer animation */
@keyframes ad-shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar .add {
        margin-bottom: 15px;
    }

    .sidebar-ad-slot {
        min-height: 200px;
        width: 280px;
    }
}

/* Hide ads that fail to load after timeout */
.sidebar .add.hide-empty {
    display: none;
}

/* AdSense styling improvements */
.sidebar .adsbygoogle {
    min-height: 250px;
    background: transparent;
    border: none;
}

/* Prevent layout shift */
.sidebar .add>div[id^="div-gpt-ad-"] {
    width: 300px;
    height: 250px;
    max-width: 100%;
}

@media (max-width: 768px) {
    .sidebar .add>div[id^="div-gpt-ad-"] {
        width: 280px;
        height: 200px;
    }
}

/* Improved spacing between ads */
.sidebar .add:not(:last-child) {
    margin-bottom: 25px;
}

/* Loading indicator for sidebar */
.sidebar-loading-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
    display: none;
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {

    0%,
    100% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }
}

/* Debug styles */
.sidebar-ads-debug {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-size: 11px;
    max-width: 200px;
    z-index: 1000;
    display: none;
}

.sidebar-ads-debug.visible {
    display: block;
}

.sidebar-ads-debug h4 {
    margin: 0 0 5px 0;
    font-size: 12px;
    color: #ffd700;
}

.sidebar-ads-debug .stat {
    margin: 2px 0;
}

.sidebar-ads-debug .stat.success {
    color: #4CAF50;
}

.sidebar-ads-debug .stat.error {
    color: #f44336;
}

.sidebar-ads-debug .stat.warning {
    color: #ff9800;
}