/**
 * TNCODTHEME - Product Grid Styles
 * Clean product cards matching reference design
 * Version: 4.0
 * Author: digitaliny
 */

/* ===========================================
   CSS CUSTOM PROPERTIES
   =========================================== */

:root {
    --product-primary: var(--primary-color, #00b894);
    --product-primary-dark: var(--secondary-color, #00a885);
    --product-text: #2d3436;
    --product-text-light: #636e72;
    --product-border: #e8e8e8;
    --product-bg: #ffffff;
    --product-badge-sale: #e91e63;
    --product-badge-new: var(--primary-color, #00b894);
    --product-badge-hot: #ff5722;
    --product-radius: 16px;
}

/* ===========================================
   PRODUCT GRID CONTAINER
   =========================================== */

.products.row,
ul.products,
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    padding: 20px 0;
    list-style: none;
    margin: 0;
}

/* Remove old column classes */
.products .col-6,
.products .col-4,
.products .col-3 {
    width: 100%;
    max-width: 100%;
    flex: none;
    padding: 0;
}

/* ===========================================
   PRODUCT CARD - Reference Design
   =========================================== */

.item-product,
li.product,
li.product-card,
.product-card,
.products-grid .product-card {
    background: var(--product-bg);
    border: 1px solid var(--product-border);
    border-radius: var(--product-radius);
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    list-style: none;
    margin: 0;
    padding: 0;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.06);
}

.item-product:hover,
li.product:hover,
.product-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(-3px);
}

/* ===========================================
   PRODUCT BADGE - Compact Inline Style
   =========================================== */

.item-product .onsale,
.item-product .product-badge,
li.product .onsale,
li.product .product-badge,
.product-card .product-badge,
.woocommerce .products .onsale,
.woocommerce ul.products li.product .onsale {
    display: inline-block !important;
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    right: auto !important;
    bottom: auto !important;
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    border-radius: 20px !important;
    z-index: 10 !important;
    color: #fff !important;
    min-height: unset !important;
    min-width: unset !important;
    max-width: fit-content !important;
    width: fit-content !important;
    height: auto !important;
    line-height: 1 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    margin: 0 !important;
    text-transform: none !important;
    white-space: nowrap !important;
}

.item-product .onsale,
li.product .onsale,
.woocommerce .products .onsale,
.badge-sale {
    background: #e53e3e !important;
}

.badge-new {
    background: var(--product-badge-new) !important;
}

.badge-hot {
    background: var(--product-badge-hot) !important;
}

.badge-bestseller {
    background: #9b59b6 !important;
}

/* RTL Badge - Move to right side */
.rtl .item-product .onsale,
.rtl .item-product .product-badge,
.rtl li.product .onsale,
.rtl li.product .product-badge,
.rtl .product-card .product-badge,
body.rtl .woocommerce ul.products li.product .onsale {
    left: auto !important;
    right: 10px !important;
}

/* ===========================================
   PRODUCT IMAGE - Fill Container No Padding
   =========================================== */

.item-product .woocommerce-LoopProduct-link,
li.product .woocommerce-LoopProduct-link,
.product-card .product-image,
.woocommerce ul.products li.product a.woocommerce-LoopProduct-link {
    display: block !important;
    position: relative !important;
    overflow: hidden !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    height: 220px !important;
    min-height: 220px !important;
    max-height: 220px !important;
}

.item-product .attachment-woocommerce_thumbnail,
.item-product .wp-post-image,
li.product .attachment-woocommerce_thumbnail,
li.product .wp-post-image,
.product-card .product-image img,
.woocommerce ul.products li.product a img,
.woocommerce ul.products li.product .woocommerce-LoopProduct-link img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center !important;
    transition: transform 0.3s ease !important;
    display: block !important;
    border-radius: 16px 16px 0 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.item-product:hover .attachment-woocommerce_thumbnail,
.item-product:hover .wp-post-image,
li.product:hover .attachment-woocommerce_thumbnail,
li.product:hover .wp-post-image,
.product-card:hover .product-image img {
    transform: scale(1.05);
}

/* No image placeholder */
.product-card .product-image .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--product-text-light);
    font-size: 48px;
    background: #f5f5f5;
    border-radius: 12px;
}

/* ===========================================
   PRODUCT INFO / CONTENT
   =========================================== */

.item-product .item-content,
li.product .item-content,
.product-card .product-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex-grow: 1;
    gap: 12px;
}

/* ===========================================
   PRODUCT TITLE - With Bullet Point
   =========================================== */

.item-product .woocommerce-loop-product__title,
li.product .woocommerce-loop-product__title,
.product-card .product-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--product-text);
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    position: relative;
}

.product-card .product-title::before {
    content: '■';
    color: var(--product-primary);
    margin-left: 6px;
    font-size: 0.6em;
    vertical-align: middle;
}

.product-card .product-title a {
    color: inherit;
    text-decoration: none;
}

.product-card .product-title a:hover {
    color: var(--product-primary);
}

.item-product:hover .woocommerce-loop-product__title,
li.product:hover .woocommerce-loop-product__title {
    color: var(--product-primary);
}

/* ===========================================
   PRODUCT PRICE - Old/New Side by Side
   =========================================== */

.item-product .price,
li.product .price,
.product-card .product-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--product-text);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Original price (strikethrough) */
.item-product .price del,
li.product .price del,
.product-card .product-price del {
    font-size: 0.9rem;
    color: #b0b0b0;
    font-weight: 500;
    text-decoration: line-through;
    order: 2;
}

