/**
 * 半糖书屋 - 广告样式
 * 开屏广告、内容广告、横幅广告、浮动广告等
 * VIP用户自动隐藏所有广告
 */

/* ========================================
   开屏广告（弹窗样式）
   ======================================== */
.splash-ad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.splash-ad-overlay.show {
    display: flex;
    opacity: 1;
}

/* 广告显示时禁止页面滚动 */
body.ad-modal-open {
    overflow: hidden;
}

.splash-ad-overlay.hiding {
    opacity: 0;
}

.splash-ad-container {
    position: relative;
    max-width: 600px;
    width: 90%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: splashSlideIn 0.3s ease;
}

@keyframes splashSlideIn {
    from {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.splash-ad-overlay.hiding .splash-ad-container {
    animation: splashSlideOut 0.3s ease;
}

@keyframes splashSlideOut {
    from {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    to {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
}

/* 真关闭按钮 - 左上角倒计时 + x */
.splash-ad-close {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s ease;
}

.splash-ad-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.splash-ad-close .countdown {
    font-weight: 600;
    color: #fff;
}

.splash-ad-close .close-icon {
    font-size: 14px;
    margin-left: 2px;
}

/* 假关闭按钮 - 右上角（诱导点击跳转广告） */
.splash-ad-fake-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.splash-ad-fake-close:hover {
    background: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.9);
}

.splash-ad-fake-close i {
    line-height: 1;
}

/* 广告图片区域 */
.splash-ad-content {
    width: 100%;
    min-height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #e8f4f8 0%, #f0f8ff 100%);
    cursor: pointer;
    overflow: hidden;
}

.splash-ad-content img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* EagleX 开屏广告容器 */
.splash-ad-content > div {
    width: 100%;
    height: 100%;
}

/* 占位符样式（未接入真实广告时显示） */
.splash-ad-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #999;
}

.splash-ad-placeholder i {
    font-size: 48px;
    color: #ccc;
}

.splash-ad-placeholder span {
    font-size: 14px;
}

/* ========================================
   内容广告（阅读页段落间）
   ======================================== */
.content-ad {
    margin: 24px 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 8px);
    text-align: center;
    overflow: hidden;
}

/* 内容广告加载前的占位样式 */
.content-ad:not(.eaglex-loaded):not(.own-ad-loaded) {
    padding: 16px;
    background: linear-gradient(135deg, #fffef5 0%, #fff9e6 100%);
    border: 1px solid rgba(210, 180, 140, 0.3);
}

/* EagleX 内容广告加载成功后的样式 */
.content-ad.eaglex-loaded {
    padding: 0;
    background: transparent;
    border: none;
}

/* EagleX 内容广告容器 */
.eaglex-content-container {
    width: 100%;
    min-height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.content-ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 80px;
    color: var(--text-light, #999);
}

.content-ad-placeholder i {
    font-size: 24px;
}

.content-ad-badge {
    margin-left: auto;
    padding: 2px 8px;
    background: rgba(196, 139, 74, 0.1);
    border-radius: 4px;
    font-size: 12px;
    color: var(--primary-color, #c48b4a);
}

/* ========================================
   横幅广告
   ======================================== */
.banner-ad {
    margin: 16px auto;
    padding: 0;
    max-width: 1200px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 8px);
    text-align: center;
    overflow: hidden;
}

/* 横幅广告加载前的占位样式 */
.banner-ad:not(.eaglex-loaded):not(.own-ad-loaded) {
    padding: 14px;
    background: linear-gradient(135deg, #fffef5 0%, #fff9e6 100%);
    border: 1px solid rgba(210, 180, 140, 0.2);
}

/* EagleX 横幅广告加载成功后的样式 */
.banner-ad.eaglex-loaded {
    padding: 0;
    background: transparent;
    border: none;
}

.banner-ad-container {
    position: relative;
}

/* EagleX 横幅广告容器 */
.eaglex-banner-container {
    width: 100%;
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.banner-ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
    color: var(--text-light, #999);
    font-size: 13px;
}

.banner-ad-placeholder i {
    font-size: 24px;
}

.banner-ad-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    font-size: 11px;
    color: #666;
}

/* ========================================
   浮动广告（右下角）
   ======================================== */
.floating-ad {
    position: fixed;
    z-index: 9998;
    display: none;
    background: #fff;
    border-radius: var(--radius-sm, 8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.floating-ad.bottom-right {
    bottom: 20px;
    right: 20px;
    transform: translateY(20px);
}

.floating-ad.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.floating-ad.hiding {
    opacity: 0;
    transform: translateY(20px);
}

.floating-ad-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s ease;
}

.floating-ad-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.floating-ad-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 200px;
    height: 150px;
    padding: 16px;
    background: linear-gradient(135deg, #fffef5 0%, #fff9e6 100%);
    color: var(--text-light, #999);
    font-size: 12px;
}

.floating-ad-placeholder i {
    font-size: 28px;
    color: var(--primary-color, #c48b4a);
}

/* ========================================
   阅读页开屏广告（与 Read.cshtml 配合）
   ======================================== */
.read-body .splash-ad-overlay {
    z-index: 100000;
}

/* ========================================
   响应式适配
   ======================================== */
@media (max-width: 768px) {
    .splash-ad-container {
        width: 95%;
        max-width: none;
    }

    .splash-ad-close {
        top: 8px;
        right: 8px;
        padding: 4px 10px;
        font-size: 12px;
    }

    .floating-ad.bottom-right {
        bottom: 10px;
        right: 10px;
    }

    .floating-ad-placeholder {
        width: 160px;
        height: 120px;
    }

    .content-ad {
        margin: 16px 0;
    }

    /* 移动端加载中状态的 padding */
    .content-ad:not(.eaglex-loaded):not(.own-ad-loaded) {
        padding: 12px;
    }

    .banner-ad {
        margin: 16px;
    }

    /* 移动端加载中状态的 padding */
    .banner-ad:not(.eaglex-loaded):not(.own-ad-loaded) {
        padding: 16px;
    }
}

/* ========================================
   暗色主题适配
   ======================================== */
.theme-dark .splash-ad-container {
    background: #2a2a2a;
}

.theme-dark .splash-ad-content {
    background: linear-gradient(135deg, #333 0%, #3a3a3a 100%);
}

.theme-dark .splash-ad-placeholder {
    color: #666;
}

.theme-dark .splash-ad-placeholder i {
    color: #555;
}

.theme-dark .content-ad:not(.eaglex-loaded):not(.own-ad-loaded) {
    background: linear-gradient(135deg, #2a2a2a 0%, #333 100%);
    border-color: rgba(100, 100, 100, 0.3);
}

.theme-dark .content-ad.eaglex-loaded {
    background: transparent;
    border: none;
}

.theme-dark .content-ad-placeholder {
    color: #666;
}

.theme-dark .floating-ad {
    background: #2a2a2a;
}

.theme-dark .floating-ad-placeholder {
    background: linear-gradient(135deg, #2a2a2a 0%, #333 100%);
    color: #666;
}

.theme-dark .banner-ad:not(.eaglex-loaded):not(.own-ad-loaded) {
    background: linear-gradient(135deg, #2a2a2a 0%, #333 100%);
    border-color: rgba(100, 100, 100, 0.2);
}

.theme-dark .banner-ad.eaglex-loaded {
    background: transparent;
    border: none;
}

/* ========================================
   自有广告样式
   ======================================== */

/* 自有广告通用容器 */
.own-ad-container {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-sm, 8px);
    background: linear-gradient(135deg, #fffef5 0%, #fff9e6 100%);
}

.own-ad-link {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.own-ad-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.own-ad-link:hover .own-ad-image {
    transform: scale(1.02);
}

/* 广告信息层 */
.own-ad-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.own-ad-title {
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.own-ad-desc {
    font-size: 12px;
    opacity: 0.9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 广告标识角标 */
.own-ad-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    font-size: 11px;
    color: #fff;
    z-index: 5;
}

/* ========================================
   开屏自有广告样式
   ======================================== */
.own-ad-splash {
    max-width: 600px;
    margin: 0 auto;
}

.own-ad-splash .own-ad-image {
    max-height: 450px;
    object-fit: contain;
    background: #000;
}

.own-ad-splash .own-ad-info {
    padding: 16px 20px;
}

.own-ad-splash .own-ad-title {
    font-size: 16px;
}

.own-ad-splash .own-ad-desc {
    font-size: 13px;
}

/* ========================================
   横幅自有广告样式
   ======================================== */
.own-ad-banner {
    max-height: 200px;
}

.own-ad-banner .own-ad-image {
    max-height: 200px;
    object-fit: cover;
}

.own-ad-banner .own-ad-info {
    padding: 10px 14px;
}

/* 横幅广告容器自有广告成功状态 */
.banner-ad.own-ad-loaded {
    padding: 0;
    background: transparent;
    border: none;
}

/* ========================================
   内容自有广告样式
   ======================================== */
.own-ad-content {
    max-height: 150px;
}

.own-ad-content .own-ad-image {
    max-height: 150px;
    object-fit: cover;
}

.own-ad-content .own-ad-info {
    padding: 8px 12px;
}

.own-ad-content .own-ad-title {
    font-size: 13px;
}

.own-ad-content .own-ad-desc {
    font-size: 11px;
}

/* 内容广告容器自有广告成功状态 */
.content-ad.own-ad-loaded {
    padding: 0;
    background: transparent;
    border: none;
}

/* ========================================
   自有广告响应式适配
   ======================================== */
@media (max-width: 768px) {
    .own-ad-splash .own-ad-image {
        max-height: 350px;
    }

    .own-ad-splash .own-ad-info {
        padding: 12px 16px;
    }

    .own-ad-splash .own-ad-title {
        font-size: 14px;
    }

    .own-ad-splash .own-ad-desc {
        font-size: 12px;
    }

    .own-ad-banner {
        max-height: 150px;
    }

    .own-ad-banner .own-ad-image {
        max-height: 150px;
    }

    .own-ad-content {
        max-height: 120px;
    }

    .own-ad-content .own-ad-image {
        max-height: 120px;
    }

    .own-ad-info {
        padding: 8px 12px;
    }

    .own-ad-title {
        font-size: 12px;
    }

    .own-ad-desc {
        font-size: 11px;
    }

    .own-ad-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* ========================================
   自有广告暗色主题适配
   ======================================== */
.theme-dark .own-ad-container {
    background: linear-gradient(135deg, #2a2a2a 0%, #333 100%);
}

.theme-dark .own-ad-badge {
    background: rgba(255, 255, 255, 0.2);
}

.theme-dark .banner-ad.own-ad-loaded,
.theme-dark .content-ad.own-ad-loaded {
    background: transparent;
    border: none;
}
