/* =================================================================
 * LensDelivery — Amasty Xsearch popup (ported from SvitLinz design)
 * Scoped via .amsearch-proto wrapper on the product list block.
 * ================================================================= */

/* ---------- Popup outer container ---------- */
/* Override legacy caps in main.css:
 *   .amsearch-wrapper-block        max-width: 1054px
 *   .amsearch-result-section       max-width: 1054px
 *   .amsearch-products-section .amsearch-product-list   max-width: 550px (!)
 *   .amsearch-products-section .amsearch-product-list .amsearch-item
 *       width: 50%; max-width: 50% !important          (!)
 */
body header.page-header .amsearch-wrapper-block {
    max-width: none !important;
    width: 100% !important;
}
body header.page-header .amsearch-result-section,
body.page-products header.page-header .amsearch-result-section,
body .amsearch-wrapper-block .amsearch-result-section {
    max-width: none !important;
    min-width: auto !important;
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    padding: 14px 10px 20px !important;
    background-color: #fff;
    border: 0;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}
body .amsearch-products-section .amsearch-product-list {
    max-width: none !important;
    width: 100% !important;
}
body .amsearch-products-section .amsearch-product-list .amsearch-item,
body .amsearch-products-section .amsearch-product-list .amsearch-item.product-item {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    float: none !important;
}

/* ---------- Product list wrapper ---------- */
body .amsearch-product-list-wrap.amsearch-proto {
    background: #fff;
    border: 0;
    box-shadow: none;
    padding: 14px 18px 18px;
    box-sizing: border-box;
    width: 100%;
    max-width: none;
}

body .amsearch-proto .amsearch-product-list-container {
    padding: 0;
    margin: 0;
}

