/* ===================================
   PROFESSIONAL PRODUCT CARDS - FINAL
   =================================== */

/* Force Grid Layout on all containers */
#gridLayout,
#gridLayout.wrapper-shop,
.wrapper-shop.tf-grid-layout,
.tf-grid-layout {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 20px !important;
}

#grid-product-wrapper,
#grid-product-wrapper.enhanced-product-wrapper {
    display: contents !important;
}

@media (max-width: 1200px) {
    #gridLayout,
    .wrapper-shop.tf-grid-layout,
    .tf-grid-layout { 
        grid-template-columns: repeat(3, 1fr) !important; 
    }
}

@media (max-width: 768px) {
    #gridLayout,
    .wrapper-shop.tf-grid-layout,
    .tf-grid-layout { 
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 12px !important; 
    }
}

/* Product Card */
.card-product {
    background: #ffffff !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08) !important;
    border: 1px solid #eee !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    flex-direction: column !important;
}

.card-product:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
    border-color: #ff6b35 !important;
    transform: translateY(-4px) !important;
}

/* Product Image Wrapper */
.card-product .card-product-wrapper {
    position: relative !important;
    background: #f8f8f8 !important;
    padding: 20px !important;
    min-height: 200px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Product Image Link */
.card-product .product-img {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: auto !important;
    min-height: 150px !important;
}

/* Product Images - CRITICAL FIX */
.card-product .product-img img,
.card-product .product-img img.img-product,
.card-product .product-img img.lazyload,
.card-product .product-img img.lazyloaded,
.card-product .product-img img.ls-is-cached {
    max-width: 100% !important;
    max-height: 160px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
    margin: 0 auto !important;
}

.card-product .product-img img.img-hover {
    display: none !important;
}

/* Discount Badge */
.card-product .product-badge {
    position: absolute !important;
    top: 12px !important;
    left: 12px !important;
    z-index: 10 !important;
}

.card-product .badge-discount {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%) !important;
    color: #fff !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    display: inline-block !important;
    box-shadow: 0 2px 8px rgba(255, 65, 108, 0.3) !important;
}

/* Quick Action Buttons */
.card-product .list-product-btn {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    opacity: 0 !important;
    transform: translateX(10px) !important;
    transition: all 0.3s ease !important;
    z-index: 10 !important;
}

.card-product:hover .list-product-btn {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

.card-product .list-product-btn .box-icon {
    width: 36px !important;
    height: 36px !important;
    background: #fff !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.card-product .list-product-btn .box-icon:hover {
    background: #ff6b35 !important;
}

.card-product .list-product-btn .box-icon:hover .icon {
    color: #fff !important;
}

.card-product .list-product-btn .tooltip {
    display: none !important;
}

/* Add to Cart Button */
.card-product .list-btn-main {
    position: absolute !important;
    bottom: 12px !important;
    left: 12px !important;
    right: 12px !important;
    opacity: 0 !important;
    transform: translateY(10px) !important;
    transition: all 0.3s ease !important;
    z-index: 10 !important;
}

.card-product:hover .list-btn-main {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.card-product .btn-main-product,
.card-product .btn-add-to-cart {
    display: block !important;
    width: 100% !important;
    padding: 12px 16px !important;
    background: linear-gradient(135deg, #ff6b35 0%, #f7522d 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-align: center !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3) !important;
    transition: all 0.2s ease !important;
}

.card-product .btn-main-product:hover,
.card-product .btn-add-to-cart:hover {
    background: linear-gradient(135deg, #f7522d 0%, #ff6b35 100%) !important;
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4) !important;
}

/* Product Info Section */
.card-product .card-product-info {
    padding: 16px !important;
    background: #fff !important;
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    border-top: 1px solid #f0f0f0 !important;
}

.card-product .card-product-info .title,
.card-product .card-product-info .title.link {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    text-decoration: none !important;
    line-height: 1.4 !important;
    margin-bottom: 6px !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    min-height: 40px !important;
}

.card-product .card-product-info .title:hover {
    color: #ff6b35 !important;
}

.card-product .card-product-info .attribute {
    font-size: 13px !important;
    color: #666 !important;
    margin-bottom: 8px !important;
    display: block !important;
    font-weight: 500 !important;
}

.card-product .card-product-info .price {
    font-size: 20px !important;
    font-weight: 700 !important;
    color: #ff6b35 !important;
    margin-top: auto !important;
    display: block !important;
}

.card-product .card-product-info .price .old-price {
    font-size: 14px !important;
    color: #999 !important;
    text-decoration: line-through !important;
    font-weight: 400 !important;
    margin-left: 8px !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .card-product .card-product-wrapper {
        min-height: 160px !important;
        padding: 15px !important;
    }
    
    .card-product .product-img {
        min-height: 120px !important;
    }
    
    .card-product .product-img img,
    .card-product .product-img img.img-product {
        max-height: 120px !important;
    }
    
    .card-product .card-product-info {
        padding: 12px !important;
    }
    
    .card-product .card-product-info .title {
        font-size: 13px !important;
        min-height: 36px !important;
    }
    
    .card-product .card-product-info .price {
        font-size: 17px !important;
    }
    
    .card-product .list-btn-main {
        bottom: 8px !important;
        left: 8px !important;
        right: 8px !important;
    }
    
    .card-product .btn-main-product,
    .card-product .btn-add-to-cart {
        padding: 10px 12px !important;
        font-size: 11px !important;
    }
}

/* ===================================
   LIST VIEW - PROFESSIONAL DESIGN
   =================================== */

/* List Layout Container */
#listLayout,
.tf-list-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
}

/* List View Card */
#listLayout .card-product,
.tf-list-layout .card-product,
.card-product.style-list {
    display: flex !important;
    flex-direction: row !important;
    background: #fff !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08) !important;
    border: 1px solid #eee !important;
    height: auto !important;
    min-height: 180px !important;
}

#listLayout .card-product:hover,
.tf-list-layout .card-product:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.12) !important;
    border-color: #ff6b35 !important;
    transform: none !important;
}

