/* === Modern Product Card Styles === */

/* Container products: garantisce altezza uniforme delle card */
ul.products,
.products {
    display: flex !important;
    flex-wrap: wrap;
    align-items: stretch;
}

/* Reset stili card esistenti */
.products .product-card-modern.product {
    padding: 0;
    margin-bottom: 30px;
    /* Tutte le card stessa altezza nella riga */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: 100%;
}

.product-card-modern .card-inner {
    background: #ffffff;
    border-radius: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card-modern .card-inner:hover {
    transform: translateY(-4px);
}

/* === Immagine Cover === */
.product-card-modern .card-image {
    position: relative;
    overflow: hidden;
    /* 3 (width) : 4 (height) = formato verticale */
    aspect-ratio: 3/4;
    background: #f5f5f5;
    flex-shrink: 0;
    width: 100%;
    min-height: 0;
}

.product-card-modern .card-image a {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    min-height: 0;
}

.product-card-modern .card-img,
.product-card-modern .card-image img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.4s ease;
    display: block;
    /* Ignora dimensioni intrinseche (width/height HTML) per uniformità */
}

.product-card-modern .card-inner:hover .card-img,
.product-card-modern .card-inner:hover .card-image img {
    transform: scale(1.05);
}

/* Labels */
.product-card-modern .card-label {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    z-index: 2;
}

.product-card-modern .card-label.sale {
    background: #E74338;
    color: #fff;
}

.product-card-modern .card-label.new {
    background: #25D366;
    color: #fff;
}

