/**
 * MATOO Product Card Styles - Vinted Style
 *
 * @package Matoo_Marketplace
 * @since 4.2.2
 */

/* ============================================
   GRID GAP - Using margin instead of gap for better compatibility
   ============================================ */

/* Reset any gap that might cause issues */
.woocommerce ul.products {
    gap: 0 !important;
}

/* Riode theme grid - use negative margin + padding approach */
.woocommerce .products.row {
    margin-left: -10px !important;
    margin-right: -10px !important;
}

.woocommerce .products.row > li,
.woocommerce .products.row > li.product {
    padding-left: 10px !important;
    padding-right: 10px !important;
    margin-bottom: 20px !important;
}

/* MATOO Recommend Grid - same approach */
.matoo-recommend-grid {
    gap: 0 !important;
    margin-left: -10px !important;
    margin-right: -10px !important;
}

.matoo-recommend-grid > li,
.matoo-recommend-grid > li.product {
    padding-left: 10px !important;
    padding-right: 10px !important;
    margin-bottom: 20px !important;
}

/* Dokan store products */
.dokan-store-products-wrap .products {
    gap: 0 !important;
    margin-left: -10px !important;
    margin-right: -10px !important;
}

.dokan-store-products-wrap .products > li {
    padding-left: 10px !important;
    padding-right: 10px !important;
    margin-bottom: 20px !important;
}

/* ============================================
   PRODUCT CARD CONTAINER
   ============================================ */

.matoo-product-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    height: 100%;
}

.matoo-product-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ============================================
   VENDOR HEADER
   ============================================ */

.matoo-card-vendor {
    padding: 12px 12px 8px;
}

.matoo-card-vendor-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.matoo-card-vendor-link:hover {
    text-decoration: none;
    color: inherit;
}

.matoo-card-vendor-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #E1DBCB;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.matoo-card-vendor-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.matoo-card-vendor-initials {
    font-size: 14px;
    font-weight: 600;
    color: #5E6A60;
}

.matoo-card-vendor-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.matoo-card-vendor-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matoo-card-vendor-meta {
    font-size: 12px;
    color: #757575;
    display: flex;
    align-items: center;
    gap: 4px;
}

.matoo-card-vendor-separator {
    color: #9e9e9e;
}

/* ============================================
   PRODUCT IMAGE
   ============================================ */

.matoo-card-image {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f5f5f5;
}

.matoo-card-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.matoo-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

/* ============================================
   BADGES (Condition) - TOP RIGHT with margin
   ============================================ */

.matoo-card-badges {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5;
}

