/* 3-dot menu cell: narrow column, centered trigger */
.item-history-listing-action-cell.item-history-listing-actions {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 37px;
    overflow: visible;
}

.item-history-listing-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.item-history-listing-action-cell.item-history-listing-actions .item-history-listing-actions-menu-btn {
    margin: 0 auto;
}

.item-history-listing-actions-menu-btn {
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #4a5568;
}

.item-history-listing-actions-menu-btn:hover {
    color: #1a202c;
}

.item-history-listing-actions-menu-btn svg {
    width: 16px;
    height: 16px;
}

.item-history-listing-actions-dropdown.item-history-listing-menu-tooltip {
    position: absolute;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
    min-width: 150px;
    width: max-content;
    max-width: 97vw;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    display: none;
    transition: opacity 0.2s, visibility 0s linear 0.2s;
    font-size: 14px;
    border: 1px solid #ddd;
}

.item-history-listing-actions-dropdown.item-history-listing-menu-tooltip.active {
    opacity: 1;
    visibility: visible;
    display: block;
    transition: opacity 0.2s;
}

.item-history-listing-actions-dropdown .item-history-listing-menu-dropdown {
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.item-history-listing-actions-dropdown .item-history-listing-menu-separator {
    width: 100%;
    height: 0;
    margin: 0;
    border: none;
    border-top: 1px solid rgb(240, 240, 240);
}

.item-history-listing-actions-dropdown .item-history-listing-menu-item {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: transparent;
    color: #1f1a17;
    white-space: nowrap;
}

.item-history-listing-menu-item.wiz-download-media-trigger {
    justify-content: flex-start;
    font: inherit;
    text-align: left;
}

.item-history-listing-actions-dropdown .item-history-listing-menu-item-icon img,
.item-history-listing-actions-dropdown .item-history-listing-menu-item-icon .wiz-download-media-icon {
    width: 20px;
    height: 20px;
    display: block;
    object-fit: contain;
}

.item-history-listing-actions-dropdown .item-history-listing-menu-item:hover {
    background-color: #f5f5f5;
}

.item-history-listing-actions-dropdown .item-history-listing-menu-item-icon {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    pointer-events: none;
}

.item-history-listing-actions-dropdown .item-history-listing-menu-item-icon svg {
    width: 16px;
    height: 16px;
}

.item-history-listing-actions-dropdown .item-history-listing-menu-item-text {
    flex: 1 1 auto;
    pointer-events: none;
}

/* Product image preview modal — image only */
.item-history-image-preview-modal {
    background: transparent;
    box-shadow: none;
}

.item-history-image-preview-modal .modal-content {
    background: transparent;
}

.item-history-image-preview-modal .item-history-image-modal-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 480px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    padding: 12px;
    box-sizing: border-box;
}

.item-history-image-preview-modal .item-history-image-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    color: rgba(0, 0, 0, 0.7);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    padding: 0;
}

.item-history-image-preview-modal .item-history-image-modal-close:hover {
    color: rgba(0, 0, 0, 0.9);
    background: #fff;
}

.item-history-image-preview-modal .item-history-image-modal-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    margin: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 4px;
}

/* ── Row actions: cart icon + 3-dot menu ─────────────────────────────── */
.item-history-listing-row-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 37px;
}

.item-history-listing-row-actions .item-history-listing-action-cell.item-history-listing-actions {
    width: auto;
}

/* ── Cart icon button ────────────────────────────────────────────────── */
/* Icon artwork: bag-add.svg / bag-in-cart.svg (design). One inline SVG, parts toggled per state. */
.item-history-cart-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #111111;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.item-history-cart-btn:hover:not([aria-disabled="true"]) {
    background-color: #f2f2f2;
}

.item-history-cart-btn:focus-visible {
    outline: 2px solid #111111;
    outline-offset: 1px;
}

.item-history-cart-btn[aria-disabled="true"]:not([data-state="checking"]) {
    cursor: default;
}

