/* WoodMart Product Customizer - Frontend Styles */

.wpc-summary {
	max-width: 100%;
	box-sizing: border-box;
}

.wpc-summary * {
	box-sizing: border-box;
}

/* ---------- Price row ---------- */

.wpc-price-row {
	display: flex;
	align-items: baseline;
	gap: 12px;
	flex-wrap: wrap;
	margin: 6px 0 18px;
}

.wpc-price {
	line-height: 1.2;
}

.wpc-price-compare {
	text-decoration: line-through;
}

.wpc-discount-badge {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 4px;
	white-space: nowrap;
}

/* ---------- Variation tabs + swatch panels ---------- */

.wpc-variations {
	border: 1px solid #e7e1da;
	border-radius: 8px;
	padding: 14px;
	margin-bottom: 18px;
}

.wpc-summary .wpc-tabs {
	display: flex !important;
	flex-wrap: nowrap !important;
	align-items: stretch !important;
	gap: 6px;
	margin-bottom: 14px;
	width: 100%;
}

.wpc-summary .wpc-tab {
	flex: 1 1 0 !important;
	min-width: 0 !important; /* allow shrinking below content size instead of wrapping to a new row */
	max-width: none !important;
	width: auto !important;
	height: auto !important;
	display: flex !important;
	flex-direction: column !important;
	align-items: center !important;
	justify-content: flex-start !important;
	border: none;
	border-radius: 6px;
	margin: 0;
	padding: 10px 6px;
	text-align: center !important;
	cursor: pointer;
	transition: background-color .15s ease;
	box-sizing: border-box;
}

.wpc-summary .wpc-tab .wpc-tab-icon {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	margin: 0 0 6px 0 !important;
	flex-shrink: 0;
}

.wpc-summary .wpc-tab .wpc-tab-icon svg,
.wpc-summary .wpc-tab .wpc-tab-icon img {
	width: 100% !important;
	height: 100% !important;
	object-fit: contain;
	display: block;
	margin: 0;
}

.wpc-summary .wpc-tab .wpc-tab-name {
	display: block !important;
	font-weight: 600;
	font-size: 12px;
	line-height: 1.2;
	width: 100%;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap !important;
	margin: 0;
}

.wpc-summary .wpc-tab .wpc-tab-selected {
	display: -webkit-box !important;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	margin: 2px 0 0 0 !important;
	width: 100%;
	max-width: 100%;
	font-size: 11px;
	line-height: 1.25;
	font-weight: 400;
	opacity: .72;
	word-break: break-word;
	white-space: normal !important;
}

.wpc-summary .wpc-tab .wpc-tab-selected:empty {
	display: none !important;
}

/* As more attribute tabs are added (Colour, Size, Storage, Headboard, Base, ...)
   everything shrinks together so all tabs stay on a single row instead of
   wrapping onto a second line or overflowing out of view. */
.wpc-summary .wpc-tabs[data-count="5"] .wpc-tab {
	padding: 8px 4px;
}
.wpc-summary .wpc-tabs[data-count="5"] .wpc-tab-icon {
	width: 26px;
	height: 26px;
	margin-bottom: 5px;
}
.wpc-summary .wpc-tabs[data-count="5"] .wpc-tab-name {
	font-size: 11px;
}
.wpc-summary .wpc-tabs[data-count="5"] .wpc-tab-selected {
	font-size: 10px;
}

.wpc-summary .wpc-tabs[data-count="6"] .wpc-tab,
.wpc-summary .wpc-tabs[data-count="7"] .wpc-tab,
.wpc-summary .wpc-tabs[data-count="8"] .wpc-tab {
	padding: 6px 3px;
}
.wpc-summary .wpc-tabs[data-count="6"] .wpc-tab-icon,
.wpc-summary .wpc-tabs[data-count="7"] .wpc-tab-icon,
.wpc-summary .wpc-tabs[data-count="8"] .wpc-tab-icon {
	width: 22px;
	height: 22px;
	margin-bottom: 4px;
}
.wpc-summary .wpc-tabs[data-count="6"] .wpc-tab-name,
.wpc-summary .wpc-tabs[data-count="7"] .wpc-tab-name,
.wpc-summary .wpc-tabs[data-count="8"] .wpc-tab-name {
	font-size: 10px;
}
.wpc-summary .wpc-tabs[data-count="6"] .wpc-tab-selected,
.wpc-summary .wpc-tabs[data-count="7"] .wpc-tab-selected,
.wpc-summary .wpc-tabs[data-count="8"] .wpc-tab-selected {
	font-size: 9px;
	-webkit-line-clamp: 1;
}

.wpc-swatch-panel {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
	gap: 10px;
	border-radius: 6px;
	padding: 12px;
}

.wpc-swatch-panel.wpc-hidden {
	display: none;
}

