 /* Ad Container Styles - Optimized for Performance */

/* Common ad container styles */
.ad-container {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: var(--background-color);
    margin: 0 auto;
    text-align: center;
    width: 100%;
    border: 1px dashed var(--card-border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
    position: relative;
    min-height: 90px;
}

.ad-container:hover {
    border-color: rgba(121, 83, 219, 0.3);
}

/* Top banner ad styles - Enhanced */
.ad-top-banner {
    max-width: 100%;
    min-height: 90px;
    margin: 0 auto 25px;
    padding: 15px;
    background: linear-gradient(135deg, var(--background-color) 0%, rgba(121, 83, 219, 0.02) 100%);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.ad-top-banner:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

/* Make banner ads responsive */
.ad-top-banner .adsbygoogle {
    width: 100%;
    max-width: 728px;
    height: auto;
    min-height: 90px;
    border-radius: 8px;
    overflow: hidden;
}

/* Page layout for sidebar ads */
.page-layout {
    display: flex;
    justify-content: space-between;
    max-width: 1600px;
    margin: 0 auto;
    gap: 10px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    padding: 0 10px; /* Add some padding on the sides */
}

/* Main content container */
.main-content {
    flex: 1;
    min-width: 0; /* Important for preventing overflow */
    width: 100%; /* Full width on mobile */
    max-width: 100%; /* Ensure it doesn't overflow */
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

/* Make main content take full width on mobile */
@media (max-width: 767px) {
    .main-content.container {
        max-width: 100%;
        padding: 0 15px;
    }
}

/* Sidebar ad containers - Enhanced */
.ad-sidebar {
    width: 300px;
    min-height: 600px;
    display: none;
    margin: 0;
    flex-shrink: 0;
}

.ad-sidebar-left {
    margin-right: 15px;
}

.ad-sidebar-right {
    margin-left: 15px;
}

/* Sticky ad positioning - Improved */
.sticky-ad {
    position: sticky;
    top: 100px;
    padding: 15px;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--background-color) 0%, rgba(121, 83, 219, 0.02) 100%);
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    overflow: hidden;
}

.sticky-ad:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: rgba(121, 83, 219, 0.3);
}

/* AdSense specific styles - Optimized */
.adsbygoogle {
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.01);
    transition: opacity 0.3s ease;
}

.adsbygoogle:hover {
    opacity: 0.95;
}

/* Ensure ads don't overflow their containers */
ins.adsbygoogle {
    max-width: 100%;
    border-radius: 8px;
}

/* Ad loading states */
.ad-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Media Queries for Responsive Behavior */

/* Desktop screens - Show sidebar ads */
@media (min-width: 1200px) {
    .page-layout {
        max-width: 1500px;
        margin: 0 auto;
        padding: 0 20px;
    }
    
    /* Show both sidebars on large desktop */
    .ad-sidebar {
        display: block;
        width: 300px;
        min-height: 600px;
    }
    
    .sticky-ad {
        min-height: 600px;
        max-height: calc(100vh - 120px);
        overflow: hidden;
    }
    
    .ad-sidebar .adsbygoogle {
        height: 600px;
        min-height: 600px;
    }
    
    /* Adjust main content width */
    .main-content {
        max-width: calc(100% - 630px);
        margin: 0 15px;
    }
}

/* Medium desktop screens - Adjust sidebar size */
@media (min-width: 992px) and (max-width: 1199px) {
    .page-layout {
        max-width: 1200px;
        padding: 0 15px;
    }
    
    /* Show only left sidebar on medium desktop */
    .ad-sidebar-right {
        display: none;
    }
    
    .ad-sidebar-left {
        display: block;
        width: 250px;
        min-height: 600px;
    }
    
    .sticky-ad {
        min-height: 600px;
        padding: 12px;
    }
    
    .ad-sidebar .adsbygoogle {
        height: 600px;
        width: 250px;
    }
    
    .main-content {
        max-width: calc(100% - 280px);
        margin-left: 15px;
    }
}

/* Tablet landscape - Only show left sidebar smaller */
@media (min-width: 768px) and (max-width: 991px) {
    .ad-sidebar-right {
        display: none;
    }
    
    .ad-sidebar-left {
        display: block;
        width: 160px;
        min-height: 600px;
    }
    
    .sticky-ad {
        min-height: 600px;
    }
    
    .ad-sidebar .adsbygoogle {
        height: 600px;
    }
    
    .ad-top-banner {
        min-height: 90px;
    }
}

/* Mobile devices - Hide sidebar ads, only show banner */
@media (max-width: 767px) {
    .page-layout {
        flex-direction: column;
    }
    
    /* Enhance banner ad for mobile */
    .ad-top-banner {
        min-height: 90px;
        margin-bottom: 15px;
        width: 100%;
        max-width: 100%;
    }
    
    .ad-top-banner .adsbygoogle {
        min-height: 90px;
        width: 100%;
        max-width: 336px; /* Common mobile ad size */
    }
    
    /* Hide sidebar ads completely on mobile */
    .ad-sidebar {
        display: none !important; /* Force hide on mobile */
    }
    
    /* Make the banner ad border more visible on mobile */
    .ad-container {
        border-width: 2px;
        margin-bottom: 20px;
    }
}

