/* ==========================================================================
   WDL Buy Button In Product Cards
   Author: WDL (https://webdevlimited.bg)
   Theme:  ci_grocery / OpenCart 3.x

   Shows a permanent "add to cart" button inside every product card in grid
   view. The theme already ships this button on listing pages but hides it
   with ".product-grid .list-btns { display: none; }", so grid cards relied
   on a hover only icon row that touch devices cannot reach.

   List view, sidebar product lists and the product page itself are left
   exactly as they were.
   ========================================================================== */

/* Button colours. Change these to restyle. */
:root {
	--wdl-buy-bg: #3A7F3B;
	--wdl-buy-bg-hover: #53B155;
	--wdl-buy-bg-active: #2F6A30;
	--wdl-buy-fg: #ffffff;
}

/* --------------------------------------------------------------------------
   1. Grid cards become a vertical flow so the button always sits last and
      pins to the bottom, whatever position the template markup puts it in.
      This is what keeps the buttons on one row level with each other when
      the product names and descriptions have different lengths.
   -------------------------------------------------------------------------- */
.product-grid .product-thumb .caption {
	display: flex;
	flex-direction: column;
}

.product-grid .product-thumb .caption > .list-btns {
	order: 10;
	margin-top: auto;
}

/* --------------------------------------------------------------------------
   2. Reveal the button group on grid cards.
   -------------------------------------------------------------------------- */
.product-grid .product-thumb .list-btns {
	display: block;
	margin: 12px 0 0;
	padding: 0;
	border: 0;
	background: none;
	text-align: center;
}

/* Wishlist and compare stay on the hover row, they are not wanted inline. */
.product-grid .product-thumb .list-btns .btn-list {
	display: none;
}

/* --------------------------------------------------------------------------
   3. The button itself.

      Bootstrap 3 sets white-space: nowrap on .btn, which truncates the label
      on narrow cards (a category page with a sidebar leaves roughly 130px).
      The label is allowed to wrap instead. Every button on a given layout
      carries the same text and the same width, so they all wrap identically
      and rows stay even.
   -------------------------------------------------------------------------- */
.product-grid .product-thumb .list-btns .btn-primary {
	display: block;
	width: 100%;
	min-height: 38px;
	margin: 0;
	padding: 9px 8px;
	border: 1px solid var(--wdl-buy-bg);
	border-radius: 4px;
	background-color: var(--wdl-buy-bg);
	background-image: none;
	color: var(--wdl-buy-fg);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.25;
	text-align: center;
	white-space: normal;
	text-shadow: none;
	box-shadow: none;
	transition: background-color .2s ease, border-color .2s ease;
}

.product-grid .product-thumb .list-btns .btn-primary:hover,
.product-grid .product-thumb .list-btns .btn-primary:focus {
	background-color: var(--wdl-buy-bg-hover);
	border-color: var(--wdl-buy-bg-hover);
	color: var(--wdl-buy-fg);
}

.product-grid .product-thumb .list-btns .btn-primary:focus-visible {
	outline: 2px solid var(--wdl-buy-bg-active);
	outline-offset: 2px;
}

.product-grid .product-thumb .list-btns .btn-primary:active,
.product-grid .product-thumb .list-btns .btn-primary:active:focus {
	background-color: var(--wdl-buy-bg-active);
	border-color: var(--wdl-buy-bg-active);
	color: var(--wdl-buy-fg);
}

.product-grid .product-thumb .list-btns .btn-primary .fa {
	margin-right: 6px;
}

/* --------------------------------------------------------------------------
   4. The hover row keeps quick view, wishlist and compare, but its cart icon
      now duplicates the visible button, so it is hidden on any card that has
      one.

      This is done in CSS rather than in the template on purpose. The GA4
      extension rewrites that same button line (it injects data-e4-* attributes
      and appends cart_add_f to the onclick), so an OCMOD search for the
      original line no longer matches once that extension has run. If a browser
      lacks :has() support the only consequence is that the old icon stays
      visible, which is what the store had before.
   -------------------------------------------------------------------------- */
.product-grid .product-thumb:has(.list-btns) .hover-btns button:has(.fa-shopping-basket) {
	display: none;
}

/* --------------------------------------------------------------------------
   5. Sidebar product lists stay compact, matching how the theme already
      hides the hover row in the left and right columns.
   -------------------------------------------------------------------------- */
#column-left .product-listing .product-thumb .list-btns,
#column-right .product-listing .product-thumb .list-btns {
	display: none;
}

/* --------------------------------------------------------------------------
   6. Phones: cards go full width, so give the button a larger tap target.
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
	.product-grid .product-thumb .list-btns .btn-primary {
		min-height: 42px;
		padding: 11px 10px;
		font-size: 14px;
	}
}