.matoo-card-badge {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: #1a1a1a;
    text-transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.matoo-card-condition {
    /* Specific styles for condition badge if needed */
}

/* ============================================
   SEASON ICON - TOP LEFT
   ============================================ */

.matoo-card-season-wrap {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 5;
}

.matoo-card-season {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.matoo-season-icon {
    width: 18px;
    height: 18px;
}

/* ============================================
   PRODUCT INFO
   ============================================ */

.matoo-card-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.matoo-card-category {
    font-size: 10px;
    font-weight: 500;
    color: #9e9e9e;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.matoo-card-title {
    font-size: 14px;
    font-weight: 400;
    color: #1a1a1a;
    text-decoration: none;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.matoo-card-title:hover {
    color: #5E6A60;
    text-decoration: none;
}

/* ============================================
   CARD FOOTER (Price + Wishlist)
   ============================================ */

.matoo-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 8px;
}

.matoo-card-price {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
}

.matoo-card-price del {
    color: #9e9e9e;
    font-weight: 400;
    font-size: 14px;
    margin-right: 6px;
}

.matoo-card-price ins {
    text-decoration: none;
    color: #007B20;
}

/* ============================================
   WISHLIST BUTTON - Custom SVG + Hidden YITH
   ============================================ */

.matoo-card-wishlist-wrap {
    flex-shrink: 0;
    position: relative;
}

/* Hide YITH button completely */
.matoo-yith-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Custom heart button */
.matoo-card-wishlist {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.matoo-card-wishlist:hover {
    background: #f5f5f5;
}

.matoo-card-wishlist svg {
    width: 22px;
    height: 22px;
    transition: all 0.2s ease;
}

.matoo-card-wishlist .heart-empty {
    color: #bdbdbd;
    display: block;
}

.matoo-card-wishlist .heart-filled {
    color: #5E6A60;
    display: none;
}

/* Hover: contorno verde brand */
.matoo-card-wishlist:hover .heart-empty {
    color: #5E6A60;
}

/* In wishlist: cuore pieno verde brand */
.matoo-card-wishlist.in-wishlist .heart-empty {
    display: none;
}

.matoo-card-wishlist.in-wishlist .heart-filled {
    display: block;
    color: #5E6A60;
}

/* Loading state */
.matoo-card-wishlist.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Animation */
@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.matoo-card-wishlist.animating .heart-filled {
    animation: heartPop 0.3s ease;
}

/* ============================================
   OWN PRODUCT CARD (with edit/delete)
   ============================================ */

/* Hide vendor header on own products */
.matoo-card-own-product .matoo-card-vendor {
    display: none;
}

/* Actions below card - uses same styles as drafts */
.matoo-card-wrap .matoo-draft-actions {
    margin-top: 0;
    padding-top: 12px;
}

/* ============================================
   OVERRIDE WOOCOMMERCE/RIODE DEFAULTS
   ============================================ */

/* Hide default WooCommerce elements when using Matoo card */
.matoo-card-wrap .product-wrap > *:not(.matoo-product-card),
.matoo-card-wrap .product-loop,
.matoo-card-wrap .product-media,
.matoo-card-wrap .product-details,
.matoo-card-wrap .product-action,
.matoo-card-wrap .yith-wcwl-add-to-wishlist,
.matoo-card-wrap .add_to_cart_button,
.matoo-card-wrap .product_type_simple,
.matoo-card-wrap .woocommerce-loop-product__title,
.matoo-card-wrap .price:not(.matoo-card-price),
.matoo-card-wrap .star-rating,
.matoo-card-wrap .product-label,
.matoo-card-wrap .label-new,
.matoo-card-wrap .label-sale {
    display: none !important;
}

.matoo-card-wrap .matoo-product-card {
    display: flex !important;
}

/* Product wrap adjustments */
.woocommerce ul.products li.product.matoo-card-wrap {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.woocommerce ul.products li.product.matoo-card-wrap .product-wrap {
    background: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Ensure card fills container */
.matoo-card-wrap,
.matoo-card-wrap .product-wrap {
    height: 100%;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 991px) {
    .woocommerce .products.row > li,
    .matoo-recommend-grid > li {
        margin-bottom: 16px !important;
    }
}

@media (max-width: 767px) {
    .woocommerce .products.row,
    .matoo-recommend-grid {
        margin-left: -8px !important;
        margin-right: -8px !important;
    }
    
    .woocommerce .products.row > li,
    .matoo-recommend-grid > li {
        padding-left: 8px !important;
        padding-right: 8px !important;
        margin-bottom: 16px !important;
    }

    .matoo-card-vendor {
        padding: 10px 10px 6px;
    }

    .matoo-card-vendor-avatar {
        width: 32px;
        height: 32px;
    }

    .matoo-card-vendor-name {
        font-size: 13px;
    }

    .matoo-card-vendor-meta {
        font-size: 11px;
    }

    .matoo-card-info {
        padding: 10px;
    }

    .matoo-card-title {
        font-size: 13px;
    }

    .matoo-card-price {
        font-size: 15px;
    }

    .matoo-card-wishlist {
        width: 32px;
        height: 32px;
    }

    .matoo-card-wishlist svg {
        width: 20px;
        height: 20px;
    }

    .matoo-card-badge {
        padding: 5px 10px;
        font-size: 11px;
    }

    .matoo-card-season {
        width: 28px;
        height: 28px;
    }

    .matoo-season-icon {
        width: 16px;
        height: 16px;
    }
    
    .matoo-card-badges {
        top: 8px;
        right: 8px;
    }
    
    .matoo-card-season-wrap {
        top: 8px;
        left: 8px;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes heartPop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

.matoo-card-wishlist.animating .heart-filled {
    animation: heartPop 0.3s ease;
}

/* ============================================
   FIX FOR RIODE THEME SPECIFIC ISSUES
   ============================================ */

/* Remove any conflicting styles from Riode */
.matoo-card-wrap.product-wrap {
    margin: 0 !important;
}

/* Ensure proper grid in all contexts */
ul.products.columns-4 .matoo-card-wrap,
ul.products.columns-3 .matoo-card-wrap,
ul.products.columns-2 .matoo-card-wrap {
    float: none !important;
}