/* 
 * Fix Sidebar Width and Ad Container 
 * Assicura larghezza minima 320px per contenere banner 300x250 
 */

/* Sidebar width fix - Forza larghezza 320px su desktop */
@media (min-width: 768px) {
    aside[class*="min-w-"],
    aside.sidebar,
    .sidebar,
    aside {
        min-width: 320px !important;
        width: 320px !important;
        max-width: 320px !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        padding: 1rem 0.5rem !important; /* Ridotto da 1.5rem per lasciare spazio ai banner */
    }
    
    /* Forza larghezza specifica per tutti i selettori Tailwind */
    aside.min-w-\[320px\],
    aside.w-\[320px\],
    aside.min-w-\[300px\],
    aside.w-\[300px\] {
        min-width: 320px !important;
        width: 320px !important;
        max-width: 320px !important;
    }
    
    /* Container principale - assicura che non si restringa troppo */
    main.max-w-screen-2xl {
        max-width: 1536px !important;
    }
    
    
    /* HOMEPAGE LAYOUT FIX - forza sidebar a comparire */
    .content-with-sidebar {
        display: flex !important;
        flex-direction: row !important;
        gap: 2rem !important;
        width: 100% !important;
    }
    
    .content-with-sidebar .main-content {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .content-with-sidebar .sidebar {
        width: 320px !important;
        min-width: 320px !important;
        max-width: 320px !important;
        flex-shrink: 0 !important;
    }
    
}

/* Responsive - mobile sidebar sotto */
@media (max-width: 1023px) {
    .content-with-sidebar {
        flex-direction: column !important;
    }
    
    .content-with-sidebar .sidebar {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        order: 2 !important;
    }
    
    .content-with-sidebar .main-content {
        order: 1 !important;
    }
}

    
    /* Assicura che gli articoli correlati non vengano compressi */
    .content-with-sidebar .main-content article,
    .content-with-sidebar .main-content .social-sharing-section,
    .content-with-sidebar .main-content aside {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Grid degli articoli correlati - mantieni layout corretto */
    .content-with-sidebar .main-content .grid {
        width: 100% !important;
        max-width: 100% !important;
        display: grid !important;
    }
    
    /* Articoli correlati - layout grid responsive */
    .content-with-sidebar .main-content .grid.grid-cols-1.md\\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
    
    @media (min-width: 768px) {
        .content-with-sidebar .main-content .grid.grid-cols-1.md\\:grid-cols-3 {
            grid-template-columns: repeat(3, 1fr) !important;
        }
    }
}

/* Widget ad containers - Spazio completo per banner 300x250 */
.adhubmedia-ad-widget .widget-content {
    width: 300px !important;
    max-width: 300px !important;
    min-width: 300px !important;
    margin: 0 auto;
    overflow: visible !important;
    padding: 0 !important;
}

/* Assicura spazio per tutti i widget nella sidebar */
@media (min-width: 768px) {
    .sidebar .widget,
    aside .widget {
        width: 100% !important;
        max-width: 310px !important; /* 320px sidebar - 10px margini = 310px disponibili */
        margin: 0 auto 2rem auto !important;
        padding: 0 !important;
    }
    
    .sidebar .widget-content,
    aside .widget-content {
        width: 100% !important;
        max-width: 310px !important;
        margin: 0 auto !important;
        padding: 0 !important;
        overflow: visible !important;
    }
}

.adhubmedia-ad-widget .widget-content > div {
    width: 300px !important;
    max-width: 300px !important;
    min-width: 300px !important;
    margin: 0 auto;
    overflow: visible !important;
    padding: 0 !important;
}

/* Tutti i tipi di banner ads - forza dimensioni corrette */
.widget-content,
.sidebar .widget,
.sidebar .widget-content {
    box-sizing: border-box !important;
    overflow: visible !important;
}

/* Container ads specifici */
div[id*="widget"],
div[class*="widget"],
div[class*="ad"] {
    box-sizing: border-box !important;
    overflow: visible !important;
}

/* Standard ad sizes */
.adhubmedia-ad-widget iframe,
.adhubmedia-ad-widget ins,
.adhubmedia-ad-widget .adsbygoogle {
    max-width: 300px !important;
    width: 100% !important;
    height: auto !important;
    display: block !important;
    margin: 0 auto !important;
}

/* AdSense responsive fix */
.adhubmedia-ad-widget .adsbygoogle[data-ad-format="auto"] {
    max-width: 300px !important;
    width: 300px !important;
}

/* Prevent content overflow */
.sidebar .widget {
    overflow: hidden;
    word-wrap: break-word;
}

.sidebar .widget-content * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Menu visibility protection */
.site-header {
    position: relative !important;
    z-index: 999 !important;
}

.site-header .menu-container,
.site-header .desktop-menu,
.site-header nav {
    position: relative !important;
    z-index: 1000 !important;
}

/* Dark mode toggle button visibility protection */
#darkToggle,
#darkToggleMobile,
button[id*="darkToggle"] {
    position: relative !important;
    z-index: 1001 !important;
    visibility: visible !important;
    opacity: 1 !important;
    display: flex !important;
}

/* Hide dark mode button only on mobile when it should be hidden */
@media (max-width: 767px) {
    #darkToggle {
        display: none !important;
    }
}

