/* 防止详情页内容引发的全局横向溢出 */
body.cb-product-detail-page {
    overflow-x: hidden !important;
    width: 100% !important;
    position: relative !important;
}

body.cb-product-detail-page html {
    overflow-x: hidden !important;
}

/* ====== 主题容器隔离层 - 仅详情页生效 ====== */
body.cb-product-detail-page #primary,
body.cb-product-detail-page #main,
body.cb-product-detail-page .content-area,
body.cb-product-detail-page .site-main,
body.cb-product-detail-page .entry-content,
body.cb-product-detail-page .page-content,
body.cb-product-detail-page article.page,
body.cb-product-detail-page article.post,
body.cb-product-detail-page .ast-container,
body.cb-product-detail-page .elementor-section,
body.cb-product-detail-page .fl-content {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    float: none !important;
    box-sizing: border-box !important;
}

/* 重置主题可能的flex/grid布局干扰 */
body.cb-product-detail-page .site-content,
body.cb-product-detail-page .content-wrap,
body.cb-product-detail-page .main-content,
body.cb-product-detail-page #content,
body.cb-product-detail-page > .container,
body.cb-product-detail-page .ast-container,
body.cb-product-detail-page .elementor-container {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 auto !important;
}

/* 隐藏主题侧边栏（如果存在） */
body.cb-product-detail-page #secondary,
body.cb-product-detail-page .sidebar,
body.cb-product-detail-page aside.widget-area {
    display: none !important;
}

/* ====== 详情页主容器 ====== */

.cb-product-detail-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 15px; /* 添加侧边距以匹配搜索页 */
    background: #f5f5f5;
    border-radius: 0;
    box-shadow: none;
    position: relative;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    width: 100%;
    box-sizing: border-box;
}

/* 头部面包屑 */
.cb-product-detail-header {
    padding: 15px 20px;
    background: #fff;
    margin-bottom: 10px;
}

