/**
 * WC Personalization — designer styles.
 *
 * Everything is scoped under .wcp-modal / .wcp-designer so no theme rule
 * leaks in and nothing here leaks out.
 *
 * The modal is printed in the footer, outside every container, because a
 * theme's `overflow:hidden` or `transform` on an ancestor will clip a
 * fixed-position overlay. This is the single most common reason a modal
 * "appears broken at the bottom of the page".
 */

.wcp-modal {
	--wcp-ink: #16161a;
	--wcp-muted: #6b6b73;
	--wcp-line: #e4e2df;
	--wcp-bg: #f7f6f4;
	--wcp-accent: #16161a;
	--wcp-danger: #d63b26;
	--wcp-ok: #1f7a45;

	position: fixed;
	inset: 0;
	z-index: 999999;
	background: rgba(14, 14, 16, .62);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--wcp-ink);
	-webkit-font-smoothing: antialiased;
}

.wcp-modal[hidden] { display: none !important; }

body.wcp-modal-open { overflow: hidden; }

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

/* ── Box ───────────────────────────────────────────────────────── */

.wcp-modal-box {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 1040px;
	max-height: 92vh;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
	overflow: hidden;
	animation: wcp-in .22s ease;
}

@keyframes wcp-in {
	from { opacity: 0; transform: translateY(18px) scale(.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ────────────────────────────────────────────────────── */

.wcp-modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 18px 22px;
	border-bottom: 1px solid var(--wcp-line);
	flex-shrink: 0;
}

.wcp-modal-title {
	margin: 0;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--wcp-ink);
}

.wcp-modal-close {
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: var(--wcp-muted);
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.wcp-modal-close:hover { background: var(--wcp-bg); color: var(--wcp-ink); }

.wcp-modal-instructions {
	padding: 12px 22px;
	background: var(--wcp-bg);
	border-bottom: 1px solid var(--wcp-line);
	font-size: 13px;
	color: var(--wcp-muted);
	flex-shrink: 0;
}

.wcp-modal-instructions p { margin: 0 0 6px; }
.wcp-modal-instructions p:last-child { margin: 0; }

/* ── Body ──────────────────────────────────────────────────────── */

.wcp-modal-body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 20px 22px;
	-webkit-overflow-scrolling: touch;
}

/* ── Footer ────────────────────────────────────────────────────── */

.wcp-modal-foot {
	padding: 14px 22px;
	border-top: 1px solid var(--wcp-line);
	background: #fff;
	flex-shrink: 0;
}

.wcp-modal-error {
	margin: 0 0 10px;
	padding: 9px 12px;
	background: #fdecea;
	border-left: 3px solid var(--wcp-danger);
	border-radius: 3px;
	font-size: 13px;
	color: #8a2318;
}

.wcp-modal-error[hidden] { display: none; }

.wcp-modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

.wcp-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 12px 24px;
	border: 0;
	border-radius: 3px;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: .3px;
	cursor: pointer;
	transition: background .16s ease;
}

.wcp-btn-primary,
.wcp-btn-primary:hover,
.wcp-btn-primary:focus {
	background: var(--wcp-accent) !important;
	color: #fff !important;
}