/* Show dark mode button on desktop */
@media (min-width: 768px) {
    #darkToggle {
        display: flex !important;
    }
}

/* Force desktop navigation to be visible on desktop screens */
@media (min-width: 768px) {
    nav#main-navigation {
        display: flex !important;
        flex: 1 !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    nav#main-navigation ul {
        display: flex !important;
        visibility: visible !important;
    }
    
    nav#main-navigation li {
        display: list-item !important;
        visibility: visible !important;
    }
    
    nav#main-navigation a {
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Fix article content layout in sidebar context */
.content-with-sidebar .main-content .prose,
.content-with-sidebar .main-content .prose-lg {
    width: 100% !important;
    max-width: 100% !important;
}

/* Ensure 728x90 ads are not constrained by main content width */
.content-with-sidebar .main-content .adhub-ad-728x90,
.content-with-sidebar .main-content .adhub-ad-container.adhub-ad-728x90,
.content-with-sidebar .main-content .adhub-ad-leaderboard {
    width: 100% !important;
    max-width: 728px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Ensure leaderboard ads have sufficient width on desktop */
@media (min-width: 768px) {
    .adhub-ad-728x90,
    .adhub-ad-container.adhub-ad-728x90,
    .adhub-ad-leaderboard {
        min-width: 728px !important;
        width: 100% !important;
        max-width: 728px !important;
    }
    
    /* If inside content area, ensure proper centering */
    .content-with-sidebar .main-content .adhub-ad-728x90,
    .content-with-sidebar .main-content .adhub-ad-container.adhub-ad-728x90,
    .content-with-sidebar .main-content .adhub-ad-leaderboard {
        width: 100% !important;
        max-width: 728px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Ensure related articles section displays properly */
.content-with-sidebar .main-content aside[role="complementary"] {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Ensure article cards in related section have proper spacing */
.content-with-sidebar .main-content aside[role="complementary"] .grid > * {
    width: 100% !important;
    max-width: 100% !important;
}

/* Fix all ad placements across all page types */

/* Header ads - full width centered */
.adhub-ad-header_ad,
.adhub-ad-container.adhub-ad-header_ad {
    width: 100% !important;
    max-width: 970px !important;
    margin: 20px auto !important;
    text-align: center !important;
    display: block !important;
}

/* Footer ads - semplificato e pulito */
.footer-ads-container {
    width: 100%;
    text-align: center;
    margin: 10px 0;
    padding: 0;
}

.adhub-ad-footer_ad,
.adhub-ad-container.adhub-ad-footer_ad {
    width: 728px;
    height: 90px;
    margin: 0 auto;
    display: block;
    background: transparent;
}

.adhub-ad-footer_ad *,
.adhub-ad-container.adhub-ad-footer_ad * {
    width: 728px !important;
    height: 90px !important;
    margin: 0 auto !important;
    display: block !important;
}

/* Footer ads responsive - mobile */
@media (max-width: 767px) {
    .adhub-ad-footer_ad,
    .adhub-ad-container.adhub-ad-footer_ad {
        width: 320px;
        height: 50px;
    }
    
    .adhub-ad-footer_ad *,
    .adhub-ad-container.adhub-ad-footer_ad * {
        width: 320px !important;
        height: 50px !important;
    }
}

/* Fix back-to-top button position */
#back-to-top {
    position: fixed !important;
    bottom: 1.5rem !important;
    right: 1.5rem !important;
    z-index: 999 !important;
    margin: 0 !important;
    padding: 0.75rem !important;
}

/* Remove any extra space after footer */
footer {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Body margin reset */
body {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* HTML margin reset */
html {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    min-height: 100% !important;
    height: auto !important;
}

/* Full page height fix - remove any forced heights */
html, body {
    overflow-x: hidden !important;
}

/* Remove any min-height forcing extra space */
body, #page, main, .wp-site-blocks {
    min-height: auto !important;
}

/* WordPress admin bar compensation */
html.admin-bar body {
    margin-top: 0 !important;
}

/* Remove any viewport height issues */
.wp-block-group,
.entry-content {
    min-height: auto !important;
}

/* Force remove all possible bottom spacing */
* {
    margin-bottom: 0 !important;
}

/* Re-enable necessary margins for content */
p, h1, h2, h3, h4, h5, h6, div.widget, article {
    margin-bottom: 1rem !important;
}

/* Specific footer spacing fixes */
footer, footer * {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Page end fix */
body::after,
html::after {
    content: none !important;
    display: none !important;
}

/* Last element specific */
body > *:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* WordPress specific footer spacing fix */
.wp-site-blocks, .wp-block-group, 
#page, .site, .site-content,
.entry-content, .wp-block-post-content {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Simple footer positioning */
footer[role="contentinfo"] {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Floor ads (mobile sticky bottom) */
.adhub-ad-floor_ad,
.adhub-ad-container.adhub-ad-floor_ad {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 999 !important;
    width: 100% !important;
    max-width: 320px !important;
    height: 50px !important;
    margin: 0 auto !important;
    text-align: center !important;
    display: none !important;
}

@media (max-width: 767px) {
    .adhub-ad-floor_ad,
    .adhub-ad-container.adhub-ad-floor_ad {
        display: block !important;
    }
}

/* Video player sticky ads - minimal styling, script gestisce il posizionamento */
.adhub-ad-videoplayer_sticky_ad,
.adhub-ad-container.adhub-ad-videoplayer_sticky_ad {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* In-content and after-content ads */
.adhub-ad-in_content_ad,
.adhub-ad-after_content_ad,
.adhub-ad-container.adhub-ad-in_content_ad,
.adhub-ad-container.adhub-ad-after_content_ad {
    width: 100% !important;
    max-width: 728px !important;
    margin: 30px auto !important;
    text-align: center !important;
    display: block !important;
}

/* All banner format fixes - ensure proper display */

/* 300x250 Medium Rectangle */
.adhub-ad-300x250,
.adhub-ad-container.adhub-ad-300x250 {
    width: 300px !important;
    max-width: 300px !important;
    min-width: 300px !important;
    height: 250px !important;
    margin: 15px auto !important;
    display: block !important;
    text-align: center !important;
}

/* 300x600 Half Page */
.adhub-ad-300x600,
.adhub-ad-container.adhub-ad-300x600 {
    width: 300px !important;
    max-width: 300px !important;
    min-width: 300px !important;
    height: 600px !important;
    margin: 15px auto !important;
    display: block !important;
    text-align: center !important;
}

/* 320x50 Mobile Banner */
.adhub-ad-320x50,
.adhub-ad-container.adhub-ad-320x50 {
    width: 320px !important;
    max-width: 320px !important;
    min-width: 320px !important;
    height: 50px !important;
    margin: 15px auto !important;
    display: block !important;
    text-align: center !important;
}

/* 160x600 Skyscraper */
.adhub-ad-160x600,
.adhub-ad-container.adhub-ad-160x600 {
    width: 160px !important;
    max-width: 160px !important;
    min-width: 160px !important;
    height: 600px !important;
    margin: 15px auto !important;
    display: block !important;
    text-align: center !important;
}

/* Mobile responsive adjustments for all banner formats */
@media (max-width: 767px) {
    .adhub-ad-300x600,
    .adhub-ad-container.adhub-ad-300x600,
    .adhub-ad-160x600,
    .adhub-ad-container.adhub-ad-160x600 {
        width: 300px !important;
        max-width: 300px !important;
        min-width: 300px !important;
        height: 250px !important;
    }
    
    .adhub-ad-728x90,
    .adhub-ad-container.adhub-ad-728x90,
    .adhub-ad-leaderboard {
        width: 320px !important;
        max-width: 320px !important;
        min-width: 320px !important;
        height: 50px !important;
    }
}

/* Archive and listing pages fixes */
.archive .adhub-ad-container,
.category .adhub-ad-container,
.tag .adhub-ad-container,
.search .adhub-ad-container,
.home .adhub-ad-container {
    margin: 2rem auto !important;
}

/* Ensure iframe and ad content fit properly */
.adhub-ad-container iframe,
.adhub-ad-container ins,
.adhub-ad-container .adsbygoogle {
    max-width: 100% !important;
    width: 100% !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Widget ad fixes in sidebar */
.sidebar .adhubmedia-ad-space-widget,
.sidebar .widget_adhubmedia_ad_space {
    width: 100% !important;
    max-width: 310px !important;
    margin: 0 auto 2rem auto !important;
}

.sidebar .adhubmedia-ad-space-widget .widget-content,
.sidebar .widget_adhubmedia_ad_space .widget-content {
    width: 300px !important;
    max-width: 300px !important;
    margin: 0 auto !important;
    text-align: center !important;
}

/* Ad space widget placeholder styling */
.adhubmedia-ad-space-placeholder {
    width: 300px !important;
    max-width: 300px !important;
    height: 250px !important;
    margin: 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    border: 2px dashed #e5e7eb !important;
    border-radius: 8px !important;
    background-color: #f9fafb !important;
    color: #6b7280 !important;
}

.adhubmedia-ad-space-placeholder:is(.dark *) {
    border-color: #374151 !important;
    background-color: #1f2937 !important;
    color: #9ca3af !important;
}

/* Footer Widget Styling */
.footer-widget-area {
    width: 100% !important;
}

.footer-widget {
    color: #d1d5db !important; /* text-gray-300 */
    margin-bottom: 2rem !important;
}

/* Footer Full Width Widget Area - layout essenziale senza override di stili */
.footer-full-width-area {
    width: 100%;
    clear: both;
}

/* Esclude l'area full-width dagli override generici dei widget */
.footer-full-width-area .widget {
    width: auto !important;
    max-width: none !important;
    overflow: visible !important;
    box-sizing: content-box !important;
}

.footer-full-width-area .widget * {
    width: auto !important;
    max-width: none !important;
}

.footer-widget:last-child {
    margin-bottom: 0 !important;
}

.footer-widget .widget-title {
    color: #60a5fa !important; /* text-blue-400 */
    font-size: 1.125rem !important; /* text-lg */
    font-weight: 600 !important; /* font-semibold */
    margin-bottom: 1rem !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

.footer-widget a {
    color: #9ca3af !important; /* text-gray-400 */
    transition: color 0.2s ease !important;
    text-decoration: none !important;
}

.footer-widget a:hover {
    color: #ffffff !important; /* text-white */
    text-decoration: underline !important;
}

/* Footer brand widget specific */
.footer-widget h3 {
    color: #ffffff !important;
    font-size: 2rem !important;
    font-weight: 700 !important;
    margin-bottom: 0.75rem !important;
}

.footer-widget p {
    color: #d1d5db !important;
    font-size: 1.125rem !important;
    line-height: 1.625 !important;
    margin-bottom: 1rem !important;
    max-width: 28rem !important; /* max-w-md */
}

/* Footer social links */
.footer-widget .flex {
    display: flex !important;
    gap: 1rem !important;
}

.footer-widget svg {
    width: 1.5rem !important;
    height: 1.5rem !important;
}

/* Footer navigation menu */
.footer-widget ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
}

.footer-widget li {
    margin: 0 !important;
    padding: 0 !important;
}

/* Footer copyright widget */
.footer-widget .text-sm {
    font-size: 0.875rem !important;
}

.footer-widget .space-y-2 > * + * {
    margin-top: 0.5rem !important;
}

/* Responsive footer grid */
@media (max-width: 767px) {
    .footer-widget-area {
        margin-bottom: 2rem;
    }
    
    .footer-widget-area:last-child {
        margin-bottom: 0;
    }
    
    .footer-widget p {
        max-width: 100% !important;
    }
}

/* Isolate ad content to prevent JS conflicts */
.adhubmedia-ad-widget {
    isolation: isolate;
}

.adhubmedia-ad-widget iframe {
    pointer-events: auto;
    position: relative;
    z-index: 1;
}

/* Fix potential layout breaks from ad code */
.sidebar .widget-content script {
    display: block !important;
}

.sidebar .widget-content > script + * {
    clear: both;
    display: block;
}

/* Skin Ads - should not take up visual space in layout */
.adhub-ad-skin_ad,
.adhub-ad-container.adhub-ad-skin_ad {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    pointer-events: none !important;
    z-index: -10 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    overflow: hidden !important;
}

/* Allow clicks on the actual ad content inside skin ads */
.adhub-ad-skin_ad * {
    pointer-events: auto !important;
}

/* Generic ad container fixes to prevent layout breaks */
.adhub-ad-container {
    max-width: 100% !important;
    box-sizing: border-box !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Remove any inherited background styles from all ad containers */
.adhub-ad-container,
.adhub-ad-container > *,
.adhub-ad-content {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* Specific ad position fixes */
.adhub-ad-header_ad,
.adhub-ad-container.adhub-ad-header_ad {
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    margin: 0 auto !important;
}

.adhub-ad-mobile_top_ad,
.adhub-ad-container.adhub-ad-mobile_top_ad {
    width: 100% !important;
    max-width: 320px !important;
    height: 50px !important;
    margin: 0 auto !important;
    text-align: center !important;
}

/* Leaderboard Banner 728x90 fixes */
.adhub-ad-728x90,
.adhub-ad-container.adhub-ad-728x90,
.adhub-ad-leaderboard {
    width: 100% !important;
    max-width: 728px !important;
    height: 90px !important;
    margin: 15px auto !important;
    text-align: center !important;
    display: block !important;
    overflow: visible !important;
}

.adhub-ad-728x90 iframe,
.adhub-ad-728x90 ins,
.adhub-ad-728x90 .adsbygoogle,
.adhub-ad-container.adhub-ad-728x90 iframe,
.adhub-ad-container.adhub-ad-728x90 ins,
.adhub-ad-container.adhub-ad-728x90 .adsbygoogle {
    max-width: 728px !important;
    width: 100% !important;
    height: 90px !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Mobile responsive for 728x90 banners */
@media (max-width: 767px) {
    .adhub-ad-728x90,
    .adhub-ad-container.adhub-ad-728x90,
    .adhub-ad-leaderboard {
        max-width: 320px !important;
        height: 50px !important;
    }
    
    .adhub-ad-728x90 iframe,
    .adhub-ad-728x90 ins,
    .adhub-ad-728x90 .adsbygoogle,
    .adhub-ad-container.adhub-ad-728x90 iframe,
    .adhub-ad-container.adhub-ad-728x90 ins,
    .adhub-ad-container.adhub-ad-728x90 .adsbygoogle {
        max-width: 320px !important;
        height: 50px !important;
    }
}