/**
 * System Builder chooser page styles.
 */

.sb-chooser-page {
	max-width: 1200px;
	margin: 0 auto;
	padding: 32px 20px;
}

.sb-chooser-page__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	margin-bottom: 28px;
	padding: 24px;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 16px;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.sb-chooser-page__eyebrow {
	margin: 0 0 6px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #6c47ff;
}

.sb-chooser-page__header h1 {
	margin: 0;
	font-size: clamp(26px, 4vw, 42px);
	line-height: 1.1;
	color: #111827;
}

.sb-chooser-page__back {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 42px;
	padding: 10px 16px;
	border-radius: 999px;
	background: #6c47ff;
	color: #ffffff;
	font-weight: 700;
	text-decoration: none;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sb-chooser-page__back:hover,
.sb-chooser-page__back:focus {
	color: #ffffff;
	transform: translateY(-1px);
	box-shadow: 0 10px 20px rgba(108, 71, 255, 0.22);
}

.sb-chooser-page__content {
	min-height: 320px;
}

.sb-chooser-page__notice {
	max-width: 760px;
	margin: 60px auto;
	padding: 32px;
	text-align: center;
	background: #ffffff;
	border: 1px solid #fee2e2;
	border-radius: 16px;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.sb-chooser-page__notice h1 {
	margin: 0 0 10px;
	color: #991b1b;
}

.sb-chooser-page__notice p {
	margin: 0;
	color: #374151;
}

@media (max-width: 767px) {
	.sb-chooser-page {
		padding: 20px 14px;
	}

	.sb-chooser-page__header {
		align-items: flex-start;
		flex-direction: column;
		padding: 18px;
	}
}

.sb-add-to-build-button {
	align-items: center;
	background: #6c47ff;
	border: 1px solid #6c47ff;
	border-radius: 8px;
	color: #ffffff;
	cursor: pointer;
	display: inline-flex;
	font-weight: 600;
	justify-content: center;
	line-height: 1.2;
	min-height: 42px;
	padding: 12px 18px;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sb-add-to-build-button:hover,
.sb-add-to-build-button:focus {
	background: #5536d9;
	border-color: #5536d9;
	color: #ffffff;
	outline: none;
	transform: translateY(-1px);
}

.sb-add-to-build-button:focus-visible {
	box-shadow: 0 0 0 3px rgba(108, 71, 255, 0.25);
}

/* Filter sidebar, sort bar, and AJAX product grid. */
.sb-filter-sidebar {
	--sb-filter-accent: #6c47ff;
	position: relative;
}

.sb-filter-sidebar__panel {
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 16px;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
	padding: 20px;
}

.sb-filter-sidebar__mobile-toggle-wrap,
.sb-filter-sidebar__mobile-header,
.sb-filter-sidebar__apply,
.sb-filter-sidebar__overlay {
	display: none;
}

.sb-filter-sidebar__topline {
	align-items: center;
	display: flex;
	gap: 12px;
	justify-content: space-between;
	margin-bottom: 14px;
}

.sb-filter-sidebar__clear,
.sb-filter-section__more {
	background: transparent;
	border: 0;
	color: var(--sb-filter-accent);
	cursor: pointer;
	font-weight: 700;
	padding: 0;
	text-decoration: none;
}

.sb-filter-sidebar__count,
.sb-sort-bar__count {
	color: #6b7280;
	font-size: 13px;
	font-weight: 600;
}

.sb-filter-sidebar__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.sb-filter-chip {
	align-items: center;
	background: rgba(108, 71, 255, 0.08);
	border: 1px solid rgba(108, 71, 255, 0.18);
	border-radius: 999px;
	color: #4c2fc9;
	cursor: pointer;
	display: inline-flex;
	font-size: 12px;
	font-weight: 700;
	gap: 6px;
	padding: 7px 10px;
}

.sb-filter-section {
	border-top: 1px solid #eef2f7;
	padding: 14px 0;
}

.sb-filter-section:first-of-type {
	border-top: 0;
}

.sb-filter-section__title {
	align-items: center;
	background: transparent;
	border: 0;
	color: #111827;
	cursor: pointer;
	display: flex;
	font-size: 14px;
	font-weight: 800;
	justify-content: space-between;
	padding: 0;
	text-align: left;
	width: 100%;
}

.sb-filter-section__title::after {
	content: "⌄";
	font-size: 16px;
	line-height: 1;
	transition: transform 0.15s ease;
}

.sb-filter-section.is-collapsed .sb-filter-section__title::after {
	transform: rotate(-90deg);
}

.sb-filter-section.is-collapsed .sb-filter-section__body {
	display: none;
}

.sb-filter-section__body {
	display: grid;
	gap: 10px;
	margin-top: 12px;
}

.sb-filter-option {
	align-items: center;
	color: #374151;
	cursor: pointer;
	display: flex;
	font-size: 14px;
	gap: 9px;
	line-height: 1.35;
}

.sb-filter-option input[type="checkbox"] {
	accent-color: var(--sb-filter-accent);
}

.sb-filter-option em {
	color: #9ca3af;
	font-style: normal;
}

.sb-filter-option.is-extra-term {
	display: none;
}

.sb-filter-section.is-expanded .sb-filter-option.is-extra-term {
	display: flex;
}

.sb-filter-sidebar__price-inputs {
	display: grid;
	gap: 10px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sb-filter-sidebar__price-inputs label {
	display: grid;
	gap: 5px;
}

.sb-filter-sidebar__price-inputs span {
	color: #6b7280;
	font-size: 12px;
	font-weight: 700;
}

.sb-filter-sidebar__price-inputs input,
.sb-sort-bar__select {
	background: #ffffff;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	color: #111827;
	min-height: 42px;
	padding: 9px 11px;
	width: 100%;
}

.sb-filter-sidebar__price-slider {
	margin-bottom: 10px;
}

.sb-sort-bar {
	align-items: center;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 16px;
	display: flex;
	gap: 16px;
	justify-content: space-between;
	margin-bottom: 18px;
	padding: 14px 16px;
}

.sb-sort-bar__field {
	align-items: center;
	display: flex;
	gap: 10px;
	margin: 0;
}

.sb-sort-bar__label {
	color: #374151;
	font-weight: 800;
	white-space: nowrap;
}

.sb-sort-bar__select {
	min-width: 190px;
}

.sb-products-grid {
	display: grid;
	gap: 18px;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	position: relative;
}

.sb-products-grid.is-loading {
	opacity: 0.62;
	pointer-events: none;
}

.sb-products-grid__message {
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 14px;
	color: #374151;
	grid-column: 1 / -1;
	padding: 20px;
	text-align: center;
}

.sb-products-grid__message.is-error {
	border-color: #fecaca;
	color: #991b1b;
}

.sb-product-card {
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 16px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.sb-product-card:hover {
	box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
	transform: translateY(-2px);
}

.sb-product-card__image {
	align-items: center;
	aspect-ratio: 1 / 0.78;
	background: #f8fafc;
	display: flex;
	justify-content: center;
	padding: 14px;
}

.sb-product-card__image img {
	height: 100%;
	max-width: 100%;
	object-fit: contain;
	width: 100%;
}

.sb-product-card__body {
	display: grid;
	gap: 10px;
	padding: 16px;
}

.sb-product-card__title {
	color: #111827;
	font-size: 16px;
	line-height: 1.35;
	margin: 0;
}

.sb-product-card__price {
	color: #111827;
	font-weight: 800;
}

.sb-product-card__stock {
	border-radius: 999px;
	font-size: 12px;
	font-weight: 800;
	justify-self: start;
	padding: 5px 9px;
}

.sb-product-card__stock.is-in-stock {
	background: #dcfce7;
	color: #166534;
}

.sb-product-card__stock.is-out-of-stock {
	background: #fee2e2;
	color: #991b1b;
}

@media (max-width: 767px) {
	.sb-filter-sidebar__mobile-toggle-wrap {
		display: block;
		margin-bottom: 14px;
	}

	.sb-filter-sidebar__mobile-toggle,
	.sb-filter-sidebar__apply {
		background: var(--sb-filter-accent);
		border: 1px solid var(--sb-filter-accent);
		border-radius: 999px;
		color: #ffffff;
		cursor: pointer;
		font-weight: 800;
		min-height: 42px;
		padding: 10px 16px;
	}

	.sb-filter-sidebar__overlay {
		background: rgba(15, 23, 42, 0.45);
		display: block;
		inset: 0;
		opacity: 0;
		pointer-events: none;
		position: fixed;
		transition: opacity 0.18s ease;
		z-index: 99997;
	}

	.sb-filter-sidebar__panel {
		bottom: 0;
		max-width: min(92vw, 380px);
		overflow-y: auto;
		position: fixed;
		top: 0;
		transform: translateX(105%);
		transition: transform 0.2s ease;
		width: 360px;
		z-index: 99998;
	}

	.sb-filter-sidebar--right .sb-filter-sidebar__panel {
		right: 0;
	}

	.sb-filter-sidebar--left .sb-filter-sidebar__panel {
		left: 0;
		transform: translateX(-105%);
	}

	.sb-filter-sidebar--bottom .sb-filter-sidebar__panel {
		border-radius: 20px 20px 0 0;
		height: min(82vh, 650px);
		left: 0;
		max-width: none;
		right: 0;
		top: auto;
		transform: translateY(105%);
		width: 100%;
	}

	.sb-filter-sidebar.is-open .sb-filter-sidebar__overlay {
		opacity: 1;
		pointer-events: auto;
	}

	.sb-filter-sidebar.is-open .sb-filter-sidebar__panel {
		transform: translate(0, 0);
	}

	.sb-filter-sidebar__mobile-header {
		align-items: center;
		display: flex;
		justify-content: space-between;
		margin-bottom: 14px;
	}

	.sb-filter-sidebar__close {
		background: #f3f4f6;
		border: 0;
		border-radius: 999px;
		cursor: pointer;
		font-size: 24px;
		height: 36px;
		line-height: 1;
		width: 36px;
	}

	.sb-filter-sidebar__apply {
		display: inline-flex;
		justify-content: center;
		margin-top: 14px;
		width: 100%;
	}

	.sb-filter-drawer-open {
		overflow: hidden;
	}

	.sb-sort-bar {
		align-items: stretch;
		flex-direction: column;
	}

	.sb-sort-bar__field {
		align-items: stretch;
		flex-direction: column;
	}

	.sb-sort-bar__select {
		min-width: 0;
	}
}

/* Keep AJAX products inside the Elementor Loop Grid area when that widget is used as the chooser product target. */
.elementor-widget-loop-grid .sb-products-grid,
[data-widget_type*="loop-grid"] .sb-products-grid {
	width: 100%;
}

.sb-product-template-card {
	min-width: 0;
}

.sb-product-template-card .sb-add-to-build-button--fallback {
	margin-top: 12px;
	width: 100%;
}

.sb-loop-template-image-fallback {
	align-items: center;
	background: #f8fafc;
	display: flex;
	justify-content: center;
	min-height: 180px;
	overflow: hidden;
	padding: 14px;
}

.sb-loop-template-image-fallback img {
	height: auto;
	max-height: 220px;
	max-width: 100%;
	object-fit: contain;
	width: auto;
}

/* Phase 35: compatibility auto filters + safer Loop Item badge/media output */
.sb-filter-option.is-auto-filter {
	opacity: 0.85;
}

.sb-filter-option.is-auto-filter input {
	cursor: not-allowed;
}

.sb-products-grid .sb-loop-empty-link {
	display: none !important;
	min-height: 0 !important;
	height: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 0 !important;
	overflow: hidden !important;
}

.sb-products-grid .sb-product-template-card,
.sb-products-grid [data-sb-product-item],
.sb-products-grid .e-loop-item,
.sb-products-grid .product {
	position: relative;
}

/* Keep only empty chooser links hidden. Sale badge styling should come from the saved Elementor Loop Item template. */
.sb-products-grid .sb-loop-sale-badge--fallback {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 20;
}

/* Phase 36: make AJAX items use the actual Elementor Loop Grid target and saved columns. */
#sb-chooser-page .elementor-loop-container.sb-products-grid--elementor,
#sb-chooser-page .elementor-widget-loop-grid .elementor-loop-container.sb-products-grid,
#sb-chooser-page [data-widget_type*="loop-grid"] .elementor-loop-container.sb-products-grid {
	display: grid !important;
	grid-template-columns: repeat(var(--sb-loop-columns, 3), minmax(0, 1fr)) !important;
	align-items: stretch;
	gap: var(--grid-row-gap, 18px) var(--grid-column-gap, 18px);
	width: 100%;
}

#sb-chooser-page .elementor-loop-container.sb-products-grid--elementor > .elementor,
#sb-chooser-page .elementor-loop-container.sb-products-grid--elementor > .e-loop-item,
#sb-chooser-page .elementor-loop-container.sb-products-grid--elementor > .product,
#sb-chooser-page .elementor-loop-container.sb-products-grid--elementor > [data-sb-product-item] {
	min-width: 0;
	width: 100% !important;
}

#sb-chooser-page .elementor-loop-container.sb-products-grid--elementor .sb-loop-media-link {
	display: flex !important;
	align-items: center;
	justify-content: center;
	min-height: inherit;
	width: 100%;
}

#sb-chooser-page .elementor-loop-container.sb-products-grid--elementor .sb-loop-template-image-fallback__img {
	display: block;
	height: auto;
	max-height: 100%;
	max-width: 100%;
	object-fit: contain;
	width: auto;
}

.sb-products-pagination {
	align-items: center;
	display: flex;
	gap: 8px;
	grid-column: 1 / -1;
	justify-content: center;
	margin-top: 20px;
	width: 100%;
}

.sb-products-pagination .page-numbers {
	align-items: center;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	color: #111827;
	cursor: pointer;
	display: inline-flex;
	font-size: 13px;
	font-weight: 700;
	height: 34px;
	justify-content: center;
	min-width: 34px;
	padding: 0 10px;
	text-decoration: none;
}

.sb-products-pagination .page-numbers.current {
	background: #6c47ff;
	border-color: #6c47ff;
	color: #ffffff;
	cursor: default;
}

.sb-products-pagination .page-numbers.dots {
	background: transparent;
	border-color: transparent;
	cursor: default;
}

@media (max-width: 1024px) {
	#sb-chooser-page .elementor-loop-container.sb-products-grid--elementor,
	#sb-chooser-page .elementor-widget-loop-grid .elementor-loop-container.sb-products-grid,
	#sb-chooser-page [data-widget_type*="loop-grid"] .elementor-loop-container.sb-products-grid {
		grid-template-columns: repeat(var(--sb-loop-columns-tablet, 2), minmax(0, 1fr)) !important;
	}
}

