/* هات حاجتك — product listing cards + product page (hat7-child 0.4.2).
 *
 * Loaded only on the shop, product category/tag archives, product search
 * results and single product pages (see inc/assets.php). The home page, cart
 * and checkout never load it.
 *
 * Older rules for the same elements live in Additional CSS (Customizer),
 * snippet #14 and legacy-bridge.css. They stay untouched; this file wins by
 * selector scope. !important is used only where an older rule already uses
 * it (card padding, grid columns on small screens, button colours, sale badge
 * colour).
 */

html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) {
	--pc-bg: #F7F5EF;
	--pc-card: #FFFEFA;
	--pc-line: #E7E0D3;
	--pc-line-strong: #D9CFBC;
	--pc-ink: #303C3C;
	--pc-mute: #6B7774;
	--pc-pri: var(--primary, #537B7B);
	--pc-pri-dark: var(--primary-dark, #294C50);
	--pc-pri-deep: var(--primary-deep, #1E3B3E);
	--pc-gold: var(--accent, #C5A46D);
}

/* ===================================================================
 * 1. Results bar (title, count, sorting)
 * ================================================================= */

html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .woocommerce-products-header__title {
	color: var(--pc-pri-dark);
	margin-bottom: 12px;
}

html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin: 0 0 16px;
	padding: 10px 14px;
	background: var(--pc-card);
	border: 1px solid var(--pc-line);
	border-radius: 14px;
	box-shadow: none;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting .woocommerce-notices-wrapper:empty { display: none; }
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting .woocommerce-result-count {
	order: 2;
	margin: 0;
	padding: 0;
	float: none;
	color: var(--pc-mute);
	font-size: .875rem;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting .woocommerce-ordering {
	order: 1;
	margin: 0;
	float: none;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting .woocommerce-ordering select {
	height: 40px;
	min-width: 190px;
	padding: 0 12px;
	border: 1px solid var(--pc-line);
	border-radius: 10px;
	background-color: #fff;
	color: var(--pc-ink);
	font-size: .9rem;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting .woocommerce-ordering select:focus {
	outline: none;
	border-color: var(--pc-pri);
	box-shadow: 0 0 0 3px rgba(83, 123, 123, .18);
}

/* ===================================================================
 * 2. Grid
 * ================================================================= */

html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 18px;
}
@media (max-width: 1100px) {
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
}
@media (max-width: 767px) {
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
@media (max-width: 339px) {
	/* Additional CSS forces 2 columns below 768px with !important. */
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ===================================================================
 * 3. Card
 * ================================================================= */

html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product {
	position: relative;
	display: flex;
	flex-direction: column;
	width: auto;
	min-width: 0;
	margin: 0;
	padding: 8px 8px 12px !important; /* Additional CSS: padding 14px !important */
	background: var(--pc-card);
	border: 1px solid var(--pc-line);
	border-radius: 16px;
	box-shadow: none;
	text-align: start;
	transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product:hover {
	transform: translateY(-2px);
	border-color: var(--pc-line-strong);
	box-shadow: 0 12px 28px rgba(41, 76, 80, .10);
}

html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product a.woocommerce-LoopProduct-link {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	color: var(--pc-ink);
	text-decoration: none;
}

/* Product photo: fixed square, whole product visible, no crop or stretch. */
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product a.woocommerce-LoopProduct-link img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	margin: 0 0 10px;
	padding: 6%;
	box-sizing: border-box;
	background: #fff;
	border-radius: 12px;
	box-shadow: none;
	transition: transform .25s ease;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product:hover a.woocommerce-LoopProduct-link img { transform: scale(1.03); }

/* No photo yet: cream tile with the brand logo (image swapped in by hat7-marketplace). */
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product a.woocommerce-LoopProduct-link img.woocommerce-placeholder {
	padding: 30% 24%;
	background: var(--pc-bg);
	opacity: .55;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product:hover a.woocommerce-LoopProduct-link img.woocommerce-placeholder { transform: none; }

/* Title: always two lines tall, so every card lines up. */
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .woocommerce-loop-product__title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: 3em;
	margin: 0 0 4px;
	padding: 0 4px;
	font: 600 .95rem/1.5 var(--font-body);
	color: var(--pc-ink);
}

/* Seller line (printed by hat7-marketplace when the product has a store). */
html body.hat7.hh-ui ul.products li.product .h7-pc-store {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	max-width: calc(100% - 8px);
	margin: 8px 4px 0;
	color: var(--pc-pri);
	font-size: .8rem;
	line-height: 1.4;
	text-decoration: none;
	position: relative;
	z-index: 1;
}
html body.hat7.hh-ui ul.products li.product .h7-pc-store svg { flex: none; width: 14px; height: 14px; }
html body.hat7.hh-ui ul.products li.product .h7-pc-store span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
html body.hat7.hh-ui ul.products li.product .h7-pc-store:hover span { text-decoration: underline; }

/* Rating: only printed by WooCommerce when real ratings exist. */
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .h7-pc-rating {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0 4px 2px;
	font-size: .78rem;
	color: var(--pc-mute);
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .h7-pc-rating .star-rating {
	margin: 0;
	font-size: .8rem;
	color: var(--pc-gold);
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .h7-pc-rating b { color: var(--pc-ink); font-weight: 700; }

/* Price: current price bold petrol, old price struck through after it. */
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .price {
	display: block;
	margin: auto 0 0;
	padding: 6px 4px 0;
	color: var(--pc-pri-dark) !important; /* snippet #14 sets !important */
	font: 700 1.05rem/1.35 var(--font-body);
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .price .amount { white-space: nowrap; }
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .price:has(del) {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 8px;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .price ins { order: 1; text-decoration: none; font-weight: 700; }
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .price del {
	order: 2;
	color: var(--pc-mute);
	font-size: .8rem;
	font-weight: 400;
	opacity: 1;
}

/* Add to cart: same height in every card; variable products keep WooCommerce's
 * "select options" link, shown as an outline button. */
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: auto;
	min-height: 42px;
	margin: 10px 4px 0 !important;
	padding: 0 12px;
	border: 1.5px solid var(--pc-pri-dark);
	border-radius: 10px;
	background: var(--pc-pri-dark) !important;
	color: #fff !important;
	font: 600 .875rem/1.2 var(--font-body);
	text-align: center;
	box-shadow: none;
	transform: none;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .button:hover {
	background: var(--pc-pri-deep) !important;
	border-color: var(--pc-pri-deep);
	box-shadow: none;
	transform: none;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .button:not(.add_to_cart_button),
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .button.product_type_variable {
	background: #fff !important;
	color: var(--pc-pri-dark) !important;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .button:not(.add_to_cart_button):hover,
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .button.product_type_variable:hover {
	background: var(--primary-tint, #EEF2EF) !important;
}
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .added_to_cart {
	display: block;
	margin: 6px 4px 0 !important;
	padding: 0;
	background: none !important;
	color: var(--pc-pri) !important;
	font-size: .8rem;
	text-align: center;
}

/* Sale badge: real discount (e.g. -17%) printed by hat7-marketplace. */
html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .onsale {
	position: absolute;
	top: 16px;
	inset-inline-start: 16px;
	inset-inline-end: auto;
	z-index: 2;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 5px 8px;
	border: 0;
	border-radius: 8px;
	background: var(--pc-pri-dark) !important; /* snippet #14 sets !important */
	color: #fff !important; /* legacy-bridge sets !important */
	font: 700 .75rem/1 var(--font-body);
}

/* Logged-in shop staff see WCFM's edit/delete buttons in the start corner of
 * left-to-right pages; drop the sale badge below them there. Visitors never
 * get these buttons, so their cards are unchanged. */
html:not([dir="rtl"]) body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .wcfm_buttons ~ a.woocommerce-LoopProduct-link .onsale {
	top: 46px;
}

/* ===================================================================
 * 4. Phones
 * ================================================================= */
@media (max-width: 767px) {
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting { padding: 8px 10px; border-radius: 12px; gap: 8px; }
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting .woocommerce-ordering { flex: 1 1 auto; }
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting .woocommerce-ordering select { width: 100%; min-width: 0; height: 38px; font-size: .85rem; }
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) .storefront-sorting .woocommerce-result-count { font-size: .78rem; }

	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product { padding: 6px 6px 10px !important; border-radius: 14px; }
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product a.woocommerce-LoopProduct-link img { margin-bottom: 8px; border-radius: 10px; }
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .woocommerce-loop-product__title { font-size: .84rem !important; /* snippet #14 sets !important */ }
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .price { font-size: .95rem; }
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .button { min-height: 38px; font-size: .8rem; padding: 0 8px; }
	html body.hat7.hh-ui:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag, .single-product) ul.products li.product .onsale { top: 12px; inset-inline-start: 12px; font-size: .7rem; }
	html body.hat7.hh-ui ul.products li.product .h7-pc-store { font-size: .74rem; }
}

/* ===================================================================
 * 5. Product page — same look as the cards
 * ================================================================= */

/* Gallery: white rounded frame with the beige border. */
html body.hat7.hh-ui.single-product div.product .woocommerce-product-gallery {
	position: relative;
}
html body.hat7.hh-ui.single-product div.product .woocommerce-product-gallery__wrapper {
	background: #fff;
	border: 1px solid var(--pc-line);
	border-radius: 18px;
	overflow: hidden;
}
html body.hat7.hh-ui.single-product div.product .woocommerce-product-gallery__image img {
	object-fit: contain;
	border-radius: 0;
}
html body.hat7.hh-ui.single-product div.product .flex-control-thumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
}
html body.hat7.hh-ui.single-product div.product .flex-control-thumbs li {
	width: 72px !important;
	margin: 0 !important;
	float: none;
}
html body.hat7.hh-ui.single-product div.product .flex-control-thumbs img {
	aspect-ratio: 1 / 1;
	object-fit: contain;
	padding: 4px;
	background: #fff;
	border: 1px solid var(--pc-line);
	border-radius: 10px;
	opacity: .75;
}
html body.hat7.hh-ui.single-product div.product .flex-control-thumbs img.flex-active,
html body.hat7.hh-ui.single-product div.product .flex-control-thumbs img:hover {
	opacity: 1;
	border-color: var(--pc-pri);
}
html body.hat7.hh-ui.single-product div.product .woocommerce-product-gallery__trigger {
	top: 14px;
	inset-inline-end: 14px;
	background: rgba(255, 255, 255, .92);
	border: 1px solid var(--pc-line);
	border-radius: 50%;
}

/* Sale badge on the photo, same style as the cards. */
html body.hat7.hh-ui.single-product div.product > .onsale,
html body.hat7.hh-ui.single-product div.product .summary .onsale {
	position: absolute;
	top: 18px;
	inset-inline-start: 18px;
	inset-inline-end: auto;
	z-index: 3;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 6px 10px;
	border: 0;
	border-radius: 9px;
	background: var(--pc-pri-dark) !important;
	color: #fff !important;
	font: 700 .85rem/1 var(--font-body);
}

/* Summary: title, price, stock, buy button. */
html body.hat7.hh-ui.single-product div.product .product_title {
	margin: 0 0 10px;
	color: var(--pc-pri-dark);
	font: 700 clamp(1.35rem, 1.1rem + .9vw, 1.9rem)/1.35 var(--font-display);
}
html body.hat7.hh-ui.single-product div.product .summary .price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 12px;
	margin: 0 0 14px;
	padding: 12px 16px;
	background: var(--pc-card);
	border: 1px solid var(--pc-line);
	border-radius: 14px;
	color: var(--pc-pri-dark) !important; /* snippet #16 sets !important */
	font: 800 1.65rem/1.3 var(--font-body);
}
html body.hat7.hh-ui.single-product div.product .summary .price .amount { white-space: nowrap; }
html body.hat7.hh-ui.single-product div.product .summary .price ins { order: 1; text-decoration: none; }
html body.hat7.hh-ui.single-product div.product .summary .price del { order: 2; color: var(--pc-mute); font-size: 1rem; font-weight: 400; opacity: 1; }
html body.hat7.hh-ui.single-product div.product .woocommerce-product-details__short-description {
	color: var(--pc-ink);
	line-height: 1.8;
}
html body.hat7.hh-ui.single-product div.product .summary .stock {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	border-radius: 999px;
	background: #E7F3EE;
	color: #256149;
	font-weight: 600;
	font-size: .85rem;
}
html body.hat7.hh-ui.single-product div.product form.cart .quantity .qty {
	height: 50px;
	border: 1px solid var(--pc-line-strong);
	border-radius: 12px;
	background: #fff;
}
html body.hat7.hh-ui.single-product div.product form.cart .single_add_to_cart_button {
	min-height: 50px;
	border-radius: 12px;
	background: var(--pc-pri-dark) !important;
	color: #fff !important;
	font: 700 1rem/1.2 var(--font-body);
	box-shadow: 0 6px 16px rgba(41, 76, 80, .18);
}
html body.hat7.hh-ui.single-product div.product form.cart .single_add_to_cart_button:hover { background: var(--pc-pri-deep) !important; }
html body.hat7.hh-ui.single-product div.product form.variations_form table.variations select {
	height: 44px;
	border: 1px solid var(--pc-line-strong);
	border-radius: 10px;
	background-color: #fff;
}

/* Description tabs as soft pills. */
html body.hat7.hh-ui.single-product .woocommerce-tabs ul.tabs li {
	border: 1px solid var(--pc-line);
	background: var(--pc-card);
}
html body.hat7.hh-ui.single-product .woocommerce-tabs ul.tabs li.active {
	background: var(--pc-pri-dark);
	border-color: var(--pc-pri-dark);
}
html body.hat7.hh-ui.single-product .woocommerce-tabs ul.tabs li.active a { color: #fff; }

@media (max-width: 767px) {
	html body.hat7.hh-ui.single-product div.product .summary .price { font-size: 1.35rem; padding: 10px 12px; }
	html body.hat7.hh-ui.single-product div.product .flex-control-thumbs li { width: 60px !important; }
}

/* Buy box on the product page: cream like the cards (overrides the mauve
 * variables from legacy-bridge.css on product pages only). */
html body.hat7.hh-ui.single-product .h7-bb {
	--bb-bg: var(--pc-card);
	--bb-line: var(--pc-line);
	--bb-muted: var(--pc-mute);
	--bb-accent: var(--pc-pri-dark);
	padding: 14px 16px;
	border-radius: 14px;
	box-shadow: 0 2px 10px rgba(41, 76, 80, .06);
}
html body.hat7.hh-ui.single-product .h7-bb__stock { color: #256149; }
html body.hat7.hh-ui.single-product .h7-bb__table th { color: var(--pc-pri-dark); }
html body.hat7.hh-ui.single-product .h7-bb__better {
	background: #fff;
	border: 1px solid var(--pc-line);
	border-radius: 10px;
}
html body.hat7.hh-ui.single-product .h7-bb__better a,
html body.hat7.hh-ui.single-product .h7-bb .button {
	background: var(--pc-pri-dark);
	color: #fff;
}
