/* Quantity controls approved on the search demo. */
body.gates-doofinder-search .dfd-card .dfd-card-row[data-quantity="true"] .dfd-card-select-quantity {
  display: grid !important;
  grid-template-columns: 28px 40px 28px minmax(0, 1fr);
  gap: 0;
  width: 100% !important;
  max-width: 100%;
  margin: 0;
  box-sizing: border-box;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="delete_quantity"],
body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="decrease_quantity"] {
  grid-column: 1;
  grid-row: 1;
  width: 28px !important;
  min-width: 0 !important;
  height: 32px !important;
  box-sizing: border-box;
  border: 1px solid #bfc4c9 !important;
  border-radius: 4px 0 0 4px !important;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="amount_selected"] {
  grid-column: 2;
  grid-row: 1;
  width: 40px !important;
  min-width: 0;
  height: 32px !important;
  box-sizing: border-box;
  text-align: center;
  border: 1px solid #bfc4c9 !important;
  border-left: 0 !important;
  border-radius: 0 !important;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="increase_quantity"] {
  grid-column: 3;
  grid-row: 1;
  width: 28px !important;
  min-width: 0 !important;
  height: 32px !important;
  box-sizing: border-box;
  border: 1px solid #bfc4c9 !important;
  border-left: 0 !important;
  border-radius: 0 4px 4px 0 !important;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button[data-role="add_to_cart"] {
  grid-column: 4;
  grid-row: 1;
  width: auto !important;
  max-width: calc(100% - 6px) !important;
  min-width: 0 !important;
  min-height: 32px;
  height: 32px !important;
  margin-left: 6px;
  padding: 0 4px !important;
  box-sizing: border-box;
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: #156b37 !important;
  color: #fff !important;
  border: 1px solid #156b37 !important;
  border-radius: 4px !important;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button[data-role="add_to_cart"] svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: currentColor;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button[data-role="add_to_cart"]::after {
  content: "Add";
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

body.gates-doofinder-search .dfd-card .dfd-cart-add-button[data-stock-status="onbackorder"] + .dfd-card-select-quantity > button[data-role="add_to_cart"] {
  background: #f2b707 !important;
  color: #000000 !important;
  border-color: #f2b707 !important;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button,
body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > input {
  box-shadow: none !important;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button[data-role="delete_quantity"]:disabled {
  opacity: 1;
  cursor: default;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button[data-role="delete_quantity"]:disabled svg {
  opacity: 0.45;
}

body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button:not([data-role="add_to_cart"]) svg {
  width: 16px;
  height: 16px;
}

/* Larger, reliable touch targets for the search cards on phones. */
@media (max-width: 575px) {
  /* The full-card product link must not intercept quantity or basket taps. */
  body.gates-doofinder-search .dfd-card a.dfd-card-link,
  body.gates-doofinder-search .dfd-card a.dfd-card-link::after {
    pointer-events: none !important;
  }

  body.gates-doofinder-search .dfd-card {
    padding: 4px !important;
  }

  body.gates-doofinder-search .dfd-card .gates-df-added-notice {
    align-items: flex-start;
    flex-direction: column;
    font-size: 13px;
    gap: 2px;
    line-height: 1.3;
    padding: 8px;
  }

  body.gates-doofinder-search .dfd-card .gates-df-added-notice a {
    align-items: center;
    align-self: stretch;
    display: flex;
    font-size: 14px;
    min-height: 44px;
  }

  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity {
    position: relative !important;
    z-index: 4 !important;
    grid-template-columns: 44px 40px 44px minmax(0, 1fr) !important;
  }

  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button,
  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > input {
    height: 48px !important;
    min-height: 48px !important;
    touch-action: manipulation;
  }

  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="delete_quantity"],
  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="decrease_quantity"],
  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="increase_quantity"] {
    width: 44px !important;
  }

  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="amount_selected"] {
    width: 40px !important;
    font-size: 16px !important;
  }

  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button:not([data-role="add_to_cart"]) svg {
    width: 24px !important;
    height: 24px !important;
  }

  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button[data-role="add_to_cart"] {
    min-height: 48px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    padding: 0 2px !important;
    gap: 2px !important;
    font-size: 12px !important;
  }
}

/* A two-column result card cannot fit four usable controls in one row at 320px. */
@media (max-width: 350px) {
  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity {
    grid-template-columns: 44px minmax(0, 1fr) 44px !important;
    row-gap: 6px !important;
  }

  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="amount_selected"] {
    grid-column: 2 !important;
    width: 100% !important;
  }

  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > [data-role="increase_quantity"] {
    grid-column: 3 !important;
  }

  body.gates-doofinder-search .dfd-card .dfd-card-select-quantity > button[data-role="add_to_cart"] {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
  }
}

/* The pinned quantity row owns the add action; retain variation selectors. */
body.gates-doofinder-search .dfd-card .dfd-card-row[data-quantity="true"] .dfd-cart-add-button > button[data-role="add_to_cart"] {
  display: none !important;
}

/* Option panels must stay above the larger mobile quantity controls. */
body.gates-doofinder-search .dfd-card .dfd-card-selector {
  z-index: 6 !important;
}
