/* ==========================================================================
   AstraOptima - Fast Product Grid Component & Cloudflare-Style Buttons/Typography
   ========================================================================== */

:root {
    --ao-btn-bg: #0f172a;
    --ao-btn-color: #ffffff;
    --ao-btn-hover-bg: #27272a;
    --ao-btn-radius: 6px;
}

/* 1. Fast Grid Container */
.ast-fast-grid {
    display: grid !important;
    grid-template-columns: repeat(var(--ast-grid-cols, 4), minmax(0, 1fr)) !important;
    gap: 16px 14px !important;
    margin: 20px 0 24px 0 !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* 2. Universal Card Container (Fast Grid, Catalog, Gutenberg Blocks, Archives) */
.ast-fast-card,
.ast-unify-wc-loop ul.products li.product,
.ast-unify-wc-loop .wc-block-grid__product,
.ast-unify-wc-loop .wc-block-components-product-card,
.ast-unify-wc-loop .wp-block-woocommerce-product-template li {
    background-color: #fafafa !important;
    border: 1px solid #eaeaea !important;
    border-radius: 10px !important;
    padding: 14px 10px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    box-sizing: border-box !important;
    height: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    float: none !important;
    clear: none !important;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease !important;
    position: relative !important;
}

.ast-fast-grid.ast-has-hover .ast-fast-card:hover,
.ast-unify-wc-loop ul.products li.product:hover,
.ast-unify-wc-loop .wc-block-grid__product:hover,
.ast-unify-wc-loop .wc-block-components-product-card:hover {
    background-color: #ebeae8 !important;
    border-color: #dcdbd8 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03) !important;
}

/* 3. Fast Grid Thumbnail & Images (Shortcode mode) */
.ast-fast-thumb {
    width: 100% !important;
    height: 230px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    line-height: 0 !important;
    margin: 0 auto 8px auto !important;
    position: relative !important;
    overflow: hidden !important;
    border-radius: 4px !important;
}

.ast-fast-img {
    max-width: 100% !important;
    max-height: 230px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
    margin: auto !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    filter: none !important;
    transition: opacity 0.35s ease, transform 0.35s ease !important;
}

.ast-fast-thumb .ast-secondary-img {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-width: 100% !important;
    max-height: 230px !important;
    width: auto !important;
    height: auto !important;
    opacity: 0 !important;
    transition: opacity 0.35s ease, transform 0.35s ease !important;
    pointer-events: none !important;
    object-fit: contain !important;
    z-index: 2 !important;
}

/* ONLY flip if the card has a secondary image */
.ast-fast-card:hover .ast-fast-thumb.ast-has-secondary .ast-secondary-img {
    opacity: 1 !important;
    transform: translate(-50%, -50%) scale(1.02) !important;
}

.ast-fast-card:hover .ast-fast-thumb.ast-has-secondary .ast-primary-img {
    opacity: 0 !important;
}

/* 4. Native WooCommerce Loop (Shop & Category Archives) */
.ast-unify-wc-loop ul.products {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 16px 14px !important;
    margin: 20px 0 24px 0 !important;
    padding: 0 !important;
    list-style: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.ast-unify-wc-loop ul.products li.product .woocommerce-LoopProduct-link {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-decoration: none !important;
    margin-bottom: auto !important;
    position: relative !important;
}

.ast-unify-wc-loop ul.products li.product .astra-shop-thumbnail-wrap,
.ast-unify-wc-loop ul.products li.product .woocommerce-LoopProduct-link > img {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 230px !important;
    margin: 0 auto 8px auto !important;
    overflow: hidden !important;
    border-radius: 4px !important;
}

.ast-unify-wc-loop ul.products li.product img {
    max-width: 100% !important;
    max-height: 230px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
    margin: auto !important;
    box-shadow: none !important;
    filter: none !important;
    border-radius: 4px !important;
    transition: opacity 0.35s ease, transform 0.35s ease !important;
}

.ast-unify-wc-loop ul.products li.product .ast-loop-secondary-img {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 230px !important;
    opacity: 0 !important;
    transition: opacity 0.35s ease, transform 0.35s ease !important;
    pointer-events: none !important;
    object-fit: contain !important;
    z-index: 2 !important;
}

/* ONLY flip on hover if the product has .ast-has-secondary */
.ast-unify-wc-loop ul.products li.product.ast-has-secondary:hover .ast-loop-secondary-img {
    opacity: 1 !important;
    transform: translate(-50%, -50%) scale(1.02) !important;
}

.ast-unify-wc-loop ul.products li.product.ast-has-secondary:hover .woocommerce-LoopProduct-link > img:not(.ast-loop-secondary-img),
.ast-unify-wc-loop ul.products li.product.ast-has-secondary:hover .astra-shop-thumbnail-wrap > img:not(.ast-loop-secondary-img) {
    opacity: 0 !important;
}

/* 5. Typography: Product Titles */
.ast-fast-title,
.ast-unify-wc-loop ul.products li.product .woocommerce-loop-product__title,
.ast-unify-wc-loop ul.products li.product h2,
.ast-unify-wc-loop ul.products li.product .ast-loop-product__link,
.ast-unify-wc-loop .wc-block-grid__product-title,
.ast-unify-wc-loop .wc-block-components-product-title {
    font-family: inherit !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1.3em !important;
    letter-spacing: -0.01em !important;
    text-align: center !important;
    color: #0f172a !important;
    margin: 4px 0 6px 0 !important;
    padding: 0 !important;
    min-height: 36px !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
}

.ast-fast-title a,
.ast-unify-wc-loop ul.products li.product .woocommerce-loop-product__title a,
.ast-unify-wc-loop ul.products li.product .ast-loop-product__link a {
    color: #0f172a !important;
    text-decoration: none !important;
    transition: color 0.2s ease !important;
}

.ast-fast-title a:hover,
.ast-unify-wc-loop ul.products li.product .woocommerce-loop-product__title:hover {
    color: #f6821f !important;
}

/* 6. Typography: Product Prices */
.ast-fast-price,
.ast-unify-wc-loop ul.products li.product .price,
.ast-unify-wc-loop .wc-block-grid__product-price,
.ast-unify-wc-loop .wc-block-components-product-price {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    font-size: 14.5px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin: 2px 0 10px 0 !important;
    line-height: 1.15em !important;
    font-feature-settings: "tnum" on, "lnum" on !important;
}

.ast-fast-price del,
.ast-unify-wc-loop ul.products li.product .price del {
    color: #94a3b8 !important;
    font-size: 12.5px !important;
    font-weight: 400 !important;
}

.ast-fast-price ins,
.ast-unify-wc-loop ul.products li.product .price ins {
    text-decoration: none !important;
    color: #0f172a !important;
}

/* 7. Cloudflare-Style Action Buttons */
.ast-fast-btn-wrap,
.ast-unify-wc-loop ul.products li.product .ast-loop-product__link + .button,
.ast-unify-wc-loop .wc-block-grid__product-add-to-cart,
.ast-unify-wc-loop .wc-block-components-product-button {
    margin-top: auto !important;
    margin-bottom: 0 !important;
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    height: 38px !important;
    position: relative !important;
}

.ast-grid-btn,
.ast-unify-wc-loop ul.products li.product .button,
.ast-unify-wc-loop ul.products li.product a.button,
.ast-unify-wc-loop .wc-block-grid__product-add-to-cart .button,
.ast-unify-wc-loop .wc-block-components-product-button .wc-block-components-product-button__button,
.ast-unify-wc-loop .wc-block-components-product-button a {
    width: 100% !important;
    max-width: 100% !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    line-height: 38px !important;
    background-color: var(--ao-btn-bg, #0f172a) !important;
    color: var(--ao-btn-color, #ffffff) !important;
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em !important;
    border-radius: var(--ao-btn-radius, 6px) !important;
    border: 1px solid transparent !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease !important;
}

.ast-grid-btn:hover,
.ast-unify-wc-loop ul.products li.product .button:hover,
.ast-unify-wc-loop ul.products li.product a.button:hover,
.ast-unify-wc-loop .wc-block-grid__product-add-to-cart .button:hover,
.ast-unify-wc-loop .wc-block-components-product-button .wc-block-components-product-button__button:hover {
    background-color: var(--ao-btn-hover-bg, #27272a) !important;
    color: var(--ao-btn-color, #ffffff) !important;
    border-color: transparent !important;
}

.ast-grid-btn:active,
.ast-unify-wc-loop ul.products li.product .button:active {
    transform: scale(0.98) !important;
}

/* 8. Removal of redundant WooCommerce AJAX nodes */
.ast-fast-btn-wrap .added_to_cart,
.ast-fast-grid .added_to_cart,
.ast-unify-wc-loop .added_to_cart {
    display: none !important;
    position: absolute !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 9. Responsiveness */
@media (max-width: 1024px) {
    .ast-fast-grid,
    .ast-unify-wc-loop ul.products {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    .ast-fast-grid,
    .ast-unify-wc-loop ul.products {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px 10px !important;
    }
    .ast-fast-btn-wrap,
    .ast-unify-wc-loop ul.products li.product .button {
        height: 42px !important;
    }
    .ast-grid-btn,
    .ast-unify-wc-loop ul.products li.product .button {
        height: 42px !important;
        line-height: 42px !important;
    }
}

@media (max-width: 420px) {
    .ast-fast-grid,
    .ast-unify-wc-loop ul.products {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
