/* ── Baliwood 3D bed designer ────────────────────────────────────────────────
   Lifted from the old designer/index.html <style> block, with every selector
   scoped under .bw-designer so it can be embedded inline in the product page
   without leaking into the shop's own styles.
   The former `body` rules now live on .bw-designer, which fills its host box.
--------------------------------------------------------------------------- */

.bw-designer,
.bw-designer *,
.bw-designer *::before,
.bw-designer *::after { box-sizing: border-box; margin: 0; padding: 0; }

.bw-designer {
	--ink:          #2a1f14;
	--ink-soft:     #6b5b4e;
	--muted:        #9b8a7c;
	--line:         #e7e0d7;
	--line-soft:    #f2ede7;
	--surface:      #fff;
	--surface-soft: #faf8f5;
	--accent:       #c8a882;
	--accent-deep:  #a3773f;
	--accent-tint:  #f7f1e7;

	font-family: 'Segoe UI', system-ui, sans-serif;
	background: #f0ede8;
	color: var(--ink);
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	min-height: 0;
	overflow: hidden;
}

/* ── Viewport ── */
.bw-designer #bwd-viewport {
	flex: 0 0 42%;
	min-height: 0;
	position: relative;
	background: #e8e4de;
}

/* The renderer calls setSize(w, h, false) - it never writes an inline canvas
   size, so these are what actually size the canvas. */
.bw-designer #bwd-viewport canvas {
	display: block;
	width: 100% !important;
	height: 100% !important;
}

.bw-designer .viewport-hint {
	position: absolute;
	bottom: 10px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(255,255,255,.65);
	backdrop-filter: blur(6px);
	border-radius: 20px;
	padding: 5px 14px;
	font-size: 11px;
	color: #6b5b4e;
	pointer-events: none;
	white-space: nowrap;
}

/* dimension labels */
.bw-designer .dim-label {
	position: absolute;
	background: #fff;
	border-radius: 20px;
	padding: 3px 10px;
	font-size: 11px;
	font-weight: 600;
	color: #2a1f14;
	box-shadow: 0 2px 8px rgba(0,0,0,.12);
	pointer-events: none;
	transition: opacity .3s;
}
.bw-designer #bwd-dim-width  { bottom: 40px; left:  16px; }
.bw-designer #bwd-dim-depth  { bottom: 16px; right: 40px; }
.bw-designer #bwd-dim-height { top: 60px;    right: 16px; }

/* ── Panel ── */
.bw-designer #bwd-panel {
	flex: 1 1 0;
	min-height: 0;
	position: relative;
	background: #fff;
	border-top: 1px solid #e0d8cf;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* ── Desktop: side-by-side ── */
@media (min-width: 768px) {
	.bw-designer {
		flex-direction: row;
	}

	.bw-designer #bwd-viewport {
		flex: 1 1 auto;
	}

	.bw-designer #bwd-panel {
		flex: 0 0 420px;
		border-top: none;
		border-left: 1px solid #e0d8cf;
	}

	.bw-designer #bwd-dim-width  { bottom: 80px; left:  40px; }
	.bw-designer #bwd-dim-depth  { bottom: 40px; right: 80px; }
	.bw-designer #bwd-dim-height { top: 120px;   right: 40px; }

	.bw-designer .dim-label  { font-size: 13px; padding: 4px 12px; }
	.bw-designer .viewport-hint { font-size: 12px; padding: 6px 16px; bottom: 16px; }
}

@media (min-width: 1440px) {
	.bw-designer #bwd-panel { flex: 0 0 480px; }
}

.bw-designer .panel-header {
	padding: 12px 16px 10px;
	border-bottom: 1px solid #f0ede8;
	flex-shrink: 0;
}

.bw-designer .panel-header h1 {
	font-size: 16px;
	font-weight: 700;
	letter-spacing: -.3px;
}

.bw-designer .panel-header p {
	font-size: 11px;
	color: #9b8a7c;
	margin-top: 1px;
}

.bw-designer .panel-body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: #f7f4f0;
	padding: 12px 12px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* every top-level block rendered by ui.js becomes an option card */
.bw-designer .panel-body > div {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 14px;
	padding: 13px 14px 14px;
	box-shadow: 0 1px 2px rgba(42,31,20,.04);
}

