/**
 * Product Card Overrides - Force Our Design
 * Higher specificity to override WooCommerce/Astra defaults
 *
 * Why !important? Astra and WooCommerce inject inline styles and
 * high-specificity selectors that our normal child theme CSS can't
 * override. This file uses !important to guarantee our design wins.
 *
 * @since 1.0.0
 */


/* ============================================
   HIDE ASTRA SHOPPING BAG HOVER ICON
   Removes the default "add to cart" overlay
   ============================================ */

.woocommerce ul.products li.product .ast-shop-product-out-of-stock,
.woocommerce ul.products li.product .astra-shop-thumbnail-wrap .ast-on-card-button,
.woocommerce ul.products li.product .ast-shop-hover-area,
.woocommerce .products .product .button.ajax_add_to_cart {
    display: none !important;
}

/* Remove Astra thumbnail overlay */
.woocommerce ul.products li.product .astra-shop-thumbnail-wrap::after {
    display: none !important;
}


/* ============================================
   PRODUCT GRID - Force CSS Grid Layout
   4 columns desktop, 2 tablet, 1 mobile
   ============================================ */

.woocommerce .products,
.woocommerce ul.products {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1.5rem !important;
    list-style: none !important;
    margin: 2rem 0 !important;
    padding: 0 !important;
}

/**
 * Sidebar layout — 3 columns when filter panel is visible.
 * Astra adds ast-left-sidebar / ast-right-sidebar to body
 * when a sidebar is active (e.g. Ryefield category pages with WOOF).
 * 4 columns is too cramped with the sidebar taking ~25% width.
 */
