/* Product Card Design System — all colors from --ag-pc-* admin tokens */

.ag-dh-product-discount,
.ag-product-card .discount-badge,
.ag-pc-discount {
    background: var(--ag-pc-discount-bg) !important;
    color: var(--ag-pc-discount-text) !important;
    border: var(--ag-pc-discount-border-width, 0) solid var(--ag-pc-discount-border) !important;
    border-radius: var(--ag-pc-discount-radius, 6px) !important;
    font-family: var(--ag-pc-discount-font, inherit) !important;
    font-size: var(--ag-pc-discount-size, 11px) !important;
    font-weight: var(--ag-pc-discount-weight, 800) !important;
    padding: var(--ag-pc-discount-pad-y, 3px) var(--ag-pc-discount-pad-x, 7px) !important;
    box-shadow: var(--ag-pc-discount-shadow, none) !important;
    width: var(--ag-pc-discount-width, auto);
    height: var(--ag-pc-discount-height, auto);
    line-height: 1.2;
    z-index: var(--ag-z-card);
}

.ag-pc-discount.is-animated,
.ag-dh-product-discount.is-animated {
    animation: ag-pc-pulse 1.6s ease-in-out infinite;
}

/* Legacy absolute positions (preview fallback only) */
.ag-pc-pos-top-start { top: var(--ag-pc-badge-edge, 8px); inset-inline-start: var(--ag-pc-badge-edge, 8px); inset-inline-end: auto; right: auto; left: auto; }
.ag-pc-pos-top-end { top: var(--ag-pc-badge-edge, 8px); inset-inline-end: var(--ag-pc-badge-edge, 8px); inset-inline-start: auto; right: auto; left: auto; }
.ag-pc-pos-bottom-start { bottom: var(--ag-pc-badge-edge, 8px); top: auto; inset-inline-start: var(--ag-pc-badge-edge, 8px); inset-inline-end: auto; }
.ag-pc-pos-bottom-end { bottom: var(--ag-pc-badge-edge, 8px); top: auto; inset-inline-end: var(--ag-pc-badge-edge, 8px); inset-inline-start: auto; }

/* Badge layout manager — corner stacks (no absolute child collisions) */
.ag-pc-badge-layer {
    position: absolute;
    inset: 0;
    z-index: var(--ag-z-card);
    pointer-events: none;
}

.ag-pc-badge-stack {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: var(--ag-pc-badge-stack-gap, 6px);
    max-width: calc(100% - (2 * var(--ag-pc-badge-edge, 8px)));
    pointer-events: none;
}

.ag-pc-badge-stack--top-start {
    top: var(--ag-pc-badge-edge, 8px);
    inset-inline-start: var(--ag-pc-badge-edge, 8px);
    align-items: flex-start;
}

.ag-pc-badge-stack--top-end {
    top: var(--ag-pc-badge-edge, 8px);
    inset-inline-end: var(--ag-pc-badge-edge, 8px);
    align-items: flex-end;
}

.ag-pc-badge-stack--bottom-start {
    bottom: var(--ag-pc-badge-edge, 8px);
    inset-inline-start: var(--ag-pc-badge-edge, 8px);
    align-items: flex-start;
}

.ag-pc-badge-stack--bottom-end {
    bottom: var(--ag-pc-badge-edge, 8px);
    inset-inline-end: var(--ag-pc-badge-edge, 8px);
    align-items: flex-end;
}

.ag-pc-badge-stack .ag-pc-badge-item,
.ag-pc-badge-stack .ag-dh-product-badge,
.ag-pc-badge-stack .ag-dh-product-discount,
.ag-pc-badge-stack .ag-pc-discount,
.ag-pc-badge-stack .ag-pc-label {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    inset-inline-start: auto !important;
    inset-inline-end: auto !important;
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: auto;
}

.ag-dh-product-badge--flash,
.ag-pc-badge-flash {
    background: var(--ag-pc-flash-bg) !important;
    color: var(--ag-pc-flash-text) !important;
    border: var(--ag-pc-flash-border-width, 0) solid var(--ag-pc-flash-border) !important;
    border-radius: var(--ag-pc-flash-radius, 6px) !important;
    font-family: var(--ag-pc-flash-font, inherit) !important;
    font-size: var(--ag-pc-flash-size, 11px) !important;
    font-weight: var(--ag-pc-flash-weight, 800) !important;
    box-shadow: var(--ag-pc-flash-shadow, none) !important;
}

.ag-pc-label {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    line-height: 1.2;
}

