/* 广告系统通用变量 */
:root {
    --ad-width: 970px;
    --ad-mobile-padding: 10px;
    --ad-border-radius: var(--radius-md, 4px);
    --ad-transition: var(--transition-normal, 0.3s);
    --ad-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
    --ad-hover-shadow: var(--shadow-hover, 0 5px 15px rgba(0,0,0,0.1));
    --close-btn-size: 20px;
}

/* 通用容器样式 */
.nimad, .bba-container, .ppap.top .ad-container, .text-ad-container, .bba-grid, .menu.menu-wrap {
    width: 100%;
    max-width: var(--ad-width);
    margin: 0 auto;
}

/* 横幅广告 */
.nimad {
    display: flex;
    justify-content: center;
}

.nimad a, .abcdHF, .abcdHF1 {
    display: block;
    width: 100%;
    max-width: var(--ad-width);
}

.abcdHF { height: 60px; }
.abcdHF1 { height: 120px; }

/* 顶部文字广告 */
.text-ad-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 10px auto;
}

.text-ad-container a {
    text-decoration: none;
    width: calc(12.5% - 5px);
}

.text-ad-container a > div {
    width: 100%;
    text-align: center;
    padding: 4px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 3px;
    font-size: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.text-ad-container a:hover > div {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 底部文字广告 */
.bba-container {
    padding: 15px 0;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px auto;
}

.bba-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    padding: 0 15px;
}

.bba-grid a {
    display: block;
    text-align: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.bba-grid a:hover {
    background: #007bff;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

/* 侧边栏广告 */
.sidebar-ad {
    position: sticky;
    top: 20px;
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: var(--ad-shadow);
    margin-bottom: 20px;
}

.sidebar-ad img {
    width: 100%;
    height: auto;
    border-radius: 6px;
}

/* 弹窗广告 */
.popup-ad {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 9999;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
}

.popup-ad .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: var(--close-btn-size);
    height: var(--close-btn-size);
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    z-index: 1;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
}

/* 浮动广告 */
.float-ad {
    position: fixed;
    z-index: 1000;
    background: white;
    border-radius: 8px;
    box-shadow: var(--ad-shadow);
    padding: 10px;
    transition: var(--ad-transition);
}

.float-ad.left {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.float-ad.right {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.float-ad img {
    max-width: 120px;
    height: auto;
    border-radius: 4px;
}

/* 内容中广告 */
.content-ad {
    margin: 20px 0;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #ddd;
}

.content-ad img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

/* 响应式适配 */
@media (max-width: 768px) {
    .text-ad-container a {
        width: calc(25% - 5px);
    }
    
    .bba-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 8px;
        padding: 0 10px;
    }
    
    .float-ad {
        display: none;
    }
    
    .popup-ad {
        margin: var(--ad-mobile-padding);
        max-width: calc(100vw - 20px);
    }
    
    .sidebar-ad {
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .text-ad-container a {
        width: calc(50% - 5px);
    }
    
    .bba-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .content-ad {
        margin: 15px 0;
        padding: 10px;
    }
}

/* 广告加载动画 */
.ad-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 广告标识 */
.ad-label {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 1;
}

/* 广告容器通用样式 */
.ad-container {
    position: relative;
    overflow: hidden;
    border-radius: var(--ad-border-radius);
    transition: var(--ad-transition);
}

.ad-container:hover {
    box-shadow: var(--ad-hover-shadow);
}

/* 特殊广告位 */
.ppap {
    width: 100%;
    text-align: center;
    margin: 15px 0;
}

.ppap.top {
    margin-top: 0;
}

.ppap.bottom {
    margin-bottom: 0;
}

/* 菜单广告 */
.menu.menu-wrap {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    padding: 15px;
    margin: 20px auto;
}

.menu.menu-wrap a {
    display: inline-block;
    margin: 5px 10px;
    padding: 8px 15px;
    background: white;
    color: #333;
    text-decoration: none;
    border-radius: 20px;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.menu.menu-wrap a:hover {
    background: #007bff;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,123,255,0.3);
}