.item-history-cart-btn__bag {
    display: block;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linejoin: round;
    stroke-linecap: round;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.item-history-cart-btn__bag-body {
    fill: transparent;
    transition: fill 0.2s ease;
}

.item-history-cart-btn__badge {
    opacity: 0;
    transform: scale(0.4);
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.item-history-cart-btn__badge circle {
    fill: #1f6f43;
    stroke: #ffffff;
    stroke-width: 1.4;
}

.item-history-cart-btn__badge path {
    stroke: #ffffff;
    stroke-width: 1.3;
}

/* added — transient green check that replaces the bag */
.item-history-cart-btn__success {
    position: absolute;
    inset: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #1f6f43;
    color: #ffffff;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.item-history-cart-btn__success svg {
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Custom icons (Cart Action controls) — cloned in by item-history-cart-button.js and
   layered over the default artwork; the default bag / tick is hidden only for the
   states whose icon was customised. */
.item-history-cart-btn__icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.item-history-cart-btn__icon svg {
    display: block;
    width: 1em;
    height: 1em;
}

/* Only Elementor's Font Awesome SVGs expect currentColor; uploaded SVGs keep their own
   fill / stroke (outline icons set fill="none"). */
.item-history-cart-btn__icon .e-font-icon-svg {
    fill: currentColor;
}

/* Blocked / checking states: uploaded SVGs keep their own colours, so mute them with a
   filter (Font Awesome icons already go grey through the button's `color`). */
.item-history-cart-btn[data-state="checking"] .item-history-cart-btn__icon > svg:not(.e-font-icon-svg),
.item-history-cart-btn[data-state="out-of-stock"] .item-history-cart-btn__icon > svg:not(.e-font-icon-svg),
.item-history-cart-btn[data-state="discontinued"] .item-history-cart-btn__icon > svg:not(.e-font-icon-svg),
.item-history-cart-btn[data-state="unavailable"] .item-history-cart-btn__icon > svg:not(.e-font-icon-svg),
.item-history-cart-btn[data-state="customizable"] .item-history-cart-btn__icon > svg:not(.e-font-icon-svg) {
    filter: grayscale(1) opacity(0.45);
}

.item-history-cart-btn--custom-add:not([data-state="in-cart"]):not([data-state="added"]):not([data-state="adding"]) .item-history-cart-btn__bag,
.item-history-cart-btn--custom-in-cart[data-state="in-cart"] .item-history-cart-btn__bag {
    opacity: 0;
}

.item-history-cart-btn--custom-add:not([data-state="in-cart"]):not([data-state="added"]):not([data-state="adding"]) .item-history-cart-btn__icon--add,
.item-history-cart-btn--custom-in-cart[data-state="in-cart"] .item-history-cart-btn__icon--in-cart {
    opacity: 1;
}

/* Custom tick lives inside the green circle, which already fades in for `added`. */
.item-history-cart-btn__success .item-history-cart-btn__icon {
    font-size: 14px;
    opacity: 1;
}

.item-history-cart-btn--custom-added .item-history-cart-btn__success > svg {
    display: none;
}

/* adding — spinner replaces the icon while the cart call is in flight. Drawn as the
   button's own ::after (no extra markup), so it can't be lost with cached row HTML. */
.item-history-cart-btn::after {
    content: '';
    position: absolute;
    top: 7px;
    right: 7px;
    bottom: 7px;
    left: 7px;
    box-sizing: border-box;
    border: 2px solid #e2e2e2;
    border-top-color: #111111;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
}

.item-history-cart-btn[data-state="adding"] {
    cursor: progress;
}

.item-history-cart-btn[data-state="adding"] .item-history-cart-btn__bag {
    opacity: 0;
}

.item-history-cart-btn[data-state="adding"]::after {
    opacity: 1;
    animation: item-history-cart-spin 0.7s linear infinite;
}

.item-history-cart-btn[data-state="added"] .item-history-cart-btn__bag {
    opacity: 0;
    transform: scale(0.6);
}

.item-history-cart-btn[data-state="added"] .item-history-cart-btn__success {
    opacity: 1;
    transform: scale(1);
}

/* in-cart — filled bag + green tick badge (bag-in-cart.svg) */
.item-history-cart-btn[data-state="in-cart"] .item-history-cart-btn__bag-body {
    fill: currentColor;
}

.item-history-cart-btn[data-state="in-cart"] .item-history-cart-btn__badge {
    opacity: 1;
    transform: scale(1);
}

/* checking — product data still resolving */
.item-history-cart-btn[data-state="checking"] {
    color: #c9c9c9;
    cursor: progress;
}

/* out-of-stock / discontinued / unavailable / customizable — one shared disabled look; tooltip says why */
.item-history-cart-btn[data-state="out-of-stock"],
.item-history-cart-btn[data-state="discontinued"],
.item-history-cart-btn[data-state="unavailable"],
.item-history-cart-btn[data-state="customizable"] {
    color: #c9c9c9;
}

@keyframes item-history-cart-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .item-history-cart-btn,
    .item-history-cart-btn__bag,
    .item-history-cart-btn__badge,
    .item-history-cart-btn__success,
    .item-history-cart-btn__icon {
        transition: none;
    }

    .item-history-cart-btn[data-state="adding"]::after {
        animation-duration: 2s;
    }
}

/* ── Cart icon tooltip (single node appended to <body>) ──────────────── */
.item-history-cart-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10001;
    width: max-content;
    /* Short labels stay on one line; long ones wrap instead of overflowing the box. */
    max-width: min(240px, calc(100vw - 16px));
    box-sizing: border-box;
    padding: 6px 10px;
    border-radius: 4px;
    background: #1f1a17;
    color: #fff;
    font-size: 13px;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: break-word;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0s linear 0.12s;
}

.item-history-cart-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.12s ease;
}