/* Porto labels override */
.product-card-modern .labels {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

.product-card-modern .labels label {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
}

/* === Contenuto Card === */
.product-card-modern .card-content {
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Categoria */
.product-card-modern .card-category {
    margin-bottom: 8px;
}

.product-card-modern .card-category a {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.product-card-modern .card-category a:hover {
    color: #E74338;
}

/* Titolo */
.product-card-modern .card-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 15px 0;
    color: #222;
}

.product-card-modern .card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.product-card-modern .card-title a:hover {
    color: #E74338;
}

/* === Attributi con icone === */
.product-card-modern .card-attributes {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-bottom: 10px;
    flex-grow: 1;
}

.product-card-modern .card-attr {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #000;
}

/* Prezzo su riga propria */
.product-card-modern .card-attr.card-price {
    width: 100%;
    align-items: center;
}

.product-card-modern .card-attr i {
    width: 18px;
    text-align: center;
    color: #E74338;
    font-size: 14px;
    flex-shrink: 0;
}

.product-card-modern .card-attr.card-price > i {
    align-self: center;
}

.product-card-modern .card-attr span {
    flex: 1;
}

/* Prezzo */
.product-card-modern .card-price {
    font-weight: 600;
    color: #222 !important;
    padding-top: 10px;
    border-top: 1px solid #eee;
    margin-top: auto;
}

.product-card-modern .card-price span {
    font-size: 18px;
}

@media (max-width: 767px) {
    .product-card-modern .card-price span {
        font-size: 14px;
    }
}

.product-card-modern .card-price .cost-prefix {
    display: inline;
    font-weight: 600;
    color: #000;
}

.product-card-modern .card-price .cost-value {
    display: inline;
    font-size: 22px;
    font-weight: 600;
    color: #E74338;
}


.product-card-modern .card-price .price {
    white-space: nowrap;
}

.product-card-modern .card-price .cost-suffix {
    display: inline;
    font-weight: 600;
    color: #E74338;
}

.product-card-modern .card-price small {
    font-weight: 400;
    color: #888;
    font-size: 12px;
}

.product-card-modern .card-price .woocommerce-Price-amount {
    color: #E74338;
}

/* Prezzo: usa SOLO le classi standard (come "Nuovi arrivi") */
.product-card-modern .card-price .price {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #222 !important;
    font-family: inherit !important;
    opacity: 1 !important;
}

.product-card-modern .card-price .cost-prefix {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #000 !important;
}

.product-card-modern .card-price .cost-value,
.product-card-modern .card-price .cost-value .woocommerce-Price-amount {
    font-size: 22px !important;
    font-weight: 600 !important;
    color: #E74338 !important;
}

.product-card-modern .card-price .cost-suffix {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #E74338 !important;
}

/* Mobile: prezzo allineato a category card */
@media (max-width: 575px) {
    .product-card-modern .card-price .price {
        font-size: 14px !important;
    }
    .product-card-modern .card-price .cost-prefix,
    .product-card-modern .card-price .cost-suffix {
        font-size: 14px !important;
    }
    .product-card-modern .card-price .cost-value,
    .product-card-modern .card-price .cost-value .woocommerce-Price-amount {
        font-size: 18px !important;
    }
}

/* Se il tema “sbiadisce” gli outofstock, non toccare il prezzo */
li.product.outofstock .product-card-modern .card-price {
    opacity: 1 !important;
}

/* Prezzo pieno (regular) prima del prezzo al mq/ml, dentro hk_unit_price_html */
.product-card-modern .card-price .cost-regular {
    font-size: 14px;
    font-weight: 400;
    color: rgba(231, 67, 56, 0.6);
    text-decoration: line-through;
    white-space: nowrap;
}

/* Variante generica: ovunque compaia .cost-regular dentro .price (es. risultati search) */
.price .cost-regular {
    font-size: 14px;
    font-weight: 400;
    color: rgba(231, 67, 56, 0.6);
    text-decoration: line-through;
    white-space: nowrap;
}

/* Font size generale per elemento price */
.price {
    font-size: 18px;
}

/* Prezzo scontato nelle search: 14px rosso bold */
.search .price .cost-value .woocommerce-Price-amount {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #E74338 !important;
}

/* === Bottone === */
.product-card-modern .card-action {
    margin-top: auto;
}

.product-card-modern .card-button {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: #222;
    color: #fff;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-decoration: none;
    border-radius: 0;
    transition: all 0.3s ease;
}

.product-card-modern .card-button:hover {
    background: #E74338;
    color: #fff;
    text-decoration: none;
}

/* === Responsive === */
@media (max-width: 991px) {
    .product-card-modern .card-content {
        padding-top: 16px;
    }
    
    .product-card-modern .card-title {
        font-size: 15px;
    }
    
    .product-card-modern .card-attr {
        font-size: 12px;
    }
}

@media (max-width: 767px) {
    .product-card-modern .card-image {
        /* Mantieni sempre formato verticale anche su mobile */
        aspect-ratio: 3/4;
    }
    
    .product-card-modern .card-content {
        padding-top: 14px;
    }
    
    .product-card-modern .card-title {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    .product-card-modern .card-attributes {
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .product-card-modern .card-button {
        padding: 12px 16px;
        font-size: 12px;
    }
}

/* === Grid override per Porto === */
/* Quando il container usa grid, le card devono avere altezza uniforme */
ul.products[class*="ccols"],
.products[class*="ccols"],
ul.products.elementor-grid,
.products.elementor-grid,
ul.products.has-ccols,
.products.has-ccols {
    display: grid !important;
    align-items: stretch !important;
}

/* Su desktop: griglia CSS con colonne uguali (risolve dimensioni immagini diverse) */
/* XL (≥1200px): 5 colonne */
@media (min-width: 1200px) {
    ul.products.elementor-grid.ccols-xl-5,
    .products.elementor-grid.ccols-xl-5,
    ul.products.products-container.ccols-xl-5,
    .products.products-container.ccols-xl-5 {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }
}
/* LG (992-1199px): 4 colonne */
@media (min-width: 992px) and (max-width: 1199px) {
    ul.products.elementor-grid.ccols-lg-4,
    .products.elementor-grid.ccols-lg-4,
    ul.products.products-container.ccols-lg-4,
    .products.products-container.ccols-lg-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

/* Ogni card occupa tutta la cella, min-width 0 evita dimensioni diverse */
ul.products.elementor-grid li.product,
.products.elementor-grid li.product,
ul.products.has-ccols li.product,
.products.has-ccols li.product {
    min-width: 0;
}

ul.products[class*="ccols"] .product-card-modern,
.products[class*="ccols"] .product-card-modern,
ul.products.elementor-grid .product-card-modern,
.products.elementor-grid .product-card-modern,
ul.products.has-ccols .product-card-modern,
.products.has-ccols .product-card-modern,
ul.products[class*="ccols"] li.product,
.products[class*="ccols"] li.product,
ul.products.elementor-grid li.product,
.products.elementor-grid li.product {
    height: 100% !important;
    display: flex !important;
    flex-direction: column;
}

.products.columns-4 .product-card-modern {
    width: calc(25% - 22.5px);
}

.products.columns-3 .product-card-modern {
    width: calc(33.333% - 20px);
}

.products.columns-2 .product-card-modern {
    width: calc(50% - 15px);
}

@media (max-width: 991px) {
    .products.columns-4 .product-card-modern,
    .products.columns-3 .product-card-modern {
        width: calc(50% - 15px);
    }
}

@media (max-width: 575px) {
    .products.columns-4 .product-card-modern,
    .products.columns-3 .product-card-modern,
    .products.columns-2 .product-card-modern {
        width: 100%;
    }
}

/* Nascondi elementi originali Porto se presenti nella stessa pagina */
.product-card-modern .product-image,
.product-card-modern .product-content,
.product-card-modern .add-links-wrap,
.product-card-modern .price:not(.card-price span),
.product-card-modern .category-list,
.product-card-modern .woocommerce-loop-product__title {
    display: none !important;
}

/* === Regole aggiuntive per altezza uniforme === */
/* Garantisce che tutte le card nella stessa riga abbiano la stessa altezza */
ul.products li.product-card-modern,
.products li.product-card-modern {
    display: flex !important;
    flex-direction: column;
    height: 100%;
}

/* Forza altezza uniforme delle immagini in tutti i contesti */
.product-card-modern .card-image {
    min-height: 0;
    flex-shrink: 0;
}

/* Assicura che le immagini rispettino sempre l'aspect-ratio */
.product-card-modern .card-image img,
.product-card-modern .card-img {
    min-height: 0;
    max-height: 100%;
}

/* Per slider e carousel */
.products-slider-track .product-card-modern,
.products-slider-wrap .product-card-modern {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Per pagine categoria e archive */
.woocommerce-page ul.products .product-card-modern,
.archive ul.products .product-card-modern,
.tax-product_cat ul.products .product-card-modern {
    height: 100%;
    display: flex;
    flex-direction: column;
}