@media (min-width: 768px) {
	.bw-designer .panel-header { padding: 24px 24px 16px; }
	.bw-designer .panel-header h1 { font-size: 20px; }
	.bw-designer .panel-header p { font-size: 12px; margin-top: 2px; }
	.bw-designer .panel-body { padding: 16px 18px 24px; gap: 12px; }
	.bw-designer .panel-body > div { padding: 16px 16px 17px; }
}

/* scrollbar */
.bw-designer .panel-body::-webkit-scrollbar { width: 4px; }
.bw-designer .panel-body::-webkit-scrollbar-track { background: transparent; }
.bw-designer .panel-body::-webkit-scrollbar-thumb { background: #d0c8bf; border-radius: 2px; }

/* section */
.bw-designer .section-label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 1.1px;
	text-transform: uppercase;
	color: #8d7b6b;
	margin-bottom: 11px;
}

.bw-designer .section-label::after {
	content: '';
	flex: 1;
	height: 1px;
	background: var(--line-soft);
}

/* selected / max counter, pushed past the rule */
.bw-designer .section-count {
	order: 1;
	padding: 2px 7px;
	border-radius: 20px;
	background: var(--accent-tint);
	color: var(--accent-deep);
	font-size: 10px;
	letter-spacing: 0;
}

/* explanatory note under a section label */
.bw-designer .section-note {
	display: flex;
	gap: 7px;
	margin: -2px 0 10px;
	padding: 8px 10px;
	border-radius: 9px;
	background: var(--accent-tint);
	color: var(--ink-soft);
	font-size: 11.5px;
	line-height: 1.35;
}

.bw-designer .section-note::before {
	content: 'ⓘ';
	color: var(--accent-deep);
	font-size: 12px;
	line-height: 1.3;
}

.bw-designer .sub-label {
	font-size: 11px;
	font-weight: 600;
	color: var(--ink-soft);
	margin: 16px 0 9px;
}
.bw-designer .sub-label:first-of-type { margin-top: 2px; }

/* option chips */
.bw-designer .chip-group {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
}

/* two-column variant — used where the labels are uniform (e.g. sizes) */
.bw-designer .chip-group.grid-2 {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}

.bw-designer .chip-group.grid-2 .chip {
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 4px 8px;
	padding: 8px 11px;
}

.bw-designer .chip {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 36px;
	padding: 8px 13px;
	border-radius: 10px;
	border: 1px solid var(--line);
	background: var(--surface-soft);
	color: var(--ink);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.15;
	cursor: pointer;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	transition: border-color .16s, background .16s, box-shadow .16s, transform .1s;
}

.bw-designer .chip:hover {
	border-color: var(--accent);
	background: #fff;
}

.bw-designer .chip:active { transform: translateY(1px); }

.bw-designer .chip:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(200,168,130,.35);
}

.bw-designer .chip.active {
	border-color: var(--accent);
	background: var(--accent-tint);
	font-weight: 600;
	box-shadow: inset 0 0 0 1px var(--accent);
}

.bw-designer .chip.disabled {
	opacity: .5;
	background: #f4f1ed;
	border-style: dashed;
	color: var(--muted);
	cursor: not-allowed;
	pointer-events: none;
}

/* surcharge badge */
.bw-designer .opt-price {
	display: inline-block;
	padding: 2px 6px;
	border-radius: 6px;
	background: #f1e9dc;
	color: var(--accent-deep);
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: -.2px;
	white-space: nowrap;
}

.bw-designer .chip.active .opt-price {
	background: #fff;
	color: var(--accent-deep);
}

/* ── option cards (icon + label + description + price) ── */
.bw-designer .card-group {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}
.bw-designer .card-group.one-col { grid-template-columns: 1fr; }

.bw-designer .opt-card {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 11px 12px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface);
	cursor: pointer;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	transition: border-color .16s, background .16s, box-shadow .16s, transform .1s;
}

.bw-designer .opt-card:hover { border-color: var(--accent); }
.bw-designer .opt-card:active { transform: translateY(1px); }
.bw-designer .opt-card:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200,168,130,.35); }

.bw-designer .opt-card.active {
	border-color: var(--accent);
	background: var(--accent-tint);
	box-shadow: inset 0 0 0 1px var(--accent);
}

