/**
 * Product cards for the Elementor "Products" widget and the native shop /
 * category archives. Everything is scoped under
 * .elementor-widget-woocommerce-products (Elementor) or .oshop-grid (native).
 */

/* ---- Card (Elementor's ul.products grid stretches each li; the inner just
        has to fill it so buttons pin to the same line per row) ---- */

/* Grid items default to min-width auto, so the 600px image's intrinsic width
   blows the track out past the viewport on mobile. Let items shrink. */
:is(.elementor-widget-woocommerce-products, .oshop-grid) ul.products li.product {
	min-width: 0;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .product-inner {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	background: #fff;
	border: 1px solid #ececec;
	border-radius: 14px;
	overflow: hidden;
	transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .product-inner:hover {
	border-color: #e2e2e2;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.09);
	transform: translateY(-3px);
}

/* Kill the global rounded/framed image block — one clean card border only */
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .product-inner .product-image {
	margin: 0;
	background: #fff;
	border: 0;
	border-radius: 0;
}

/* Square image box regardless of source ratio (woocommerce_single is uncropped,
   so portrait originals would otherwise stretch the row) */
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .product-image .inner {
	aspect-ratio: 1 / 1;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .product-image img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .product-content {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	padding: 14px 16px 16px;
	text-align: left;
}

/* ---- Discount badge ---- */
:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-discount-badge {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 5;
	background: #d5202a;
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	line-height: 1;
	padding: 7px 11px;
	border-radius: 6px;
	pointer-events: none;
}

/* Hide Porto's own sale flash / countdown so badges don't double up */
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .onsale,
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .labels,
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .sale-product-period {
	display: none !important;
}

/* ---- Category + title: no underline, calmer type ---- */
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .category-list {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #8a8f98;
	margin-bottom: 4px;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .category-list a,
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .category-list a:hover,
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product a.product-loop-title,
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product a.product-loop-title:hover {
	text-decoration: none;
	border-bottom: 0;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .category-list a {
	color: #8a8f98;
	transition: color 0.2s ease;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .category-list a:hover {
	color: #4b5057;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .woocommerce-loop-product__title {
	font-size: 16px;
	font-weight: 600;
	line-height: 1.35;
	color: #1d2327;
	margin: 0 0 6px;
	/* Porto's archive skin forces single-line nowrap/ellipsis titles with
	   display: flow-root; !important restores the 2-line clamp there. */
	display: -webkit-box !important;
	white-space: normal !important;
	text-overflow: unset !important;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	transition: color 0.2s ease;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product a.product-loop-title:hover .woocommerce-loop-product__title {
	color: var(--brand-navy);
}

/* ---- Rating (custom SVG stars) ---- */
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .rating-wrap {
	margin: 0 0 6px;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-rating {
	display: flex;
	align-items: center;
	gap: 6px;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-rating .orthexa-star-rating-wrapper {
	max-width: 96px;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-rating-count {
	font-size: 13px;
	color: #6b7076;
	line-height: 1;
}

/* ---- Price ---- */
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .price {
	display: flex;
	align-items: baseline;
	gap: 8px;
	margin: 2px 0 0;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .price del {
	font-size: 14px;
	color: #9aa0a6;
	text-decoration: line-through;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .price ins {
	font-size: 20px;
	font-weight: 700;
	color: #1e1e1e;
	text-decoration: none;
	background: none;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .price > .woocommerce-Price-amount {
	font-size: 20px;
	font-weight: 700;
	color: #1e1e1e;
}

/* ---- Hide Porto's default loop buttons / quick view ---- */
:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .add-links-wrap {
	display: none !important;
}

/* ---- Action buttons ---- */
:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: auto;
	padding-top: 14px;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 44px;
	padding: 10px 14px;
	border-radius: 8px;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn:hover,
:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn:focus {
	text-decoration: none;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn--cart {
	background: #8cb83b;
	color: #fff;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn--cart:hover,
:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn--cart:focus {
	background: #7ca634;
	color: #fff;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn--view {
	background: #fff;
	border: 1px solid #dcdfe3;
	color: #3c4147;
	font-weight: 600;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn--view:hover,
:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn--view:focus {
	border-color: #b8bdc4;
	color: #1d2327;
	background: #f8f9fa;
}

/* Loading state while adding to cart */
:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn--cart.is-loading {
	pointer-events: none;
	opacity: 0.75;
	position: relative;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn--cart.is-loading .oshop-btn-label {
	visibility: hidden;
}

:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn--cart.is-loading::after {
	content: "";
	position: absolute;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: oshop-spin 0.7s linear infinite;
}

@keyframes oshop-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---- Mobile tweaks ---- */
@media (max-width: 575px) {
	:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .product-content {
		padding: 12px;
	}

	:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .category-list {
		display: block;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	:is(.elementor-widget-woocommerce-products, .oshop-grid) li.product .woocommerce-loop-product__title {
		font-size: 15px;
	}

	:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-discount-badge {
		top: 8px;
		left: 8px;
		font-size: 13px;
		padding: 6px 9px;
	}

	:is(.elementor-widget-woocommerce-products, .oshop-grid) .oshop-btn {
		font-size: 14px;
		min-height: 40px;
		padding: 8px 10px;
	}
}

/* ---- Category grid (top of shop page, replaces the old hero) ---- */
.oshop-cats {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 14px;
	margin: 12px 0 30px;
}

.oshop-cat {
	display: flex;
	align-items: center;
	gap: 14px;
	background: #fff;
	border: 1px solid #ececec;
	border-radius: 14px;
	padding: 12px 16px;
	min-height: 84px;
	text-decoration: none;
	transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.oshop-cat:hover,
.oshop-cat:focus {
	border-color: #e2e2e2;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.09);
	transform: translateY(-2px);
	text-decoration: none;
}

.oshop-cat__image {
	flex: 0 0 64px;
	width: 64px;
	height: 64px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.oshop-cat__image img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

.oshop-cat__name {
	flex: 1 1 auto;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.35;
	color: #1d2327;
	transition: color 0.2s ease;
}

.oshop-cat:hover .oshop-cat__name {
	color: var(--brand-navy);
}

.oshop-cat__chevron {
	display: flex;
	align-items: center;
	color: #9aa0a6;
	transition: color 0.2s ease, transform 0.2s ease;
}

.oshop-cat:hover .oshop-cat__chevron {
	color: #1d2327;
	transform: translateX(2px);
}

@media (max-width: 991px) {
	.oshop-cats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 575px) {
	.oshop-cats {
		grid-template-columns: 1fr;
		gap: 10px;
	}

	.oshop-cat {
		min-height: 68px;
		padding: 8px 12px;
	}

	.oshop-cat__image {
		flex-basis: 52px;
		width: 52px;
		height: 52px;
	}

	.oshop-cat__name {
		font-size: 15px;
	}
}

/* ---- Archive page title (shop / category / tag) ----
   h1.page-title doubles the class count so this outranks style.css's
   `.post-type-archive h1.page-title { margin-top: 0 }`. */
h1.page-title.oshop-page-title {
	margin: 40px 0 24px;
}

@media (max-width: 575px) {
	h1.page-title.oshop-page-title {
		margin: 24px 0 16px;
	}
}
