/* Hide post date */
.entry-date,
.posted-on,
.date,
.published,
.updated,
.entry-meta .date,
.entry-meta .posted-on,
.post .date,
.single .date,
.ast-published-date,
.tribe-events-cal-links,
.entry-meta .byline,
.entry-meta .author,
.post-author,
.author-box,
.entry-author,
.author-info,
.posted-by,
.byline {
    display: none !important;
}

/* Hide author name */
.author,
.author-name,
.author-link,
.entry-meta .author,
.byline .author,
.posted-by,
.wp-block-post-author,
.wp-block-post-author__name {
    display: none !important;
}

/* If your theme uses a container for both, hide the whole meta line */
.entry-meta,
.post-meta,
.meta-info,
.post-info {
    /* This hides the entire bar that might contain date & author – remove if you still want categories */
    /* display: none !important; */
}

/* More specific: hide author and date only inside entry-meta */
.entry-meta .posted-on,
.entry-meta .byline,
.entry-meta .author {
    display: none !important;
}

/* Hide the post date block */
.wp-block-post-date {
    display: none !important;
}

/* Hide the post author block if it exists */
.wp-block-post-author {
    display: none !important;
}

/* Also hide any wrapper that might contain both */
.wp-block-post-date + .wp-block-post-author,
.wp-block-post-author + .wp-block-post-date {
    display: none !important;
}

/* Force product grid styling on ALL products, including Art & Jan Barboglio, even after AJAX filter */
.products li.product,
ul.products li.product,
.woocommerce ul.products li.product {
    flex: 1 1 23% !important;
    min-width: 200px !important;
    max-width: 23% !important;
    background: white !important;
    border: 1px solid #e8e1d7 !important;
    border-radius: 8px !important;
    padding: 15px !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Ensure buttons are green */
.products li.product .button,
ul.products li.product .button,
.woocommerce ul.products li.product .button {
    background: #1F4127 !important;
    color: white !important;
    margin-top: auto !important;
}

/* Force product grid styling on ALL products, including Art & Jan Barboglio, even after AJAX filter */
.products li.product,
ul.products li.product,
.woocommerce ul.products li.product {
    flex: 1 1 23% !important;
    min-width: 200px !important;
    max-width: 23% !important;
    background: white !important;
    border: 1px solid #e8e1d7 !important;
    border-radius: 8px !important;
    padding: 15px !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Ensure buttons are green */
.products li.product .button,
ul.products li.product .button,
.woocommerce ul.products li.product .button {
    background: #1F4127 !important;
    color: white !important;
    margin-top: auto !important;
}

/* Force product grid for all content areas – including AJAX-loaded */
.products,
ul.products,
.woocommerce div.products {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
}

.products li.product,
ul.products li.product,
.woocommerce ul.products li.product {
    flex: 1 1 23% !important;
    background: white !important;
    border: 1px solid #e8e1d7 !important;
    border-radius: 8px !important;
    padding: 15px !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Override pink hover on YITH label filters */
.yith-wcan-filters .filter-items .filter-item.label a:hover,
.yith-wcan-filters .filter-items .filter-item.label:hover {
    background-color: #1F4127 !important;
    border-color: #1F4127 !important;
    color: white !important;
}

/* If the pink appears on active filters too */
.yith-wcan-filters .filter-items .filter-item.label.active a,
.yith-wcan-filters .filter-items .filter-item.label.active {
    background-color: #1F4127 !important;
    border-color: #1F4127 !important;
    color: white !important;
}

/* For a lighter hover (optional) */
.yith-wcan-filters .filter-items .filter-item.label a:hover,
.yith-wcan-filters .filter-items .filter-item.label:hover {
    background-color: #2d5a3a !important; /* slightly lighter green */
}

/* Remove pink outline on hover/focus/active for YITH label filters */
.yith-wcan-filters .filter-items .filter-item.label a:hover,
.yith-wcan-filters .filter-items .filter-item.label a:focus,
.yith-wcan-filters .filter-items .filter-item.label a:active,
.yith-wcan-filters .filter-items .filter-item.label a:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border-color: #1F4127 !important;
}

/* Also target the span or div inside if needed */
.yith-wcan-filters .filter-items .filter-item.label a:focus-visible span,
.yith-wcan-filters .filter-items .filter-item.label a:hover span {
    outline: none !important;
    box-shadow: none !important;
}

function sort_by_newest_first( $q ) {
    // Check if we're on a product archive or the main shop page
    if ( $q->is_main_query() && ( is_shop() || is_product_category() ) ) {
        $q->set( 'orderby', 'date' );
        $q->set( 'order', 'DESC' );
    }
}
add_action( 'woocommerce_product_query', 'sort_by_newest_first' );