.cb-breadcrumb {
    font-size: 13px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cb-breadcrumb a {
    color: var(--cb-link-color, #1a237e);
    text-decoration: none;
}

/* 模块 1: 商品信息模块 */
.cb-product-info-module {
    display: flex;
    gap: 30px;
    background: #fff;
    padding: 30px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.cb-product-info-left {
    flex: 0 0 450px;
    max-width: 450px;
}

.cb-main-image-wrapper {
    width: 100%;
    height: 450px;
    border: 1px solid #eee;
    margin-bottom: 15px;
    overflow: hidden;
}

.cb-main-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cb-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.cb-thumb {
    width: 70px;
    height: 70px;
    border: 1px solid #eee;
    cursor: pointer;
    object-fit: cover;
    flex-shrink: 0;
}

.cb-thumb.active {
    border: 2px solid var(--cb-primary-color, #1a237e);
}

.cb-product-info-right {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cb-product-title {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    margin: 0 0 20px;
    line-height: 1.4;
}

.cb-product-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: var(--cb-accent-color, #f8f9ff);
    border-radius: 8px;
    margin-bottom: 25px;
}

.cb-current-price {
    font-size: 32px;
    color: var(--cb-price-color, #ff5722);
    font-weight: 700;
}

.cb-current-price span {
    font-size: 20px;
    margin-right: 2px;
}

.cb-trade-badge {
    background: rgba(var(--cb-primary-color-rgb), 0.1);
    color: var(--cb-primary-color, #1a237e);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* SKU Section - Korean Minimalist Style */
.cb-product-sku-section {
    margin-bottom: 35px;
    border-top: 1px solid #f0f0f0;
    padding-top: 20px;
    width: 100%;
    box-sizing: border-box;
}

.cb-sku-group {
    margin-bottom: 25px;
}

.cb-sku-label-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.cb-sku-label {
    font-size: 14px;
    color: #333;
    font-weight: 700;
    min-width: 60px;
}

.cb-selected-value {
    font-size: 13px;
    color: var(--cb-primary-color, #1a237e);
    font-weight: 500;
}

.cb-selected-value::before {
    content: ":";
    margin-right: 8px;
    color: #ccc;
}

.cb-sku-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cb-sku-item {
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 2px;
    font-size: 13px;
    cursor: pointer;
    background: #fff;
    transition: all 0.15s ease-in-out;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 45px;
    justify-content: center;
    color: #555;
}

.cb-sku-item.has-image {
    padding: 2px;
    width: 50px;
    height: 50px;
    min-width: 50px;
}

.cb-sku-img-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 带有图片的SKU项隐藏文字，只显示图片 */
.cb-sku-item.has-image span {
    display: none;
}

.cb-sku-item:hover {
    border-color: #999;
}

.cb-sku-item.active {
    border: 2px solid var(--cb-primary-color, #1a237e);
    padding: 7px 15px; /* 补偿边框厚度 */
    background: #fff;
    color: var(--cb-primary-color, #1a237e);
    font-weight: 600;
    position: relative;
}

.cb-sku-item.has-image.active {
    padding: 1px; /* 补偿边框厚度 */
}

/* 选中标记 (可选) */
.cb-sku-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 12px 12px;
    border-color: transparent transparent var(--cb-primary-color, #1a237e) transparent;
}

/* Actions Row */
.cb-product-actions-row {
    display: flex;
    gap: 15px;
    margin-top: auto;
}

.cb-btn-primary {
    flex: 1;
    background: var(--cb-primary-color, #1a237e);
    color: var(--cb-btn-text-color, #fff);
    border: none;
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 4px;
    text-align: center;
    text-decoration: none;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cb-icon-buy {
    width: 20px;
    height: 20px;
}

.cb-btn-primary:hover {
    background: var(--cb-primary-color, #1a237e);
    opacity: 0.9;
}

.cb-selection-cart-btn {
    width: 54px;
    height: 54px;
    background: #fff;
    border: 1px solid var(--cb-primary-color, #1a237e);
    color: var(--cb-primary-color, #1a237e);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.cb-selection-cart-btn:hover {
    background: #f0f2ff;
}

.cb-icon-cart {
    width: 24px;
    height: 24px;
}

/* 模块 2: 商品参数模块 */
.cb-product-params-module {
    background: #fff;
    padding: 30px;
    margin-bottom: 20px;
}

.cb-params-header {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f5f5f5;
}

.cb-params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.cb-params-item {
    display: flex;
    font-size: 14px;
    line-height: 1.6;
}

.cb-params-label {
    color: #888;
    width: 120px;
    flex-shrink: 0;
}

.cb-params-value {
    color: #333;
    word-break: break-all;
}

/* 模块 3: 商品详情模块 */
.cb-product-detail-module {
    background: #fff;
}

.cb-detail-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
}

.cb-tab {
    padding: 15px 30px;
    font-size: 15px;
    font-weight: 600;
    color: var(--cb-primary-color, #1a237e);
    border-bottom: 3px solid var(--cb-primary-color, #1a237e);
}

.cb-detail-content {
    padding: 40px;
    min-height: 400px;
    overflow-x: hidden;
}

.cb-detail-content * {
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-wrap: break-word;
}

.cb-detail-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    padding: 0;
    border: none;
}

/* 响应式适配 */

/* Tablet (iPad) - 992px to 768px */
@media (max-width: 992px) {
    .cb-product-detail-container {
        margin: 0;
        padding: 0 10px;
    }
    
    .cb-product-info-module {
        flex-direction: column;
        gap: 20px;
        padding: 20px;
    }
    
    .cb-product-info-left {
        max-width: 100%;
        flex: none;
        width: 100%;
    }
    
    .cb-main-image-wrapper {
        height: auto;
        aspect-ratio: 1/1;
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;
    }

    .cb-product-info-right {
        margin-top: 10px;
    }
}

/* Small Tablet & Mobile - 767px and below */
@media (max-width: 767px) {
    /* 移动端强制隔离主题干扰 */
    body.cb-product-detail-page,
    body.cb-product-detail-page #primary,
    body.cb-product-detail-page #main,
    body.cb-product-detail-page .content-area,
    body.cb-product-detail-page .site-main,
    body.cb-product-detail-page .site-content,
    body.cb-product-detail-page #content,
    body.cb-product-detail-page .container,
    body.cb-product-detail-page .ast-container,
    body.cb-product-detail-page .elementor-container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow-x: hidden !important;
    }

    .cb-product-detail-container {
        margin: 0 !important;
        padding: 0 0 80px 0 !important; /* 移动端重置边距，保留底部空间 */
        background: #fff !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .cb-product-detail-header {
        padding: 8px 12px !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }

    .cb-breadcrumb {
        font-size: 10px !important;
        color: #bbb !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cb-product-info-module {
        flex-direction: column !important;
        gap: 0 !important;
        padding: 10px 12px !important;
        border-bottom: 6px solid #f7f7f7 !important;
    }

    .cb-product-info-left {
        max-width: 100% !important;
        flex: none !important;
        margin-bottom: 10px !important;
    }

    .cb-main-image-wrapper {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important; /* 强制正方形 */
        border-radius: 4px !important;
        border: none !important;
        margin-bottom: 8px !important;
        overflow: hidden !important;
        cursor: zoom-in !important; /* 提示可以放大 */
    }

    .cb-main-img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important; /* 确保填满 */
    }

    .cb-thumbnails {
        gap: 5px !important;
        padding-bottom: 5px !important;
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .cb-thumb {
        width: 50px !important;
        height: 50px !important;
        border-radius: 3px !important;
        flex-shrink: 0 !important;
    }

    .cb-product-title {
        font-size: 18px !important; /* 优化标题字体 */
        font-weight: 600 !important;
        color: #111 !important;
        line-height: 1.4 !important;
        margin-bottom: 12px !important;
        padding: 0 4px !important;
    }

    /* 价格行适配 - 参考图色系 */
    .cb-product-price-row {
        padding: 12px 15px !important;
        background: var(--cb-accent-color, #f6f9ff) !important;
        border: none !important;
        margin-bottom: 15px !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    .cb-current-price {
        font-size: 24px !important;
        color: var(--cb-price-color, #ff5a1f) !important;
        font-weight: bold !important;
    }

    .cb-current-price span {
        font-size: 14px !important;
    }

    .cb-trade-badge {
        background: rgba(var(--cb-primary-color-rgb), 0.1) !important;
        color: var(--cb-primary-color, #5c84ff) !important;
        font-size: 10px !important;
        padding: 2px 8px !important;
        border-radius: 12px !important;
        font-weight: 500 !important;
    }

    /* SKU 精致化适配 - 参考图风格 */
    .cb-product-sku-section {
        padding-top: 15px !important;
        margin-bottom: 20px !important;
        border-top: 1px solid #f0f0f0 !important;
    }

    .cb-sku-group {
        margin-bottom: 15px !important;
    }

    .cb-sku-label-row {
        display: flex !important;
        align-items: center !important;
        margin-bottom: 10px !important;
    }

    .cb-sku-label {
        font-size: 13px !important; /* 优化SKU标题字体 */
        min-width: 45px !important;
        color: #333 !important;
        font-weight: 600 !important;
    }

    .cb-selected-value {
        font-size: 13px !important;
        color: var(--cb-primary-color, #1a237e) !important;
        font-weight: 500 !important;
        margin-left: 8px !important;
    }

    .cb-selected-value::before {
        content: ":" !important;
        margin-right: 5px !important;
        color: #999 !important;
    }

    .cb-sku-list {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .cb-sku-item {
        min-width: 50px !important;
        padding: 6px 14px !important;
        font-size: 13px !important; /* 优化选项字体 */
        border-radius: 4px !important;
        background: #f8f8f8 !important;
        border: 1px solid #f0f0f0 !important;
        color: #333 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: all 0.2s !important;
    }

    .cb-sku-item.active {
        background: #fff !important;
        border: 2px solid var(--cb-primary-color, #1a237e) !important;
        color: var(--cb-primary-color, #1a237e) !important;
        font-weight: bold !important;
        position: relative !important;
        padding: 5px 13px !important; /* 补偿边框 */
    }

    .cb-sku-item.active::after {
        content: '' !important;
        position: absolute !important;
        bottom: 0 !important;
        right: 0 !important;
        width: 0 !important;
        height: 0 !important;
        border-style: solid !important;
        border-width: 0 0 10px 10px !important;
        border-color: transparent transparent var(--cb-primary-color, #1a237e) transparent !important;
    }

    .cb-sku-item.has-image {
        width: 56px !important; /* 优化图片规格尺寸 */
        height: 56px !important;
        padding: 2px !important;
    }

    /* 参数模块适配 */
    .cb-product-params-module {
        padding: 12px !important;
        border-bottom: 6px solid #f7f7f7 !important;
    }

    .cb-params-header {
        font-size: 13px !important;
        margin-bottom: 10px !important;
    }

    .cb-params-item {
        font-size: 11px !important;
        margin-bottom: 6px !important;
    }

    /* 详情内容通配符强制适配 */
    .cb-tab {
        font-size: 13px !important;
        padding: 10px 0 !important;
    }

    .cb-detail-content {
        padding: 15px !important;
        min-height: auto !important;
    }

    .cb-detail-content img {
        width: 100% !important;
        height: auto !important;
        display: block !important;
        margin: 5px 0 !important;
    }

    /* 底部固定操作栏 - 参考图样式 */
    .cb-product-actions-row {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: #fff !important;
        padding: 10px 15px !important;
        display: flex !important;
        gap: 10px !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.06) !important;
        z-index: 1000 !important;
        border-top: 1px solid #f0f0f0 !important;
    }

    .cb-btn-primary {
        flex: 1 !important;
        background: var(--cb-primary-color, #1a237e) !important;
        height: 48px !important; /* 优化BUY NOW高度 */
        border-radius: 6px !important;
        font-size: 16px !important;
        font-weight: bold !important;
        color: var(--cb-btn-text-color, #fff) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-decoration: none !important;
        gap: 8px !important;
    }

    .cb-icon-buy {
        width: 18px !important;
        height: 18px !important;
        display: inline-block !important; /* 确保图标显示 */
    }

    .cb-selection-cart-btn {
        width: 46px !important;
        height: 46px !important;
        background: #fff !important;
        border: 1px solid #ccc !important;
        border-radius: 4px !important;
        color: #333 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
    }
}

/* 全屏图片放大层 */
.cb-image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.cb-image-overlay img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

/* 强力隐藏悬浮窗 (防止主题或插件残留) */
.cb-floating-hider,
#wp-live-chat-by-3cx,
#wechat-float,
.float-box,
.floating-widget,
.side-floating,
.customer-service-float,
#ss-chat-container,
.joinchat {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Extra Small Mobile - 480px and below */
@media (max-width: 480px) {
    .cb-sku-label {
        min-width: 50px;
        font-size: 13px;
    }

    .cb-sku-item {
        padding: 6px 12px;
        font-size: 12px;
    }

    .cb-sku-item.has-image {
        width: 45px;
        height: 45px;
        min-width: 45px;
    }

    .cb-current-price {
        font-size: 20px;
    }

    .cb-trade-badge {
        padding: 2px 8px;
        font-size: 11px;
    }
}

.cb-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.cb-loading-overlay.hidden {
    display: none;
}

.cb-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--cb-primary-color, #1a237e);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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