/**
 * Box configurator — scoped styles (all classes prefixed .wbc-).
 * Mobile-first, accessible focus states, no external dependencies.
 *
 * @package BoxKonfigurator
 */

.wbc-configurator {
	--wbc-accent: #b5341d;
	--wbc-accent-2: #e0612f;
	--wbc-ink: #1f2329;
	--wbc-muted: #6b7280;
	--wbc-line: #e6e8eb;
	--wbc-bg: #ffffff;
	--wbc-bg-soft: #f7f8fa;
	--wbc-ok: #2f9e44;
	--wbc-warn: #e8893b;
	--wbc-danger: #c0392b;
	--wbc-radius: 14px;
	--wbc-shadow: 0 6px 24px rgba(20, 24, 31, 0.08);

	box-sizing: border-box;
	color: var(--wbc-ink);
	font-size: 15px;
	line-height: 1.45;
	margin: 1.5rem 0;
	/* Fill the hosting widget/container. */
	width: 100%;
	max-width: 100%;
}

.wbc-configurator *,
.wbc-configurator *::before,
.wbc-configurator *::after {
	box-sizing: border-box;
}

/* Make ONLY the Elementor shortcode widget that hosts the configurator stretch
   to its column width (covers flex columns whose align-items isn't "stretch").
   Scoped to the widget itself — never its ancestor containers — so it can't
   blow out the page layout. */
.elementor-widget-shortcode:has( > .elementor-widget-container .wbc-configurator ) {
	width: 100%;
	max-width: 100%;
	align-self: stretch;
}

.wbc-configurator__heading {
	font-size: 1.35rem;
	font-weight: 700;
	margin: 0 0 1rem;
}

/* ---------------- Summary (sticky on desktop) ---------------- */

.wbc-summary {
	position: sticky;
	top: 12px;
	z-index: 5;
	display: grid;
	grid-template-columns: 1fr;
	gap: 1rem;
	padding: 1rem 1.1rem;
	background: var(--wbc-bg);
	border: 1px solid var(--wbc-line);
	border-radius: var(--wbc-radius);
	box-shadow: var(--wbc-shadow);
	margin-bottom: 1.1rem;
}

@media (min-width: 640px) {
	.wbc-summary {
		grid-template-columns: 1fr auto;
		align-items: center;
	}
}

.wbc-summary__label {
	display: block;
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--wbc-muted);
	margin-bottom: 0.25rem;
}

.wbc-summary__progress-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.5rem;
	margin-bottom: 0.4rem;
}

.wbc-summary__weight {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.wbc-progress {
	height: 12px;
	background: var(--wbc-bg-soft);
	border-radius: 999px;
	overflow: hidden;
	box-shadow: inset 0 0 0 1px var(--wbc-line);
}

.wbc-progress__bar {
	height: 100%;
	width: 0;
	border-radius: 999px;
	background: var(--wbc-accent);
	transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.wbc-summary__full-msg {
	margin: 0.5rem 0 0;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--wbc-danger);
}

.wbc-flash {
	animation: wbc-shake 0.4s ease;
}

@keyframes wbc-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-4px); }
	75% { transform: translateX(4px); }
}

.wbc-summary__price {
	text-align: left;
}

@media (min-width: 640px) {
	.wbc-summary__price { text-align: right; }
}

.wbc-price-total {
	font-size: 1.4rem;
	font-weight: 800;
	color: var(--wbc-accent);
}

/* ---------------- Toolbar ---------------- */

.wbc-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	margin-bottom: 1rem;
}

.wbc-toolbar__search { flex: 1 1 220px; }
.wbc-toolbar__sort { flex: 0 1 200px; min-width: 170px; }

.wbc-configurator .wbc-search,
.wbc-configurator .wbc-sort {
	width: 100%;
	height: 46px;
	padding: 0 0.85rem;
	border: 1px solid var(--wbc-line);
	border-radius: 10px;
	background: var(--wbc-bg);
	font-size: 0.95rem;
	color: var(--wbc-ink);
	line-height: normal;
	box-shadow: none;
}

/* Custom chevron + room for it on the sort select. */
.wbc-configurator .wbc-sort {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	padding-right: 2.2rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8 0 2l1.4-1.4L6 5.2 10.6.6 12 2z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.85rem center;
	cursor: pointer;
}

.wbc-configurator .wbc-search:focus,
.wbc-configurator .wbc-sort:focus {
	outline: 2px solid var(--wbc-accent);
	outline-offset: 1px;
	border-color: var(--wbc-accent);
}