.wpc-swatch {
	position: relative;
	border: 2px solid transparent;
	border-radius: 6px;
	background: #fff;
	padding: 8px;
	cursor: pointer;
	text-align: center;
	transition: border-color .15s ease;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
}

.wpc-swatch img {
	width: 100%;
	height: 70px;
	object-fit: cover;
	border-radius: 4px;
	background: #f1ece6;
}

.wpc-swatch-name {
	display: block;
	line-height: 1.3;
}

.wpc-swatch-diff {
	display: block;
	opacity: .8;
}

.wpc-swatch-check {
	position: absolute;
	top: -8px;
	right: -8px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	color: #fff;
	font-size: 12px;
	display: none;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.wpc-swatch.is-selected .wpc-swatch-check {
	display: flex;
}

.wpc-swatch.is-disabled {
	opacity: .4;
	cursor: not-allowed;
}

/* ---------- Mattress upsell bar ---------- */

/* Spacing once #wpc-gallery-addons has been moved underneath the
   product gallery by JS (see wpcRelocateGalleryAddons). */
.wpc-gallery-addons {
	margin-top: 16px;
}
.wpc-gallery-addons > * + * {
	margin-top: 12px;
}

.wpc-mattress-bar {
	display: flex;
	align-items: center;
	gap: 12px;
	border: 1px solid #e7e1da;
	border-radius: 8px;
	padding: 12px 16px;
	margin-bottom: 14px;
}

.wpc-mattress-bar .wpc-mattress-bar-head {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1;
	min-width: 0;
}

.wpc-mattress-bar .wpc-mattress-icon {
	font-size: 22px;
	flex-shrink: 0;
}

.wpc-mattress-bar .wpc-mattress-bar-label {
	flex: 1;
}

.wpc-mattress-choose-btn,
.wpc-mattress-change-btn {
	border: 1px solid #d8cfc4;
	background: #fff;
	border-radius: 6px;
	padding: 8px 14px;
	cursor: pointer;
	white-space: nowrap;
}

.wpc-mattress-selected-row {
	display: none;
	align-items: center;
	gap: 10px;
	border: 1px solid #e7e1da;
	border-radius: 8px;
	padding: 10px 14px;
	margin-bottom: 14px;
}

.wpc-mattress-selected-row.is-visible {
	display: flex;
}

.wpc-mattress-selected-row img {
	width: 44px;
	height: 44px;
	object-fit: cover;
	border-radius: 4px;
}

.wpc-mattress-selected-row .wpc-mattress-remove {
	margin-left: auto;
	background: none;
	border: none;
	cursor: pointer;
	text-decoration: underline;
	opacity: .7;
}

/* ---------- Mattress slide-out panel ---------- */

.wpc-mattress-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .4);
	z-index: 99998;
	opacity: 0;
	visibility: hidden;
	transition: opacity .2s ease;
}

.wpc-mattress-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

.wpc-mattress-panel {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 420px;
	max-width: 92vw;
	z-index: 99999;
	transform: translateX(100%);
	transition: transform .25s ease;
	overflow-y: auto;
	box-shadow: -4px 0 24px rgba(0, 0, 0, .15);
}

.wpc-mattress-panel.is-open {
	transform: translateX(0);
}

.wpc-mattress-panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 20px;
	border-bottom: 1px solid #eee;
	position: sticky;
	top: 0;
	background: inherit;
}

.wpc-mattress-panel-close {
	background: none;
	border: none;
	font-size: 22px;
	cursor: pointer;
	line-height: 1;
	padding: 4px 8px;
}

.wpc-mattress-list {
	padding: 16px 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.wpc-mattress-card {
	display: flex;
	gap: 12px;
	border: 1px solid #e7e1da;
	border-radius: 8px;
	padding: 12px;
	align-items: center;
}

.wpc-mattress-card img {
	width: 70px;
	height: 70px;
	object-fit: cover;
	border-radius: 6px;
	flex-shrink: 0;
}

.wpc-mattress-card-body {
	flex: 1;
	min-width: 0;
}

.wpc-mattress-card-name {
	font-weight: 600;
	margin-bottom: 4px;
}

.wpc-mattress-card-prices {
	display: flex;
	align-items: baseline;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 6px;
}

.wpc-mattress-card-was {
	text-decoration: line-through;
	opacity: .6;
	font-size: 13px;
}

.wpc-save-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 4px;
	font-size: 12px;
}

.wpc-mattress-select-btn {
	border: 1px solid #d8cfc4;
	background: #fff;
	border-radius: 6px;
	padding: 6px 14px;
	cursor: pointer;
	white-space: nowrap;
}

.wpc-mattress-select-btn.is-selected {
	background: #2e7d32;
	color: #fff;
	border-color: #2e7d32;
}

/* ---------- Assembly box ---------- */

.wpc-assembly-box {
	display: flex;
	align-items: center;
	gap: 14px;
	border: 1px solid #e7e1da;
	border-radius: 8px;
	padding: 14px 16px;
	margin-bottom: 18px;
}

