/* =========================================================
   STW Shop Grid — base styles
   Designed to look intentional on any site, every value
   overridable via the Elementor Style tab.
   ========================================================= */

/* ---------------------------------------------------------
   HARDENED RESETS
   Themes frequently set global rules on svg, button, [hidden],
   and inputs. These scoped rules make sure the plugin's own
   layout wins without affecting anything outside .sgp-wrap.
   --------------------------------------------------------- */
.sgp-wrap svg { max-width: 100%; height: auto; }

/* SVG chevron must keep its exact size regardless of theme svg rules */
.sgp-wrap .sgp-sort-chevron {
	width: 11px !important;
	height: 7px !important;
	flex: 0 0 auto;
}

/* The spinner must stay hidden until JS shows it. Some themes nuke [hidden]. */
.sgp-wrap .sgp-spinner[hidden],
.sgp-wrap .sgp-search-clear[hidden] {
	display: none !important;
}

/* Neutralize theme button resets inside the widget */
.sgp-wrap button {
	font-family: inherit;
	line-height: normal;
}

/* Themes often set global input padding/height. Lock the search field. */
.sgp-wrap .sgp-search-input {
	padding-left: 16px !important;
	padding-right: 38px !important;
	height: 44px !important;
	text-indent: 0 !important;
}

.sgp-wrap {
	--sgp-ink:        #1a1d24;   /* primary text            */
	--sgp-muted:      #707683;   /* secondary text          */
	--sgp-line:       #e6e8ec;   /* hairline borders        */
	--sgp-line-soft:  #eef0f3;   /* lighter dividers        */
	--sgp-field:      #ffffff;   /* input backgrounds       */
	--sgp-field-bg:   #f5f6f8;   /* resting control fill    */
	--sgp-accent:     #20539c;   /* brand blue              */
	--sgp-accent-hover: #1a4580;
	--sgp-card-radius: 16px;
	--sgp-control-radius: 10px;
	position: relative;
	color: var(--sgp-ink);
}

.sgp-wrap,
.sgp-wrap *,
.sgp-wrap *::before,
.sgp-wrap *::after { box-sizing: border-box !important; }

/* =========================================================
   TOOLBAR
   ========================================================= */
.sgp-toolbar {
	display: flex;
	flex-direction: column;
	gap: 18px;
	margin-bottom: 28px;
}
.sgp-toolbar--compact {
	gap: 0;
	margin-bottom: 20px;
}
/* Keep search/sort on the right like BARF Shop (no filter row). */
.sgp-toolbar--compact .sgp-toolbar-controls {
	margin-left: auto;
}

/* --- top row: heading left, controls right --- */
.sgp-toolbar-top {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 16px 20px;
	flex-wrap: wrap;
}
.sgp-toolbar-top:has(.sgp-heading) {
	justify-content: space-between;
}
.sgp-toolbar-top .sgp-count {
	margin: 0;
	white-space: nowrap;
}

.sgp-heading {
	margin: 0;
	font-size: 1.6rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.15;
	color: var(--sgp-ink);
}

/* --- controls cluster: search + price + sort --- */
.sgp-toolbar-controls {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	flex-wrap: nowrap;
	gap: 10px;
	margin-left: auto;
}

/* --- search (no icon) --- */
.sgp-search {
	position: relative;
	display: flex;
	align-items: center;
	flex: 0 1 300px;
	min-width: 200px;
}
.sgp-search-input {
	width: 100%;
	height: 44px;
	border: 1px solid var(--sgp-line);
	background: var(--sgp-field);
	border-radius: var(--sgp-control-radius);
	padding: 0 38px 0 16px;
	font-size: 0.9rem;
	color: var(--sgp-ink);
	transition: border-color .15s ease, box-shadow .15s ease;
	-webkit-appearance: none;
	appearance: none;
}
.sgp-search-input::placeholder { color: var(--sgp-muted); }
.sgp-search-input:focus {
	outline: none;
	border-color: var(--sgp-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--sgp-accent) 14%, transparent);
}
/* hide native search clear */
.sgp-search-input::-webkit-search-decoration,
.sgp-search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.sgp-search-clear {
	position: absolute;
	right: 8px;
	width: 26px;
	height: 26px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: var(--sgp-field-bg);
	color: var(--sgp-muted);
	border-radius: 50%;
	font-size: 1.05rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color .15s ease, color .15s ease;
}
.sgp-search-clear:hover { background: var(--sgp-line); color: var(--sgp-ink); }

