/* ====================================
   MODERN PRODUCT CARD STYLE
   Theo layout divineshop.vn
   ==================================== */

/* Product Grid Container */
/* Mobile-first: 2 cột mặc định */
.product-grid-modern {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

/* Tablet (≥768px và <992px): 3 cột */
@media (min-width: 768px) and (max-width: 991px) {
    .product-grid-modern {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
    
    /* Giữ nguyên tỉ lệ 1:1 */
    .product-card-image-wrapper {
        padding-top: 100%;
    }
}

/* PC (≥992px): 4 cột */
@media (min-width: 992px) {
    .product-grid-modern {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    
    /* Giữ nguyên tỉ lệ 1:1, không cần min-height */
    .product-card-image-wrapper {
        padding-top: 100%; /* Vẫn giữ tỉ lệ vuông */
    }
}

/* Override Bootstrap khi dùng với product-grid-modern */
.product-grid-modern .prod-item {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    margin-bottom: 0 !important;
    /* Đảm bảo không có viền thừa */
    border: none !important;
    box-sizing: border-box !important;
}

/* Đảm bảo product-card-modern trong grid không có margin/padding thừa */
.product-grid-modern .product-card-modern {
    margin: 0;
    padding: 0;
    border: none;
}

/* Product Card Modern */
.product-card-modern {
    position: relative;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Đảm bảo không có viền thừa */
    margin: 0;
    padding: 0;
    border: none;
}

.product-card-modern:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.product-card-modern.product-disable {
    opacity: 0.7;
    pointer-events: none;
}

/* Product Image Container */
.product-card-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 aspect ratio - khung vuông cố định */
    background: #fff; /* Nền trắng để ảnh nhỏ hơn khung vẫn đẹp */
    overflow: hidden;
    border-radius: 12px 12px 0 0;
    /* Đảm bảo khung không thay đổi kích thước */
    height: 0;
    /* Loại bỏ mọi viền và khoảng trống */
    margin: 0;
    padding: 0;
    border: none;
    /* Đảm bảo khung cố định, không giãn */
    box-sizing: border-box;
}

/* Link wrapper bên trong image-wrapper */
.product-card-image-wrapper > a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
    text-decoration: none;
    /* Loại bỏ viền và khoảng trống */
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
    /* Đảm bảo link phủ kín wrapper */
    box-sizing: border-box;
}

.product-card-image-wrapper img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Căn giữa hoàn hảo */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain; /* Ảnh vừa khung, không bị crop - giống logo TikTok */
    object-position: center center; /* Căn giữa ảnh cả ngang và dọc */
    transition: transform 0.3s ease;
    /* Loại bỏ viền trắng và khoảng trống */
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent; /* Không có nền */
    /* Đảm bảo ảnh vừa khung dù to hay nhỏ */
    box-sizing: content-box;
}

.product-card-modern:hover .product-card-image-wrapper img {
    transform: translate(-50%, -50%) scale(1.05); /* Giữ căn giữa khi scale */
}