/* Sale price */
.item-product .price ins,
li.product .price ins,
.product-card .product-price ins {
    background: none;
    text-decoration: none;
    font-weight: 700;
    color: var(--product-text);
    order: 1;
}

.item-product .price .woocommerce-Price-amount,
li.product .price .woocommerce-Price-amount {
    color: inherit;
}

/* ===========================================
   PRODUCT RATING
   =========================================== */

.item-product .star-rating,
li.product .star-rating {
    margin: 5px 0;
    font-size: 14px;
}

.item-product .star-rating span::before,
li.product .star-rating span::before {
    color: #f1c40f;
}

/* ===========================================
   ADD TO CART BUTTON - Full Width Black
   =========================================== */

.item-product .button,
.item-product .add_to_cart_button,
li.product .button,
li.product .add_to_cart_button,
.product-card .product-btn,
.woocommerce ul.products li.product .button,
.woocommerce ul.products li.product a.add_to_cart_button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 14px 20px !important;
    background: #2d3436 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 12px !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    margin-top: 12px !important;
    text-decoration: none !important;
    line-height: 1.2 !important;
}

.item-product .button:hover,
.item-product .add_to_cart_button:hover,
li.product .button:hover,
li.product .add_to_cart_button:hover,
.product-card .product-btn:hover,
.woocommerce ul.products li.product .button:hover,
.woocommerce ul.products li.product a.add_to_cart_button:hover {
    background: #1a1d1e !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3) !important;
    color: #fff !important;
}

/* Cart icon before text */
.item-product .button::before,
.item-product .add_to_cart_button::before,
li.product .button::before,
li.product .add_to_cart_button::before,
.woocommerce ul.products li.product .button::before,
.woocommerce ul.products li.product a.add_to_cart_button::before {
    content: '\f07a';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 1rem;
}

.product-card .product-btn i {
    font-size: 1.1rem;
}

/* Variable/Grouped Products */
.item-product .button.product_type_variable,
.item-product .button.product_type_grouped,
li.product .button.product_type_variable,
li.product .button.product_type_grouped {
    background: #f8f9fa;
    color: var(--product-text) !important;
    border: 2px solid var(--product-border);
}

.item-product .button.product_type_variable:hover,
.item-product .button.product_type_grouped:hover,
li.product .button.product_type_variable:hover,
li.product .button.product_type_grouped:hover {
    background: var(--product-primary);
    color: #fff !important;
    border-color: transparent;
}

/* ===========================================
   OUT OF STOCK
   =========================================== */

.item-product.outofstock .attachment-woocommerce_thumbnail,
li.product.outofstock .attachment-woocommerce_thumbnail {
    opacity: 0.5;
    filter: grayscale(30%);
}

.item-product.outofstock::after,
li.product.outofstock::after {
    content: 'نفذ المخزون';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    z-index: 15;
}

/* ===========================================
   NO PRODUCTS MESSAGE
   =========================================== */

.no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 30px;
    background: var(--product-bg);
    border-radius: var(--product-radius);
    border: 2px dashed var(--product-border);
}

.no-products i {
    font-size: 48px;
    color: var(--product-text-light);
    margin-bottom: 20px;
    display: block;
}

.no-products.woo-notice i {
    color: #f39c12;
}

.no-products p {
    font-size: 1.1rem;
    color: var(--product-text-light);
    margin-bottom: 20px;
}

.add-product-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: var(--product-primary);
    color: #fff !important;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.add-product-btn:hover {
    background: var(--product-primary-dark);
    color: #fff !important;
    transform: translateY(-2px);
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 768px) {

    .products.row,
    ul.products,
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .item-product .item-content,
    li.product .item-content,
    .product-card .product-info {
        padding: 15px;
        gap: 10px;
    }

    .item-product .woocommerce-loop-product__title,
    li.product .woocommerce-loop-product__title,
    .product-card .product-title {
        font-size: 0.9rem;
    }

    .item-product .price,
    li.product .price,
    .product-card .product-price {
        font-size: 1rem;
        gap: 8px;
    }

    .item-product .price del,
    li.product .price del,
    .product-card .product-price del {
        font-size: 0.8rem;
    }

    .item-product .button,
    .item-product .add_to_cart_button,
    li.product .button,
    li.product .add_to_cart_button,
    .product-card .product-btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .item-product .onsale,
    .item-product .product-badge,
    li.product .onsale,
    li.product .product-badge,
    .product-card .product-badge {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {

    .products.row,
    ul.products,
    .products-grid {
        gap: 12px;
    }

    :root {
        --product-radius: 14px;
    }

    .item-product .item-content,
    li.product .item-content,
    .product-card .product-info {
        padding: 12px;
    }
}

/* ===========================================
   RTL SUPPORT
   =========================================== */

.rtl .item-product .item-content,
.rtl li.product .item-content,
.rtl .product-card .product-info {
    text-align: center;
}

.rtl .product-card .product-title::before {
    margin-left: 0;
    margin-right: 6px;
}

.rtl .item-product .price,
.rtl li.product .price,
.rtl .product-card .product-price {
    direction: ltr;
}

.rtl .item-product .price del,
.rtl li.product .price del {
    order: 1;
}

.rtl .item-product .price ins,
.rtl li.product .price ins {
    order: 2;
}