@media (max-width: 991.98px) {
    .ag-pc-badge-stack {
        gap: max(4px, calc(var(--ag-pc-badge-stack-gap, 6px) - 1px));
    }
}

@media (max-width: 575.98px) {
    .ag-pc-badge-stack {
        gap: max(3px, calc(var(--ag-pc-badge-stack-gap, 6px) - 2px));
        max-width: calc(48% - var(--ag-pc-badge-edge, 8px));
    }

    .ag-pc-badge-stack .ag-pc-badge-item,
    .ag-pc-badge-stack .ag-dh-product-badge,
    .ag-pc-badge-stack .ag-dh-product-discount {
        font-size: max(9px, 0.85em);
        padding-inline: 6px;
    }
}

.ag-pc-label--new { background: var(--ag-pc-label-new-bg); color: var(--ag-pc-label-new-text); border: 1px solid var(--ag-pc-label-new-border); border-radius: var(--ag-pc-label-new-radius); font-size: var(--ag-pc-label-new-size); font-weight: var(--ag-pc-label-new-weight); box-shadow: var(--ag-pc-label-new-shadow); }
.ag-pc-label--best_seller { background: var(--ag-pc-label-best_seller-bg); color: var(--ag-pc-label-best_seller-text); border: 1px solid var(--ag-pc-label-best_seller-border); border-radius: var(--ag-pc-label-best_seller-radius); font-size: var(--ag-pc-label-best_seller-size); font-weight: var(--ag-pc-label-best_seller-weight); box-shadow: var(--ag-pc-label-best_seller-shadow); }
.ag-pc-label--featured,
.ag-dh-product-badge--bestseller { background: var(--ag-pc-label-featured-bg) !important; color: var(--ag-pc-label-featured-text) !important; border: 1px solid var(--ag-pc-label-featured-border) !important; border-radius: var(--ag-pc-label-featured-radius) !important; font-size: var(--ag-pc-label-featured-size) !important; font-weight: var(--ag-pc-label-featured-weight) !important; box-shadow: var(--ag-pc-label-featured-shadow) !important; }
.ag-pc-label--limited_stock { background: var(--ag-pc-label-limited_stock-bg); color: var(--ag-pc-label-limited_stock-text); border: 1px solid var(--ag-pc-label-limited_stock-border); border-radius: var(--ag-pc-label-limited_stock-radius); font-size: var(--ag-pc-label-limited_stock-size); font-weight: var(--ag-pc-label-limited_stock-weight); box-shadow: var(--ag-pc-label-limited_stock-shadow); }
.ag-pc-label--out_of_stock { background: var(--ag-pc-label-out_of_stock-bg); color: var(--ag-pc-label-out_of_stock-text); border: 1px solid var(--ag-pc-label-out_of_stock-border); border-radius: var(--ag-pc-label-out_of_stock-radius); font-size: var(--ag-pc-label-out_of_stock-size); font-weight: var(--ag-pc-label-out_of_stock-weight); box-shadow: var(--ag-pc-label-out_of_stock-shadow); }
.ag-pc-label--preorder { background: var(--ag-pc-label-preorder-bg); color: var(--ag-pc-label-preorder-text); border: 1px solid var(--ag-pc-label-preorder-border); border-radius: var(--ag-pc-label-preorder-radius); font-size: var(--ag-pc-label-preorder-size); font-weight: var(--ag-pc-label-preorder-weight); box-shadow: var(--ag-pc-label-preorder-shadow); }

.ag-dh-price-row strong,
.ag-product-price,
.product-price {
    color: var(--ag-pc-price-current) !important;
}

.ag-dh-price-row strong small,
.ag-dh-price-row .ag-pc-currency {
    color: var(--ag-pc-price-currency) !important;
}

.ag-dh-price-row del,
.ag-product-old-price,
.old-price {
    color: var(--ag-pc-price-old) !important;
}

.ag-dh-rating .bi-star-fill,
.ag-dh-rating .bi-star-half {
    color: var(--ag-pc-rating-star) !important;
}

.ag-dh-rating .bi-star {
    color: var(--ag-pc-rating-empty) !important;
}

.ag-dh-rating-count {
    color: var(--ag-pc-rating-count) !important;
}

.ag-dh-icon-btn {
    background: var(--ag-pc-btn-wishlist-bg) !important;
    color: var(--ag-pc-btn-wishlist-text) !important;
    border: 1px solid var(--ag-pc-btn-wishlist-border) !important;
}

.ag-dh-icon-btn:hover {
    background: var(--ag-pc-btn-wishlist-hover-bg) !important;
    color: var(--ag-pc-btn-wishlist-hover-text) !important;
}

