/* ===== BS3 Grid Conflict Fix ===== */
.row:before,
.row:after {
    content: none !important;
    display: none !important;
}

/* ===== Product Grid Fix ===== */
.row-cols-1.row,
.row-cols-sm-3.row,
.row-cols-md-4.row,
[class*="row-cols-"].row {
    display: grid !important;
    grid-template-columns: repeat(1, 1fr);
    column-gap: 1.875rem;
    row-gap: 0;
    margin-right: 0 !important;
    margin-left: 0 !important;
}
.row-cols-2.row,
[class*="row-cols-2"].row {
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 576px) {
    .row-cols-sm-3.row,
    [class*="row-cols-sm-3"].row {
        grid-template-columns: repeat(3, 1fr);
    }
    .row-cols-sm-2.row {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (min-width: 768px) {
    .row-cols-md-4.row,
    [class*="row-cols-md-4"].row {
        grid-template-columns: repeat(4, 1fr);
    }
    .row-cols-md-2.row {
        grid-template-columns: repeat(2, 1fr);
    }
}
.row-cols-1.row > *,
.row-cols-sm-3.row > *,
.row-cols-md-4.row > *,
[class*="row-cols-"].row > * {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    flex: none !important;
    -webkit-box-flex: 0 !important;
    -ms-flex: none !important;
    padding: 0 !important;
    margin-top: 0 !important;
    float: none !important;
}

/* ===== 修复手机端产品网格一大一小 ===== */
/* BS3 移动端会 float 所有 [class*="col-"]，覆盖掉防止宽度异常 */
@media (max-width: 767px) {
    .shop-section .row-cols-2.row > [class*="col-"],
    .shop-section [class*="row-cols-2"].row > [class*="col-"] {
        float: none !important;
        min-width: 0 !important;
    }
}

/* 防止长产品名撑开网格列宽 */
.sort-layout-single .pro-name {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* 确保产品卡片图片在网格中不超出容器 */
.sort-layout-single .pro-image img {
    max-width: 100%;
}

/* ===== Global Clearfix ===== */
.fix:before,
.fix:after { content: " "; display: table; }
.fix:after { clear: both; }

/* ===== Float Utilities ===== */
.float-left  { float: left !important; }
.float-right { float: right !important; }

/* ===== Offcanvas Cart ===== */
.offcanvas-overlay {
    position: fixed;
    z-index: 999999;
    top: 0; right: 0; bottom: 0; left: 0;
    display: none;
    background-color: rgba(0, 0, 0, 0.5);
}
#offcanvas-add-cart {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000000;
    width: 300px;
    height: 100vh;
    background: #fff;
    padding: 20px;
    overflow-y: auto;
    transform: translateX(100%);
    -webkit-transform: translateX(100%);
    transition: transform 0.3s ease;
    -webkit-transition: -webkit-transform 0.3s ease;
    visibility: hidden;
}
#offcanvas-add-cart.offcanvas-open {
    transform: translateX(0);
    -webkit-transform: translateX(0);
    visibility: visible;
}
.offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}
.offcanvas-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: #252525;
}
.offcanvas-close {
    width: 36px;
    height: 36px;
    line-height: 34px;
    text-align: center;
    border: 1px solid #999;
    border-radius: 50%;
    color: #666;
    font-size: 16px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.offcanvas-close:hover {
    color: #ea1c26;
    border-color: #ea1c26;
}
.offcanvas-body {
    flex-grow: 1;
    overflow-y: auto;
}
.offcanvas-cart { list-style: none; padding: 0; margin: 0; }
.offcanvas-cart-item-single {
    display: flex;
    align-items: flex-start;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    position: relative;
}
.offcanvas-cart-item-block {
    display: flex;
    align-items: flex-start;
    flex: 1;
    gap: 12px;
}
.offcanvas-cart-item-image-link { flex-shrink: 0; }
.offcanvas-cart-item-image-link img {
    width: 60px !important;
    height: 75px !important;
    max-width: 60px !important;
    object-fit: cover;
    border: 1px solid #eee;
    display: block;
}
.offcanvas-cart-item-content { flex: 1; }
.offcanvas-cart-item-link {
    font-size: 13px;
    color: #252525;
    display: block;
    margin-bottom: 5px;
    text-decoration: none;
    line-height: 1.4;
}
.offcanvas-cart-item-link:hover { color: #ff343b; text-decoration: none; }
.offcanvas-cart-item-details { font-size: 13px; color: #888; }
.offcanvas-cart-item-details-price { color: #252525; font-weight: 600; }
.offcanvas-cart-item-delete { margin-left: 10px; }
.offcanvas-remove-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ddd;
    color: #666;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    line-height: 1;
    transition: all 0.2s;
}
.offcanvas-remove-item:hover {
    background: #ea1c26;
    color: #fff;
    text-decoration: none;
}
.offcanvas-cart-total-price {
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}
.offcanvas-cart-total-price-value { float: right; font-weight: 700; }
.offcanvas-cart-action-button {
    list-style: none;
    padding: 15px 0 0;
    margin: 0;
    display: flex;
    gap: 10px;
}
.offcanvas-cart-action-button-list { flex: 1; }
.offcanvas-cart-action-button-link {
    display: block;
    text-align: center;
    padding: 10px;
    background: #252525;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 3px;
    transition: background 0.3s;
}
.offcanvas-cart-action-button-link:hover { background: #ff343b; color: #fff; text-decoration: none; }
@media (max-width: 575px) {
    #offcanvas-add-cart { width: 280px; padding: 15px; }
}

/* ===== 统一产品图片宽高比，修复手机端图片一大一小 ===== */
.single-product .pro-image {
    display: block;
    overflow: hidden;
    aspect-ratio: 1 / 1;
}

.single-product .pro-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== CLS 修复：Owl Carousel 初始化前预布局，防止高度坍塌 ===== */
/* 核心思路：在 JS 初始化前，用 flex 把轮播项排成一行；
   Owl Carousel 初始化后会重构 DOM，此 CSS 自动失效，不会冲突 */

.propular-slider,
.feature-slider,
.propular-sidebar-slider,
.feature-sidebar-slider,
.blog-slider,
.blog-slider-2,
.testimonial-slider {
    overflow: hidden;
}

/* 把 carousel 容器内的子元素（等待被 owl 包装的 .single-product 等）排成一行 */
.propular-slider,
.feature-slider {
    display: flex;
    flex-wrap: nowrap;
}

/* ---------- 按 Owl Carousel responsive 配置设定各断点可见宽度 ---------- */

/* Mobile: items=1 */
.propular-slider > .single-product,
.feature-slider > .single-product {
    flex: 0 0 100%;
    max-width: 100%;
}

/* ≥480px: items=2 (propular-slider)，items=1 (feature-slider 保持1) */
@media (min-width: 480px) {
    .propular-slider > .single-product {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ≥768px: propular-slider items=3，feature-slider items=2 */
@media (min-width: 768px) {
    .propular-slider > .single-product {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }
    .feature-slider > .single-product {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ≥992px: propular-slider items=4，feature-slider items=3 */
@media (min-width: 992px) {
    .propular-slider > .single-product {
        flex: 0 0 25%;
        max-width: 25%;
    }
    .feature-slider > .single-product {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }
}

/* ===== 字体 CLS：减小 fallback 字体与 web 字体的尺寸差异 ===== */
/* Raleway 比 Arial 略窄，Lato 比 Arial 略窄；适度调整以减少跳变 */
body {
    font-size-adjust: 0.5;
}

/* ===== 商品详情页图片：响应式 + 1:1 容器 ===== */
.product-image .simpleLens-big-image-container {
    aspect-ratio: 1 / 1;
    overflow: hidden;
}
.product-image .simpleLens-big-image-container a,
.product-image .simpleLens-big-image-container img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