/* List View - Image Wrapper */
#listLayout .card-product .card-product-wrapper,
.tf-list-layout .card-product .card-product-wrapper {
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    min-height: 180px !important;
    padding: 15px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #f8f8f8 !important;
    position: relative !important;
}

/* List View - Product Image */
#listLayout .card-product .product-img,
.tf-list-layout .card-product .product-img {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    min-height: auto !important;
}

#listLayout .card-product .product-img img,
.tf-list-layout .card-product .product-img img {
    max-width: 150px !important;
    max-height: 140px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

/* List View - Discount Badge */
#listLayout .card-product .product-badge,
.tf-list-layout .card-product .product-badge {
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
}

/* List View - Quick Actions - Hide on list */
#listLayout .card-product .list-product-btn,
.tf-list-layout .card-product .list-product-btn {
    display: none !important;
}

/* List View - Add to Cart - Always hide in wrapper */
#listLayout .card-product .list-btn-main,
.tf-list-layout .card-product .list-btn-main {
    display: none !important;
}

/* List View - Product Info */
#listLayout .card-product .card-product-info,
.tf-list-layout .card-product .card-product-info {
    flex: 1 !important;
    padding: 20px 24px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    background: #fff !important;
    border-top: none !important;
}

#listLayout .card-product .card-product-info .title,
.tf-list-layout .card-product .card-product-info .title {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin-bottom: 8px !important;
    min-height: auto !important;
    -webkit-line-clamp: 2 !important;
}

#listLayout .card-product .card-product-info .attribute,
.tf-list-layout .card-product .card-product-info .attribute {
    font-size: 14px !important;
    color: #666 !important;
    margin-bottom: 12px !important;
    background: #f5f5f5 !important;
    padding: 4px 12px !important;
    border-radius: 20px !important;
    display: inline-block !important;
    width: fit-content !important;
}

#listLayout .card-product .card-product-info .price,
.tf-list-layout .card-product .card-product-info .price {
    font-size: 22px !important;
    font-weight: 700 !important;
    color: #ff6b35 !important;
    margin-bottom: 16px !important;
}

/* List View - Add Button in Info Section */
#listLayout .card-product .card-product-info::after,
.tf-list-layout .card-product .card-product-info::after {
    content: 'ADD TO CART' !important;
    display: inline-block !important;
    padding: 12px 24px !important;
    background: linear-gradient(135deg, #ff6b35 0%, #f7522d 100%) !important;
    color: #fff !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    width: fit-content !important;
    margin-top: auto !important;
}

/* Mobile List View */
@media (max-width: 768px) {
    #listLayout .card-product,
    .tf-list-layout .card-product {
        flex-direction: column !important;
        min-height: auto !important;
    }
    
    #listLayout .card-product .card-product-wrapper,
    .tf-list-layout .card-product .card-product-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 160px !important;
    }
    
    #listLayout .card-product .card-product-info,
    .tf-list-layout .card-product .card-product-info {
        padding: 16px !important;
    }
}

/* ===================================
   SORT DROPDOWN FIXES
   =================================== */

.tf-dropdown-sort {
    position: relative !important;
    cursor: pointer !important;
}

.tf-dropdown-sort .btn-select {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 16px !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    cursor: pointer !important;
}

.tf-dropdown-sort .dropdown-menu {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    z-index: 1000 !important;
    display: none !important;
    margin-top: 4px !important;
    min-width: 200px !important;
}

.tf-dropdown-sort .dropdown-menu.show {
    display: block !important;
}

.tf-dropdown-sort .select-item {
    padding: 10px 16px !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
}

.tf-dropdown-sort .select-item:hover {
    background: #f5f5f5 !important;
}

/* View Toggle Buttons */
.tf-view-layout-switch {
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
}

.tf-view-layout-switch:hover,
.tf-view-layout-switch.active {
    background: #333 !important;
    border-color: #333 !important;
    color: #fff !important;
}

.tf-view-layout-switch.active svg,
.tf-view-layout-switch.active .icon {
    color: #fff !important;
    fill: #fff !important;
}

/* ENSURE PRODUCTS ARE ALWAYS VISIBLE */
#gridLayout .card-product,
#grid-product-wrapper .card-product,
.tf-grid-layout .card-product,
.enhanced-product-wrapper .card-product {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}
/* ENSURE PRODUCTS ARE ALWAYS VISIBLE */
#gridLayout .card-product,
#grid-product-wrapper .card-product,
.tf-grid-layout .card-product,
.tf-list-layout .card-product,
.enhanced-product-wrapper .card-product,
.product-list-item .card-product {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

/* Default state: grid visible, list hidden (JS will toggle) */
#listLayout:not([style*="display: block"]) {
    display: none !important;
}

#gridLayout:not([style*="display: none"]) {
    display: grid !important;
}

/* Product List Item Wrapper */
.product-list-item {
    width: 100%;
    margin-bottom: 20px;
}

.product-list-item .card-product {
    display: flex !important;
    flex-direction: row !important;
    width: 100% !important;
}
