/*!
 * Memorial Product Designer — workbench styles
 *
 * The workbench does not load the theme, so it ships its own reset and the entire layout here.
 * The design tool has to own the whole screen (see docs/architecture.md §1).
 */

:root {
	--mpd-bg: #f4f5f7;
	--mpd-surface: #ffffff;
	--mpd-ink: #1f2430;
	--mpd-muted: #6b7280;
	--mpd-line: #e3e5ea;
	--mpd-accent: #2f6fed;
	--mpd-accent-ink: #ffffff;
	--mpd-warn: #b45309;
	--mpd-danger: #b91c1c;
	--mpd-topbar-h: 56px;
	--mpd-bottombar-h: 64px;
	--mpd-tools-w: 84px;
	--mpd-props-w: 320px;
	--mpd-radius: 8px;
}

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

html,
body.mpd-wb {
	margin: 0;
	padding: 0;
	height: 100%;
}

body.mpd-wb {
	background: var(--mpd-bg);
	color: var(--mpd-ink);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
		"Hiragino Sans GB", "Microsoft YaHei", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	overflow: hidden;
}

.mpd-wb__link {
	color: var(--mpd-accent);
}

/* ---------- Fatal error page ---------- */

.mpd-wb__fatal {
	max-width: 480px;
	margin: 15vh auto;
	padding: 32px;
	background: var(--mpd-surface);
	border-radius: var(--mpd-radius);
	text-align: center;
}

.mpd-wb__fatal h1 {
	margin: 0 0 12px;
	font-size: 20px;
}

/* ---------- App shell ---------- */

.mpd-wb__app {
	display: grid;
	grid-template-rows: var(--mpd-topbar-h) 1fr var(--mpd-bottombar-h);
	height: 100vh;
	height: 100dvh;
}

/* ---------- Top bar ---------- */

.mpd-wb__topbar {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 0 16px;
	background: var(--mpd-surface);
	border-bottom: 1px solid var(--mpd-line);
}

.mpd-wb__back {
	color: var(--mpd-muted);
	text-decoration: none;
	white-space: nowrap;
}

.mpd-wb__back:hover {
	color: var(--mpd-ink);
}

.mpd-wb__title {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	flex: 1;
}

