/* ==========================================================================
   Laser Product Designer — product page
   Desktop: preview on the left, fields on the right.
   Phone: full-screen window, preview pinned at the top, fields scroll below,
   validate button always visible at the bottom.
   ========================================================================== */

.lpd-designer-root {
	--lpd-accent: #2271b1;
	--lpd-text: #1d2327;
	--lpd-muted: #646970;
	--lpd-border: #dcdcde;
	--lpd-soft: #f6f7f7;
	--lpd-error: #c0392b;
}

/* ---------- Launcher on the product page ---------- */

.lpd-launcher {
	margin: 12px 0;
	width: 100%;
}

.lpd-open-designer-btn {
	display: inline-block;
	padding: 12px 24px;
	background: #2271b1;
	color: #fff;
	border: none;
	border-radius: 4px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	line-height: 1.3;
}

.lpd-open-designer-btn:hover {
	background: #195a8c;
}

.lpd-summary {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 10px;
	border: 1px solid #dcdcde;
	border-radius: 6px;
	background: #f6f7f7;
	font-size: 14px;
	line-height: 1.4;
}

.lpd-summary[hidden] {
	display: none;
}

.lpd-summary-thumb {
	width: 84px;
	height: auto;
	border-radius: 4px;
	border: 1px solid #dcdcde;
	flex-shrink: 0;
	background: #fff;
}

.lpd-summary-title {
	font-weight: 700;
	margin-bottom: 4px;
}

.lpd-summary-lines {
	list-style: none;
	margin: 0 0 6px;
	padding: 0;
}

.lpd-summary-lines li {
	margin: 0 0 2px;
	word-break: break-word;
}

.lpd-summary-key {
	color: #646970;
}

.lpd-summary-edit {
	background: none;
	border: none;
	padding: 0;
	color: #2271b1;
	text-decoration: underline;
	cursor: pointer;
	font-size: 14px;
}

/* ---------- Modal shell ---------- */

body.lpd-modal-open {
	overflow: hidden;
}

.lpd-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	box-sizing: border-box;
}

.lpd-modal-panel {
	background: #fff;
	color: var(--lpd-text);
	border-radius: 10px;
	width: 100%;
	max-width: 1120px;
	max-height: calc(100vh - 48px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	box-sizing: border-box;
	text-align: left;
	direction: ltr;
	font-size: 15px;
	line-height: 1.4;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Defensive resets: isolate the modal's internal layout from the theme. */
.lpd-modal-panel *,
.lpd-modal-panel *::before,
.lpd-modal-panel *::after {
	box-sizing: border-box;
	float: none;
	letter-spacing: normal;
	text-transform: none;
}

.lpd-modal-panel [hidden] {
	display: none !important;
}

.lpd-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 20px;
	border-bottom: 1px solid var(--lpd-border);
	flex-shrink: 0;
}

.lpd-designer-root .lpd-title {
	margin: 0;
	font-size: 19px;
	line-height: 1.3;
}

.lpd-modal-close {
	background: none;
	border: none;
	font-size: 30px;
	line-height: 1;
	cursor: pointer;
	color: #50575e;
	padding: 4px 10px;
	margin: -6px -10px -6px 0;
	min-width: 44px;
	min-height: 44px;
}

.lpd-modal-close:hover {
	color: #000;
}

.lpd-designer-body {
	display: grid;
	grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr);
	flex: 1 1 auto;
	min-height: 0;
}

.lpd-preview-col {
	padding: 16px 20px;
	background: var(--lpd-soft);
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.lpd-fields-col {
	padding: 16px 20px 24px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	border-left: 1px solid var(--lpd-border);
	counter-reset: lpd-step;
}

.lpd-modal-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 12px 20px;
	border-top: 1px solid var(--lpd-border);
	background: #fff;
	flex-shrink: 0;
}

.lpd-modal-validate {
	padding: 13px 26px;
	background: var(--lpd-accent);
	color: #fff;
	border: none;
	border-radius: 6px;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
	min-height: 48px;
}

.lpd-modal-validate:disabled {
	opacity: 0.7;
	cursor: progress;
}

.lpd-total {
	font-size: 15px;
}

.lpd-total strong {
	font-size: 18px;
}

