/* 
 * Modern Product Card UI for WooCommerce
 */

/* General Card Resets to remove theme clutters if possible */
body.mbd-active .products .product {
    position: relative;
    border-radius: var(--mbd-radius, 8px);
    background: var(--mbd-card-bg, #fff);
    box-shadow: var(--mbd-shadow, none);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

body.mbd-active .products .product:hover {
    box-shadow: var(--mbd-shadow, 0 8px 24px rgba(0,0,0,0.1));
    transform: translateY(-2px);
}

body.mbd-active .products .product a.woocommerce-LoopProduct-link {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

body.mbd-active .products .product img {
    border-radius: var(--mbd-radius, 8px) var(--mbd-radius, 8px) 0 0;
    margin-bottom: 0;
    width: 100%;
    object-fit: contain;
    background: var(--mbd-card-bg, #fff);
}
body.mbd-active .products .product .attachment-woocommerce_thumbnail,
body.mbd-active .products .product > a img,
body.mbd-active .products .product .woocommerce-LoopProduct-link img {
    height: var(--mbd-img-height, auto);
    aspect-ratio: var(--mbd-img-ratio, auto);
    object-fit: contain;
}
body.mbd-active .products .product .mbd-product-gallery-hover {
    aspect-ratio: var(--mbd-img-ratio, auto);
    height: var(--mbd-img-height, auto);
    overflow: hidden;
}
body.mbd-active .products .product .mbd-product-gallery-hover .mbd-gallery-slide-img {
    object-fit: contain;
    background: var(--mbd-card-bg, #fff);
}

/* Product card: hover gallery slider (scoped to wrapper — works with any grid markup, not only ul.products) */
body.mbd-gallery-hover-enabled .mbd-product-gallery-hover {
    display: block;
    width: 100%;
    max-width: 100%;
    position: relative;
    overflow: hidden;
    border-radius: var(--mbd-radius, 8px) var(--mbd-radius, 8px) 0 0;
    flex-shrink: 0;
}

body.mbd-gallery-hover-enabled .mbd-gallery-viewport {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    line-height: 0;
}

body.mbd-gallery-hover-enabled .mbd-gallery-track {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    width: calc(var(--mbd-slide-count, 1) * 100%);
    max-width: none;
    transform: translate3d(0, 0, 0);
    transition: transform 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    box-sizing: border-box;
}

body.mbd-gallery-hover-enabled .mbd-gallery-slide-img {
    flex: 0 0 calc(100% / var(--mbd-slide-count, 1));
    width: calc(100% / var(--mbd-slide-count, 1)) !important;
    max-width: calc(100% / var(--mbd-slide-count, 1)) !important;
    min-width: 0;
    height: auto;
    display: block;
    object-fit: contain;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-sizing: border-box;
}

@media (prefers-reduced-motion: reduce) {
    body.mbd-gallery-hover-enabled .mbd-gallery-track {
        transition: none;
    }
}

body.mbd-active .products .product .woocommerce-loop-product__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--mbd-title-color, #111);
    margin: 15px 15px 8px;
    padding: 0;
    line-height: 1.4;
}

/* Category text color — !important needed to override high-specificity theme rules */
body.mbd-active .products .product .product-categories,
body.mbd-active .products .product .product-categories a,
body.mbd-active .products .product .woocommerce-loop-product__categories,
body.mbd-active .products .product .woocommerce-loop-product__categories a,
body.mbd-active .products .product .ast-woo-product-category,
body.mbd-active .products .product .ast-woo-product-category a,
body.mbd-active .products .product .ast-loop-product__category,
body.mbd-active .products .product .ast-loop-product__category a,
body.mbd-active .products .product .loop-product-categories,
body.mbd-active .products .product .loop-product-categories a,
body.mbd-active .products .product .owp-product-categories,
body.mbd-active .products .product .owp-product-categories a,
body.mbd-active .products .product .elementor-loop-product__category,
body.mbd-active .products .product .elementor-loop-product__category a,
body.mbd-active .products .product [rel="tag"],
body.mbd-active .products .product .posted_in,
body.mbd-active .products .product .posted_in a {
    color: var(--mbd-category-color, #888) !important;
}

body.mbd-active .products .product .price {
    font-size: 16px;
    font-weight: 700;
    color: var(--mbd-sale-color, #e74c3c);
    margin: 0 15px 15px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

body.mbd-active .products .product .price del {
    color: var(--mbd-muted-color, #888);
    font-size: 14px;
    font-weight: 400;
    opacity: 0.7;
}

body.mbd-active .products .product .price ins {
    background: transparent;
    text-decoration: none;
    font-weight: 700;
}

/* Action Wrapper */
.mbd-action-wrapper {
    padding: 0 15px 15px;
    margin-top: auto; /* Push to bottom */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Buttons Container */
.mbd-buttons-container {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.mbd-buttons-container.mbd-full-width {
    flex-direction: column;
}

/*
 * Simple product + quantity: matches admin preview — row 1: qty | Add to cart, row 2: Buy now full width.
 */
.mbd-action-primary-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.mbd-action-wrapper .mbd-action-primary-row .mbd-qty-control {
    flex: 0 1 42%;
    min-width: 110px;
    max-width: 48%;
    width: auto;
}

.mbd-action-wrapper .mbd-action-primary-row a.button.mbd-atc-button {
    flex: 1 1 0;
    min-width: 0;
    flex-grow: 1;
}

.mbd-action-secondary-row {
    display: flex;
    width: 100%;
}

.mbd-action-secondary-row .mbd-buy-now-btn {
    flex: 1 1 100%;
    width: 100%;
}

/* Icons */
.mbd-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    display: inline-block;
    vertical-align: middle;
}

/* Base Button Styles */
.mbd-action-wrapper a.button.mbd-atc-button,
.mbd-action-wrapper a.mbd-buy-now-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 40px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--mbd-radius, 8px);
    transition: all 0.2s ease;
    text-decoration: none;
    flex-grow: 1;
    border: none;
    line-height: 1;
    cursor: pointer;
    margin: 0;
}

/* Primary ATC */
.mbd-action-wrapper a.button.mbd-atc-button {
    background: var(--mbd-primary-bg, #000);
    color: var(--mbd-primary-text, #fff);
}
.mbd-action-wrapper a.button.mbd-atc-button:hover {
    opacity: 0.9;
    color: var(--mbd-primary-text, #fff);
    background: var(--mbd-primary-bg, #000);
}
.mbd-action-wrapper a.button.mbd-atc-button.loading,
.mbd-action-wrapper a.mbd-buy-now-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}
.mbd-action-wrapper a.button.mbd-atc-button.mbd-added {
    background: #27ae60 !important;
    color: #fff !important;
}

/* Secondary Button (Variable / Select Options) */
.mbd-action-wrapper a.button.mbd-atc-button.mbd-btn-secondary {
    background: var(--mbd-select-opts-bg, transparent);
    color: var(--mbd-select-opts-text, #000);
    border: 1px solid var(--mbd-select-opts-border, #000);
    width: 100%;
}
.mbd-action-wrapper a.button.mbd-atc-button.mbd-btn-secondary:hover {
    background: var(--mbd-select-opts-text, #000);
    color: var(--mbd-select-opts-bg, #fff);
    border-color: var(--mbd-select-opts-text, #000);
}

/* Full Width Container Fix */
.mbd-buttons-container.mbd-full-width a.button.mbd-atc-button {
    width: 100%;
    flex: none;
}

/* Buy Now */
.mbd-action-wrapper a.mbd-buy-now-btn {
    background: var(--mbd-buy-now-bg, #f1f1f1);
    color: var(--mbd-buy-now-text, #111);
}
.mbd-action-wrapper a.mbd-buy-now-btn:hover {
    background: var(--mbd-buy-now-bg, #f1f1f1);
    color: var(--mbd-buy-now-text, #111);
    filter: brightness(0.92);
}

/* Quantity Control */
.mbd-qty-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--mbd-qty-border, #e5e5e5);
    border-radius: var(--mbd-radius, 8px);
    height: 40px;
    overflow: hidden;
    width: auto;
    min-width: 0;
    box-sizing: border-box;
}

.mbd-qty-btn {
    background: var(--mbd-qty-bg, #f9f9f9);
    border: none;
    width: 40px;
    height: 100%;
    font-size: 18px;
    cursor: pointer;
    color: var(--mbd-qty-text, #333);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}

.mbd-qty-btn:hover {
    background: var(--mbd-qty-bg, #f9f9f9);
    filter: brightness(0.92);
}

.mbd-qty-input {
    flex-grow: 1;
    border: none !important;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--mbd-qty-text, #333);
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    background: var(--mbd-card-bg, #fff);
    -moz-appearance: textfield;
}

.mbd-qty-input::-webkit-outer-spin-button,
.mbd-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Density Settings */
body.mbd-density-compact .products .product .woocommerce-loop-product__title {
    margin: 10px 10px 5px;
    font-size: 14px;
}
body.mbd-density-compact .products .product .price {
    margin: 0 10px 10px;
    font-size: 14px;
}
body.mbd-density-compact .mbd-action-wrapper {
    padding: 0 10px 10px;
    width: 100%;
}
body.mbd-density-compact .mbd-action-wrapper a.button.mbd-atc-button,
body.mbd-density-compact .mbd-action-wrapper a.mbd-buy-now-btn,
body.mbd-density-compact .mbd-qty-control {
    height: 36px;
    font-size: 13px;
}


/* Inline Feedback */
.mbd-inline-feedback {
    display: none;
    margin-top: 10px;
    font-size: 13px;
    text-align: center;
    padding: 8px;
    background: #f8fff9;
    border: 1px solid #c3e6cb;
    border-radius: var(--mbd-radius, 8px);
    color: #155724;
}
.mbd-inline-feedback a.mbd-view-cart-link {
    font-weight: 600;
    color: #155724;
    text-decoration: underline;
    margin-left: 5px;
}

/* Toast Container */
.mbd-toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mbd-toast {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    padding: 12px 20px;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 350px;
    border-left: 4px solid #27ae60;
}

.mbd-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.mbd-toast-icon {
    width: 24px;
    height: 24px;
    background: #27ae60;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.mbd-toast-icon svg {
    width: 14px;
    height: 14px;
}

.mbd-toast-content {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

.mbd-toast-content a {
    font-weight: 600;
    color: var(--mbd-primary-bg, #000);
    text-decoration: underline;
    margin-left: 5px;
}


/* === STYLE PRESETS === */

/* Style 1: Minimal Fashion */
body.mbd-style-1 .products .product {
    border-radius: 0;
    box-shadow: none;
    border: none;
    background: transparent;
    text-align: start;
}
body.mbd-style-1 .products .product:hover {
    box-shadow: none;
    transform: none;
}
body.mbd-style-1 .products .product img {
    border-radius: 0;
}
body.mbd-style-1 .mbd-action-wrapper {
    padding: 0;
    margin-top: 15px;
}
body.mbd-style-1 .mbd-action-wrapper a.button.mbd-atc-button,
body.mbd-style-1 .mbd-action-wrapper a.mbd-buy-now-btn,
body.mbd-style-1 .mbd-qty-control {
    border-radius: 0;
    border: 1px solid var(--mbd-primary-bg, #000);
}
body.mbd-style-1 .mbd-action-wrapper a.mbd-buy-now-btn {
    background: transparent;
    color: var(--mbd-primary-bg, #000);
}
body.mbd-style-1.single-product .mbd-single-buy-now-btn {
    border-radius: 0;
    border: 1px solid var(--mbd-primary-bg, #000);
    background: transparent;
    color: var(--mbd-primary-bg, #000);
}
body.mbd-style-1 .mbd-buttons-container {
    flex-direction: column;
}
body.mbd-style-1 .mbd-action-primary-row {
    flex-direction: column;
}
body.mbd-style-1 .mbd-action-primary-row .mbd-qty-control,
body.mbd-style-1 .mbd-action-primary-row a.button.mbd-atc-button {
    max-width: none;
    width: 100%;
}

/* Style 2: Compact Premium */
body.mbd-style-2 .products .product {
    text-align: start;
}
body.mbd-style-2 .products .product .woocommerce-loop-product__title {
    font-size: 15px;
}
body.mbd-style-2 .mbd-buttons-container {
    flex-wrap: wrap;
}
body.mbd-style-2 .mbd-action-primary-row {
    flex-wrap: wrap;
}

/* Style 3: Floating Pill */
body.mbd-style-3 .products .product {
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border: none;
    text-align: start;
}
body.mbd-style-3 .products .product img {
    border-radius: 24px 24px 0 0;
}
body.mbd-style-3 .mbd-action-wrapper a.button.mbd-atc-button,
body.mbd-style-3 .mbd-action-wrapper a.mbd-buy-now-btn,
body.mbd-style-3 .mbd-qty-control {
    border-radius: 30px;
}
body.mbd-style-3.single-product .mbd-single-buy-now-btn {
    border-radius: 30px;
}

/* Style 4: Bold Brutalist */
body.mbd-style-4 .products .product {
    border: 2px solid #000;
    border-radius: 0;
    box-shadow: 4px 4px 0px #000;
    text-align: start;
}
body.mbd-style-4 .products .product:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #000;
}
body.mbd-style-4 .products .product img {
    border-radius: 0;
    border-bottom: 2px solid #000;
}
body.mbd-style-4 .mbd-action-wrapper a.button.mbd-atc-button,
body.mbd-style-4 .mbd-action-wrapper a.mbd-buy-now-btn,
body.mbd-style-4 .mbd-qty-control {
    border: 2px solid #000;
    border-radius: 0;
    font-weight: 800;
    text-transform: uppercase;
}
body.mbd-style-4 .mbd-action-wrapper a.mbd-buy-now-btn {
    background: #fff;
}
body.mbd-style-4.single-product .mbd-single-buy-now-btn {
    border: 2px solid #000;
    border-radius: 0;
    font-weight: 800;
    text-transform: uppercase;
}

/* Style 5: Clean Iconic Compact */
body.mbd-style-5 .products .product {
    /* Centers title, price, category row, and other theme meta from one place */
    text-align: center;
}
body.mbd-style-5 .products .product .woocommerce-loop-product__title,
body.mbd-style-5 .products .product .price {
    text-align: center;
    justify-content: center;
}
/* Category / shop loop meta — themes use many class names; inherit center from .product */
body.mbd-style-5 .products .product .product-categories,
body.mbd-style-5 .products .product .woocommerce-loop-product__categories,
body.mbd-style-5 .products .product .ast-woo-product-category,
body.mbd-style-5 .products .product .ast-loop-product__category,
body.mbd-style-5 .products .product .product-category,
body.mbd-style-5 .products .product .loop-product-categories,
body.mbd-style-5 .products .product .wc-product-category,
body.mbd-style-5 .products .product .elementor-loop-product__category,
body.mbd-style-5 .products .product .woocommerce-loop-category,
body.mbd-style-5 .products .product .owp-product-categories {
    text-align: center;
    justify-content: center;
}
/* Themes that use flex for the category row */
body.mbd-style-5 .products .product .ast-woo-product-category,
body.mbd-style-5 .products .product .ast-loop-product__category,
body.mbd-style-5 .products .product .product-categories.ast-woo-product-category {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}
body.mbd-style-5 .products .product .product-categories a,
body.mbd-style-5 .products .product .ast-woo-product-category a {
    display: inline-block;
}
body.mbd-style-5 .mbd-buttons-container {
    justify-content: center;
}
body.mbd-style-5 .mbd-action-primary-row,
body.mbd-style-5 .mbd-action-secondary-row {
    justify-content: center;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 100%;
}


/* ── Single Product Page: Buy Now ── */
body.mbd-active.single-product .mbd-single-buy-now-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: auto;
    padding: 12px 28px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--mbd-radius, 8px);
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
    line-height: 1;
    cursor: pointer;
    margin-left: 10px;
    background: var(--mbd-buy-now-bg, #f1f1f1);
    color: var(--mbd-buy-now-text, #111);
    vertical-align: middle;
}
body.mbd-active.single-product .mbd-single-buy-now-btn:hover {
    filter: brightness(0.90);
}
body.mbd-active.single-product .mbd-single-buy-now-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}
body.mbd-active.single-product .mbd-single-buy-now-btn .mbd-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
}

@media (max-width: 768px) {
    body.mbd-active.single-product .mbd-single-buy-now-btn {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        padding: 14px 20px;
    }
    body.mbd-active.single-product form.cart .single_add_to_cart_button {
        width: 100%;
    }
}

/* Hide default WooCommerce ATC wrapper if it exists outside our wrapper (Theme defenses) */
body.mbd-active .products .product > .button.add_to_cart_button,
body.mbd-active .products .product .added_to_cart.wc-forward,
body.mbd-active .mbd-action-wrapper .added_to_cart.wc-forward {
    display: none !important;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .mbd-buttons-container {
        flex-direction: column;
    }
    .mbd-buttons-container .mbd-atc-button,
    .mbd-buttons-container .mbd-buy-now-btn {
        width: 100%;
    }
    .mbd-action-primary-row {
        flex-wrap: nowrap;
        gap: 8px;
    }
    .mbd-action-primary-row .mbd-qty-control,
    .mbd-action-wrapper .mbd-action-primary-row a.button.mbd-atc-button {
        height: 44px;
        width: auto;
    }
    .mbd-action-primary-row .mbd-qty-control {
        flex: 0 1 40%;
        min-width: 100px;
        max-width: 50%;
    }
    .mbd-action-wrapper .mbd-action-primary-row a.button.mbd-atc-button {
        flex: 1 1 0;
        min-width: 0;
    }
    .mbd-action-secondary-row .mbd-buy-now-btn {
        width: 100%;
        height: 44px;
    }
    .mbd-action-wrapper a.button.mbd-atc-button,
    .mbd-action-wrapper a.mbd-buy-now-btn {
        min-height: 44px;
    }
    body.mbd-active .products .product .woocommerce-loop-product__title {
        font-size: 14px;
        margin: 10px 10px 5px;
    }
    body.mbd-active .products .product .price {
        font-size: 14px;
        margin: 0 10px 10px;
    }
    .mbd-action-wrapper {
        padding: 0 10px 10px;
    }
}