.mpd-wb__product {
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mpd-wb__badge {
	flex: none;
	padding: 2px 8px;
	border-radius: 999px;
	background: #eef2ff;
	color: #3730a3;
	font-size: 12px;
}

.mpd-wb__topbar-right {
	display: flex;
	align-items: center;
	gap: 12px;
}

.mpd-wb__leadtime {
	color: var(--mpd-muted);
	font-size: 13px;
	white-space: nowrap;
}

/*
 * The single primary action: add to cart.
 * (There used to be a second, identical top-bar button sharing this rule under
 * `.mpd-wb__primary`; it was removed as a duplicate — see workbench.js bindUI().)
 */
.mpd-wb__add {
	padding: 8px 18px;
	border: 0;
	border-radius: var(--mpd-radius);
	background: var(--mpd-accent);
	color: var(--mpd-accent-ink);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.mpd-wb__add:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* ---------- Main three-column layout ---------- */

.mpd-wb__body {
	display: grid;
	grid-template-columns: var(--mpd-tools-w) minmax(0, 1fr) var(--mpd-props-w);
	min-height: 0;
}

/* ---------- Left toolbar ---------- */

.mpd-wb__tools {
	background: var(--mpd-surface);
	border-right: 1px solid var(--mpd-line);
	overflow-y: auto;
}

.mpd-wb__tools ul {
	margin: 0;
	padding: 8px 0;
	list-style: none;
}

.mpd-wb__tool-btn {
	display: block;
	width: 100%;
	padding: 12px 6px;
	border: 0;
	background: transparent;
	color: var(--mpd-muted);
	font-size: 12px;
	cursor: pointer;
	border-left: 3px solid transparent;
}

.mpd-wb__tool-btn:hover {
	color: var(--mpd-ink);
	background: #f8f9fb;
}

.mpd-wb__tool.is-active .mpd-wb__tool-btn {
	color: var(--mpd-accent);
	border-left-color: var(--mpd-accent);
	background: #f3f7ff;
	font-weight: 600;
}

/* ---------- Canvas area ---------- */

.mpd-wb__stage {
	display: grid;
	grid-template-rows: minmax(0, 1fr) 28px;
	min-width: 0;
	background:
		linear-gradient(45deg, #eceef2 25%, transparent 25%) -8px 0/16px 16px,
		linear-gradient(-45deg, #eceef2 25%, transparent 25%) -8px 0/16px 16px,
		linear-gradient(45deg, transparent 75%, #eceef2 75%) -8px 0/16px 16px,
		linear-gradient(-45deg, transparent 75%, #eceef2 75%) -8px 0/16px 16px,
		#f7f8fa;
}

.mpd-wb__stage-inner {
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: auto;
	padding: 24px;
	min-height: 0;
}

.mpd-wb__canvas-wrap {
	position: relative;
	background: #fff;
	box-shadow: 0 2px 16px rgba(15, 23, 42, 0.14);
}

.mpd-wb__canvas-wrap canvas {
	display: block;
}

.mpd-wb__statusbar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 12px;
	background: var(--mpd-surface);
	border-top: 1px solid var(--mpd-line);
	color: var(--mpd-muted);
	font-size: 12px;
}

.mpd-wb__sep {
	color: var(--mpd-line);
}

/* ---------- Zoom ---------- */

.mpd-wb__zoom {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-left: auto;
	color: var(--mpd-muted);
	font-size: 11px;
}

.mpd-wb__zoom-btn {
	padding: 2px 8px;
	border: 1px solid var(--mpd-line);
	border-radius: 4px;
	background: #fff;
	color: var(--mpd-muted);
	font: inherit;
	font-size: 11px;
	cursor: pointer;
}

.mpd-wb__zoom-btn:hover {
	border-color: #c9ced6;
	color: var(--mpd-ink);
}

.mpd-wb__zoom-btn.is-active {
	border-color: var(--mpd-accent);
	background: #f3f7ff;
	color: var(--mpd-accent);
	font-weight: 600;
}

/* ---------- Right property panel ---------- */

.mpd-wb__props {
	background: var(--mpd-surface);
	border-left: 1px solid var(--mpd-line);
	overflow-y: auto;
}

.mpd-wb__props-empty {
	padding: 24px 16px;
	color: var(--mpd-muted);
	font-size: 13px;
}

.mpd-panel {
	padding: 16px;
}

.mpd-panel__title {
	margin: 0 0 12px;
	font-size: 14px;
	font-weight: 600;
}

.mpd-field {
	margin-bottom: 16px;
}

.mpd-field__label {
	display: block;
	margin-bottom: 6px;
	color: var(--mpd-muted);
	font-size: 12px;
}

.mpd-field select,
.mpd-field input[type="text"],
.mpd-field input[type="number"] {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid var(--mpd-line);
	border-radius: 6px;
	background: #fff;
	color: inherit;
	font: inherit;
}

.mpd-field input[type="range"] {
	width: 100%;
}

.mpd-panel__note {
	margin: 12px 0 0;
	color: var(--mpd-muted);
	font-size: 12px;
	line-height: 1.6;
}

/* Base swatches */

.mpd-swatches {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
}

.mpd-swatch {
	position: relative;
	aspect-ratio: 1;
	border: 2px solid transparent;
	border-radius: 6px;
	background-color: #fff;
	background-size: cover;
	background-repeat: no-repeat;
	background-position: center;
	cursor: pointer;
	padding: 0;
}

.mpd-swatch.is-active {
	border-color: var(--mpd-accent);
}

.mpd-swatch::after {
	content: attr(data-label);
	position: absolute;
	inset: auto 0 -18px;
	font-size: 10px;
	color: var(--mpd-muted);
	text-align: center;
}

.mpd-swatches {
	row-gap: 22px;
}

/* ---------- Pattern ink swatches ---------- */

.mpd-colors {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
}

.mpd-color {
	position: relative;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 2px solid #fff;
	border-radius: 50%;
	box-shadow: 0 0 0 1px var(--mpd-line);
	cursor: pointer;
}

.mpd-color.is-active {
	box-shadow: 0 0 0 2px var(--mpd-accent);
}

/* Custom colour: the native colour picker is hidden inside the circle, so clicking the circle opens the picker */
.mpd-color--custom {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: conic-gradient(#b03030, #c9a227, #1b3a2a, #1f3a6e, #6b4a9e, #b03030);
}

.mpd-color--custom input[type='color'] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	padding: 0;
	border: 0;
	opacity: 0;
	cursor: pointer;
}

/* ---------- Bottom bar ---------- */

.mpd-wb__bottombar {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 0 16px;
	background: var(--mpd-surface);
	border-top: 1px solid var(--mpd-line);
}

.mpd-wb__spec {
	color: var(--mpd-muted);
	font-size: 13px;
}

.mpd-wb__price {
	margin-left: auto;
	text-align: right;
}

.mpd-wb__unit {
	display: block;
	color: var(--mpd-muted);
	font-size: 12px;
}

.mpd-wb__total {
	display: block;
	font-size: 18px;
	font-weight: 700;
}

.mpd-wb__toast {
	position: fixed;
	left: 50%;
	bottom: calc(var(--mpd-bottombar-h) + 16px);
	transform: translateX(-50%);
	padding: 10px 18px;
	border-radius: var(--mpd-radius);
	background: rgba(31, 36, 48, 0.92);
	color: #fff;
	font-size: 13px;
	opacity: 0;
	transition: opacity 0.2s;
	pointer-events: none;
}

.mpd-wb__toast.is-visible {
	opacity: 1;
}

.mpd-wb__toast.is-error {
	background: var(--mpd-danger);
}

/* ---------- Narrow screens ---------- */

@media (max-width: 900px) {
	.mpd-wb__body {
		grid-template-columns: var(--mpd-tools-w) minmax(0, 1fr);
	}

	.mpd-wb__props {
		display: none;
	}
}

/* ---------- Generic buttons ---------- */

.mpd-btn {
	display: block;
	width: 100%;
	margin-bottom: 14px;
	padding: 9px 12px;
	border: 1px dashed var(--mpd-line);
	border-radius: 6px;
	background: #fff;
	color: var(--mpd-accent);
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}

.mpd-btn:hover {
	border-color: var(--mpd-accent);
	background: #f3f7ff;
}

/* Secondary actions (for example "Remove this image"): they must not compete with the primary button for attention */
.mpd-btn--ghost {
	margin-top: 4px;
	border-style: solid;
	color: var(--mpd-muted);
}

.mpd-btn--ghost:hover {
	border-color: #d06a6a;
	background: #fdf4f4;
	color: #b03030;
}

/* ---------- Text list ---------- */

.mpd-text-list {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.mpd-text-item {
	padding: 12px;
	border: 1px solid var(--mpd-line);
	border-radius: 6px;
	background: #fafbfc;
}

/* The entry selected on the canvas must be visible in the panel too — otherwise the customer cannot tell which one is being edited */
.mpd-text-item.is-selected {
	border-color: var(--mpd-accent);
	box-shadow: 0 0 0 1px var(--mpd-accent);
	background: #f7faff;
}

.mpd-text-item__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
	color: var(--mpd-muted);
	font-size: 12px;
}

.mpd-text-del {
	width: 22px;
	height: 22px;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: var(--mpd-muted);
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
}

.mpd-text-del:hover {
	background: #fee2e2;
	color: var(--mpd-danger);
}

.mpd-text-content {
	width: 100%;
	margin-bottom: 8px;
	padding: 7px 9px;
	border: 1px solid var(--mpd-line);
	border-radius: 5px;
	background: #fff;
	color: inherit;
	font: inherit;
}

.mpd-text-row {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-bottom: 10px;
}

.mpd-text-row select {
	flex: 1;
	min-width: 0;
	padding: 6px 8px;
	border: 1px solid var(--mpd-line);
	border-radius: 5px;
	background: #fff;
	font: inherit;
	font-size: 13px;
}

.mpd-text-color {
	flex: none;
	width: 36px;
	height: 32px;
	padding: 2px;
	border: 1px solid var(--mpd-line);
	border-radius: 5px;
	background: #fff;
	cursor: pointer;
}

.mpd-text-item .mpd-field__label {
	margin-top: 8px;
}

.mpd-text-item .mpd-field__label b {
	color: var(--mpd-ink);
	font-weight: 600;
}

.mpd-text-item input[type="range"] {
	width: 100%;
	margin: 0;
}

/* ---------- Divider ---------- */

.mpd-hr {
	margin: 16px 0;
	border: 0;
	border-top: 1px dashed var(--mpd-line);
}

/* ---------- Upload control ---------- */

.mpd-field input[type="file"] {
	width: 100%;
	margin-bottom: 8px;
	font-size: 12px;
}

.mpd-field input[type="file"]::file-selector-button {
	margin-right: 8px;
	padding: 5px 10px;
	border: 1px solid var(--mpd-line);
	border-radius: 5px;
	background: #fff;
	font: inherit;
	font-size: 12px;
	cursor: pointer;
}