/* --- price filter --- */
.sgp-price-filter {
	display: flex;
	align-items: center;
	gap: 8px;
	height: 44px;
	padding: 0 6px 0 12px;
	border: 1px solid var(--sgp-line);
	border-radius: var(--sgp-control-radius);
	background: var(--sgp-field);
}
.sgp-price-filter input {
	width: 64px;
	height: 30px;
	border: none;
	background: transparent;
	font-size: 0.875rem;
	color: var(--sgp-ink);
	-webkit-appearance: none;
	appearance: none;
}
.sgp-price-filter input:focus { outline: none; }
.sgp-price-filter input::-webkit-outer-spin-button,
.sgp-price-filter input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sgp-price-sep { color: var(--sgp-muted); font-size: 0.85rem; }
.sgp-price-apply {
	height: 32px;
	padding: 0 14px;
	border: none;
	background: var(--sgp-ink);
	color: #fff;
	border-radius: 7px;
	font-size: 0.8rem;
	font-weight: 600;
	cursor: pointer;
	transition: opacity .15s ease;
}
.sgp-price-apply:hover { opacity: .85; }

/* --- sort (custom chevron, no native arrow) --- */
.sgp-sort-wrap {
	position: relative;
	display: flex;
	align-items: center;
}
.sgp-sort {
	height: 44px;
	border: 1px solid var(--sgp-line);
	background: var(--sgp-field);
	border-radius: var(--sgp-control-radius);
	padding: 0 38px 0 14px;
	font-size: 0.9rem;
	font-weight: 500;
	color: var(--sgp-ink);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.sgp-sort:focus {
	outline: none;
	border-color: var(--sgp-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--sgp-accent) 14%, transparent);
}
.sgp-sort-chevron {
	position: absolute;
	right: 14px;
	width: 11px;
	height: 7px;
	color: var(--sgp-muted);
	pointer-events: none;
}

/* --- filters row: pills left, count right --- */
.sgp-toolbar-filters {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	padding-top: 18px;
	border-top: 1px solid var(--sgp-line-soft);
}

