/**
 * 商品推荐模块样式 - 韩式电商风格
 * 兼容任何WordPress主题
 */

/* 容器重置 */
.cb-recommend-container,
.cb-recommend-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.cb-recommend-container {
    width: 100%;
    max-width: 1400px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f8f8f8; /* 浅灰底色 */
    padding: 20px;
}

/* ===== 头部：标题盒 + 分类标签 ===== */
.cb-recommend-header {
    display: flex;
    align-items: stretch;
    gap: 15px;
    margin-bottom: 15px;
}

.cb-recommend-title {
    width: 300px; /* 与海报同宽 */
    min-width: 300px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: var(--cb-text-color, #333);
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    flex-shrink: 0;
    height: 60px;
    position: relative;
}

.cb-recommend-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: var(--cb-primary-color, #ff4400);
    border-radius: 0 2px 2px 0;
}

.cb-recommend-tabs-container {
    flex: 1;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    overflow: hidden; /* 防止内部溢出破坏圆角 */
}

.cb-recommend-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap; /* 移动端优先不换行，支持滑动 */
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    padding: 10px 0;
    width: 100%;
}

.cb-recommend-tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.cb-recommend-tab {
    padding: 6px 16px;
    border: 1px solid #eee;
    border-radius: 20px;
    background: #fff;
    color: var(--cb-tab-text-color, #666);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap; /* 强制不换行 */
    flex-shrink: 0; /* 防止被挤压 */
}

.cb-recommend-tab:hover {
    border-color: var(--cb-tab-active-bg-color, #ff6600);
    color: var(--cb-tab-active-bg-color, #ff6600);
}

.cb-recommend-tab.active {
    background: var(--cb-tab-active-bg-color, #ff4400); /* 韩式亮橙 */
    border-color: var(--cb-tab-active-bg-color, #ff4400);
    color: var(--cb-tab-active-text-color, #fff);
    font-weight: 500;
}

/* ===== 主体布局 ===== */
.cb-recommend-body {
    display: flex;
    gap: 15px;
}

/* ===== 左侧海报区域 ===== */
.cb-recommend-poster {
    width: 300px;
    min-width: 300px;
    height: 620px; /* 增加高度以匹配两行商品 */
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    flex-shrink: 0;
    background: #fff;
}

.cb-poster-slide {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.cb-poster-slide.active {
    opacity: 1;
}

.cb-poster-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 轮播指示器 - 长条状 */
.cb-poster-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
}

.cb-poster-dot {
    width: 25px;
    height: 3px;
    background: rgba(255,255,255,0.4);
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 2px;
}

.cb-poster-dot.active {
    background: #fff;
    width: 35px;
}

/* ===== 右侧商品区域 ===== */
.cb-recommend-main {
    flex: 1;
    min-width: 0;
}

.cb-recommend-products {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.cb-recommend-product {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #f2f2f2;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.cb-recommend-product:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

.cb-recommend-product a {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cb-recommend-product-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    position: relative; /* 为悬浮按钮提供定位基准 */
}

.cb-recommend-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cb-recommend-product-info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cb-recommend-product-title {
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    height: 39px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 8px;
}

/* 1688 标签 */
.cb-tag-1688 {
    background: var(--cb-primary-color, #ff4400);
    color: var(--cb-btn-text-color, #fff);
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 2px;
    margin-right: 4px;
    font-weight: bold;
    vertical-align: middle;
}

.cb-recommend-product-price-row {
    margin-bottom: 6px;
}

.cb-recommend-product-price {
    font-size: 18px;
    font-weight: bold;
    color: var(--cb-price-color, #ff4400);
}

.cb-recommend-product-meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #999;
    padding-top: 8px;
    border-top: 1px solid #f9f9f9;
}

/* ===== 响应式适配 ===== */
@media (max-width: 1200px) {
    .cb-recommend-products {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .cb-recommend-container {
        padding: 10px;
    }

    .cb-recommend-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .cb-recommend-title {
        width: 100%;
        min-width: unset;
        height: 45px;
        font-size: 18px;
    }
    
    .cb-recommend-tabs-container {
        width: 100%;
        padding: 0 10px;
    }

    .cb-recommend-body {
        flex-direction: column;
    }
    
    .cb-recommend-poster {
        width: 100%;
        height: 220px;
    }
}

@media (max-width: 768px) {
    .cb-recommend-products {
        grid-template-columns: repeat(2, 1fr) !important; /* 强制两列 */
        gap: 10px;
    }
    
    .cb-recommend-product-title {
        font-size: 12px;
        height: 36px;
    }

    .cb-recommend-product-price {
        font-size: 16px;
    }

    .cb-recommend-product-meta {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .cb-recommend-container {
        padding: 5px;
    }

    .cb-recommend-poster {
        height: 160px;
    }

    .cb-recommend-tabs {
        gap: 8px;
    }

    .cb-recommend-tab {
        padding: 5px 12px;
        font-size: 12px;
    }
}