.wpc-assembly-icon {
	font-size: 24px;
	flex-shrink: 0;
}

.wpc-assembly-head {
	display: flex;
	align-items: center;
	gap: 14px;
	flex: 1;
	min-width: 0;
}

.wpc-assembly-foot {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

.wpc-assembly-text {
	flex: 1;
	min-width: 0;
}

.wpc-section-heading {
	display: block;
	margin-bottom: 2px;
}

.wpc-assembly-price {
	white-space: nowrap;
	margin: 0 10px;
}

.wpc-assembly-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	flex-shrink: 0;
}

/* ---------- Total row ---------- */

.wpc-total-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-radius: 8px;
	padding: 12px 16px;
	margin-bottom: 14px;
}

/* ---------- Add to cart button ---------- */

.wpc-add-to-cart-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	border: none;
	border-radius: 8px;
	padding: 14px 20px;
	cursor: pointer;
	transition: background-color .15s ease;
}

.wpc-add-to-cart-btn:disabled {
	opacity: .6;
	cursor: not-allowed;
}

.wpc-add-to-cart-btn.is-added {
	background-color: #2e7d32 !important;
}

.wpc-stock-message {
	margin-top: 10px;
	font-size: 13px;
}

.wpc-stock-message.is-out-of-stock {
	color: #c0392b;
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
	.wpc-mattress-panel {
		width: 100%;
	}

	/* On mobile, keep the attribute tabs (Size / Colour / Base / Headboard /
	   Storage) compact — smaller than desktop — and let the row scroll
	   horizontally within its own box if there are more tabs than fit. */
	.wpc-summary .wpc-tabs {
		flex-wrap: nowrap !important;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		gap: 5px;
		padding-bottom: 2px;
		scroll-snap-type: x mandatory;
		scroll-padding-left: 0;
	}

	.wpc-summary .wpc-tabs::-webkit-scrollbar {
		display: none;
	}

	.wpc-summary .wpc-tab {
		flex: 0 0 auto !important;
		width: 78px !important;
		padding: 6px 4px !important;
		scroll-snap-align: start;
	}

	.wpc-summary .wpc-tab .wpc-tab-icon {
		width: 18px !important;
		height: 18px !important;
		margin-bottom: 3px !important;
	}

	.wpc-summary .wpc-tab .wpc-tab-name {
		font-size: 9px !important;
		white-space: nowrap !important;
		overflow: hidden !important;
		text-overflow: ellipsis !important;
	}

	.wpc-summary .wpc-tab .wpc-tab-selected {
		font-size: 8px !important;
		-webkit-line-clamp: 1;
	}

	/* Same idea for the swatch options inside each panel (e.g. "2 Drawers
	   Left Side" / "2 Drawers Right Side" / "No Storage") — smaller cards
	   on mobile, scrolling sideways instead of a cramped grid. */
	.wpc-swatch-panel {
		display: flex;
		flex-wrap: nowrap;
		grid-template-columns: none;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		scroll-snap-type: x mandatory;
		gap: 6px;
		padding: 8px;
	}

	.wpc-swatch-panel::-webkit-scrollbar {
		display: none;
	}

	.wpc-swatch-panel .wpc-swatch {
		flex: 0 0 auto;
		width: 90px;
		padding: 5px;
		scroll-snap-align: start;
	}

	.wpc-swatch-panel .wpc-swatch img {
		height: 50px;
	}

	.wpc-swatch-panel .wpc-swatch .wpc-swatch-name {
		font-size: 10px;
	}

	/* ---------- Mattress bar: heading, then action, stacked ---------- */
	.wpc-mattress-bar {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}

	.wpc-mattress-choose-btn,
	.wpc-mattress-change-btn {
		width: 100%;
		text-align: center;
	}

	/* ---------- Assembly box: heading, then content, then action ---------- */
	.wpc-assembly-box {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}

	.wpc-assembly-foot {
		width: 100%;
		justify-content: space-between;
	}

	/* ---------- Match the attribute-term swatches (Size/Colour/Base/...)
	   to the exact icon + text size used by the tabs above them, so the
	   selected term ("DOUBLE" / "KING" / "QUEEN") doesn't look oversized
	   next to the small "SIZE" tab it belongs to. ---------- */
	.wpc-swatch-panel .wpc-swatch {
		width: 78px;
		padding: 6px 4px;
		gap: 3px;
	}

	.wpc-swatch-panel .wpc-swatch img {
		width: 18px;
		height: 18px;
		object-fit: contain;
		background: transparent;
	}

	.wpc-swatch-panel .wpc-swatch .wpc-swatch-name {
		font-size: 9px !important;
		font-weight: 600;
		line-height: 1.2;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		max-width: 100%;
	}

	.wpc-swatch-panel .wpc-swatch .wpc-swatch-diff {
		font-size: 8px;
	}
}