.sgp-filter-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.sgp-pill,
a.sgp-pill {
	-webkit-appearance: none;
	appearance: none;
	border: 1px solid transparent;
	background: var(--sgp-field-bg);
	color: var(--sgp-muted);
	padding: 8px 16px;
	border-radius: 999px;
	font-size: 0.85rem;
	font-weight: 500;
	line-height: 1.2;
	cursor: pointer;
	white-space: nowrap;
	text-decoration: none;
	display: inline-block;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.sgp-pill:hover,
a.sgp-pill:hover { color: var(--sgp-ink); background: var(--sgp-line-soft); }
.sgp-pill.is-active,
a.sgp-pill.is-active {
	background: var(--sgp-accent);
	border-color: var(--sgp-accent);
	color: #fff;
	font-weight: 600;
}

.sgp-count {
	font-size: 0.82rem;
	color: var(--sgp-muted);
	white-space: nowrap;
	letter-spacing: .01em;
}

/* =========================================================
   GRID — column count is --sgp-cols only.
   Desktop fallback: --sgp-cols-desktop (inline from PHP).
   Elementor Columns control sets --sgp-cols per breakpoint.
   No hardcoded column counts in media queries.
   ========================================================= */
.sgp-grid {
	--sgp-cols: var(--sgp-cols-desktop, 1);
	--sgp-gap: 24px;
	display: grid;
	grid-template-columns: repeat( var(--sgp-cols), minmax(0, 1fr) ) !important;
	gap: var(--sgp-gap);
	align-items: stretch;
	transition: opacity .2s ease;
}

/* =========================================================
   CARD
   ========================================================= */
.sgp-card {
	display: flex;
	flex-direction: column;
	height: 100%;
	background: #fff;
	border: 1px solid #e8ebf0;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(22, 32, 43, 0.04);
	transition:
		transform .25s cubic-bezier(.2, .8, .2, 1),
		box-shadow .25s cubic-bezier(.2, .8, .2, 1),
		border-color .25s ease;
}
.sgp-card:hover {
	transform: translateY(-3px);
	border-color: color-mix(in srgb, var(--sgp-accent) 32%, #e8ebf0);
	box-shadow: 0 18px 40px -18px rgba(32, 83, 156, 0.32);
}
@media (prefers-reduced-motion: reduce) {
	.sgp-card,
	.sgp-card-media img { transition: none; }
	.sgp-card:hover { transform: none; }
	.sgp-card:hover .sgp-card-media img { transform: none; }
}

.sgp-card-media {
	position: relative;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: linear-gradient(180deg, #f5f7fa 0%, #eef1f5 100%);
}
.sgp-card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .45s cubic-bezier(.2, .8, .2, 1);
}
.sgp-card:hover .sgp-card-media img { transform: scale(1.04); }

.sgp-badge {
	position: absolute;
	top: 12px;
	left: 12px;
	font-size: 0.66rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .05em;
	padding: 5px 10px;
	border-radius: 7px;
	color: #fff;
	backdrop-filter: blur(2px);
}
.sgp-badge-sale { background: #d6342c; }
.sgp-badge-oos  { background: rgba(26, 29, 36, 0.78); left: auto; right: 12px; }

.sgp-card-body {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 16px 16px 18px;
	flex: 1 1 auto;
	text-align: center;
}

.sgp-card-cat {
	font-size: 0.68rem;
	text-transform: uppercase;
	letter-spacing: .07em;
	color: var(--sgp-muted);
	font-weight: 600;
}
.sgp-card-cat a { color: inherit; text-decoration: none; }
.sgp-card-cat a:hover { color: var(--sgp-accent); }

.sgp-card-title {
	font-size: 0.98rem;
	font-weight: 600;
	line-height: 1.35;
	margin: 0;
	letter-spacing: -0.015em;
	color: var(--sgp-ink);
	/* Reserve two lines so CTAs stay on one row across the grid. */
	min-height: calc(1.35em * 2);
}
.sgp-card-title a { color: inherit; text-decoration: none; }
.sgp-card-title a:hover { color: var(--sgp-accent); }

.sgp-card-rating { font-size: 0.85rem; line-height: 1; }

.sgp-card-price {
	font-weight: 700;
	font-size: 0.98rem;
	margin-top: 0;
	color: var(--sgp-ink);
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.01em;
}
.sgp-card-price .woocommerce-Price-amount,
.sgp-card-price bdi {
	font-weight: inherit;
	color: inherit;
}
.sgp-card-price del { color: var(--sgp-muted); font-weight: 400; font-size: 0.9em; margin-right: 7px; }
.sgp-card-price ins { text-decoration: none; color: #d6342c; }

/* --- add to cart — beat Astra/Woo `.button` + :visited quirks --- */
.sgp-wrap a.sgp-add-to-cart,
.sgp-wrap a.sgp-add-to-cart:link,
.sgp-wrap a.sgp-add-to-cart:visited,
.sgp-wrap a.sgp-add-to-cart.button,
.sgp-wrap a.sgp-add-to-cart.button:link,
.sgp-wrap a.sgp-add-to-cart.button:visited,
.sgp-wrap a.sgp-add-to-cart.add_to_cart_button {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	/* Pin CTA to card footer so every button shares one row. */
	margin: auto 0 0 !important;
	border: 0 !important;
	border-width: 0 !important;
	border-style: none !important;
	border-color: transparent !important;
	outline: none !important;
	cursor: pointer;
	background: #20539c !important;
	background-color: #20539c !important;
	background-image: none !important;
	color: #fff !important;
	padding: 11px 16px !important;
	border-radius: 12px !important;
	font-family: inherit !important;
	font-size: 0.8rem !important;
	font-weight: 600 !important;
	letter-spacing: .02em !important;
	line-height: 1.2 !important;
	text-transform: none !important;
	text-decoration: none !important;
	text-shadow: none !important;
	width: 100% !important;
	height: auto !important;
	min-height: 44px;
	box-shadow: none !important;
	filter: none !important;
	opacity: 1 !important;
	white-space: nowrap !important;
	transition: background-color .15s ease, transform .08s ease;
}
.sgp-wrap a.sgp-add-to-cart:hover,
.sgp-wrap a.sgp-add-to-cart.button:hover,
.sgp-wrap a.sgp-add-to-cart:focus,
.sgp-wrap a.sgp-add-to-cart.button:focus {
	background: #1a4580 !important;
	background-color: #1a4580 !important;
	background-image: none !important;
	border: 0 !important;
	border-color: transparent !important;
	color: #fff !important;
	opacity: 1 !important;
	box-shadow: none !important;
}
.sgp-wrap a.sgp-add-to-cart:focus-visible {
	outline: 2px solid #20539c !important;
	outline-offset: 2px !important;
}
.sgp-wrap a.sgp-add-to-cart:active { transform: scale(.985); }
.sgp-wrap a.sgp-add-to-cart.is-loading,
.sgp-wrap a.sgp-add-to-cart.loading {
	opacity: .7 !important;
	cursor: default;
	pointer-events: none;
}
.sgp-wrap a.sgp-add-to-cart.is-added,
.sgp-wrap a.sgp-add-to-cart.added {
	background: #1f9d57 !important;
	background-color: #1f9d57 !important;
	border: 0 !important;
}
.sgp-wrap .sgp-cart-label {
	font: inherit !important;
	font-weight: 600 !important;
	letter-spacing: inherit !important;
	text-transform: none !important;
	color: #fff !important;
	opacity: 1 !important;
}

/* WooCommerce auto-appends an "added_to_cart" view-cart link after the button.
   Hide it inside our cards — the cart drawer / mini-cart handles that. */
.sgp-card .added_to_cart {
	display: none !important;
}

/* WooCommerce loading spinner ::after on the button — keep it subtle. */
.sgp-add-to-cart.loading::after {
	font-family: "WooCommerce";
	content: "\e01c";
	margin-left: 8px;
	animation: sgp-rotate 1s linear infinite;
	display: inline-block;
}

/* =========================================================
   STATES
   ========================================================= */
.sgp-no-results {
	grid-column: 1 / -1;
	text-align: center;
	padding: 56px 16px;
	color: var(--sgp-muted);
	font-size: 1rem;
}

.sgp-spinner {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding-top: 100px;
	pointer-events: none;
}
.sgp-spin {
	width: 34px; height: 34px;
	border: 3px solid var(--sgp-line);
	border-top-color: var(--sgp-accent);
	border-radius: 50%;
	animation: sgp-rotate .7s linear infinite;
}
@keyframes sgp-rotate { to { transform: rotate(360deg); } }

/* =========================================================
   PAGINATION
   ========================================================= */
.sgp-pagination { margin-top: 36px; display: flex; justify-content: center; }
.sgp-pages { display: flex; flex-wrap: wrap; gap: 8px; }
.sgp-page {
	width: 44px;
	min-width: 44px;
	height: 44px;
	padding: 0 !important;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1 !important;
	border: 1px solid var(--sgp-line);
	background: #fff;
	border-radius: var(--sgp-control-radius);
	cursor: pointer;
	font-size: 0.9rem;
	font-weight: 500;
	color: var(--sgp-ink);
	text-align: center;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.sgp-page:hover:not(.is-active) {
	background: var(--sgp-field-bg);
	border-color: var(--sgp-muted);
	color: var(--sgp-ink);
}
.sgp-page.is-active {
	background: var(--sgp-accent);
	color: #fff;
	border-color: var(--sgp-accent);
	cursor: default;
}
.sgp-page.is-active:hover {
	background: var(--sgp-accent);
	color: #fff;
}

.sgp-load-more {
	border: 1px solid var(--sgp-line);
	background: #fff;
	color: var(--sgp-ink);
	padding: 13px 32px;
	border-radius: 10px;
	cursor: pointer;
	font-size: 0.9rem;
	font-weight: 600;
	transition: background-color .15s ease, border-color .15s ease;
}
.sgp-load-more:hover { background: var(--sgp-field-bg); border-color: var(--sgp-muted); }

/* =========================================================
   FOCUS VISIBILITY (a11y)
   ========================================================= */
.sgp-pill:focus-visible,
.sgp-page:focus-visible,
.sgp-load-more:focus-visible,
.sgp-add-to-cart:focus-visible,
.sgp-price-apply:focus-visible {
	outline: 2px solid var(--sgp-accent);
	outline-offset: 2px;
}

/* =========================================================
   RESPONSIVE — toolbar / card chrome only (not columns).
   ========================================================= */
@media (max-width: 680px) {
	.sgp-toolbar-top { flex-direction: column; align-items: stretch; }
	.sgp-heading { font-size: 1.4rem; }
	.sgp-toolbar-controls { justify-content: stretch; margin-left: 0; }
	.sgp-search { flex: 1 1 100%; }
	.sgp-sort-wrap, .sgp-sort { flex: 1 1 auto; }
	.sgp-sort { width: 100%; }
	.sgp-toolbar-filters {
		flex-direction: column;
		align-items: flex-start;
	}
	.sgp-filter-pills {
		flex-wrap: nowrap;
		overflow-x: auto;
		width: 100%;
		padding-bottom: 4px;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}
	.sgp-filter-pills::-webkit-scrollbar { display: none; }
}
@media (max-width: 480px) {
	.sgp-grid { --sgp-gap: 14px; }
	/* Full-width 1:1 image dominates the viewport — trim height a notch. */
	.sgp-card-media { aspect-ratio: 4 / 3; }
	.sgp-card-body { padding: 12px 14px 14px; gap: 4px; }
	.sgp-card-title { font-size: 0.95rem; }
	.sgp-card-price { font-size: 0.98rem; }
	.sgp-wrap a.sgp-add-to-cart,
	.sgp-wrap a.sgp-add-to-cart.button {
		padding: 10px 16px !important;
		font-size: 0.8rem !important;
	}
}