.wcp-btn-primary:hover { background: #000 !important; }

.wcp-btn-ghost,
.wcp-btn-ghost:hover,
.wcp-btn-ghost:focus {
	background: #fff !important;
	color: var(--wcp-ink) !important;
	border: 1px solid var(--wcp-line) !important;
}

.wcp-btn-ghost:hover { background: var(--wcp-bg) !important; }

/* ══════════════════════════════════════════════════════════════════
   DESIGNER — split layout
   Left: live product preview. Right: the customization controls.
   ══════════════════════════════════════════════════════════════════ */

.wcp-designer {
	display: grid;
	grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
	gap: 24px;
	align-items: start;
}

.wcp-designer.is-busy { opacity: .6; pointer-events: none; }

/* ── LEFT: preview ─────────────────────────────────────────────── */

.wcp-preview { min-width: 0; }

.wcp-area-tabs {
	display: flex;
	gap: 6px;
	border-bottom: 1px solid var(--wcp-line);
	margin-bottom: 12px;
}

.wcp-area-tab {
	padding: 9px 16px;
	border: 0;
	background: none;
	color: var(--wcp-muted);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
}

.wcp-area-tab:hover { color: var(--wcp-ink); }
.wcp-area-tab.is-active { color: var(--wcp-ink); border-bottom-color: var(--wcp-ink); }

.wcp-stage {
	background: var(--wcp-bg);
	border-radius: 6px;
	padding: 16px;
	display: flex;
	justify-content: center;
	min-height: 260px;
}

.wcp-canvas-wrap { position: relative; max-width: 100%; line-height: 0; }
.wcp-canvas-wrap[hidden] { display: none; }

.wcp-canvas-wrap .canvas-container { max-width: 100%; margin: 0 auto; }

.wcp-canvas-wrap canvas {
	max-width: 100%;
	border-radius: 3px;
	touch-action: none;   /* Fabric owns touch gestures */
}

.wcp-preview-hint {
	margin: 10px 0 0;
	font-size: 12px;
	color: var(--wcp-muted);
	text-align: center;
	line-height: 1.45;
}

/* ── RIGHT: controls ───────────────────────────────────────────── */

.wcp-controls { min-width: 0; }

.wcp-control-list { display: flex; flex-direction: column; gap: 18px; }

.wcp-control {
	padding: 14px;
	border: 1px solid var(--wcp-line);
	border-radius: 6px;
	background: #fff;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.wcp-control.is-selected {
	border-color: var(--wcp-ink);
	box-shadow: 0 0 0 1px var(--wcp-ink);
}

.wcp-control-label {
	display: block;
	font-size: 13px;
	font-weight: 700;
	color: var(--wcp-ink);
	margin-bottom: 8px;
}

.wcp-req { color: var(--wcp-danger); }

.wcp-input {
	display: block;
	width: 100%;
	padding: 11px 12px;
	border: 1px solid var(--wcp-line);
	border-radius: 3px;
	background: #fff;
	color: var(--wcp-ink);
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	box-shadow: none;
}

.wcp-input:focus {
	outline: none;
	border-color: var(--wcp-ink);
	box-shadow: inset 0 0 0 1px var(--wcp-ink);
}

textarea.wcp-input { resize: vertical; min-height: 76px; }

.wcp-counter {
	display: block;
	margin-top: 6px;
	font-size: 11.5px;
	color: var(--wcp-muted);
	text-align: right;
}

.wcp-counter.is-max { color: var(--wcp-danger); font-weight: 600; }

.wcp-control-help {
	margin: 8px 0 0;
	font-size: 12px;
	color: var(--wcp-muted);
	line-height: 1.45;
}

.wcp-controls-empty {
	padding: 28px 16px;
	text-align: center;
	color: var(--wcp-muted);
	font-size: 13px;
	background: var(--wcp-bg);
	border-radius: 6px;
}

/* ── Image control ─────────────────────────────────────────────── */

.wcp-image-control { display: flex; flex-direction: column; gap: 10px; }

.wcp-image-thumb { position: relative; align-self: flex-start; }
.wcp-image-thumb[hidden] { display: none; }

.wcp-image-thumb img {
	display: block;
	width: 90px;
	height: 90px;
	object-fit: cover;
	border: 1px solid var(--wcp-line);
	border-radius: 4px;
}

.wcp-image-remove {
	position: absolute;
	top: -8px;
	right: -8px;
	width: 22px;
	height: 22px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--wcp-danger);
	color: #fff;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wcp-upload-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	width: 100%;
	min-height: 44px;
	padding: 11px 16px;
	border: 1px dashed var(--wcp-line);
	border-radius: 3px;
	background: var(--wcp-bg);
	color: var(--wcp-ink);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.wcp-upload-btn:hover:not(:disabled) { border-color: var(--wcp-ink); background: #fff; }
.wcp-upload-btn:disabled { opacity: .6; cursor: default; }

/* ── Colour swatches ───────────────────────────────────────────── */

.wcp-swatches { display: flex; flex-wrap: wrap; gap: 8px; }

.wcp-swatch {
	width: 32px;
	height: 32px;
	border: 2px solid #fff;
	border-radius: 50%;
	cursor: pointer;
	padding: 0;
	box-shadow: 0 0 0 1px var(--wcp-line);
}

.wcp-swatch.is-active { box-shadow: 0 0 0 2px var(--wcp-ink); }

/* ── Notices ───────────────────────────────────────────────────── */

.wcp-notice {
	padding: 11px 14px;
	border-radius: 4px;
	font-size: 12.5px;
	line-height: 1.45;
	margin-bottom: 14px;
	background: var(--wcp-bg);
	color: var(--wcp-ink);
	border-left: 3px solid var(--wcp-muted);
}

.wcp-notice[hidden] { display: none; }
.wcp-notice[data-level="warning"] { background: #fff8e5; border-left-color: #d98600; color: #7a4d00; }
.wcp-notice[data-level="error"] { background: #fdecea; border-left-color: var(--wcp-danger); color: #8a2318; }

/* ── Standalone open button (no DMJ) ───────────────────────────── */

.wcp-open-designer {
	display: block;
	width: 100%;
	min-height: 48px;
	margin-bottom: 12px;
	padding: 14px 20px;
	background: #16161a !important;
	color: #fff !important;
	border: 0 !important;
	border-radius: 3px;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: .5px;
	text-transform: uppercase;
	cursor: pointer;
}

.wcp-open-designer:hover { background: #000 !important; color: #fff !important; }

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 860px) {
	.wcp-modal { padding: 0; }

	.wcp-modal-box {
		max-width: 100%;
		max-height: 100vh;
		height: 100vh;
		border-radius: 0;
	}

	.wcp-designer {
		grid-template-columns: minmax(0, 1fr);
		gap: 18px;
	}

	.wcp-stage { padding: 10px; min-height: 0; }

	.wcp-modal-body { padding: 16px; }
	.wcp-modal-head { padding: 14px 16px; }
	.wcp-modal-foot { padding: 12px 16px; }

	.wcp-modal-actions { flex-direction: column-reverse; }
	.wcp-btn { width: 100%; }

	.wcp-control { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
	.wcp-modal-box { animation: none; }
	.wcp-btn { transition: none; }
}


/* ══════════════════════════════════════════════════════════════════
   ADD-TO-CART TOAST
   Shown after the design goes into the cart. The customer stays on
   the product page, so this is the only confirmation they get.
   ══════════════════════════════════════════════════════════════════ */

.wcp-toast {
	position: fixed;
	left: 50%;
	bottom: 28px;
	transform: translate(-50%, 16px);
	z-index: 1000000;
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 14px 20px;
	background: #16161a;
	color: #fff;
	border-radius: 6px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.4;
	box-shadow: 0 12px 34px rgba(0, 0, 0, .28);
	opacity: 0;
	transition: opacity .25s ease, transform .25s ease;
	max-width: calc(100vw - 32px);
}

.wcp-toast[hidden] { display: none !important; }
.wcp-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.wcp-toast::before {
	content: "\2713";
	flex-shrink: 0;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #1f7a45;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 13px;
}

.wcp-toast a {
	color: #fff;
	text-decoration: underline;
	font-weight: 600;
	white-space: nowrap;
}

.wcp-toast a:hover { color: #fff; }

/* Add to Cart button while it is locked */
.wcp-btn-primary:disabled,
.wcp-btn-primary[disabled] {
	opacity: .45;
	cursor: not-allowed;
}

@media (max-width: 600px) {
	.wcp-toast {
		left: 16px;
		right: 16px;
		bottom: 16px;
		transform: translateY(16px);
		max-width: none;
	}

	.wcp-toast.is-visible { transform: translateY(0); }
}


/* Why the Add to Cart button is still off */
.wcp-modal-hint {
	margin: 0 0 10px;
	font-size: 12.5px;
	color: var(--wcp-muted);
	text-align: right;
}

.wcp-modal-hint[hidden] { display: none; }