/* ---------------- Listing ---------------- */

.wbc-listing { position: relative; min-height: 120px; }

.wbc-listing__loader {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	background: rgba(255, 255, 255, 0.7);
	backdrop-filter: blur(2px);
	z-index: 4;
	font-size: 0.9rem;
	color: var(--wbc-muted);
	border-radius: var(--wbc-radius);
}

.wbc-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid var(--wbc-line);
	border-top-color: var(--wbc-accent);
	border-radius: 50%;
	animation: wbc-spin 0.7s linear infinite;
}

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

.wbc-products {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.wbc-products__empty {
	text-align: center;
	color: var(--wbc-muted);
	padding: 2rem 1rem;
}

/* Single-column horizontal product rows. */
.wbc-product {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	padding: 0.6rem 0.75rem;
	background: var(--wbc-bg);
	border: 1px solid var(--wbc-line);
	border-radius: var(--wbc-radius);
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wbc-product:hover {
	border-color: #d6d9dd;
	box-shadow: var(--wbc-shadow);
}

.wbc-product.is-selected {
	border-color: var(--wbc-accent);
	box-shadow: 0 0 0 1px var(--wbc-accent) inset;
	background: #fdf7f5;
}

.wbc-product.is-blocked { opacity: 0.6; }

.wbc-product__media {
	position: relative;
	flex: 0 0 auto;
}

.wbc-product__media img {
	width: 60px;
	height: 60px;
	object-fit: cover;
	border-radius: 10px;
	display: block;
}

.wbc-badge {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	bottom: -7px;
	font-size: 0.6rem;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 6px;
	white-space: nowrap;
}

.wbc-badge--oos {
	background: var(--wbc-danger);
	color: #fff;
}

.wbc-product__body {
	flex: 1 1 auto;
	min-width: 0;
}

.wbc-product__name {
	display: block;
	font-weight: 600;
	font-size: 0.98rem;
	line-height: 1.25;
	margin-bottom: 0.25rem;
}

.wbc-product__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

.wbc-product__actions {
	flex: 0 0 auto;
}

.wbc-product__price .amount,
.wbc-product__price {
	font-weight: 700;
	color: var(--wbc-ink);
}

.wbc-product__weight {
	font-size: 0.82rem;
	color: var(--wbc-muted);
	background: var(--wbc-bg-soft);
	padding: 1px 7px;
	border-radius: 6px;
}

/* ---------------- Stepper ---------------- */

.wbc-configurator .wbc-stepper {
	display: inline-flex;
	align-items: stretch;
	border: 1px solid var(--wbc-line);
	border-radius: 10px;
	overflow: hidden;
	background: var(--wbc-bg);
	height: 40px;
}

.wbc-configurator .wbc-stepper button {
	border: 0;
	background: var(--wbc-bg-soft);
	flex: 0 0 38px;
	width: 38px;
	font-size: 1.15rem;
	line-height: 1;
	cursor: pointer;
	color: var(--wbc-accent);
	font-weight: 700;
	transition: background 0.15s ease, color 0.15s ease;
}

.wbc-configurator .wbc-stepper button:hover:not(:disabled) { background: var(--wbc-accent); color: #fff; }
.wbc-configurator .wbc-stepper button:disabled { opacity: 0.35; cursor: not-allowed; }

/* Compact qty field — override theme/Woo input width that otherwise stretches it. */
.wbc-configurator .wbc-stepper .wbc-qty-input {
	flex: 0 0 44px;
	width: 44px !important;
	min-width: 44px;
	max-width: 44px;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-left: 1px solid var(--wbc-line);
	border-right: 1px solid var(--wbc-line);
	border-radius: 0;
	text-align: center;
	font-size: 0.95rem;
	font-weight: 600;
	background: var(--wbc-bg);
	color: var(--wbc-ink);
	box-shadow: none;
	-moz-appearance: textfield;
}

.wbc-qty-input::-webkit-outer-spin-button,
.wbc-qty-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.wbc-stepper--sm { height: 32px; }
.wbc-stepper--sm button { width: 30px; font-size: 1rem; }
.wbc-stepper--sm .wbc-sel-qty {
	min-width: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 0.9rem;
	border-left: 1px solid var(--wbc-line);
	border-right: 1px solid var(--wbc-line);
	padding: 0 4px;
}

.wbc-configurator button:focus-visible,
.wbc-search:focus-visible,
.wbc-sort:focus-visible {
	outline: 2px solid var(--wbc-accent);
	outline-offset: 2px;
}

/* ---------------- Pagination ---------------- */

.wbc-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	margin-top: 1.2rem;
}

.wbc-configurator .wbc-page {
	border: 1px solid var(--wbc-line);
	background: var(--wbc-bg);
	border-radius: 10px;
	padding: 0.55rem 1.1rem;
	cursor: pointer;
	font-weight: 600;
	font-size: 0.9rem;
	color: var(--wbc-ink);
	line-height: 1;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wbc-configurator .wbc-page:hover:not(:disabled) {
	border-color: var(--wbc-accent);
	background: var(--wbc-accent);
	color: #fff;
}

.wbc-configurator .wbc-page:disabled { opacity: 0.4; cursor: not-allowed; }

.wbc-page-info {
	font-size: 0.85rem;
	color: var(--wbc-muted);
	font-variant-numeric: tabular-nums;
}

/* ---------------- Selection panel ---------------- */

/* Compact selection — a single wrapping row of removable chips. */
.wbc-selection {
	margin-top: 1.1rem;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem 0.5rem;
}

.wbc-selection[hidden] { display: none; }

.wbc-selection__title {
	font-size: 0.8rem;
	font-weight: 700;
	color: var(--wbc-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	margin-right: 0.25rem;
}

.wbc-configurator .wbc-chips {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.wbc-configurator .wbc-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	height: 30px;
	margin: 0;
	padding: 0 0.3rem 0 0.7rem;
	background: #fdf1ee;
	border: 1px solid #f2cdc3;
	border-radius: 999px;
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--wbc-accent);
	max-width: 100%;
	line-height: 1;
}

.wbc-configurator .wbc-chip::before { content: none; } /* kill theme list markers */

.wbc-configurator .wbc-chip-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 220px;
}

.wbc-configurator .wbc-chip-qty { opacity: 0.8; font-weight: 700; }

/* Force the round remove button regardless of theme button styles. */
.wbc-configurator .wbc-chip-remove {
	border: 0 !important;
	background: rgba(181, 52, 29, 0.12) !important;
	color: var(--wbc-accent) !important;
	cursor: pointer;
	width: 20px !important;
	height: 20px !important;
	min-width: 20px !important;
	min-height: 20px !important;
	padding: 0 !important;
	margin: 0 !important;
	border-radius: 50% !important;
	font-size: 1rem;
	line-height: 1;
	box-shadow: none !important;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	transition: background 0.15s ease, color 0.15s ease;
}

.wbc-configurator .wbc-chip-remove:hover {
	background: var(--wbc-accent) !important;
	color: #fff !important;
}

/* ---------------- Actions ---------------- */

.wbc-actions {
	margin-top: 1.3rem;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.wbc-error {
	margin: 0;
	padding: 0.6rem 0.8rem;
	background: #fdecea;
	border: 1px solid #f5c6c0;
	border-radius: 9px;
	color: var(--wbc-danger);
	font-size: 0.9rem;
	font-weight: 500;
}

.wbc-configurator .wbc-add-to-cart {
	width: 100%;
	min-height: 54px;
	padding: 0 1.5rem;
	font-size: 1.05rem;
	font-weight: 700;
	border: 0;
	border-radius: 12px;
	background: var(--wbc-accent) !important;
	color: #fff !important;
	cursor: pointer;
	transition: background 0.18s ease, transform 0.1s ease;
}

.wbc-configurator .wbc-add-to-cart:hover:not(:disabled) { background: #962c18 !important; }
.wbc-configurator .wbc-add-to-cart:active:not(:disabled) { transform: translateY(1px); }
.wbc-configurator .wbc-add-to-cart:disabled {
	background: #d7dadf !important;
	color: #fff !important;
	cursor: not-allowed;
}

/* Loading state keeps the button red and shows a spinner. */
.wbc-configurator .wbc-add-to-cart.is-loading {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	background: var(--wbc-accent) !important;
	cursor: progress;
}

.wbc-btn-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.45);
	border-top-color: #fff;
	border-radius: 50%;
	display: inline-block;
	animation: wbc-spin 0.7s linear infinite;
	flex: 0 0 auto;
}

.wbc-notice {
	padding: 1rem;
	background: var(--wbc-bg-soft);
	border-radius: var(--wbc-radius);
	color: var(--wbc-muted);
}

/* Respect reduced motion preferences. */
@media (prefers-reduced-motion: reduce) {
	.wbc-progress__bar,
	.wbc-add,
	.wbc-add-to-cart,
	.wbc-product { transition: none; }
	.wbc-flash, .wbc-spinner { animation: none; }
}