.ag-dh-product-action-form[data-product-action="compare"] .ag-dh-icon-btn {
    background: var(--ag-pc-btn-compare-bg) !important;
    color: var(--ag-pc-btn-compare-text) !important;
    border-color: var(--ag-pc-btn-compare-border) !important;
}

.ag-dh-product-action-form[data-product-action="compare"] .ag-dh-icon-btn:hover {
    background: var(--ag-pc-btn-compare-hover-bg) !important;
    color: var(--ag-pc-btn-compare-hover-text) !important;
}

.ag-dh-product-actions > a.ag-dh-icon-btn {
    background: var(--ag-pc-btn-quick_view-bg) !important;
    color: var(--ag-pc-btn-quick_view-text) !important;
    border-color: var(--ag-pc-btn-quick_view-border) !important;
}

.ag-dh-product-actions > a.ag-dh-icon-btn:hover {
    background: var(--ag-pc-btn-quick_view-hover-bg) !important;
    color: var(--ag-pc-btn-quick_view-hover-text) !important;
}

.ag-dh-cart-btn {
    background: var(--ag-pc-btn-add_to_cart-bg) !important;
    color: var(--ag-pc-btn-add_to_cart-text) !important;
    border: 1px solid var(--ag-pc-btn-add_to_cart-border) !important;
}

.ag-dh-product-card:hover .ag-dh-cart-btn,
.ag-dh-cart-btn:hover {
    background: var(--ag-pc-btn-add_to_cart-hover-bg) !important;
    color: var(--ag-pc-btn-add_to_cart-hover-text) !important;
}

.ag-dh-cart-btn:disabled,
.ag-dh-cart-btn[disabled] {
    background: var(--ag-pc-btn-add_to_cart-disabled-bg) !important;
    color: var(--ag-pc-btn-add_to_cart-disabled-text) !important;
    border-color: transparent !important;
}

@keyframes ag-pc-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
    .ag-pc-discount.is-animated,
    .ag-dh-product-discount.is-animated {
        animation: none;
    }
}

body.ag-theme-dark .ag-dh-icon-btn,
body.ag-prefers-dark .ag-dh-icon-btn {
    /* Tokens still drive colors; ensure contrast track */
    box-shadow: none;
}

/* =========================================================
   Fixed-height marketplace product card layout
   Equal card heights + bottom-aligned Add to Cart
   ========================================================= */

.ag-dh-product-card--fixed {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.ag-dh-product-card--fixed .ag-dh-product-media-wrap {
    flex: 0 0 auto;
    width: 100%;
}

.ag-dh-product-card--fixed .ag-dh-product-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 0;
}

.ag-dh-product-card--fixed .ag-dh-product-body-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: .28rem;
    min-height: 0;
}

