/* =========================================================
   Shop Grid Pro — 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:     #1C54A1;   /* brand blue              */
	--sgp-card-radius: 14px;
	--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;
}

/* --- top row: heading left, controls right --- */
.sgp-toolbar-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px 20px;
	flex-wrap: wrap;
}

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

/* --- 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 {
	-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;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.sgp-pill:hover { color: var(--sgp-ink); background: var(--sgp-line-soft); }
.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
   ========================================================= */
.sgp-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 24px;
	transition: opacity .2s ease;
}

/* =========================================================
   CARD
   ========================================================= */
.sgp-card {
	display: flex;
	flex-direction: column;
	background: #fff;
	border: 1px solid var(--sgp-line);
	border-radius: var(--sgp-card-radius);
	overflow: hidden;
	transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.sgp-card:hover {
	transform: translateY(-4px);
	border-color: transparent;
	box-shadow: 0 12px 32px -12px rgba(20, 24, 36, 0.18);
}

.sgp-card-media {
	position: relative;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #f7f8fa;
}
.sgp-card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .4s ease;
}
.sgp-card:hover .sgp-card-media img { transform: scale(1.05); }

.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: 6px;
	padding: 18px 18px 20px;
	flex: 1 1 auto;
	text-align: center;
}

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

.sgp-card-title {
	font-size: 1.02rem;
	font-weight: 600;
	line-height: 1.35;
	margin: 0;
	letter-spacing: -0.01em;
}
.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: 1.05rem;
	margin-top: 2px;
	color: var(--sgp-ink);
}
.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 (no icon) --- */
.sgp-add-to-cart {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: 14px;
	border: none;
	cursor: pointer;
	background: var(--sgp-accent);
	color: #fff;
	padding: 12px 20px;
	border-radius: 10px;
	font-size: 0.85rem;
	font-weight: 600;
	letter-spacing: .01em;
	text-decoration: none;
	width: 100%;
	transition: background-color .15s ease, transform .08s ease;
}
.sgp-add-to-cart:hover { background: #16407B; }
.sgp-add-to-cart:active { transform: scale(.985); }
.sgp-add-to-cart.is-loading,
.sgp-add-to-cart.loading { opacity: .7; cursor: default; pointer-events: none; }
.sgp-add-to-cart.is-added,
.sgp-add-to-cart.added { background: #1f9d57; }

/* 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
   ========================================================= */
@media (max-width: 1024px) {
	.sgp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@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 { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}
