/*!
 * JezPress Woo Product Configurator — frontend styles
 *
 * BEM-ish class system:
 *  .jwpc-config
 *  .jwpc-config__columns
 *  .jwpc-config__group
 *  .jwpc-swatch (.jwpc-swatch--color | .jwpc-swatch--image)
 *  .jwpc-swatch.is-selected
 *  .jwpc-preview
 */

.jwpc-config {
	margin: 1.25em 0;
	font-size: 14px;
	line-height: 1.4;
}

/* Two-column layout: groups left, preview right. Collapses below 768px. */
.jwpc-config__columns {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 1.5em;
	align-items: start;
}

@media (max-width: 768px) {
	.jwpc-config__columns {
		grid-template-columns: 1fr;
	}
}

.jwpc-config__groups {
	display: flex;
	flex-direction: column;
	gap: 1em;
	min-width: 0;
}

.jwpc-config__preview-col {
	min-width: 0;
}

/* Group "card" */
.jwpc-config__group {
	border: 1px solid #c3c4c7;
	background: #ffffff;
	border-radius: 3px;
	overflow: hidden;
}

.jwpc-config__group-header {
	background: #2271b1;
	color: #ffffff;
	padding: 0.55em 0.85em;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 0.35em;
}

.jwpc-config__group-label {
	flex: 1 1 auto;
}

.jwpc-config__required {
	color: #ffd166;
	font-weight: 700;
}

.jwpc-config__swatches {
	padding: 0.85em;
	display: grid;
	gap: 0.6em;
	/* --jwpc-cols is set inline per group from the saved `columns` value (1–6).
	   Falls back to 3 if the variable is missing. */
	grid-template-columns: repeat(var(--jwpc-cols, 3), minmax(0, 1fr));
}

@media screen and (max-width: 600px) {
	/* On phones, cap the column count so swatches don't get unreadably small. */
	.jwpc-config__swatches {
		grid-template-columns: repeat(min(var(--jwpc-cols, 3), 2), minmax(0, 1fr));
	}
}

/* Swatch button — shared base */
.jwpc-swatch {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.35em 0.5em;
	border: 1px solid transparent;
	background: transparent;
	border-radius: 3px;
	cursor: pointer;
	text-align: left;
	font: inherit;
	color: inherit;
	transition: border-color 120ms ease, background-color 120ms ease;
}

.jwpc-swatch:hover {
	background: #f6f7f7;
}

.jwpc-swatch:focus {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.jwpc-swatch.is-selected {
	border-color: #2271b1;
	background: #f0f6fc;
}

/* Selected checkmark overlay */
.jwpc-swatch.is-selected::after {
	content: "";
	position: absolute;
	top: 4px;
	right: 4px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #2271b1
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23fff' d='M6.4 11.2 3.2 8l1.1-1.1 2.1 2.1 4.5-4.5 1.1 1.1z'/%3E%3C/svg%3E")
		center / 12px 12px no-repeat;
	box-shadow: 0 0 0 2px #ffffff;
}

/* ----- Chip rendering — colour hex chip ----- */
/* Chip shape (circle vs square) is driven by the merchant's swatch-style
   setting on the configurator root: .jwpc-config--hex-circle/square. */
.jwpc-swatch--chip-color .jwpc-swatch__chip {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	border: 1px solid rgba(0, 0, 0, 0.1);
	background-clip: padding-box;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.jwpc-config--hex-circle .jwpc-swatch--chip-color .jwpc-swatch__chip { border-radius: 50%; }
.jwpc-config--hex-square .jwpc-swatch--chip-color .jwpc-swatch__chip { border-radius: 6px; }

/* ----- Chip rendering — image thumbnail chip ----- */
/* Same shape control via .jwpc-config--thumb-circle/square. The thumbnail
   container is a fixed 56x40 box; the inner image is contained. */
.jwpc-swatch--chip-image .jwpc-swatch__media {
	flex: 0 0 auto;
	width: 56px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	border: 1px solid rgba(0, 0, 0, 0.08);
	background: #ffffff;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.jwpc-config--thumb-circle .jwpc-swatch--chip-image .jwpc-swatch__media { border-radius: 50%; }
.jwpc-config--thumb-square .jwpc-swatch--chip-image .jwpc-swatch__media { border-radius: 6px; }

.jwpc-swatch--chip-image .jwpc-swatch__media img,
.jwpc-swatch--chip-image .jwpc-swatch__thumb {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	display: block;
}

/* ----- Swatch row — both chip and image swatches share this layout ----- */
.jwpc-swatch__label {
	flex: 1 1 auto;
	font-size: 13px;
	line-height: 1.2;
	color: #1d2327;
}

/* Preview area */
.jwpc-preview {
	position: relative;
	background: #ffffff;
	border: 1px solid #c3c4c7;
	border-radius: 3px;
	padding: 0.5em;
	max-width: 100%;
}

.jwpc-preview__img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	opacity: 1;
	transition: opacity 200ms ease;
}

.jwpc-preview.is-loading .jwpc-preview__img {
	opacity: 0;
}

.jwpc-preview__error {
	margin-top: 0.5em;
	padding: 0.5em 0.75em;
	background: #fcf0f1;
	border: 1px solid #d63638;
	color: #b32d2e;
	font-size: 12px;
	border-radius: 3px;
}

/* Cart thumbnail (rendered via JWPC_Cart::swap_cart_thumbnail) */
.jwpc-cart-thumb {
	max-width: 100%;
	height: auto;
	display: block;
}
