/* ================= ADAPTIVE GRID WRAPPER (CHỐNG BỂ LAYOUT) ================= */
.sfm-product-module-wrapper {
    display: grid;
    /* auto-fit: Các sản phẩm sẽ dãn ra căng đầy màn hình nếu số lượng ít hơn chuẩn thay vì bị lẹm một góc */
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    width: 100%;
}

/* ================= CUSTOM TABS ================= */
/* Phục hồi chế độ tự động rớt dòng cho các tab theo thiết kế cũ, không trượt ngang nữa */
.sfm-custom-tabs .e-n-tabs-heading {
    display: flex;
    flex-wrap: wrap !important; 
}
.sfm-custom-tabs .e-n-tab-title {
    flex-shrink: 0;
    border: none !important; 
    border-bottom: 3px solid transparent !important; 
    background: transparent !important; 
    transition: all 0.3s ease !important; 
    box-shadow: none !important; 
}

/* Hiệu ứng khi Hover và khi Tab đang được chọn (Active) */
.sfm-custom-tabs .e-n-tab-title:hover,
.sfm-custom-tabs .e-n-tab-title[aria-selected="true"] {
    border-bottom-color: var(--sfm-btn-bg, #117552) !important; 
    background: transparent !important;
}

/* ================= ITEM ================= */
.sfm-item1-product, .item1-product {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Product Card */
.sfm-product {
    background: var(--sfm-card-bg, #fff);
    border-radius: var(--sfm-card-radius, 24px);
    border-color: var(--sfm-card-border, #E6E6E6);
    border-width: var(--sfm-card-border-width, 1px);
    border-style: solid;
    min-height: 371px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.3s ease;
    text-decoration: none !important;
    box-shadow: var(--sfm-card-shadow, none);
}

.sfm-product:hover {
    box-shadow: var(--sfm-card-shadow-h, 0 10px 30px rgba(0,0,0,0.1));
}

/* No Posts Alert */
.sfm-pro-page-wrapper .sfm-no-posts {
    color: #664d03;
    background-color: #fff3cd;
    border: 1px solid #ffecb5;
    padding: 15px 20px;
    border-radius: 4px;
    margin-bottom: 30px;
}

.sfm-pro-page-wrapper .sfm-no-posts p {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
}


/* ================= IMAGE ================= */
.sfm-product .images {
    border-radius: var(--sfm-card-radius, 24px) var(--sfm-card-radius, 24px) 0 0;
    overflow: hidden;
    position: relative;
}

.sfm-product .images img {
    width: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

/* Hover zoom */
.sfm-product:hover .scale-img img {
    transform: scale(1.05);
}

/* ================= LINK ================= */
.product_item {
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
}

/* ================= CONTENT ================= */
.sfm-product .info {
    padding: var(--sfm-card-padding, 20px);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Title */
.sfm-product .info h3.name {
    font-size: var(--sfm-title-size, 20px);
    color: var(--sfm-title-color, #421E13);
    font-weight: var(--sfm-title-weight, 700);
    font-family: var(--sfm-title-font, 'Montserrat', sans-serif);
    line-height: 1.4;
    margin: 0 0 8px 0;
    transition: color 0.3s ease;
    --line-clamp: 1; /* Ép buộc hiển thị 1 dòng trên Grid */
}

.sfm-product:hover .info h3.name {
    /* Mặc định không đổi màu khi hover vào card, trừ khi user chọn màu trong Elementor */
    color: var(--sfm-title-color, #421E13);
}

/* Description */
.sfm-product .desc-product {
    color: var(--sfm-excerpt-color, #A09F9F);
    font-size: var(--sfm-excerpt-size, 13px);
    font-family: var(--sfm-excerpt-font, 'Montserrat', sans-serif);
    margin-bottom: 20px;
    line-height: 1.5;
    min-height: 20px;
    display: -webkit-box;
    -webkit-line-clamp: var(--sfm-excerpt-lines, 2);
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Button */
.sfm-product .more-product {
    background: var(--sfm-btn-bg, var(--clr-main));
    width: 150px;
    text-align: center;
    height: 36px;
    line-height: 36px;
    color: var(--sfm-btn-color, #fff);
    border-radius: var(--sfm-btn-radius, 20px);
    font-family: var(--sfm-btn-font, 'Montserrat', sans-serif);
    font-size: 14px;
    margin-top: auto;
    transition: all 0.3s ease;
}

.sfm-product:hover .more-product {
    background: var(--sfm-btn-hover-bg, #117552);
}

/* ================= TEXT CLAMP ================= */
.text-split {
  --line-clamp: 2;
  overflow: hidden;
  display: -webkit-box;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--line-clamp);
  line-clamp: var(--line-clamp);
}

/* ================= RESPONSIVE CAO CẤP ================= */
/* Desktop / Standard Tablet */
@media (max-width: 1140px) {
    .sfm-product-module-wrapper {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 20px;
    }
    .sfm-product .info {
        padding: 15px;
        text-align: left;
    }
    .sfm-product {
        min-height: auto;
    }
    .sfm-product .info h3.name {
        font-size: 16px;
        height: auto;
        min-height: 24px;
        margin-bottom: 5px;
    }
    .sfm-product .desc-product {
        margin-bottom: 15px;
    }
}

/* Tablet Nhỏ & Mobile Ngang (Dưới 769px) */
@media (max-width: 769px) {
    .sfm-product-module-wrapper {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 15px;
    }
}

/* Mobile (Dưới 576px) */
@media (max-width: 576px) {
    
    .sfm-custom-tabs .e-n-tabs-heading {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important; 
        gap: 0 !important; 
        width: 100% !important;
    }
    .sfm-custom-tabs .e-n-tab-title {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        padding: 10px 5px !important;
        min-width: 0 !important;
    }
    .sfm-custom-tabs .e-n-tab-title .e-n-tab-title-text {
        font-size: 13px !important; 
        text-align: center !important;
        white-space: normal !important;
        word-break: break-word !important; 
        line-height: 1.3 !important;
    }

    .sfm-product-module-wrapper {
        /* Ép chuẩn 2 cột cho các điện thoại nhỏ và cho dãn tự do theo khung chứa */
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
    }
    .sfm-product .images img {
        border-radius: 15px 15px 0 0;
    }
    .sfm-product {
        border-radius: 15px;
    }
    .sfm-product .info {
        padding: 10px;
    }
    .sfm-product .info h3.name {
        font-size: 15px;
        height: auto;
    }
    .sfm-product .more-product {
        width: 100%;
        font-size: 12px;
        height: 32px;
        line-height: 32px;
    }
}