.bw-designer .opt-card.disabled {
	opacity: .55;
	background: #f6f3ef;
	border-style: dashed;
	cursor: not-allowed;
}
.bw-designer .opt-card.disabled:hover { border-color: var(--line); }

.bw-designer .oc-icon {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	display: grid;
	place-items: center;
	border-radius: 8px;
	background: var(--surface-soft);
	color: var(--ink-soft);
	transition: background .16s, color .16s;
}

.bw-designer .oc-icon svg { width: 17px; height: 17px; display: block; }

.bw-designer .opt-card.active .oc-icon { background: #fff; color: var(--accent-deep); }

.bw-designer .oc-body {
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	padding-top: 1px;
}

.bw-designer .oc-title {
	font-size: 13px;
	font-weight: 600;
	line-height: 1.25;
}

.bw-designer .oc-desc {
	font-size: 10.5px;
	line-height: 1.3;
	color: var(--muted);
}

.bw-designer .opt-card.active .oc-title { font-weight: 700; }

/* card carrying a switch on the right */
.bw-designer .toggle-card {
	align-items: center;
	gap: 11px;
}
.bw-designer .toggle-card .oc-body { flex: 1; padding-top: 0; }
.bw-designer .toggle-card .toggle { margin-left: auto; }

/* color swatches */
.bw-designer .swatch-group {
	display: flex;
	column-gap: 14px;
	row-gap: 22px;
	flex-wrap: wrap;
	/* room for the label rendered under each swatch */
	margin-bottom: 17px;
}

.bw-designer .swatch {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	position: relative;
	flex: 0 0 auto;
	box-shadow:
		inset 0 0 0 1px rgba(42,31,20,.14),
		inset 0 -3px 6px rgba(0,0,0,.10),
		0 1px 2px rgba(42,31,20,.14);
	transition: box-shadow .18s, transform .18s;
	-webkit-tap-highlight-color: transparent;
}

/* dense palette (RAL): captions would collide, so the name shows above */
.bw-designer .swatch-group.compact {
	column-gap: 10px;
	row-gap: 10px;
	margin-bottom: 2px;
}

.bw-designer .swatch-group.compact .swatch::after { content: none; }

.bw-designer .swatch:hover { transform: translateY(-2px); }

.bw-designer .swatch:focus-visible { outline: none; transform: translateY(-2px); }

.bw-designer .swatch.active {
	transform: translateY(-1px);
	box-shadow:
		inset 0 0 0 1px rgba(255,255,255,.35),
		inset 0 -3px 6px rgba(0,0,0,.12),
		0 0 0 2px var(--surface),
		0 0 0 3.5px var(--ink);
}

/* check mark on the selected tone */
.bw-designer .swatch::before {
	content: '';
	position: absolute;
	inset: 0;
	margin: auto;
	width: 10px;
	height: 5px;
	border-left: 2px solid #fff;
	border-bottom: 2px solid #fff;
	transform: translateY(-1px) rotate(-45deg) scale(.4);
	opacity: 0;
	filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.45));
	transition: opacity .18s, transform .18s;
}

.bw-designer .swatch.active::before {
	opacity: 1;
	transform: translateY(-1px) rotate(-45deg) scale(1);
}

.bw-designer .swatch::after {
	content: attr(data-label);
	position: absolute;
	top: calc(100% + 6px);
	left: 50%;
	transform: translateX(-50%);
	font-size: 9.5px;
	line-height: 1;
	letter-spacing: -.1px;
	white-space: nowrap;
	color: var(--muted);
	pointer-events: none;
	transition: color .15s;
}

.bw-designer .swatch.active::after { color: var(--ink); font-weight: 700; }

/* ── RAL colour ──────────────────────────────────────────────────────────────
   213 colours: the panel carries the current one plus a shortlist, and the full
   palette opens as an overlay over the panel only — the bed stays visible and
   repaints while the customer browses.
--------------------------------------------------------------------------- */
.bw-designer .ral-current {
	display: flex;
	align-items: center;
	gap: 11px;
	width: 100%;
	padding: 8px 10px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface-soft);
	font: inherit;
	color: var(--ink);
	text-align: left;
	cursor: pointer;
	transition: border-color .18s, background .18s;
	-webkit-tap-highlight-color: transparent;
}

.bw-designer .ral-current:hover,
.bw-designer .ral-current:focus-visible {
	outline: none;
	border-color: var(--accent);
	background: var(--surface);
}