@media (min-width: 1025px) {
    .ast-left-sidebar .woocommerce .products,
    .ast-left-sidebar .woocommerce ul.products,
    .ast-right-sidebar .woocommerce .products,
    .ast-right-sidebar .woocommerce ul.products {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}


/* ============================================
   PRODUCT CARD BASE
   Clean white cards with subtle border
   ============================================ */

.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    background: var(--white, #ffffff) !important;
    border: 1px solid var(--border-color, #e5e7eb) !important;
    border-radius: var(--radius-md, 8px) !important;
    overflow: hidden !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
}


/* ============================================
   HOVER EFFECT - Card Lift + Shadow
   ============================================ */

.woocommerce ul.products li.product:hover,
.woocommerce-page ul.products li.product:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1) !important;
    border-color: var(--primary-red, #dc2626) !important;
}


/* ============================================
   PRODUCT IMAGE - 1:1 Ratio Container
   Excludes .product-category items (subcategory tiles)
   ============================================ */

/* Product link — normal flow so title + price are visible below image.
   Previously this had padding-top:100% + overflow:hidden which clipped
   the title and price that sit inside the same link element.
   position:static stops Astra's position:relative from making this a
   positioning context (only .astra-shop-thumbnail-wrap should be).
   height:auto + min-height:0 override the global 48px min-height for
   <a> tags (responsive.css touch targets) which constrains this wrapper. */
.woocommerce ul.products li.product:not(.product-category) .woocommerce-loop-product__link,
.woocommerce ul.products li.product:not(.product-category) a.woocommerce-LoopProduct-link {
    display: block !important;
    text-decoration: none !important;
    overflow: visible !important;
    position: static !important;
    height: auto !important;
    min-height: 0 !important;
}

/* Image wrapper — 1:1 aspect ratio, clips the image zoom effect only */
.woocommerce ul.products li.product:not(.product-category) .astra-shop-thumbnail-wrap {
    position: relative !important;
    padding-top: 100% !important;
    overflow: hidden !important;
    background: var(--light-gray, #f3f4f6) !important;
}

.woocommerce ul.products li.product:not(.product-category) .astra-shop-thumbnail-wrap img,
.woocommerce ul.products li.product:not(.product-category) .astra-shop-thumbnail-wrap .attachment-woocommerce_thumbnail {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    padding: 1rem !important;
    box-sizing: border-box !important;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Image zoom on hover — scoped to thumbnail wrap */
.woocommerce ul.products li.product:not(.product-category):hover .astra-shop-thumbnail-wrap img,
.woocommerce ul.products li.product:not(.product-category):hover .astra-shop-thumbnail-wrap .attachment-woocommerce_thumbnail {
    transform: scale(1.08) !important;
}

/**
 * Larger thumbnails when sidebar is active.
 * Reduce inner padding from 1rem to 0.5rem so the product image
 * fills more of the 1:1 square, making it more prominent.
 */
.ast-left-sidebar .woocommerce ul.products li.product:not(.product-category) .astra-shop-thumbnail-wrap img,
.ast-right-sidebar .woocommerce ul.products li.product:not(.product-category) .astra-shop-thumbnail-wrap img {
    padding: 0.5rem !important;
}

/* ============================================
   SUBCATEGORY TILES
   Structured card: gray image zone + text area
   Matches product card design language
   ============================================ */

/* Link wrapper — flex column fills the entire card */
.woocommerce ul.products li.product-category a {
    display: flex !important;
    flex-direction: column !important;
    text-decoration: none !important;
    height: 100% !important;
    padding: 0 !important;
}

/* Image zone — white background, border separates from text */
.woocommerce ul.products li.product-category a img {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 140px !important;
    object-fit: contain !important;
    padding: 0.75rem !important;
    background: var(--white, #ffffff) !important;
    border-bottom: 1px solid var(--border-color, #e5e7eb) !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
}

/* Title — override Astra's absolute positioning so it flows below the image */
.woocommerce ul.products li.product-category .woocommerce-loop-category__title {
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    background-color: #fef2f2 !important;
    font-family: var(--font-heading, 'Outfit', sans-serif) !important;
    font-size: var(--font-size-sm, 0.875rem) !important;
    font-weight: var(--font-weight-semibold, 600) !important;
    color: var(--dark-gray, #1f2937) !important;
    text-transform: none !important;
    text-align: center !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    padding: 0.75rem !important;
    flex: 1 !important;
}

/* Product count — lighter, smaller, below title */
.woocommerce ul.products li.product-category .woocommerce-loop-category__title mark,
.woocommerce ul.products li.product-category .woocommerce-loop-category__title .count {
    display: block !important;
    font-size: 0.75rem !important;
    font-weight: 400 !important;
    color: var(--medium-gray, #6b7280) !important;
    background: none !important;
    margin-top: 0.25rem !important;
}


/* ============================================
   PRODUCT TITLE
   ============================================ */

.woocommerce ul.products li.product .woocommerce-loop-product__title,
.woocommerce ul.products li.product:not(.product-category) h2 {
    font-family: 'Outfit', sans-serif !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: var(--dark-gray, #1f2937) !important;
    padding: 0 1rem 0.5rem !important;
    margin: 0 !important;
    line-height: 1.3 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    min-height: 3.9em !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Tighten up product card spacing */
.woocommerce ul.products li.product .astra-shop-summary-wrap {
    padding-top: 0.5em !important;
}


/* ============================================
   PRODUCT PRICE
   Visible upfront - trade customers need prices
   ============================================ */

.woocommerce ul.products li.product .price {
    font-family: 'DM Sans', sans-serif !important;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: var(--dark-gray, #1f2937) !important;
    padding: 0 1rem 0.5rem !important;
    margin: 0 !important;
}


/* ============================================
   CATEGORY BADGE - Hidden
   ============================================ */

.woocommerce ul.products li.product .ast-woo-product-category,
.ast-woo-product-category {
    display: none !important;
}


/* ============================================
   ADD TO CART BUTTON
   Red branded CTA at bottom of card
   ============================================ */

.woocommerce ul.products li.product .button.add_to_cart_button,
.woocommerce ul.products li.product .button.product_type_simple {
    display: block !important;
    width: calc(100% - 2rem) !important;
    margin: 0 1rem 1rem !important;
    padding: 0.875rem 1.5rem !important;
    background: var(--primary-red, #dc2626) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    font-family: 'DM Sans', sans-serif !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    text-align: center !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
}

.woocommerce ul.products li.product .button:hover {
    background: var(--red-hover, #b91c1c) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3) !important;
}


/* ============================================
   STOCK STATUS BADGE
   ============================================ */

.woocommerce ul.products li.product .stock {
    display: inline-block !important;
    padding: 0.25rem 0.75rem !important;
    background: #10b981 !important;
    color: white !important;
    border-radius: 4px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    margin: 0 0 0.5rem 1rem !important;
}

.woocommerce ul.products li.product .out-of-stock {
    background: #ef4444 !important;
}


/* ============================================
   CART — REMOVE BUTTON
   Replace Astra's naff SVG with a clean red circle + white X
   ============================================ */

.woocommerce-cart-form .product-remove a.remove {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    background: var(--primary-red, #dc2626) !important;
    border-radius: var(--radius-full, 9999px) !important;
    font-size: 0 !important; /* Hide original text content */
    text-decoration: none !important;
    text-indent: -9999px !important;
    transition: all var(--transition-fast, 0.15s ease) !important;
}

/* Hide Astra's SVG icon */
.woocommerce-cart-form .product-remove a.remove > * {
    display: none !important;
}

/* Clean bold white X */
.woocommerce-cart-form .product-remove a.remove::after {
    content: '\00d7' !important; /* × multiplication sign */
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    color: var(--white, #ffffff) !important;
    line-height: 1 !important;
    text-indent: 0 !important;
}

.woocommerce-cart-form .product-remove a.remove:hover {
    background: var(--red-hover, #b91c1c) !important;
    transform: scale(1.1) !important;
}


/* ============================================
   CART — PRODUCT NAME LINKS
   Red branded text to match site identity
   ============================================ */

.woocommerce-cart-form .product-name a {
    color: var(--primary-red, #dc2626) !important;
    text-decoration: none !important;
    font-weight: 600 !important;
}

.woocommerce-cart-form .product-name a:hover {
    color: var(--red-hover, #b91c1c) !important;
}


/* ============================================
   RESPONSIVE - Tablet (2 columns)
   ============================================ */

@media (max-width: 1024px) {
    .woocommerce .products,
    .woocommerce ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}


/* ============================================
   RESPONSIVE - Mobile (1 column)
   ============================================ */

@media (max-width: 768px) {
    .woocommerce .products,
    .woocommerce ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    /* Compact product cards on mobile - tighter padding */
    .woocommerce ul.products li.product .woocommerce-loop-product__title,
    .woocommerce ul.products li.product:not(.product-category) h2 {
        font-size: 0.8rem !important;
        padding: 0 0.625rem 0.35rem !important;
        min-height: 3.12em !important; /* 2-line clamp at smaller font */
    }

    .woocommerce ul.products li.product .price {
        font-size: 0.95rem !important;
        padding: 0 0.625rem 0.35rem !important;
    }

    .woocommerce ul.products li.product .button.add_to_cart_button,
    .woocommerce ul.products li.product .button.product_type_simple {
        width: calc(100% - 1.25rem) !important;
        margin: 0 0.625rem 0.625rem !important;
        padding: 0.625rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
}


/* ============================================
   WOOF FILTER SIDEBAR
   CEF-style compact collapsible filter sections
   ============================================ */

/* --- Sidebar heading --- */
.ye-woof-filters__title {
    font-family: var(--font-heading, 'Outfit', sans-serif) !important;
    font-size: 1rem !important;
    font-weight: var(--font-weight-bold, 700) !important;
    color: var(--dark-gray, #1f2937) !important;
    margin: 0 0 0.5rem !important;
    padding-bottom: 0.5rem !important;
    border-bottom: 2px solid var(--primary-red, #dc2626) !important;
}


/* --- Filter blocks: zero gap between sections --- */
.ye-woof-filters .woof_container {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    float: none !important;
    width: 100% !important;
}

.ye-woof-filters .woof_container + .woof_container {
    border-top: 1px solid var(--border-color, #e5e7eb) !important;
}

.ye-woof-filters .woof_container_inner {
    padding: 0 !important;
    margin: 0 !important;
}

.ye-woof-filters .woof_container_overlay_item {
    display: none !important;
}


/* --- Toggle header: tight single-line button --- */
.ye-woof-filters h4.ye-woof-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 5px 0 !important;
    margin: 0 !important;
    font-family: var(--font-body, 'DM Sans', sans-serif) !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: var(--dark-gray, #1f2937) !important;
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    user-select: none !important;
    line-height: 1.2 !important;
    min-height: 0 !important;
}

.ye-woof-filters h4.ye-woof-toggle:hover {
    color: var(--primary-red, #dc2626) !important;
}

/* Chevron triangle — right-aligned */
.ye-woof-filters h4.ye-woof-toggle::after {
    content: '' !important;
    display: inline-block !important;
    width: 0 !important;
    height: 0 !important;
    border-left: 4px solid transparent !important;
    border-right: 4px solid transparent !important;
    border-top: 5px solid currentColor !important;
    flex-shrink: 0 !important;
    margin-left: 8px !important;
    transition: transform 0.15s ease !important;
}

/* Rotate chevron when expanded */
.ye-woof-filters h4.ye-woof-toggle:not(.is-collapsed)::after {
    transform: rotate(180deg) !important;
}


/* --- Checkbox list: tight vertical spacing --- */
.ye-woof-filters .woof_list,
.ye-woof-filters ul.woof_list_checkbox {
    margin: 0 !important;
    padding: 0 0 4px !important;
    list-style: none !important;
}

.ye-woof-filters .woof_list li {
    padding: 1px 0 !important;
    margin: 0 !important;
    line-height: 1.2 !important;
    min-height: 0 !important;
}

.ye-woof-filters .woof_block_html_items {
    padding: 0 !important;
    margin: 0 !important;
}

/* Checkbox labels — compact */
.ye-woof-filters .woof_checkbox_label {
    font-size: 0.8rem !important;
    font-weight: 400 !important;
    line-height: 1.2 !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    min-height: 0 !important;
}

/* Product count badge */
.ye-woof-filters .woof_checkbox_count {
    font-size: 0.7rem !important;
    color: var(--medium-gray, #6b7280) !important;
}

/* Hide WOOF's own toggle buttons if present */
.ye-woof-filters .woof_container_toggle {
    display: none !important;
}