/* ---------- Section title ---------- */
body .amsearch-proto .amsearch-block-header {
    margin: 0 0 12px;
    padding: 0;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
body .amsearch-proto .amsearch-block-header .amsearch-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e1e1e;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
body .amsearch-proto .amsearch-block-header a.amsearch-link.-view-all,
body .amsearch-proto .amsearch-block-header .amsearch-count {
    display: none !important;
}

/* ---------- Grid ---------- */
body .amsearch-proto .amsearch-product-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 14px !important;
    align-items: stretch !important;
    float: none !important;
}
@media (max-width: 1200px) {
    body .amsearch-proto .amsearch-product-list {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}
@media (max-width: 900px) {
    body .amsearch-proto .amsearch-product-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (max-width: 560px) {
    body .amsearch-proto .amsearch-product-list {
        grid-template-columns: 1fr !important;
    }
}

/* ---------- Card ---------- */
body .amsearch-proto .amsearch-item.product-item {
    position: relative;
    margin: 0;
    padding: 12px 14px 12px;
    background: #fff;
    border: 1px solid rgba(30, 30, 30, 0.1);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: none;
    width: auto;
    min-width: 0;
    float: none;
    list-style: none;
    box-sizing: border-box;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
}
body .amsearch-proto .amsearch-item.product-item:hover {
    background: none;
    border-color: rgba(30, 30, 30, 0.2);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

/* ---------- Name (2-line clamp, fixed height for alignment) ---------- */
body .amsearch-proto .amsearch-item .product_name {
    margin: 0 0 6px;
    padding: 0;
}
body .amsearch-proto .amsearch-item .product_name a.product-item-link,
body .amsearch-proto .amsearch-item .product_name a.amsearch-link {
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: #1e1e1e;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    min-height: calc(14px * 1.3 * 2);
    max-height: calc(14px * 1.3 * 2);
}
body .amsearch-proto .amsearch-item .product_name a:hover {
    opacity: 0.7;
    text-decoration: none;
}
body .amsearch-proto .amsearch-item .product_name strong,
body .amsearch-proto .amsearch-item .product_name em {
    font-weight: 700;
    font-style: normal;
    color: #00a2e7;
    background: transparent;
}

/* ---------- Image (below name; pushed down to fill free space) ---------- */
body .amsearch-proto .amsearch-item .product_image {
    margin: 6px 0 8px;
    padding: 0;
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    overflow: hidden;
}
body .amsearch-proto .amsearch-item .product_image a.amsearch-image {
    padding: 0;
    width: 100%;
    height: 100%;
    display: block;
    position: relative;
}
/* Amasty wraps the <img> inside a <span> placeholder — neutralize it */
body .amsearch-proto .amsearch-item .product_image a.amsearch-image span {
    padding: 0 !important;
    padding-bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}
body .amsearch-proto .amsearch-item .product_image img,
body .amsearch-proto .amsearch-item .product_image .product-image-photo {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    display: block !important;
}

/* ---------- Details (price + actions) ---------- */
body .amsearch-proto .amsearch-item .product-item-details {
    margin: 0;
    padding: 0;
    border: 0;
    display: flex;
    flex-direction: column;
    min-height: auto;
}

/* Price */
body .amsearch-proto .amsearch-item .product_price_wrap {
    margin: 0 0 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    line-height: 1;
}
body .amsearch-proto .amsearch-item .product_price_wrap .price,
body .amsearch-proto .amsearch-item .product_price_wrap .price-wrapper,
body .amsearch-proto .amsearch-item .product_price_wrap .price-container,
body .amsearch-proto .amsearch-item .product_price_wrap .price-box,
body .amsearch-proto .amsearch-item .product_price_wrap .price-box span {
    padding: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1e1e1e;
}

/* Hide "Ціна:" label */
body .amsearch-proto .amsearch-item .price-label,
body .amsearch-proto .amsearch-item [class*="price-label"] {
    display: none !important;
}

/* Cashback: tiny green line "Отримати X грн. кешбеку" */
body .amsearch-proto .amsearch-item .rewards-notification-block,
body .amsearch-proto .amsearch-item .rewards__notification,
body .amsearch-proto .amsearch-item .mst-rewards-message,
body .amsearch-proto .amsearch-item .rewards__product-earn-points .tooltiptext,
body .amsearch-proto .amsearch-item .rewards__product-earn-points .fa-info-circle,
body .amsearch-proto .amsearch-item .rewards__product-earn-points i,
body .amsearch-proto .amsearch-item .tooltiptext {
    display: none !important;
}
/* Cashback — higher specificity to beat the broad .price-box span rule above */
body .amsearch-proto .amsearch-item .product_price_wrap .rewards__product-earn-points,
body .amsearch-proto .amsearch-item .product_price_wrap .rewards__product-points,
body .amsearch-proto .amsearch-item .rewards__product-earn-points,
body .amsearch-proto .amsearch-item .rewards__product-points {
    display: inline-block !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: #00a2e7 !important;
    background: transparent !important;
    margin: 2px 0 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
}
body .amsearch-proto .amsearch-item .product_price_wrap .rewards__product-earn-points .price,
body .amsearch-proto .amsearch-item .product_price_wrap .rewards__product-points .price,
body .amsearch-proto .amsearch-item .rewards__product-earn-points .price,
body .amsearch-proto .amsearch-item .rewards__product-points .price {
    font-size: 11px !important;
    font-weight: 500 !important;
    color: #00a2e7 !important;
    background: transparent !important;
    padding: 0 !important;
}
body .amsearch-proto .amsearch-item .rewards__product-earn-points .points-text:not(:empty)::after {
    content: " кешбеку";
    color: #00a2e7;
    font-size: 11px;
    font-weight: 500;
}
body .amsearch-proto .amsearch-item .rewards__product-earn-points .points-loader {
    display: none !important;
}
/* NOTE: :empty rule removed — the outer rewards__product-points span
 * always contains the inner earn-points child, so :empty would not
 * match anyway, but let's be explicit that we never hide it. */

/* ---------- Actions row (wishlist left, cart right) ---------- */
body .amsearch-proto .amsearch-item .amsearch-tocart-wrap {
    margin-top: auto;
    padding-top: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
body .amsearch-proto .amsearch-item .amasty-xsearch-form {
    margin: 0 0 0 auto;
    padding: 0;
}

/* Wishlist button — circle, same size as cart */
body .amsearch-proto .amsearch-item .amsearch-button.-wishlist {
    margin: 0;
    padding: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8fafe;
    border: 0;
    border-radius: 50%;
    color: #1e1e1e;
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
body .amsearch-proto .amsearch-item .amsearch-button.-wishlist:hover {
    background: #e4ecf9;
    opacity: 1;
    filter: none;
}
body .amsearch-proto .amsearch-item .amsearch-button.-wishlist.added_to_wishlist {
    background: #00a2e7;
}
body .amsearch-proto .amsearch-item .amsearch-button.-wishlist svg {
    width: 22px;
    height: 22px;
    display: block;
}
body .amsearch-proto .amsearch-item .amsearch-button.-wishlist svg g {
    opacity: 1 !important;
    transition: all 0.3s linear;
}
body .amsearch-proto .amsearch-item .amsearch-button.-wishlist svg path {
    fill: #1e1e1e !important;
    stroke: none !important;
}
body .amsearch-proto .amsearch-item .amsearch-button.-wishlist.added_to_wishlist svg path {
    fill: #fff !important;
}

/* Cart button — green circle */
body .amsearch-proto .amsearch-item button.action.tocart.primary.amsearch-tocart-btn {
    position: relative;
    margin: 0;
    padding: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 0;
    background: #00a2e7;
    background-image: none;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 162, 231, 0.25);
    transition: background 0.15s ease, transform 0.1s ease;
    font-size: 0;
    line-height: 1;
}
body .amsearch-proto .amsearch-item button.action.tocart.primary.amsearch-tocart-btn:hover {
    background: #0086c5;
    opacity: 1;
    filter: none;
}
body .amsearch-proto .amsearch-item button.action.tocart.primary.amsearch-tocart-btn:active {
    transform: scale(0.96);
}
body .amsearch-proto .amsearch-item button.action.tocart.primary.amsearch-tocart-btn > span {
    display: none;
}
body .amsearch-proto .amsearch-item button.action.tocart.primary.amsearch-tocart-btn .amsearch-tocart-icon {
    width: 20px;
    height: 20px;
    stroke: #fff;
}

/* Amasty Stockstatus "Купити" label if present */
body .amsearch-proto .amsearch-item .amstockstatus-label,
body .amsearch-proto .amsearch-item [class*="amstockstatus"] {
    display: none !important;
}

/* ---------- Footer "View all" link ---------- */
body .amsearch-proto .view_all_results_btn_wrap {
    margin-top: 18px;
    text-align: center;
}
body .amsearch-proto .view_all_results_btn_wrap a.amsearch-link {
    display: inline-block;
    padding: 9px 20px;
    background: #f2f2f2;
    color: #1e1e1e;
    border-radius: 22px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s ease;
}
body .amsearch-proto .view_all_results_btn_wrap a.amsearch-link:hover {
    background: #e4e4e4;
    color: #1e1e1e;
}

/* ---------- Harden against legacy main.css float/flex rules ---------- */
body .amsearch-products-section .amsearch-product-list.amsearch-proto-list,
body .amsearch-product-list-wrap.amsearch-proto .amsearch-product-list {
    float: none !important;
}
body .amsearch-products-section .amsearch-product-list .amsearch-item.product-item {
    float: none;
    max-width: none;
    min-width: 0;
    width: auto;
}

/* ---------- Highlighted matched terms (green → blue) ----------
 * Override main.css line 91:
 *   body .amsearch-products-section .amsearch-product-list
 *       .amsearch-item .amsearch-highlight { background-color: #3ac39c; }
 * Also covers tab/category highlights and the product-link highlights.
 */
body header.page-header .amsearch-highlight,
body header.page-header .amsearch-result-section .amsearch-highlight,
body .amsearch-products-section .amsearch-product-list .amsearch-item .amsearch-highlight,
body header.page-header .amsearch-item-container .amsearch-tab-items .amsearch-link .amsearch-highlight,
body header.page-header .amsearch-item-container.-category .amsearch-description .amsearch-highlight,
body .amsearch-proto .amsearch-item .amsearch-highlight {
    background-color: #00a2e7 !important;
    color: #fff !important;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}