.lpd-total-extra {
	color: var(--lpd-muted);
	font-size: 13px;
}

.lpd-total-note {
	display: block;
	color: var(--lpd-muted);
	font-size: 12px;
}

/* ---------- Preview ---------- */

.lpd-side-tabs {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.lpd-side-tab {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 999px;
	padding: 7px 16px;
	cursor: pointer;
	font-weight: 600;
	font-size: 14px;
	color: var(--lpd-text);
	min-height: 38px;
}

.lpd-side-tab.is-active {
	background: var(--lpd-accent);
	border-color: var(--lpd-accent);
	color: #fff;
}

.lpd-side-tab.is-off:not(.is-active) {
	opacity: 0.55;
}

.lpd-canvas-wrap {
	position: relative;
	display: flex;
	justify-content: center;
}

.lpd-canvas-wrap canvas {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 260px);
	width: auto;
	height: auto;
	border-radius: 6px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
	/* The preview is display-only: nothing on it can be dragged. */
	pointer-events: none;
	user-select: none;
}

.lpd-face-inactive {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	margin: 0;
	padding: 10px 14px;
	max-width: 80%;
	background: rgba(255, 255, 255, 0.92);
	border-radius: 6px;
	text-align: center;
	font-size: 14px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.lpd-canvas-hint {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	margin: 0;
	font-size: 12px;
	color: var(--lpd-muted);
}

.lpd-legend-swatch {
	display: inline-block;
	width: 22px;
	height: 0;
	margin-top: 8px;
	border-top: 2px dashed rgba(40, 40, 40, 0.65);
	flex-shrink: 0;
}

.lpd-required-note {
	margin: 0 0 16px;
	padding: 10px 12px;
	border-radius: 6px;
	background: #fcf0f1;
	border-left: 4px solid var(--lpd-error);
	color: #8a2424;
	font-size: 14px;
	font-weight: 600;
}

/* ---------- Steps ---------- */

.lpd-step {
	margin: 0 0 22px;
	counter-increment: lpd-step;
}

.lpd-step[hidden] {
	counter-increment: none;
}

.lpd-step-title {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 10px;
	font-size: 16px;
	font-weight: 700;
}

.lpd-step-title::before {
	content: counter(lpd-step);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--lpd-accent);
	color: #fff;
	font-size: 13px;
	flex-shrink: 0;
}

/* ---------- Product options (color, size...) ---------- */

.lpd-attr-group {
	margin-bottom: 12px;
}

.lpd-attr-label {
	margin-bottom: 6px;
	font-size: 14px;
}

.lpd-attr-options {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.lpd-attr-option {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 42px;
	padding: 6px 14px;
	border: 2px solid var(--lpd-border);
	border-radius: 8px;
	background: #fff;
	color: var(--lpd-text);
	font-size: 14px;
	cursor: pointer;
}

.lpd-attr-option:hover:not(:disabled) {
	border-color: #8c8f94;
}

.lpd-attr-option.is-selected {
	border-color: var(--lpd-accent);
	box-shadow: 0 0 0 1px var(--lpd-accent);
	font-weight: 600;
}

.lpd-swatch-dot {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.25);
	flex-shrink: 0;
}

.lpd-soldout-badge {
	display: none;
	font-size: 11px;
	font-weight: 700;
	color: var(--lpd-error);
	text-transform: uppercase;
}

.lpd-attr-option.is-soldout .lpd-soldout-badge {
	display: inline;
}

.lpd-attr-option:disabled {
	cursor: not-allowed;
	opacity: 0.55;
}

.lpd-attr-option.is-soldout .lpd-attr-option-label,
.lpd-attr-option.is-soldout .lpd-swatch-dot {
	text-decoration: line-through;
	opacity: 0.6;
}

.lpd-stock-note {
	margin: 4px 0 0;
	padding: 8px 10px;
	border-radius: 6px;
	background: #fcf0f1;
	color: #8a2424;
	font-size: 13px;
}

/* ---------- Optional faces ---------- */

.lpd-face-option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	margin-bottom: 8px;
	border: 2px solid var(--lpd-border);
	border-radius: 8px;
	cursor: pointer;
	font-weight: 600;
}

.lpd-face-option.is-checked {
	border-color: var(--lpd-accent);
	background: #f0f6fc;
}

