/**
 * 广告样式 - 优化版
 * 参考淘宝联盟商品展示风格
 */

/* 广告容器 */
.ad-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: visible;
    position: relative;
}

/* 侧边栏广告 */
.ad-sidebar-title {
    padding: 12px 15px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e8e 100%);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ad-products-sidebar {
    padding: 10px;
    background: #fafafa;
    max-height: 500px;
    overflow-y: auto;
    position: relative;
}

/* 侧边栏商品项 - 卡片式布局 */
.ad-product-item {
    background: #fff;
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
}

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

.ad-product-item:last-child {
    margin-bottom: 0;
}

.ad-product-item .ad-product-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.ad-product-item .ad-product-img {
    width: 100%;
    height: 130px;
    overflow: hidden;
    position: relative;
}

.ad-product-item .ad-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.ad-product-item:hover .ad-product-img img {
    transform: scale(1.08);
}

/* 销量标签 */
.ad-product-item .sales-tag {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    color: #fff;
    font-size: 11px;
    padding: 20px 8px 6px;
    text-align: left;
}

.ad-product-item .ad-product-info {
    padding: 10px;
}

.ad-product-item .ad-product-title {
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 6px;
    height: 39px;
    font-weight: 500;
}

/* 店铺名 */
.ad-product-item .ad-product-shop {
    color: #999;
    font-size: 11px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 价格区域 */
.ad-product-item .ad-product-price {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

/* 价格标签样式 */
.price-section {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.price-label {
    font-size: 11px;
    color: #ff5000;
    background: rgba(255, 80, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
}

.original-section {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.original-section .price-label {
    color: #ff0000;
    background: rgba(255, 0, 0, 0.1);
}

.ad-product-item .final-price {
    color: #ff5000;
    font-weight: 700;
    font-size: 18px;
}

/* 原价样式 - 更显眼，红色 */
.ad-product-item .original-price {
    color: #ff0000;
    font-size: 14px;
    text-decoration: line-through;
    font-weight: 600;
}

/* 优惠券标签 */
.ad-product-item .coupon-tag {
    background: linear-gradient(135deg, #ff5000 0%, #ff7846 100%);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
    margin-top: 4px;
}

.ad-product-item .coupon-tag::before {
    content: '券';
    background: #fff;
    color: #ff5000;
    font-size: 9px;
    padding: 1px 3px;
    border-radius: 2px;
}

/* 操作按钮区域 */
.ad-product-actions {
    display: flex;
    gap: 8px;
    padding: 0 10px 10px;
}

.buy-btn {
    flex: 1;
    background: linear-gradient(135deg, #ff5000 0%, #ff7846 100%);
    color: #fff;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
}

.buy-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 3px 10px rgba(255, 80, 0, 0.3);
    color: #fff;
}

.tklp-btn-small {
    background: #fff5f0;
    border: 1px solid #ffd4c7;
    color: #ff5000;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.tklp-btn-small:hover {
    background: linear-gradient(135deg, #ff5000 0%, #ff7846 100%);
    color: #fff;
    border-color: #ff5000;
}

/* 水平广告（顶部/横幅） - 网格布局 */
.ad-products-horizontal {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 12px;
    background: #fafafa;
}

.ad-product-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
}

.ad-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.ad-product-card .ad-product-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.ad-product-card .ad-product-img {
    width: 100%;
    height: 140px;
    overflow: hidden;
    position: relative;
}

.ad-product-card .ad-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.ad-product-card:hover .ad-product-img img {
    transform: scale(1.08);
}

/* 销量标签 */
.ad-product-card .sales-tag {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    color: #fff;
    font-size: 12px;
    padding: 25px 10px 8px;
}

.ad-product-card .ad-product-info {
    padding: 10px;
}

.ad-product-card .ad-product-title {
    font-size: 12px;
    color: #333;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 4px;
    height: 36px;
    font-weight: 500;
}

.ad-product-card .ad-product-shop {
    color: #999;
    font-size: 10px;
    margin-bottom: 6px;
}

.ad-product-card .ad-product-price-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 6px;
}

.ad-product-card .final-price {
    color: #ff5000;
    font-weight: 700;
    font-size: 18px;
}

/* 原价样式 - 更显眼，红色 */
.ad-product-card .original-price {
    color: #ff0000;
    font-size: 14px;
    text-decoration: line-through;
    font-weight: 600;
}

.ad-product-card .coupon-tag {
    background: linear-gradient(135deg, #ff5000 0%, #ff7846 100%);
    color: #fff;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.ad-product-card .coupon-tag::before {
    content: '券';
    background: #fff;
    color: #ff5000;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 2px;
}

/* 卡片操作按钮 */
.ad-product-card .ad-product-actions {
    display: flex;
    gap: 6px;
    padding: 0 10px 10px;
}

.ad-product-card .buy-btn {
    flex: 1;
    padding: 6px 8px;
    font-size: 11px;
}

.ad-product-card .tklp-btn {
    background: #fff5f0;
    border: 1px solid #ffd4c7;
    color: #ff5000;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.ad-product-card .tklp-btn:hover {
    background: linear-gradient(135deg, #ff5000 0%, #ff7846 100%);
    color: #fff;
    border-color: #ff5000;
}

/* ========== 顶部广告紧凑样式 - 进一步缩小 ========== */
.ad-products-scroll {
    width: 100%;
    overflow-x: scroll; /* 强制显示横向滚动条 */
    overflow-y: hidden;
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    padding: 6px 0 0 0;
    max-height: 220px; /* 增加高度以容纳内嵌提示 */
    position: relative;
}

.ad-products-scroll-inner {
    display: flex;
    gap: 6px;
    padding: 0 6px;
    will-change: transform;
    width: max-content; /* 让内容撑开宽度 */
}

/* 紧凑卡片样式 */
.ad-product-card-compact {
    flex: 0 0 120px; /* 进一步缩小宽度 */
    border-radius: 6px;
}

.ad-product-card-compact .ad-product-img {
    height: 70px; /* 大幅缩小图片高度 */
}

.ad-product-card-compact .sales-tag {
    font-size: 8px;
    padding: 10px 4px 2px;
}

.ad-product-card-compact .ad-product-info {
    padding: 5px;
}

.ad-product-card-compact .ad-product-title {
    font-size: 9px;
    height: 24px;
    margin-bottom: 2px;
    -webkit-line-clamp: 2;
    line-height: 1.3;
}

.ad-product-card-compact .ad-product-shop {
    font-size: 8px;
    margin-bottom: 2px;
}

.ad-product-card-compact .ad-product-price-row {
    gap: 1px;
    margin-bottom: 2px;
}

.ad-product-card-compact .price-label {
    font-size: 7px;
    padding: 1px 2px;
}

.ad-product-card-compact .final-price {
    font-size: 12px;
}

/* 紧凑卡片原价样式 */
.ad-product-card-compact .original-price {
    font-size: 10px;
    color: #ff0000;
    text-decoration: line-through;
    font-weight: 600;
}

.ad-product-card-compact .coupon-tag {
    font-size: 7px;
    padding: 1px 4px;
    margin-top: 1px;
}

.ad-product-card-compact .ad-product-actions {
    gap: 2px;
    padding: 0 5px 5px;
}

.ad-product-card-compact .buy-btn {
    padding: 3px 4px;
    font-size: 8px;
}

.ad-product-card-compact .buy-btn span {
    font-size: 8px;
}

.ad-product-card-compact .tklp-btn {
    padding: 3px 4px;
    font-size: 8px;
}

.ad-product-card-compact .tklp-btn span {
    font-size: 8px;
}

/* ========== 顶部广告内嵌提示样式 ========== */
.ad-tip-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 10px;
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    cursor: pointer;
    z-index: 10;
    border-radius: 4px;
    white-space: nowrap;
}

.ad-tip-inline:hover {
    background: rgba(0,0,0,0.85);
}

/* ========== 广告提示样式 - 修复 ========== */
.ad-tip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 11px;
    z-index: 1000;
    border-radius: 4px;
    white-space: nowrap;
    cursor: pointer;
}

.ad-tip:hover {
    background: rgba(0,0,0,0.85);
}

/* 侧边栏广告提示 - 在内容内侧 */
.ad-tip-sidebar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    height: auto;
    min-height: 120px;
    padding: 10px 4px;
}

.ad-tip-right {
    right: -22px;
    border-radius: 0 6px 6px 0;
}

.ad-tip-left {
    left: -22px;
    border-radius: 6px 0 0 6px;
}

/* 底部广告提示 */
.ad-tip-bottom {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 6px 6px;
    padding: 3px 12px;
}

.ad-tip-label {
    font-weight: 600;
    color: #ff5000;
    font-size: 11px;
}

.ad-tip-link {
    color: #fff;
    text-decoration: underline;
    cursor: pointer;
    font-size: 10px;
}

.ad-tip-link:hover {
    color: #ff5000;
}

/* 淘口令提示弹窗 */
.ad-tklp-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.ad-tklp-toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    position: relative;
    min-width: 300px;
}

.ad-tklp-toast-icon {
    font-size: 32px;
}

.ad-tklp-toast-text {
    flex: 1;
}

.ad-tklp-toast-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.ad-tklp-toast-desc {
    font-size: 13px;
    color: #666;
}

.ad-tklp-toast-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.ad-tklp-toast-close:hover {
    color: #333;
}

/* 侧边栏广告位 - 随页面滚动，永远居中显示 */
.ad-sidebar-fixed {
    position: fixed;
    top: 200px;
    width: 230px;
    z-index: 500;
    max-height: 70vh;
    display: none;
}

.ad-sidebar-fixed:not(:empty) {
    display: block;
}

/* 左侧广告位 */
.ad-sidebar-fixed-left {
    left: 15px;
}

/* 右侧广告位 */
.ad-sidebar-fixed-right {
    right: 15px;
}

/* 确保广告容器可见 */
.ad-top-banner {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 15px;
    display: none;
}

.ad-top-banner:not(:empty) {
    display: block;
}

/* 固定头部容器 */
.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* 顶部广告位 - 限制高度 */
.ad-top-banner-sticky {
    position: relative;
    width: 100%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: none;
    overflow: visible;
    max-height: 240px; /* 增加高度以容纳内嵌提示 */
}

.ad-top-banner-sticky:not(:empty) {
    display: block;
}

/* 导航栏 */
.navbar {
    position: relative;
    width: 100%;
    transition: none;
}

/* 页面内容添加顶部边距 */
body.has-top-ad,
body:not(.has-top-ad) {
    padding-top: 0;
}

/* 页面内容的顶部间距由 JavaScript 动态设置 */
.fixed-header-spacer {
    width: 100%;
    min-height: 80px;
    display: block;
}

/* 页面主体容器需要相对定位 */
.container {
    position: relative;
}

/* 响应式 */
@media (max-width: 1400px) {
    .ad-sidebar-fixed {
        display: none;
    }
}

@media (max-width: 768px) {
    .ad-products-horizontal {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px;
    }
    
    .ad-product-card .ad-product-img {
        height: 120px;
    }
    
    .ad-product-card-compact {
        flex: 0 0 110px;
    }
    
    .ad-product-card-compact .ad-product-img {
        height: 65px;
    }
}

/* 滚动条样式 */
.ad-products-horizontal::-webkit-scrollbar,
.ad-sidebar-fixed::-webkit-scrollbar,
.ad-products-sidebar::-webkit-scrollbar,
.ad-products-scroll::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.ad-products-horizontal::-webkit-scrollbar-track,
.ad-sidebar-fixed::-webkit-scrollbar-track,
.ad-products-sidebar::-webkit-scrollbar-track,
.ad-products-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ad-products-horizontal::-webkit-scrollbar-thumb,
.ad-sidebar-fixed::-webkit-scrollbar-thumb,
.ad-products-sidebar::-webkit-scrollbar-thumb,
.ad-products-scroll::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ad-products-horizontal::-webkit-scrollbar-thumb:hover,
.ad-sidebar-fixed::-webkit-scrollbar-thumb:hover,
.ad-products-sidebar::-webkit-scrollbar-thumb:hover,
.ad-products-scroll::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 复制成功提示动画 */
@keyframes copySuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.tklp-btn.copied,
.tklp-btn-small.copied {
    animation: copySuccess 0.3s ease;
    background: linear-gradient(135deg, #52c41a 0%, #73d13d 100%) !important;
    color: #fff !important;
    border-color: #52c41a !important;
}

/* 顶部广告标题 - 顶部广告不使用 */
.ad-top-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e8e 100%);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}

.ad-top-title .more-link {
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
}

.ad-top-title .more-link:hover {
    color: #fff;
}
