 /* 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;
    }
}
 
 / *   R E S P O N S I V E   B A N N E R   A D   I M P R O V E M E N T S   * / 
 
 / *   O v e r r i d e   f i x e d   b a n n e r   a d   s i z e s   w i t h   r e s p o n s i v e   o n e s   * / 
 . a d - t o p - b a n n e r   . a d s b y g o o g l e [ s t y l e * = " w i d t h : 7 2 8 p x " ]   { 
         w i d t h :   1 0 0 %   ! i m p o r t a n t ; 
         m a x - w i d t h :   7 2 8 p x   ! i m p o r t a n t ; 
         h e i g h t :   a u t o   ! i m p o r t a n t ; 
         m i n - h e i g h t :   9 0 p x   ! i m p o r t a n t ; 
 } 
 
 / *   E n h a n c e d   r e s p o n s i v e   b a n n e r   a d   s i z i n g   * / 
 @ m e d i a   ( m i n - w i d t h :   7 6 8 p x )   { 
         . a d - t o p - b a n n e r   . a d s b y g o o g l e   { 
                 w i d t h :   7 2 8 p x   ! i m p o r t a n t ; 
                 h e i g h t :   9 0 p x   ! i m p o r t a n t ; 
                 m i n - h e i g h t :   9 0 p x ; 
                 m a x - w i d t h :   7 2 8 p x ; 
         } 
 } 
 
 / *   T a b l e t   -   M e d i u m   R e c t a n g l e   ( 3 3 6 x 2 8 0 )   * / 
 @ m e d i a   ( m i n - w i d t h :   4 8 1 p x )   a n d   ( m a x - w i d t h :   7 6 7 p x )   { 
         . a d - t o p - b a n n e r   { 
                 m i n - h e i g h t :   2 5 0 p x ; 
                 p a d d i n g :   2 0 p x   1 5 p x ; 
         } 
         
         . a d - t o p - b a n n e r   . a d s b y g o o g l e   { 
                 w i d t h :   3 3 6 p x   ! i m p o r t a n t ; 
                 h e i g h t :   2 8 0 p x   ! i m p o r t a n t ; 
                 m i n - h e i g h t :   2 8 0 p x ; 
                 m a x - w i d t h :   3 3 6 p x ; 
         } 
 } 
 
 / *   M o b i l e   -   L a r g e   M o b i l e   B a n n e r   ( 3 2 0 x 1 0 0 )   * / 
 @ m e d i a   ( m a x - w i d t h :   4 8 0 p x )   { 
         . a d - t o p - b a n n e r   { 
                 m i n - h e i g h t :   1 0 0 p x ; 
                 p a d d i n g :   1 5 p x   1 0 p x ; 
                 m a r g i n - b o t t o m :   2 0 p x ; 
         } 
         
         . a d - t o p - b a n n e r   . a d s b y g o o g l e   { 
                 w i d t h :   3 2 0 p x   ! i m p o r t a n t ; 
                 h e i g h t :   1 0 0 p x   ! i m p o r t a n t ; 
                 m i n - h e i g h t :   1 0 0 p x ; 
                 m a x - w i d t h :   3 2 0 p x ; 
         } 
 } 
 
 / *   S m a l l   M o b i l e   -   M o b i l e   B a n n e r   ( 3 2 0 x 5 0 )   * / 
 @ m e d i a   ( m a x - w i d t h :   3 6 0 p x )   { 
         . a d - t o p - b a n n e r   { 
                 m i n - h e i g h t :   5 0 p x ; 
                 p a d d i n g :   1 0 p x   5 p x ; 
         } 
         
         . a d - t o p - b a n n e r   . a d s b y g o o g l e   { 
                 w i d t h :   3 2 0 p x   ! i m p o r t a n t ; 
                 h e i g h t :   5 0 p x   ! i m p o r t a n t ; 
                 m i n - h e i g h t :   5 0 p x ; 
                 m a x - w i d t h :   3 0 0 p x ; 
         } 
 }  
 

/* OPTIMIZED MOBILE-FRIENDLY AD IMPROVEMENTS */

/* Override fixed banner ad sizes with responsive ones */
.ad-top-banner .adsbygoogle[style*="width:728px"] {
    width: 100% !important;
    max-width: 728px !important;
    height: auto !important;
    min-height: 90px !important;
}

/* Desktop - Standard Leaderboard (728x90) */
@media (min-width: 768px) {
    .ad-top-banner .adsbygoogle {
        width: 728px !important;
        height: 90px !important;
        min-height: 90px;
        max-width: 728px;
    }
}

/* Tablet - Responsive Banner (adapts to screen) */
@media (min-width: 481px) and (max-width: 767px) {
    .ad-top-banner {
        min-height: 90px;
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .ad-top-banner .adsbygoogle {
        width: 100% !important;
        height: 90px !important;
        min-height: 90px;
        max-width: 468px; /* Tablet banner size */
    }
}

/* Mobile - Large Mobile Banner (320x100) */
@media (max-width: 480px) {
    .ad-top-banner {
        min-height: 100px;
        padding: 10px 5px;
        margin-bottom: 15px;
    }
    
    .ad-top-banner .adsbygoogle {
        width: 320px !important;
        height: 100px !important;
        min-height: 100px;
        max-width: 320px;
    }
}

/* Small Mobile - Mobile Banner (320x50) */
@media (max-width: 360px) {
    .ad-top-banner {
        min-height: 50px;
        padding: 8px 3px;
    }
    
    .ad-top-banner .adsbygoogle {
        width: 320px !important;
        height: 50px !important;
        min-height: 50px;
        max-width: 300px;
    }
}

/* Extra Small Mobile - Adaptive Banner */
@media (max-width: 320px) {
    .ad-top-banner {
        min-height: 50px;
        padding: 5px 2px;
    }
    
    .ad-top-banner .adsbygoogle {
        width: 300px !important;
        height: 50px !important;
        min-height: 50px;
        max-width: 280px;
    }
}

/* Mobile-specific optimizations */
@media (max-width: 767px) {
    /* Ensure ads don't cause horizontal scroll */
    .ad-top-banner {
        overflow: hidden;
        max-width: 100vw;
    }
    
    /* Better touch targets */
    .ad-top-banner .adsbygoogle {
        touch-action: manipulation;
    }
    
    /* Reduce visual clutter on mobile */
    .ad-container::before {
        font-size: 9px;
        padding: 2px 6px;
    }
}