@media (max-width: 767px) {
	#sb-chooser-page .elementor-loop-container.sb-products-grid--elementor,
	#sb-chooser-page .elementor-widget-loop-grid .elementor-loop-container.sb-products-grid,
	#sb-chooser-page [data-widget_type*="loop-grid"] .elementor-loop-container.sb-products-grid {
		grid-template-columns: repeat(var(--sb-loop-columns-mobile, 1), minmax(0, 1fr)) !important;
	}
}

/* System Builder Search Bar */
.sb-search-bar {
    width: 100%;
    margin: 0;
}

.sb-search-bar__box {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 54px;
    padding: 10px 16px 10px 20px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    box-sizing: border-box;
}

.sb-search-bar__input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: #111827;
    font-size: 16px;
    line-height: 1.4;
}

.sb-search-bar__input::-webkit-search-decoration,
.sb-search-bar__input::-webkit-search-cancel-button,
.sb-search-bar__input::-webkit-search-results-button,
.sb-search-bar__input::-webkit-search-results-decoration {
    display: none;
}

.sb-search-bar__input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.sb-search-bar__actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex: 0 0 auto;
}

.sb-search-bar__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #111827;
    cursor: pointer;
    line-height: 1;
}

.sb-search-bar__button:hover,
.sb-search-bar__button:focus {
    background: rgba(17, 24, 39, .06);
    color: #111827;
    outline: none;
}

.sb-search-bar__button svg {
    display: block;
    width: 24px;
    height: 24px;
}