.bw-designer .ral-current-swatch {
	width: 38px;
	height: 38px;
	border-radius: 10px;
	flex: 0 0 auto;
	box-shadow:
		inset 0 0 0 1px rgba(42,31,20,.14),
		inset 0 -4px 8px rgba(0,0,0,.10);
}

.bw-designer .ral-current-meta {
	display: flex;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
}

.bw-designer .ral-current-id {
	font-size: 13.5px;
	font-weight: 700;
	letter-spacing: -.2px;
}

.bw-designer .ral-current-hint { font-size: 10.5px; color: var(--muted); }

.bw-designer .ral-current-cta {
	margin-left: auto;
	flex: 0 0 auto;
	padding: 6px 11px;
	border-radius: 20px;
	background: var(--accent-tint);
	color: var(--accent-deep);
	font-size: 11px;
	font-weight: 700;
	white-space: nowrap;
}

/* the overlay */
.bw-designer .ral-picker {
	position: absolute;
	inset: 0;
	z-index: 20;
	display: flex;
	flex-direction: column;
	background: var(--surface);
}

.bw-designer .ral-picker[hidden] { display: none; }

.bw-designer .rp-head {
	display: flex;
	align-items: center;
	gap: 11px;
	flex-shrink: 0;
	padding: 12px 14px;
	border-bottom: 1px solid var(--line-soft);
}

.bw-designer .rp-swatch {
	width: 34px;
	height: 34px;
	border-radius: 9px;
	flex: 0 0 auto;
	box-shadow:
		inset 0 0 0 1px rgba(42,31,20,.14),
		inset 0 -4px 8px rgba(0,0,0,.10);
}

.bw-designer .rp-head-text { display: flex; flex-direction: column; gap: 1px; }
.bw-designer .rp-code-big { font-size: 14px; font-weight: 700; letter-spacing: -.2px; }
.bw-designer .rp-head-sub { font-size: 10.5px; color: var(--muted); }

.bw-designer .rp-close {
	margin-left: auto;
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 1px solid var(--line);
	background: var(--surface);
	color: var(--ink-soft);
	font-size: 12px;
	line-height: 1;
	cursor: pointer;
	transition: border-color .18s, color .18s;
}

.bw-designer .rp-close:hover,
.bw-designer .rp-close:focus-visible { outline: none; border-color: var(--accent); color: var(--ink); }

.bw-designer .rp-tools { flex-shrink: 0; padding: 10px 14px 8px; }

.bw-designer .rp-search {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface-soft);
	font: inherit;
	font-size: 13px;
	color: var(--ink);
	-webkit-appearance: none;
	appearance: none;
}

.bw-designer .rp-search:focus {
	outline: none;
	border-color: var(--accent);
	background: var(--surface);
}

/* family tabs - they wrap, so every family stays reachable without scrolling */
.bw-designer .rp-families {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 9px;
}