/* Badge Container (Top Right) */
.product-card-badges {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.product-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.product-badge.badge-pro {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.product-badge.badge-premium {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.product-badge.badge-hot {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
}

.product-badge.badge-sale {
    background: #ff4757;
}

.product-badge.badge-discount {
    background: #ff4757;
    font-size: 12px;
    padding: 5px 12px;
}

/* Product Content */
.product-card-content {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Product Name */
.product-card-name {
    font-size: 15px;
    font-weight: 600;
    color: #2d3436;
    margin-bottom: 8px;
    line-height: 1.4;
    min-height: 42px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-name a {
    color: #2d3436;
    text-decoration: none;
    transition: color 0.2s;
}

.product-card-name a:hover {
    color: var(--primary);
}

/* Product Duration/Type */
.product-card-duration {
    font-size: 12px;
    color: #636e72;
    margin-bottom: 12px;
    font-weight: 500;
}

/* Price Container */
.product-card-price-wrapper {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
}

.product-card-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 10px;
}

.product-card-price-current {
    font-size: 20px;
    font-weight: 700;
    color: #2d3436;
    line-height: 1;
}

.product-card-price-original {
    font-size: 14px;
    color: #95a5a6;
    text-decoration: line-through;
    font-weight: 500;
}

.product-card-discount-badge {
    background: #ff4757;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

/* Buy Button */
.product-card-buy-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary1) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.product-card-buy-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.product-card-buy-btn:active:not(:disabled) {
    transform: translateY(0);
}

.product-card-buy-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    opacity: 0.7;
}

.product-card-buy-btn i {
    font-size: 14px;
}

/* Stock Info */
.product-card-stock-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e9ecef;
}

.product-card-stock-info .label-text {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    margin: 0;
    white-space: nowrap;
}

/* Action Buttons Container */
.product-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Detail Button */
.product-card-detail-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: transparent;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.product-card-detail-btn:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.product-card-detail-btn i {
    font-size: 14px;
}

/* Buy Button - Adjust width when with detail button */
.product-card-actions .product-card-buy-btn {
    flex: 1;
}

/* Stock Info (Optional - có thể ẩn) */
.product-card-stock {
    font-size: 11px;
    color: #636e72;
    margin-top: 8px;
    text-align: center;
}

.product-card-stock .stock-label {
    font-weight: 600;
}

.product-card-stock .stock-value {
    color: #00b894;
    font-weight: 700;
}

/* Sold Info (Optional) */
.product-card-sold {
    font-size: 11px;
    color: #636e72;
    margin-top: 4px;
    text-align: center;
}

/* Responsive Adjustments - Mobile */
@media (max-width: 575px) {
    .product-card-modern {
        border-radius: 10px;
    }
    
    .product-card-image-wrapper {
        padding-top: 100%; /* Giữ 1:1 aspect ratio trên mobile - không thay đổi */
        border-radius: 10px 10px 0 0; /* Match với card border-radius */
    }
    
    /* Ảnh tự động vừa khung, không bị crop */
    .product-card-image-wrapper img {
        /* Ảnh vừa khung dù to hay nhỏ - giống logo TikTok */
        object-fit: contain;
        object-position: center center;
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    .product-card-content {
        padding: 12px;
    }
    
    .product-card-name {
        font-size: 15px;
        min-height: 44px;
    }
    
    .product-card-price-current {
        font-size: 18px;
    }
    
    .product-card-buy-btn {
        padding: 12px;
        font-size: 13px;
        min-height: 44px;
    }
    
    .product-card-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .product-card-detail-btn,
    .product-card-buy-btn {
        width: 100%;
    }
    
    .product-card-stock-info {
        flex-direction: column;
        gap: 6px;
    }
}

/* Override Bootstrap grid khi dùng với product-grid-modern */
.product-grid-modern .prod-item {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    /* Đảm bảo không có viền thừa */
    border: none !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Đảm bảo product-card-modern trong grid không có margin/padding thừa */
.product-grid-modern .product-card-modern {
    margin: 0;
    padding: 0;
    border: none;
    /* Đảm bảo kích thước đồng nhất */
    width: 100%;
    box-sizing: border-box;
}

/* Đảm bảo image-wrapper có kích thước đồng nhất trên mọi thiết bị */
.product-grid-modern .product-card-image-wrapper {
    /* Luôn giữ tỉ lệ 1:1 trên mọi thiết bị */
    aspect-ratio: 1 / 1;
    padding-top: 100%;
}

/* Đảm bảo ảnh vừa khung - áp dụng cho tất cả breakpoint */
.product-grid-modern .product-card-image-wrapper img {
    /* Ảnh vừa khung, không bị crop - giống logo TikTok */
    object-fit: contain !important;
    object-position: center center !important;
    /* Căn giữa hoàn hảo */
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
}