.ag-dh-product-card--fixed .ag-dh-product-cat {
    display: block;
    height: 1.05em;
    min-height: 1.05em;
    max-height: 1.05em;
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ag-dh-product-card--fixed .ag-dh-product-title {
    display: block !important;
    -webkit-line-clamp: unset !important;
    -webkit-box-orient: unset !important;
    height: 1.4em;
    min-height: 1.4em;
    max-height: 1.4em;
    line-height: 1.4;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ag-dh-product-card--fixed .ag-dh-rating {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    height: 1.15rem;
    min-height: 1.15rem;
    max-height: 1.15rem;
    margin: 0;
    overflow: hidden;
    white-space: nowrap;
}

.ag-dh-product-card--fixed .ag-dh-price-row {
    display: flex;
    align-items: baseline;
    flex-wrap: nowrap;
    gap: 8px;
    height: 1.55rem;
    min-height: 1.55rem;
    max-height: 1.55rem;
    margin: 0;
    overflow: hidden;
}

.ag-dh-product-card--fixed .ag-dh-price-row strong,
.ag-dh-product-card--fixed .ag-dh-price-row .ag-dh-price-current,
.ag-dh-product-card--fixed .ag-dh-price-row del,
.ag-dh-product-card--fixed .ag-dh-price-row .ag-dh-price-compare {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ag-dh-product-card--fixed .ag-dh-price-row .ag-dh-price-compare.is-empty {
    visibility: hidden;
}

.ag-dh-product-card--fixed .ag-dh-product-meta {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-height: 1.2rem;
    margin: 0;
    overflow: hidden;
}

.ag-dh-product-card--fixed .ag-dh-product-seller,
.ag-dh-product-card--fixed .ag-dh-product-shipping,
.ag-dh-product-card--fixed .ag-dh-product-stock-label {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ag-dh-product-card--fixed .ag-dh-product-seller {
    height: 1.15em;
    min-height: 1.15em;
    max-height: 1.15em;
    line-height: 1.15;
}

.ag-dh-product-card--fixed .ag-dh-product-shipping,
.ag-dh-product-card--fixed .ag-dh-product-stock-label {
    height: 1.1em;
    min-height: 1.1em;
    max-height: 1.1em;
    line-height: 1.1;
    font-size: .6875rem;
}

.ag-dh-product-card--fixed.ag-dh-product-card--compact .ag-dh-product-shipping,
.ag-dh-product-card--fixed.ag-dh-product-card--compact .ag-dh-product-stock-label {
    display: none;
}

.ag-dh-product-card--fixed .ag-dh-product-stock-slot {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    margin-top: auto;
    min-height: 2.75rem;
    height: 2.75rem;
    max-height: 2.75rem;
    overflow: hidden;
}

.ag-dh-product-card--fixed .ag-dh-product-stock-slot .ag-stock-progress {
    width: 100%;
    margin-top: 0;
    display: grid;
    grid-template-rows: minmax(1.05em, auto) auto;
    gap: 0.25rem;
    align-content: end;
}

.ag-dh-product-card--fixed .ag-dh-product-stock-slot .ag-stock-progress__meta {
    min-height: 1.05em;
    max-height: 1.05em;
    overflow: hidden;
    white-space: nowrap;
}

.ag-dh-product-card--fixed .ag-dh-product-stock-slot .ag-stock-progress__meta.is-empty {
    visibility: hidden;
}

.ag-dh-product-card--fixed .ag-dh-product-stock-slot.is-empty {
    visibility: hidden;
}

.ag-dh-product-card--fixed .ag-dh-product-cat.is-empty,
.ag-dh-product-card--fixed .ag-dh-rating.is-empty,
.ag-dh-product-card--fixed .ag-dh-product-seller.is-empty,
.ag-dh-product-card--fixed .ag-dh-product-shipping.is-empty,
.ag-dh-product-card--fixed .ag-dh-product-stock-label.is-empty {
    visibility: hidden;
}

.ag-dh-product-card--fixed:not(.ag-dh-product-card--compact) .ag-dh-product-meta {
    min-height: calc(1.15em + 1.1em + 1.1em + .3rem);
}

.ag-dh-product-card--fixed .ag-dh-product-footer {
    margin-top: auto;
    padding-top: .55rem;
    flex: 0 0 auto;
}

.ag-dh-product-card--fixed .ag-dh-product-cart-form {
    margin: 0;
    width: 100%;
}

.ag-dh-product-card--fixed .ag-dh-cart-btn {
    margin-top: 0 !important;
    width: 100%;
    white-space: nowrap;
}

/* Grid stretch so siblings share one row height */
.ag-dh-product-cards,
.ag-dh-product-rail,
.ag-dh-product-rail-grid,
.ag-catalog-grid {
    align-items: stretch;
}

.ag-dh-product-cards > *,
.ag-dh-product-rail > *,
.ag-dh-product-rail-grid > *,
.ag-catalog-grid > [role="listitem"],
.ag-catalog-grid > * {
    display: flex;
    min-width: 0;
    height: 100%;
}

.ag-dh-product-cards .ag-dh-product-card--fixed,
.ag-dh-product-rail .ag-dh-product-card--fixed,
.ag-dh-product-rail-grid .ag-dh-product-card--fixed,
.ag-catalog-grid .ag-dh-product-card--fixed {
    width: 100%;
    height: 100%;
}

@media (max-width: 991.98px) {
    .ag-dh-product-card--fixed .ag-dh-product-stock-slot {
        min-height: 2.5rem;
        height: 2.5rem;
        max-height: 2.5rem;
    }
}

@media (max-width: 575.98px) {
    .ag-dh-product-card--fixed .ag-dh-product-title {
        font-size: .78rem;
    }

    .ag-dh-product-card--fixed .ag-dh-product-stock-slot {
        min-height: 2.35rem;
        height: 2.35rem;
        max-height: 2.35rem;
    }

    .ag-dh-product-card--fixed .ag-dh-product-footer {
        padding-top: .45rem;
    }
}

/* Legacy AG product card — equal height + single-line title */
.ag-product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ag-product-card .ag-card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.ag-product-card .ag-product-title,
.ag-product-card .product-title {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.35;
    min-height: 1.35em;
    max-height: 1.35em;
}

.ag-product-card form {
    margin-top: auto;
}