/* Small mobile screens - Optimize banner ad */
@media (max-width: 480px) {
    .ad-top-banner {
        min-height: 50px;
        padding: 15px 0;
    }
    
    .ad-top-banner .adsbygoogle {
        min-height: 50px;
        max-width: 320px; /* Common small mobile ad size */
    }
    
    /* Center banner ad on very small screens */
    .ad-container {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    /* Adjust padding and margins for very small screens */
    .page-layout {
        padding: 0 5px;
        gap: 10px;
    }
    
    /* Make ad label smaller on mobile */
    .ad-container::before {
        font-size: 9px;
        padding: 1px 0;
    }
}

/* Extra small screens - Further optimize banner */
@media (max-width: 320px) {
    .ad-top-banner {
        padding: 10px 0;
        min-height: 50px;
    }
    
    .ad-top-banner .adsbygoogle {
        max-width: 300px; /* Smallest common ad size */
    }
}

/* Ad labels for transparency - Enhanced */
.ad-container::before, .sticky-ad::before {
    content: "Advertisement";
    display: block;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--submenu-text);
    opacity: 0.7;
    margin-bottom: 8px;
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 8px;
    background-color: rgba(121, 83, 219, 0.1);
    border-radius: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.ad-container:hover::before, .sticky-ad:hover::before {
    opacity: 0.9;
}

/* Ad container position relative for the label */
.ad-container, .sticky-ad {
    position: relative;
    padding-top: 25px;
}

/* Performance optimizations */
.ad-container, .sticky-ad, .adsbygoogle {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Ad visibility control for lazy loading */
.ad-hidden {
    visibility: hidden;
    height: 0;
    min-height: 0;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.ad-visible {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* Intersection Observer optimizations */
.ad-container[data-loaded="false"], 
.sticky-ad[data-loaded="false"] {
    background: linear-gradient(90deg, #f8f9fa 25%, #e9ecef 50%, #f8f9fa 75%);
    background-size: 200% 100%;
    animation: adLoading 1.5s infinite;
}

@keyframes adLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .ad-container, .sticky-ad, .adsbygoogle {
        transition: none;
        animation: none;
    }
    
    .ad-container:hover, .sticky-ad:hover {
        transform: none;
    }
}

/* Upload Page - Keep Sidebar Ads */
body[data-page="upload"] .page-layout {
    display: flex;
    justify-content: space-between;
    max-width: 1500px;
    margin: 0 auto;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 10px;
}

body[data-page="upload"] .main-content {
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body[data-page="upload"] .ad-sidebar {
    width: 300px;
    min-height: 600px;
    display: none;
    margin: 0;
    flex-shrink: 0;
}

/* Edit Page - Full Width, No Sidebars */
body[data-page="edit"] .page-layout {
    display: block !important;
    max-width: 100% !important;
}

body[data-page="edit"] .main-content {
    max-width: 100% !important;
    margin: 0 !important;
}

body[data-page="edit"] .ad-sidebar {
    display: none !important;
}

body[data-page="edit"] .tool-section .container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
    width: 100%;
}

body[data-page="edit"] .cropper-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

/* Upload Page Responsive Sidebar Ads */
@media (min-width: 1200px) {
    body[data-page="upload"] .page-layout {
        max-width: 1500px;
        padding: 0 20px;
    }
    
    body[data-page="upload"] .ad-sidebar {
        display: block;
        width: 300px;
        min-height: 600px;
    }
    
    body[data-page="upload"] .main-content {
        max-width: calc(100% - 630px);
        margin: 0 15px;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    body[data-page="upload"] .page-layout {
        max-width: 1200px;
        padding: 0 15px;
    }
    
    body[data-page="upload"] .ad-sidebar-right {
        display: none;
    }
    
    body[data-page="upload"] .ad-sidebar-left {
        display: block;
        width: 250px;
        min-height: 600px;
    }
    
    body[data-page="upload"] .main-content {
        max-width: calc(100% - 280px);
        margin-left: 15px;
    }
}

@media (max-width: 991px) {
    body[data-page="upload"] .page-layout {
        flex-direction: column;
    }
    
    body[data-page="upload"] .ad-sidebar {
        display: none !important;
    }
    
    body[data-page="upload"] .main-content {
        max-width: 100%;
        margin: 0;
    }
}

/* Edit Page Responsive */
@media (min-width: 1200px) {
    body[data-page="edit"] .tool-section .container {
        max-width: 1400px;
        padding: 0 20px;
    }
}

@media (min-width: 1400px) {
    body[data-page="edit"] .tool-section .container {
        max-width: 1600px;
        padding: 0 30px;
    }
}