/**
 * Mud Ads Div - 广告插件样式
 * 响应式设计，兼容各种WordPress主题
 */

/* Universal fix for Google AdSense No slot size error */
/* 确保所有 Mud Ads Div 广告容器都可见并有基本尺寸 */
.mud-ads-div-ad-content,
.mud-ads-div-google-ads {
    display: block !important; /* 强制显示为块级元素 */
    width: 100% !important;    /* 强制占据所有可用宽度 */
    max-width: 100% !important; /* 确保不超过父容器 */
    height: auto !important; /* 允许高度自适应 */
    min-height: 50px !important; /* 确保最小高度 */
    text-align: center !important; /* 居中广告内容 */
    overflow: hidden !important; /* 防止内容溢出 */
    box-sizing: border-box !important; /* 确保 padding/border 不会增加总宽度 */
    margin: 15px auto !important; /* 居中广告容器并提供外边距 */
    padding: 0 !important; /* 移除内边距，防止影响 AdSense 自身的布局 */
    background: transparent !important; /* 防止任何不必要的背景色 */
    border: none !important; /* 移除边框，防止影响 AdSense 自身的布局 */
    clear: both !important; /* 清除浮动，确保独立行 */
    float: none !important; /* 强制不浮动，解决布局偏移问题 */
    position: static !important; /* 强制静态定位，防止绝对/相对定位引起的布局问题 */
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Google AdSense 特殊样式 */
.mud-ads-div-google-ads {
    background-color: transparent;
    border: none;
}

/* 首页广告样式 */
#mud-ads-div-homepage-top,
#mud-ads-div-homepage-middle,
#mud-ads-div-homepage-bottom,
#mud-ads-div-homepage-bottom-footer {
    width: 100%;
    max-width: 100%;
    margin: 20px auto !important; /* 强制居中 */
    padding: 15px;
    box-sizing: border-box;
    clear: both !important; /* 清除浮动 */
    text-align: center !important; /* 居中内容 */
}

#mud-ads-div-homepage-top {
    border-bottom: 1px solid #eee;
    margin-bottom: 30px;
}

#mud-ads-div-homepage-middle {
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    margin: 30px auto;
}

#mud-ads-div-homepage-bottom {
    border-top: 1px solid #eee;
    margin-top: 30px;
}

/* 分类页广告样式 */
#mud-ads-div-category-top,
#mud-ads-div-category-middle,
#mud-ads-div-category-bottom {
    width: 100%;
    max-width: 100%;
    margin: 20px auto;
    padding: 15px;
    box-sizing: border-box;
}

#mud-ads-div-category-top {
    margin-bottom: 25px;
}

#mud-ads-div-category-middle {
    margin: 25px auto;
}

#mud-ads-div-category-bottom {
    margin-top: 25px;
}

/* 文章页广告样式 */
.mud-ads-div-post-ad {
    width: 100%;
    margin: 25px 0;
    padding: 15px;
    text-align: center;
    box-sizing: border-box;
}

/* 侧边栏广告样式 */
#mud-ads-div-sidebar-middle {
    width: 100%;
    margin: 20px 0;
    padding: 10px;
    text-align: center;
    box-sizing: border-box;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
    .mud-ads-div-ad-content,
    .mud-ads-div-google-ads {
        margin: 10px 0;
        padding: 8px;
    }
    
    #mud-ads-div-homepage-top,
    #mud-ads-div-homepage-middle,
    #mud-ads-div-homepage-bottom,
    #mud-ads-div-homepage-bottom-footer,
    #mud-ads-div-category-top,
    #mud-ads-div-category-middle,
    #mud-ads-div-category-bottom {
        margin: 15px auto;
        padding: 10px;
    }
    
    .mud-ads-div-post-ad {
        margin: 15px 0;
        padding: 10px;
    }
    
    #mud-ads-div-sidebar-middle {
        margin: 15px 0;
        padding: 8px;
    }
}

@media screen and (max-width: 480px) {
    .mud-ads-div-ad-content,
    .mud-ads-div-google-ads {
        margin: 8px 0;
        padding: 5px;
    }
    
    #mud-ads-div-homepage-top,
    #mud-ads-div-homepage-middle,
    #mud-ads-div-homepage-bottom,
    #mud-ads-div-homepage-bottom-footer,
    #mud-ads-div-category-top,
    #mud-ads-div-category-middle,
    #mud-ads-div-category-bottom {
        margin: 10px auto;
        padding: 8px;
    }
    
    .mud-ads-div-post-ad {
        margin: 10px 0;
        padding: 8px;
    }
    
    #mud-ads-div-sidebar-middle {
        margin: 10px 0;
        padding: 5px;
    }
}

/* 主题兼容性 */
/* 确保广告不会被主题样式覆盖 */
.mud-ads-div-ad-content * {
    max-width: 100% !important;
    height: auto !important;
}

.mud-ads-div-google-ads * {
    max-width: 100% !important;
}

/* 清除浮动 */
.mud-ads-div-ad-content:after,
.mud-ads-div-google-ads:after {
    content: "";
    display: table;
    clear: both;
}

/* 确保广告在各种主题中都能正确显示 */
.mud-ads-div-homepage-ad,
.mud-ads-div-category-ad,
.mud-ads-div-post-ad,
.mud-ads-div-sidebar-ad {
    position: relative;
    z-index: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 防止广告内容溢出 */
.mud-ads-div-ad-content,
.mud-ads-div-google-ads {
    overflow: hidden;
    word-wrap: break-word;
}

/* 确保 Google AdSense 广告单元本身有正确的尺寸和可见性 */
.mud-ads-div-google-ads ins.adsbygoogle {
    display: block !important; /* 强制 AdSense ins 标签显示为块级元素 */
    width: 100% !important;    /* 强制 AdSense ins 标签占据可用宽度 */
    min-height: 50px !important; /* 强制 AdSense ins 标签有最小高度 */
    margin: 0 auto !important; /* 居中 AdSense ins 标签 */
    background: transparent !important; /* 防止任何不必要的背景色 */
}

/* 确保 Google AdSense 广告单元本身有正确的尺寸和可见性 */
#mud-ads-div-homepage-top ins.adsbygoogle {
    margin: 0 auto !important; /* 居中 AdSense ins 标签 */
    display: block !important; /* 强制 AdSense ins 标签显示为块级元素 */
}

/* 适配深色主题 */
@media (prefers-color-scheme: dark) {
    #mud-ads-div-sidebar-middle {
        background-color: #2d2d2d;
        border-color: #444;
        color: #fff;
    }
}

/* 打印时隐藏广告 */
@media print {
    .mud-ads-div-ad-content,
    .mud-ads-div-google-ads,
    .mud-ads-div-homepage-ad,
    .mud-ads-div-category-ad,
    .mud-ads-div-post-ad,
    .mud-ads-div-sidebar-ad {
        display: none !important;
    }
}

/* 确保在不同的容器宽度下都能正确显示 */
.mud-ads-div-ad-content img,
.mud-ads-div-google-ads img {
    max-width: 100%;
    height: auto;
}

/* RTL语言支持 */
.rtl .mud-ads-div-ad-content,
.rtl .mud-ads-div-google-ads {
    direction: rtl;
    text-align: center;
}