.lpd-face-option input {
	width: 20px;
	height: 20px;
	margin: 0;
	flex-shrink: 0;
}

.lpd-face-option-name {
	flex: 1;
}

.lpd-face-option-fee {
	color: var(--lpd-muted);
	font-weight: 600;
	white-space: nowrap;
}

/* ---------- Text fields ---------- */

.lpd-face-field-group {
	margin-bottom: 8px;
}

.lpd-face-field-title {
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--lpd-muted);
	margin: 12px 0 8px;
}

.lpd-zone-field {
	margin-bottom: 14px;
	padding: 12px;
	border: 1px solid var(--lpd-border);
	border-radius: 8px;
}

.lpd-zone-field-title {
	font-weight: 600;
	margin-bottom: 8px;
}

.lpd-zone-field-title .required {
	color: var(--lpd-error);
}

.lpd-zone-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
	cursor: pointer;
}

.lpd-line-count-row {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
	font-size: 14px;
}

.lpd-line-count-row select {
	min-height: 40px;
	font-size: 16px;
	padding: 4px 8px;
}

.lpd-line-input {
	position: relative;
	margin-bottom: 8px;
}

/* 16px minimum: iOS zooms the page on focus below that. */
.lpd-zone-lines input[type="text"] {
	width: 100%;
	min-height: 46px;
	padding: 10px 56px 10px 12px;
	font-size: 16px;
	border: 1px solid #8c8f94;
	border-radius: 6px;
	background: #fff;
	color: var(--lpd-text);
}

.lpd-zone-lines input[type="text"]:focus {
	outline: 2px solid var(--lpd-accent);
	outline-offset: 0;
	border-color: var(--lpd-accent);
}

.lpd-char-counter {
	position: absolute;
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
	font-size: 12px;
	color: var(--lpd-muted);
	pointer-events: none;
}

.lpd-zone-field.has-error {
	border-color: var(--lpd-error);
}

.lpd-zone-field.has-error input[type="text"] {
	border-color: var(--lpd-error);
}

.lpd-field-error {
	color: var(--lpd-error);
	font-size: 13px;
	margin: 4px 0 0;
}

.lpd-font-row {
	margin: 6px 0 8px;
}

.lpd-font-row-label,
.lpd-font-size-label {
	font-size: 13px;
	color: var(--lpd-muted);
	margin-bottom: 6px;
}

.lpd-font-chips {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 6px;
}

