/**
 * Green Upshot Loop Card Conflict Fix v1.2.0
 *
 * The Elementor loop template remains the visual design source.
 * This file fixes only:
 * 1. Safe whole-card navigation around buttons and variation controls.
 * 2. The complete equal-height parent chain.
 * 3. Desktop category/title spacing matching the shop archive.
 * 4. A fixed two-line desktop title slot and true bottom action row.
 * 5. The existing mobile bottom-button behaviour.
 */

/* =========================================================
   SAFE WHOLE-CARD LINK
   ========================================================= */

body .elementor-loop-container #gu-product-card
.gu-card-link-widget,
body .elementor-loop-container #gu-product-card
.gu-card-stretched-link {
  pointer-events: none !important;
}

body .elementor-loop-container #gu-product-card {
  cursor: pointer !important;
}

body .elementor-loop-container #gu-product-card
:is(
  a,
  button,
  input,
  select,
  textarea,
  label,
  [role="button"],
  .gu-add-button,
  .gu-card-variant-control,
  .gu-card-variation-panel
) {
  pointer-events: auto !important;
}

body .elementor-loop-container #gu-product-card
.gu-add-button,
body .elementor-loop-container #gu-product-card
.gu-loop-card-action,
body .elementor-loop-container #gu-product-card
.gu-card-view-action,
body .elementor-loop-container #gu-product-card
.gu-card-quote-action,
body .elementor-loop-container #gu-product-card
.gu-card-sold-out-action,
body .elementor-loop-container #gu-product-card
.gu-card-variant-control,
body .elementor-loop-container #gu-product-card
[data-gu-card-choose] {
  position: relative !important;
  z-index: 80 !important;
  pointer-events: auto !important;
}

body .elementor-loop-container #gu-product-card
.gu-card-variation-panel {
  z-index: 120 !important;
  pointer-events: none !important;
}

body .elementor-loop-container #gu-product-card
.gu-card-variation-panel.is-open,
body .elementor-loop-container #gu-product-card
.gu-card-variation-panel.is-open *,
body .elementor-loop-container #gu-product-card
[data-gu-card-swatch],
body .elementor-loop-container #gu-product-card
[data-gu-card-close] {
  pointer-events: auto !important;
}

/* =========================================================
   COMPLETE EQUAL-HEIGHT CHAIN
   ========================================================= */

body .elementor-loop-container > .e-loop-item:has(#gu-product-card),
body .elementor-loop-container .e-loop-item.gu-loop-card-item-fixed {
  display: flex !important;
  flex-direction: column !important;
  align-self: stretch !important;
  height: auto !important;
  min-height: 100% !important;
}

body .elementor-loop-container > .e-loop-item:has(#gu-product-card)
> #gu-product-card,
body .elementor-loop-container > .e-loop-item:has(#gu-product-card)
> .elementor-element#gu-product-card,
body .elementor-loop-container .e-loop-item
#gu-product-card.gu-product-card,
body .elementor-loop-container
#gu-product-card.gu-product-card.gu-loop-card-layout-fixed {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  align-self: stretch !important;

  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
}

body .elementor-loop-container .e-loop-item
#gu-product-card.gu-product-card .gu-product-content,
body .elementor-loop-container
#gu-product-card.gu-product-card.gu-loop-card-layout-fixed
.gu-product-content {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;

  width: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

body .elementor-loop-container .e-loop-item
#gu-product-card.gu-product-card
.gu-product-content > .e-con-inner,
body .elementor-loop-container
#gu-product-card.gu-product-card.gu-loop-card-layout-fixed
.gu-product-content > .e-con-inner {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;

  width: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

/* =========================================================
   DESKTOP: ARCHIVE SPACING + TRUE BOTTOM ACTION ROW
   ========================================================= */

@media (min-width: 768px) {
  /* Match the shop archive's 5px category-to-title spacing. */
  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-product-brand {
    margin: 0 0 5px !important;
    padding: 0 !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card
  .gu-product-brand .elementor-widget-container,
  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card
  .gu-product-brand .elementor-shortcode,
  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-product-brand p,
  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-product-brand a {
    margin: 0 !important;
    padding: 0 !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-product-name {
    margin: 0 !important;
    padding: 0 !important;
  }

  /*
   * Reserve exactly two desktop title lines. A one-line title therefore does
   * not pull its rating, quote text or View/Add button upward.
   */
  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card
  .gu-product-name :is(h1, h2, h3, h4, .elementor-heading-title) {
    min-height: 35.84px !important;
    height: 35.84px !important;
    max-height: 35.84px !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-product-bottom {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;

    width: 100% !important;
    min-width: 0 !important;
    min-height: 30px !important;

    margin: auto 0 0 !important;
    padding: 13px 0 0 !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card
  .gu-product-bottom > .e-con-inner {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;

    width: 100% !important;
    min-width: 0 !important;
    min-height: 30px !important;

    margin: 0 !important;
    padding: 0 !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-loop-price-widget,
  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-add-button {
    flex: 0 0 auto !important;
    margin-top: 0 !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-add-button {
    margin-left: auto !important;
    padding-top: 0 !important;
  }
}

/* =========================================================
   MOBILE: KEEP EXISTING GOOD LAYOUT
   ========================================================= */

@media (max-width: 767px) {
  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-product-content {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;

    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card
  .gu-product-content > .e-con-inner {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;

    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-product-bottom {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;

    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;

    margin: 6px 0 0 !important;
    padding: 0 !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card
  .gu-product-bottom > .e-con-inner {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;

    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-loop-price-widget {
    flex: 0 0 auto !important;
  }

  body .elementor-loop-container .e-loop-item
  #gu-product-card.gu-product-card .gu-add-button {
    flex: 0 0 auto !important;
    margin-top: auto !important;
    padding-top: 10px !important;
  }
}