.bw-designer .rp-fam {
	flex: 0 0 auto;
	padding: 6px 10px;
	border: 1px solid var(--line);
	border-radius: 20px;
	background: var(--surface-soft);
	font: inherit;
	font-size: 11.5px;
	color: var(--ink-soft);
	white-space: nowrap;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.bw-designer .rp-fam.active {
	border-color: var(--accent);
	background: var(--accent-tint);
	color: var(--accent-deep);
	font-weight: 700;
}

.bw-designer .rp-grid {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 4px 14px 14px;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
	gap: 9px 8px;
	align-content: start;
}

.bw-designer .rp-tile {
	cursor: pointer;
	text-align: center;
	-webkit-tap-highlight-color: transparent;
}

.bw-designer .rp-tile[hidden] { display: none; }

.bw-designer .rp-chip {
	display: block;
	width: 100%;
	height: 42px;
	border-radius: 9px;
	box-shadow:
		inset 0 0 0 1px rgba(42,31,20,.14),
		inset 0 -5px 10px rgba(0,0,0,.08);
	transition: box-shadow .15s, transform .15s;
}

.bw-designer .rp-tile-code {
	display: block;
	margin-top: 4px;
	font-size: 10px;
	line-height: 1;
	letter-spacing: -.2px;
	color: var(--muted);
}

.bw-designer .rp-tile:hover .rp-chip,
.bw-designer .rp-tile:focus-visible .rp-chip { transform: translateY(-2px); }
.bw-designer .rp-tile:focus-visible { outline: none; }

.bw-designer .rp-tile.active .rp-chip {
	box-shadow:
		inset 0 0 0 1px rgba(255,255,255,.35),
		0 0 0 2px var(--surface),
		0 0 0 3.5px var(--ink);
}

.bw-designer .rp-tile.active .rp-tile-code { color: var(--ink); font-weight: 700; }

.bw-designer .rp-empty {
	padding: 26px 14px;
	text-align: center;
	font-size: 12px;
	color: var(--muted);
}

.bw-designer .rp-foot {
	flex-shrink: 0;
	padding: 10px 14px;
	border-top: 1px solid var(--line-soft);
}

.bw-designer .rp-done {
	width: 100%;
	padding: 11px;
	border: none;
	border-radius: 11px;
	background: var(--ink);
	color: #fff;
	font: inherit;
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
}

.bw-designer .rp-done:hover { background: #3c2c1c; }

@media (min-width: 768px) {
	.bw-designer .rp-head  { padding: 14px 18px; }
	.bw-designer .rp-tools { padding: 12px 18px 8px; }
	.bw-designer .rp-grid  {
		padding: 4px 18px 18px;
		grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
	}
	.bw-designer .rp-chip { height: 46px; }
	.bw-designer .rp-foot { padding: 12px 18px; }
}

/* toggle switch */
.bw-designer .toggle {
	position: relative;
	flex: 0 0 auto;
	width: 40px;
	height: 23px;
}

.bw-designer .toggle input { opacity: 0; width: 0; height: 0; }

.bw-designer .toggle-track {
	position: absolute;
	inset: 0;
	border-radius: 12px;
	background: #e2dbd2;
	box-shadow: inset 0 1px 2px rgba(42,31,20,.12);
	cursor: pointer;
	transition: background .2s;
}

.bw-designer .toggle-track::before {
	content: '';
	position: absolute;
	width: 17px; height: 17px;
	border-radius: 50%;
	background: #fff;
	top: 3px; left: 3px;
	transition: transform .2s cubic-bezier(.4,.2,.2,1);
	box-shadow: 0 1px 3px rgba(42,31,20,.28);
}

.bw-designer .toggle input:checked + .toggle-track { background: var(--accent); }
.bw-designer .toggle input:checked + .toggle-track::before { transform: translateX(17px); }
.bw-designer .toggle input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px rgba(200,168,130,.35); }
.bw-designer .toggle input:disabled + .toggle-track { cursor: not-allowed; }

/* price footer */
.bw-designer .panel-footer {
	flex-shrink: 0;
	padding: 10px 16px max(10px, env(safe-area-inset-bottom));
	border-top: 1px solid #f0ede8;
	background: #fff;
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 12px;
}

.bw-designer .price-row {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: baseline;
	width: 100%;
}

.bw-designer .price-label { font-size: 11px; color: #9b8a7c; }
.bw-designer .price-value { font-size: 20px; font-weight: 700; line-height: 1.1; }

@media (min-width: 768px) {
	.bw-designer .panel-footer {
		padding: 16px 24px;
	}
	.bw-designer .price-label { font-size: 12px; }
	.bw-designer .price-value { font-size: 22px; }
}

/* ── Host: the product page's configurator modal ─────────────────────────────
   Same box the old external configurator iframe used, but the designer is now
   a flex child of the body instead of an iframe.
--------------------------------------------------------------------------- */
.designer-modal .config-modal-content {
	width: min(96vw, 1100px);
	max-width: 1100px;
	height: 90vh;
	max-height: 90vh;
}

.designer-modal .config-modal-body {
	padding: 0;
	display: flex;
	overflow: hidden;
}

.designer-modal .config-modal-body > .bw-designer {
	flex: 1 1 auto;
	min-width: 0;
}


/* index.css pins every modal to the top-left corner and lets it fill the screen
   below 1024px, but only overrides width/height at a lower specificity than the
   two rules above - so the desktop 96vw x 90vh box survived and the modal sat in
   the corner. Restore the full-screen box here. */
@media screen and (max-width: 1024px) {
	.designer-modal .config-modal-content {
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
	}

	.designer-modal .config-modal-body {
		min-height: 0;
	}
}
