/*
 * Mailer layout — the shell around the workbench engine.
 *
 *    | preview (canvas) | upload → the image + two text lines → colour → simple edit |
 *
 * The engine's own stylesheet (workbench.css) stays loaded: this file only lays the two columns out
 * and dresses the mailer's own controls.
 */

.mpd-wb--mailer {
	background: #f6f7f9;
}

.mpd-mailer {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	color: #1f2328;
}

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

.mpd-mailer__topbar {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.75rem 1rem;
	background: #ffffff;
	border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.mpd-mailer__back {
	text-decoration: none;
	font-size: 0.85rem;
	color: #2563eb;
	white-space: nowrap;
}

.mpd-mailer__title {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	margin-right: auto;
}

.mpd-mailer__product {
	font-weight: 600;
}

.mpd-mailer__badge {
	font-size: 0.75rem;
	padding: 0.1rem 0.45rem;
	border-radius: 999px;
	background: #eef2ff;
	color: #3730a3;
}

.mpd-mailer__leadtime {
	font-size: 0.8rem;
	color: #57606a;
}

/* ------------------------------- Columns ------------------------------- */

.mpd-mailer__body {
	display: grid;
	grid-template-columns: minmax(320px, 1fr) 380px;
	gap: 1rem;
	padding: 1rem;
	/*
	 * ⚠️ `stretch`, not `start`: the sheet is fitted to the preview box, and a short box is what kept
	 * the preview small (a portrait sheet in a wide, short stage is limited by HEIGHT). Sharing the
	 * height of the controls column gives the sheet the whole area to grow into.
	 */
	align-items: stretch;
	flex: 1;
}

@media (max-width: 1000px) {
	.mpd-mailer__body {
		grid-template-columns: 1fr;
	}
}

.mpd-mailer__col {
	background: #ffffff;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 0.6rem;
	padding: 0.85rem;
	min-width: 0;
}

.mpd-mailer__heading {
	margin: 0 0 0.6rem;
	font-size: 0.85rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: #57606a;
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

.mpd-mailer__step {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.25rem;
	height: 1.25rem;
	border-radius: 50%;
	background: #2563eb;
	color: #ffffff;
	font-size: 0.75rem;
}

/* ------------------------------- Preview ------------------------------- */

.mpd-mailer__preview {
	display: flex;
	flex-direction: column;
}

/*
 * The stage takes every pixel the column can give it: the engine fits the sheet to this box (minus its
 * own 48px padding), so its height is what decides how big the design is on screen.
 */
.mpd-mailer__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 auto;
	min-height: clamp(420px, 60vh, 680px);
	background: #eef0f3;
	border-radius: 0.4rem;
	/*
	 * The picture and the mask are a fixed window; the sheet scrolls inside it (see .mpd-mailer__viewport).
	 * `padding: 0` because the engine subtracts a 48px allowance from this box when it fits the sheet, and
	 * the padding now lives on the scrolling layer instead.
	 */
	overflow: hidden;
	padding: 0;
}

/*
 * The product's own photo as the preview backdrop: 80% of the area, centred, never stretched.
 */
.mpd-mailer__photo {
	position: absolute;
	top: 50%;
	left: 50%;
	max-width: 80%;
	max-height: 80%;
	transform: translate(-50%, -50%);
	object-fit: contain;
	border-radius: 0.3rem;
	z-index: 0;
}

/* The mask: it dims the photo so the sheet and its ink are what the eye lands on. */
.mpd-mailer__mask {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
	z-index: 1;
	pointer-events: none;
}

/*
 * The scrolling layer.
 *
 * ⚠️ The sheet has to scroll when it is zoomed: at fit scale it is centred by `margin: auto`, and as
 * soon as zoom makes it bigger than this box the same `auto` margins keep its edges reachable instead
 * of letting the flex centring crop the top/left. The picture and the mask sit *outside* this layer, so
 * zooming changes the design area only.
 */
.mpd-mailer__viewport {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	overflow: auto;
	padding: 24px;
	box-sizing: border-box;
}

/*
 * The designable area. The canvas inside is exactly the printable sheet, so the customer's image and
 * text are cut off at its edge — here, and in the proof image, which covers the same rectangle.
 */
.mpd-mailer__sheet {
	margin: auto;
	overflow: hidden;
	background: #ffffff;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* --------------------------- Image and text --------------------------- */

.mpd-mailer__thumb {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 150px;
	margin-bottom: 0.75rem;
	border: 1px dashed rgba(0, 0, 0, 0.25);
	border-radius: 0.4rem;
	background: #fafbfc;
	overflow: hidden;
}

.mpd-mailer__thumb img {
	display: block;
	max-width: 100%;
	max-height: 220px;
}

.mpd-mailer__thumb-empty {
	font-size: 0.8rem;
	color: #8b949e;
}

.mpd-mailer__field {
	display: block;
	margin-top: 0.6rem;
}

.mpd-mailer__field span {
	display: block;
	margin-bottom: 0.2rem;
	font-size: 0.8rem;
	color: #57606a;
}

.mpd-mailer__field input {
	width: 100%;
	padding: 0.45rem 0.6rem;
	border: 1px solid rgba(0, 0, 0, 0.2);
	border-radius: 0.35rem;
	font-size: 0.95rem;
}

/* ------------------------------- Controls ------------------------------- */

.mpd-mailer__block + .mpd-mailer__block {
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.mpd-mailer__upload {
	width: 100%;
	padding: 0.6rem;
	border: 1px solid #2563eb;
	border-radius: 0.35rem;
	background: #2563eb;
	color: #ffffff;
	font-weight: 600;
	cursor: pointer;
}

.mpd-mailer__upload[disabled] {
	opacity: 0.55;
	cursor: progress;
}

.mpd-mailer__note {
	margin: 0.5rem 0 0;
	font-size: 0.75rem;
	color: #8b949e;
}

/*
 * Colour circles: a round swatch inside a round button, each drawn with a **double ring** (a white gap
 * plus an outer line, so a white paper and a black paper are both framed visibly).
 */
.mpd-mailer__colours {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.mpd-mailer__colour {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.3rem;
	width: 4.6rem;
	padding: 0.35rem 0.25rem;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 0.5rem;
	background: #ffffff;
	cursor: pointer;
}

.mpd-mailer__colour-dot {
	display: block;
	width: 2.4rem;
	height: 2.4rem;
	border-radius: 50%;
	background-color: #e5e7eb;
	background-size: cover;
	background-position: center;
	box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.mpd-mailer__colour-name {
	font-size: 0.72rem;
	line-height: 1.1;
	text-align: center;
	word-break: break-word;
}

.mpd-mailer__colour-tick {
	display: none;
	position: absolute;
	top: 0.15rem;
	right: 0.25rem;
	font-size: 0.8rem;
	font-weight: 700;
	color: #2563eb;
}

/* Selected: the ring gets thicker (and the tick appears). */
.mpd-mailer__colour.is-active {
	border-color: #2563eb;
}

.mpd-mailer__colour.is-active .mpd-mailer__colour-dot {
	box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 4px #2563eb;
}

.mpd-mailer__colour.is-active .mpd-mailer__colour-tick {
	display: block;
}

/* The colour input is never seen: it covers the circle and opens the browser's picker. */
.mpd-mailer__colorpick {
	position: absolute;
	top: 0.35rem;
	left: 50%;
	width: 2.4rem;
	height: 2.4rem;
	margin: 0 0 0 -1.2rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	opacity: 0;
	cursor: pointer;
}

/* ---------------------------- Simple edit ---------------------------- */

.mpd-mailer__edit {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 0.35rem;
}

.mpd-mailer__edit button {
	padding: 0.45rem 0;
	border: 1px solid rgba(0, 0, 0, 0.18);
	border-radius: 0.35rem;
	background: #ffffff;
	font-size: 1rem;
	line-height: 1;
	cursor: pointer;
}

.mpd-mailer__edit button:hover {
	border-color: #2563eb;
	color: #2563eb;
}

/* ------------------------------- Footer ------------------------------- */

.mpd-mailer__bottombar {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.75rem 1rem;
	background: #ffffff;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
	position: sticky;
	bottom: 0;
}

.mpd-mailer__bottombar .mpd-wb__spec {
	margin-right: auto;
	font-size: 0.85rem;
	color: #57606a;
}

.mpd-mailer__bottombar .mpd-wb__price {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	font-size: 0.8rem;
}

.mpd-mailer__bottombar .mpd-wb__total {
	font-weight: 700;
	font-size: 1rem;
}
