/**
 * Alimm 子比增强插件 - 广告样式
 * 
 * @package ZibllUnified
 * @version 1.0.0
 */

/* ========================================
   广告容器基础样式
   ======================================== */

.zib-ad-container {
    margin: 20px 0;
    padding: 15px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ========================================
   广告头部（标题+按钮）
   ======================================== */

.zib-ad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px; /* 减少间距 */
    padding-bottom: 10px; /* 减少间距 */
    border-bottom: 2px solid #f0f0f0;
}

/* 小工具标题区域样式 */
.zib-widget h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
}

.zib-ad-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.zib-ad-join-btn {
    color: #333;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 2px solid #ff6b9d; /* 下划线效果 */
    padding-bottom: 2px;
    transition: all 0.3s ease;
}

.zib-ad-join-btn:hover {
    color: #ff6b9d;
    border-bottom-color: #ff6b9d;
}

.zib-ad-join-btn i {
    font-size: 14px;
}

/* ========================================
   图片广告网格布局
   ======================================== */

.zib-ad-grid {
    display: grid;
    grid-template-columns: repeat(var(--per-row, 2), 1fr);
    gap: 12px; /* 减少网格间距 */
}

@media (max-width: 768px) {
    .zib-ad-grid {
        grid-template-columns: repeat(var(--mobile-per-row, 1), 1fr);
        gap: 12px;
    }
}

/* ========================================
   单个广告项
   ======================================== */

.zib-ad-item {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    background: #f8f9fa; /* 添加浅灰色背景，与图片包装器一致 */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.zib-ad-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.zib-ad-link {
    display: block;
    text-decoration: none;
    color: inherit;
    overflow: hidden; /* 防止内容溢出 */
}

/* ========================================
   图片包装器（保持宽高比）
   ======================================== */

.zib-ad-image-wrapper {
    position: relative;
    width: 100%;
    height: 0; /* 高度由 padding-bottom 控制 */
    overflow: hidden;
    background: #f8f9fa;
    border-radius: 6px; /* 与容器圆角一致 */
}

.zib-ad-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: fill; /* 完全铺满容器，允许变形拉伸，不裁剪 */
    transition: transform 0.3s ease;
}

.zib-ad-item:hover .zib-ad-image {
    transform: scale(1.05);
}

/* ========================================
   占位符样式
   ======================================== */

.zib-ad-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    opacity: 0.8;
}

/* ========================================
   文本链接容器
   ======================================== */

.zib-text-links-container {
    margin-top: 12px; /* 减少间距，与图片网格保持一致 */
    padding-top: 12px;
    border-top: 1px dashed #e0e0e0;
}

/* ========================================
   文本链接网格
   ======================================== */

.zib-text-links-grid {
    display: grid;
    grid-template-columns: repeat(var(--per-row, 3), 1fr);
    gap: 12px; /* 与图片网格保持一致 */
}

@media (max-width: 768px) {
    .zib-text-links-grid {
        grid-template-columns: repeat(var(--mobile-per-row, 2), 1fr);
        gap: 10px;
    }
}

/* ========================================
   单个文本链接项
   ======================================== */

.zib-text-link-item {
    position: relative;
}

.zib-text-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.zib-text-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #ff6b9d;
}

/* ========================================
   图标样式
   ======================================== */

.zib-text-link i,
.zib-text-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 107, 157, 0.1);
    border-radius: 50%;
    font-size: 14px;
    color: #ff6b9d;
    flex-shrink: 0;
}

.zib-text-link i {
    font-family: 'Font Awesome 5 Free', 'FontAwesome';
    font-weight: 900;
}

/* ========================================
   文字标题
   ======================================== */

.zib-text-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========================================
   空白占位符
   ======================================== */

.zib-text-placeholder .zib-text-link {
    background: #f0f0f0;
    border: 2px dashed #ccc;
    color: #999;
    cursor: default;
}

.zib-text-placeholder .zib-text-link:hover {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #4caf50;
}

.zib-text-placeholder i {
    background: rgba(76, 175, 80, 0.1);
    color: #4caf50;
}

/* ========================================
   响应式优化
   ======================================== */

@media (max-width: 480px) {
    .zib-ad-container {
        padding: 15px;
        margin: 15px 0;
    }
    
    .zib-ad-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .zib-ad-join-btn {
        align-self: stretch;
        justify-content: center;
    }
    
    .zib-ad-title {
        font-size: 15px;
    }
    
    .zib-text-link {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .zib-text-link i,
    .zib-text-icon {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

/* ========================================
   暗色模式适配(如果主题支持)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .zib-ad-container {
        background: #1e1e1e;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .zib-ad-title {
        color: #e0e0e0;
    }
    
    .zib-ad-header {
        border-bottom-color: #333;
    }
    
    .zib-text-link {
        background: #2a2a2a;
        color: #e0e0e0;
    }
    
    .zib-text-link:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    .zib-text-placeholder .zib-text-link {
        background: #252525;
        border-color: #444;
        color: #888;
    }
    
    .zib-ad-image-wrapper {
        background: #2a2a2a;
    }
    
    .zib-text-links-container {
        border-top-color: #333;
    }
    
    /* 立即入驻按钮 - 黑夜模式 */
    .zib-ad-join-btn {
        color: #e0e0e0 !important;
        border-bottom-color: #ff6b9d !important;
    }
    
    .zib-ad-join-btn:hover {
        color: #ff6b9d !important;
    }
}

/* 子比主题黑夜模式适配 */
body.dark-theme .zib-ad-container,
body.night-mode .zib-ad-container,
html.dark .zib-ad-container {
    background: #1e1e1e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-theme .zib-ad-title,
body.night-mode .zib-ad-title,
html.dark .zib-ad-title {
    color: #e0e0e0;
}

body.dark-theme .zib-ad-header,
body.night-mode .zib-ad-header,
html.dark .zib-ad-header {
    border-bottom-color: #333;
}

body.dark-theme .zib-text-link,
body.night-mode .zib-text-link,
html.dark .zib-text-link {
    background: #2a2a2a;
    color: #e0e0e0;
}

body.dark-theme .zib-text-link:hover,
body.night-mode .zib-text-link:hover,
html.dark .zib-text-link:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-theme .zib-text-placeholder .zib-text-link,
body.night-mode .zib-text-placeholder .zib-text-link,
html.dark .zib-text-placeholder .zib-text-link {
    background: #252525;
    border-color: #444;
    color: #888;
}

body.dark-theme .zib-ad-image-wrapper,
body.night-mode .zib-ad-image-wrapper,
html.dark .zib-ad-image-wrapper {
    background: #2a2a2a;
}

body.dark-theme .zib-text-links-container,
body.night-mode .zib-text-links-container,
html.dark .zib-text-links-container {
    border-top-color: #333;
}

/* 立即入驻按钮 - 子比主题黑夜模式 */
body.dark-theme .zib-ad-join-btn,
body.night-mode .zib-ad-join-btn,
html.dark .zib-ad-join-btn {
    color: #e0e0e0 !important;
    border-bottom-color: #ff6b9d !important;
}

body.dark-theme .zib-ad-join-btn:hover,
body.night-mode .zib-ad-join-btn:hover,
html.dark .zib-ad-join-btn:hover {
    color: #ff6b9d !important;
}

/* ========================================
   动画效果
   ======================================== */

@keyframes adFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.zib-ad-container {
    animation: adFadeIn 0.4s ease-out;
}

/* ========================================
   加载状态
   ======================================== */

.zib-ad-loading {
    opacity: 0.6;
    pointer-events: none;
}

.zib-ad-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ff6b9d;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