.lpd-font-chip {
	min-height: 44px;
	padding: 6px 8px;
	border: 2px solid var(--lpd-border);
	border-radius: 6px;
	background: #fff;
	color: var(--lpd-text);
	font-size: 16px;
	line-height: 1.1;
	cursor: pointer;
	text-align: center;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.lpd-font-chip.is-selected {
	border-color: var(--lpd-accent);
	box-shadow: 0 0 0 1px var(--lpd-accent);
	background: #f0f6fc;
}

.lpd-font-size-row {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 6px 0 0;
}

.lpd-font-size-row .lpd-font-size-label {
	margin: 0;
	white-space: nowrap;
}

.lpd-font-size-row input[type="range"] {
	flex: 1;
	min-height: 32px;
	accent-color: var(--lpd-accent);
}

/* ---------- Cart ---------- */

.lpd-cart-preview {
	max-width: 64px;
	height: auto;
	border-radius: 3px;
}

/* ---------- Phones / small tablets ---------- */

@media (max-width: 782px) {
	.lpd-modal-overlay {
		padding: 0;
		align-items: stretch;
	}

	.lpd-modal-panel {
		max-width: none;
		max-height: none;
		height: 100%;
		height: 100dvh;
		border-radius: 0;
	}

	.lpd-modal-header {
		padding: 8px 12px 8px 16px;
	}

	.lpd-designer-root .lpd-title {
		font-size: 17px;
	}

	/* One scrolling column; the preview stays pinned at the top. */
	.lpd-designer-body {
		display: block;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.lpd-preview-col {
		position: sticky;
		top: 0;
		z-index: 2;
		padding: 10px 12px;
		overflow: visible;
		box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
		gap: 8px;
	}

	.lpd-canvas-wrap canvas {
		max-height: 26vh;
	}

	.lpd-side-tab {
		min-height: 34px;
		padding: 5px 14px;
	}

	.lpd-total-note {
		display: none;
	}

	.lpd-canvas-hint {
		display: none;
	}

	.lpd-fields-col {
		border-left: none;
		overflow: visible;
		padding: 14px 16px 24px;
	}

	.lpd-modal-footer {
		padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
		box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.06);
	}

	.lpd-modal-validate {
		flex: 1 1 auto;
		padding: 12px 16px;
	}

	.lpd-font-chips {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* ==========================================================================
   Inline mode: the configurator is part of the product page (no pop-up).
   Narrow product column: preview pinned at the top while the fields scroll.
   Wide area (>= 820px): preview on the left, fields on the right.
   ========================================================================== */

.lpd-designer-root.is-inline {
	display: block;
	width: 100%;
	margin: 16px 0;
	container-type: inline-size;
	container-name: lpd;
}

/* The theme's own variation selectors would duplicate the configurator's
 * (both drive the same hidden <select> elements). */
form.lpd-inline-active table.variations {
	display: none !important;
}

.lpd-designer-root.is-inline .lpd-modal-overlay {
	position: static;
	inset: auto;
	display: block;
	padding: 0;
	background: none;
	overflow: visible;
	z-index: auto;
}

.lpd-designer-root.is-inline .lpd-modal-panel {
	max-width: none;
	max-height: none;
	height: auto;
	overflow: visible;
	border: 1px solid var(--lpd-border);
	border-radius: 10px;
	box-shadow: none;
}

.lpd-designer-root.is-inline .lpd-modal-close,
.lpd-designer-root.is-inline .lpd-modal-validate {
	display: none;
}

.lpd-designer-root.is-inline .lpd-modal-header {
	padding: 12px 16px;
}

.lpd-designer-root.is-inline .lpd-designer-body {
	display: block;
	overflow: visible;
}

.lpd-designer-root.is-inline .lpd-preview-col {
	position: sticky;
	top: var(--lpd-sticky-top, 0px);
	z-index: 2;
	overflow: visible;
	padding: 10px 16px;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.lpd-designer-root.is-inline .lpd-canvas-wrap canvas {
	max-height: 34vh;
}

.lpd-designer-root.is-inline .lpd-fields-col {
	border-left: none;
	overflow: visible;
	padding: 16px;
}

/* The running total stays in view at the bottom of the screen while the
 * customer scrolls through the fields. */
.lpd-designer-root.is-inline .lpd-modal-footer {
	position: sticky;
	bottom: 0;
	z-index: 2;
	border-radius: 0 0 10px 10px;
	box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.06);
	padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}

@container lpd (min-width: 820px) {
	.lpd-designer-root.is-inline .lpd-designer-body {
		display: grid;
		grid-template-columns: minmax(0, 1.2fr) minmax(300px, 1fr);
	}

	.lpd-designer-root.is-inline .lpd-preview-col {
		align-self: start;
		top: calc(var(--lpd-sticky-top, 0px) + 16px);
		box-shadow: none;
		padding: 16px 20px;
	}

	.lpd-designer-root.is-inline .lpd-canvas-wrap canvas {
		max-height: 70vh;
	}

	.lpd-designer-root.is-inline .lpd-fields-col {
		border-left: 1px solid var(--lpd-border);
		padding: 16px 20px 24px;
	}
}

/* ---------- Inline, full width (below the photo + description) ---------- */

.lpd-designer-root.is-inline.is-fullwidth {
	clear: both;
	flex: 0 0 100%;
	grid-column: 1 / -1;
	width: 100%;
	max-width: none;
	margin: 28px 0;
}

.lpd-add-to-cart {
	padding: 12px 24px;
	background: var(--lpd-accent);
	color: #fff;
	border: none;
	border-radius: 6px;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
	min-height: 46px;
	white-space: nowrap;
}

.lpd-add-to-cart[hidden] {
	display: none;
}

@media (max-width: 782px) {
	.lpd-add-to-cart {
		flex: 1 1 auto;
		padding: 12px 14px;
	}
}

/* ==========================================================================
   Theme-proofing: many themes style every <button>, <select> and <input>
   with high-specificity selectors (dark backgrounds, uppercase...). Pin the
   configurator's controls so they look the same on every theme.
   ========================================================================== */

.lpd-designer-root button.lpd-attr-option,
.lpd-designer-root button.lpd-font-chip,
.lpd-designer-root button.lpd-side-tab {
	background: #fff !important;
	color: var(--lpd-text) !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	box-shadow: none !important;
	text-decoration: none !important;
}

.lpd-designer-root button.lpd-attr-option {
	border: 2px solid var(--lpd-border) !important;
	border-radius: 8px !important;
}

.lpd-designer-root button.lpd-attr-option.is-selected {
	border-color: var(--lpd-accent) !important;
	box-shadow: 0 0 0 1px var(--lpd-accent) !important;
}

.lpd-designer-root button.lpd-attr-option.is-soldout {
	color: #999 !important;
}

.lpd-designer-root button.lpd-font-chip {
	border: 2px solid var(--lpd-border) !important;
	border-radius: 6px !important;
}

.lpd-designer-root button.lpd-font-chip.is-selected {
	border-color: var(--lpd-accent) !important;
	background: #f0f6fc !important;
	box-shadow: 0 0 0 1px var(--lpd-accent) !important;
}

.lpd-designer-root button.lpd-side-tab {
	border: 1px solid #c3c4c7 !important;
	border-radius: 999px !important;
}

.lpd-designer-root button.lpd-side-tab.is-active {
	background: var(--lpd-accent) !important;
	border-color: var(--lpd-accent) !important;
	color: #fff !important;
}

.lpd-designer-root button.lpd-modal-close,
.lpd-designer-root button.lpd-summary-edit,
.lpd-designer-root button.lpd-toggle-zone {
	background: none !important;
	box-shadow: none !important;
}

.lpd-designer-root button.lpd-summary-edit {
	color: var(--lpd-accent) !important;
}

.lpd-designer-root .lpd-modal-panel select,
.lpd-designer-root .lpd-zone-lines input[type="text"] {
	background-color: #fff !important;
	color: var(--lpd-text) !important;
	border: 1px solid #8c8f94 !important;
	text-transform: none !important;
}

.lpd-designer-root .lpd-modal-panel select {
	background-image: none;
	appearance: auto;
	-webkit-appearance: menulist;
	width: auto;
	min-width: 64px;
	padding: 6px 10px;
}

.lpd-edit-note {
	margin: 0;
	padding: 10px 16px;
	background: #fff8e5;
	border-bottom: 1px solid #f0d78c;
	font-size: 14px;
}

/* ---------- Image zones: library grid ---------- */

.lpd-image-fee {
	font-weight: 400;
	color: var(--lpd-muted);
}

.lpd-image-search {
	width: 100%;
	min-height: 42px;
	margin: 0 0 8px;
	padding: 8px 12px;
	font-size: 16px;
	border: 1px solid #8c8f94;
	border-radius: 6px;
	background: #fff;
	color: var(--lpd-text);
}

.lpd-image-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
	gap: 8px;
	max-height: 320px;
	overflow-y: auto;
	padding: 2px;
}

.lpd-designer-root button.lpd-image-tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	min-height: 86px;
	padding: 6px;
	background: #fff !important;
	color: var(--lpd-text) !important;
	border: 2px solid var(--lpd-border) !important;
	border-radius: 8px !important;
	box-shadow: none !important;
	cursor: pointer;
	font-size: 12px;
	line-height: 1.2;
	text-transform: none !important;
}

.lpd-designer-root button.lpd-image-tile[hidden] {
	display: none !important;
}

.lpd-designer-root button.lpd-image-tile.is-selected {
	border-color: var(--lpd-accent) !important;
	box-shadow: 0 0 0 1px var(--lpd-accent) !important;
	background: #f0f6fc !important;
}

.lpd-image-tile img {
	display: block;
	width: 100%;
	height: 52px;
	object-fit: contain;
}

.lpd-image-tile-label {
	display: block;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.lpd-image-none {
	font-weight: 600;
}

.lpd-image-empty {
	margin: 6px 0 0;
	font-size: 13px;
	color: var(--lpd-muted);
}

.lpd-image-credit {
	margin: 6px 0 0;
	font-size: 11px;
	color: var(--lpd-muted);
}

.lpd-image-credit a {
	color: inherit;
	text-decoration: underline;
}
