/* ════════════════════════════════════════════════════════════════════
 *  MS Frame Configurator — frontend styles
 *  All rules scoped under .msfc-app to avoid conflicts with theme CSS.
 * ════════════════════════════════════════════════════════════════════ */

.msfc-app {
	--msfc-bg:          #fafaf8;
	--msfc-panel:       #ffffff;
	--msfc-line:        #e5e2dc;
	--msfc-line-strong: #c9c4bc;
	--msfc-text:        #1a1814;
	--msfc-text-dim:    #6b6760;
	--msfc-text-mute:   #9b968d;
	--msfc-accent:      #8b6f47;
	--msfc-accent-dk:   #5d4a2f;
	--msfc-accent-soft: rgba(139, 111, 71, 0.08);
	--msfc-shadow:      0 1px 3px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
	--msfc-radius:      10px;

	font-family: inherit;
	color: var(--msfc-text);
	background: var(--msfc-bg);
	padding: 24px;
	border-radius: var(--msfc-radius);
	border: 1px solid var(--msfc-line);
	position: relative;
	box-sizing: border-box;
}
.msfc-app *, .msfc-app *::before, .msfc-app *::after { box-sizing: border-box; }

.msfc-layout {
	display: grid;
	grid-template-columns: 320px 1fr;
	gap: 24px;
	align-items: start;
}

/* ───── Panels ───── */
.msfc-panel {
	background: var(--msfc-panel);
	border: 1px solid var(--msfc-line);
	border-radius: var(--msfc-radius);
	padding: 20px;
}
.msfc-panel--preview { padding: 0; overflow: hidden; }

.msfc-section { margin-bottom: 22px; }
.msfc-section:last-child { margin-bottom: 0; }
.msfc-section__title {
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.1em;
	color: var(--msfc-text-mute);
	text-transform: uppercase;
	margin: 0 0 10px;
	padding-bottom: 6px;
	border-bottom: 1px solid var(--msfc-line);
}
.msfc-section__hint {
	font-size: 11px;
	color: var(--msfc-text-mute);
	margin: -4px 0 14px;
	line-height: 1.5;
}

/* ───── Dropzone ───── */
.msfc-dropzone {
	border: 1.5px dashed var(--msfc-line-strong);
	border-radius: var(--msfc-radius);
	padding: 22px 14px;
	text-align: center;
	cursor: pointer;
	transition: all 0.15s ease;
	background: #fff;
}
.msfc-dropzone:hover,
.msfc-dropzone.is-dragover {
	border-color: var(--msfc-accent);
	background: var(--msfc-accent-soft);
}
.msfc-dropzone.has-image {
	padding: 10px;
}
.msfc-dropzone__icon {
	width: 32px;
	height: 32px;
	color: var(--msfc-accent);
	margin-bottom: 8px;
	display: block;
	margin-inline: auto;
}
.msfc-dropzone.has-image .msfc-dropzone__icon { display: none; }
.msfc-dropzone__text {
	font-size: 13px;
	color: var(--msfc-text-dim);
	line-height: 1.4;
}
.msfc-dropzone__text strong {
	color: var(--msfc-accent);
	font-weight: 600;
}
.msfc-dropzone__hint {
	font-size: 11px;
	color: var(--msfc-text-mute);
	margin-top: 4px;
	font-variant-numeric: tabular-nums;
	direction: ltr;
	unicode-bidi: bidi-override;
}
.msfc-dropzone.has-image .msfc-dropzone__hint {
	color: var(--msfc-accent-dk);
	font-weight: 600;
}

/* ───── Sliders ───── */
.msfc-slider { margin-bottom: 16px; }
.msfc-slider__header {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 6px;
}
.msfc-slider__header label {
	font-size: 13px;
	font-weight: 500;
	color: var(--msfc-text);
}
.msfc-slider__value {
	font-size: 13px;
	font-weight: 700;
	color: var(--msfc-accent);
	font-variant-numeric: tabular-nums;
	direction: ltr;
}

/* Dimension readout panel — shows total frame+image dims and photo-only
   dims, updated live as the size slider moves. Structured as a tight
   two-column list so values line up cleanly. */
.msfc-dim-readout {
	margin-top: 14px;
	padding: 12px 14px;
	background: var(--msfc-accent-soft);
	border: 1px solid var(--msfc-line);
	border-radius: 8px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.msfc-dim-readout__row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	font-size: 12px;
}
.msfc-dim-readout__row--sub {
	padding-top: 6px;
	border-top: 1px dashed var(--msfc-line);
	margin-top: 2px;
}
.msfc-dim-readout__row--sub .msfc-dim-readout__label,
.msfc-dim-readout__row--sub .msfc-dim-readout__value {
	font-size: 11px;
	color: var(--msfc-text-mute);
}
.msfc-dim-readout__label {
	font-weight: 500;
	color: var(--msfc-text-dim);
}
.msfc-dim-readout__value {
	font-weight: 700;
	color: var(--msfc-accent-dk);
	font-variant-numeric: tabular-nums;
	direction: ltr;
}

.msfc-app input[type="range"] {
	-webkit-appearance: none;
	width: 100%;
	height: 4px;
	background: var(--msfc-line);
	border-radius: 2px;
	outline: none;
	cursor: pointer;
	direction: ltr;
	margin: 0;
	padding: 0;
}
.msfc-app input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	background: var(--msfc-accent);
	border-radius: 50%;
	cursor: pointer;
	border: 3px solid #fff;
	box-shadow: 0 0 0 1px var(--msfc-accent-dk), 0 2px 4px rgba(0,0,0,.15);
	transition: transform 0.1s;
}
.msfc-app input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.msfc-app input[type="range"]::-moz-range-thumb {
	width: 18px;
	height: 18px;
	background: var(--msfc-accent);
	border-radius: 50%;
	cursor: pointer;
	border: 3px solid #fff;
}

/* ───── Material gallery ───── */
.msfc-materials {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}
.msfc-materials__loading,
.msfc-materials__empty {
	grid-column: 1 / -1;
	text-align: center;
	color: var(--msfc-text-mute);
	font-size: 12px;
	padding: 20px 10px;
}
.msfc-material {
	border: 2px solid var(--msfc-line);
	background: #fff;
	border-radius: 8px;
	padding: 6px;
	cursor: pointer;
	transition: all 0.15s;
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-family: inherit;
	font-size: 11px;
	color: var(--msfc-text-dim);
	text-align: center;
}
.msfc-material:hover {
	border-color: var(--msfc-accent-dk);
}
.msfc-material.is-active {
	border-color: var(--msfc-accent);
	background: var(--msfc-accent-soft);
	color: var(--msfc-accent-dk);
}
.msfc-material__thumb {
	width: 100%;
	aspect-ratio: 1;
	background-size: 60px 60px; /* show tile pattern at useful scale */
	background-repeat: repeat;
	border-radius: 4px;
	box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.msfc-material__name {
	font-weight: 600;
	line-height: 1.2;
}

/* ───── Buttons ───── */
.msfc-btn {
	width: 100%;
	padding: 11px 14px;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	border-radius: 8px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	transition: all 0.15s;
	border: 1px solid transparent;
}
.msfc-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.msfc-btn--primary {
	background: var(--msfc-accent);
	color: #fff;
	border-color: var(--msfc-accent);
}
.msfc-btn--primary:hover:not(:disabled) {
	background: var(--msfc-accent-dk);
	border-color: var(--msfc-accent-dk);
}

/* ───── Preview area ───── */
.msfc-preview-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 18px;
	border-bottom: 1px solid var(--msfc-line);
	background: #fbfaf7;
}
.msfc-preview-header__title {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--msfc-text-mute);
}
.msfc-preview-header__dims {
	font-size: 12px;
	color: var(--msfc-text-dim);
	font-variant-numeric: tabular-nums;
	direction: ltr;
	unicode-bidi: bidi-override;
}

.msfc-preview-stage {
	min-height: 400px;
	padding: 36px 24px;
	/* Grid centering is the most bullet-proof way to keep a single child
	   glued to the geometric center regardless of its size — unlike flex,
	   the grid cell fills the available area and place-items:center is
	   applied within that cell, so the content never drifts. */
	display: grid;
	place-items: center;
	background:
		linear-gradient(45deg, #f2f0eb 25%, transparent 25%) 0 0 / 20px 20px,
		linear-gradient(-45deg, #f2f0eb 25%, transparent 25%) 0 10px / 20px 20px,
		linear-gradient(45deg, transparent 75%, #f2f0eb 75%) 10px -10px / 20px 20px,
		linear-gradient(-45deg, transparent 75%, #f2f0eb 75%) -10px 0 / 20px 20px,
		#fbfaf7;
}
/* Every direct child of the stage occupies the SAME grid cell so they
   overlay each other — the currently-hidden one disappears, the visible
   one stays centered. */
.msfc-preview-stage > * { grid-area: 1 / 1; }
.msfc-preview-empty {
	text-align: center;
	color: var(--msfc-text-mute);
}
.msfc-preview-empty svg {
	margin-bottom: 12px;
	opacity: 0.5;
}
.msfc-preview-empty p { margin: 0; font-size: 14px; }

/* ═════════════════════════════════════════════════════════════════
 *  THE FRAME ITSELF
 *
 *  Structure (built by JS):
 *
 *  <div class="msfc-frame-wrap">
 *    <div class="msfc-frame">                ← the frame (border-box)
 *      ::before                              ← mitered inner cut
 *      <img class="msfc-frame__img">         ← customer's image, inside
 *    </div>
 *  </div>
 *
 *  The frame border is actually a border-image that tiles the texture
 *  seamlessly around all four sides with 45° mitered corners — courtesy
 *  of the built-in behaviour of `border-image-slice` with `repeat`.
 * ═════════════════════════════════════════════════════════════════ */
.msfc-frame-wrap {
	max-width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}
.msfc-frame {
	/* Dimensions set inline by JS */
	max-width: 100%;
	background: var(--frame-fallback, #8b6f47);
	border-style: solid;
	border-width: var(--frame-thickness, 40px);
	/* border-image tiles the texture seamlessly along all 4 sides and
	   miters the corners automatically — the cleanest native way to
	   build a picture frame in pure CSS. */
	border-image-source: var(--frame-texture, none);
	border-image-slice: 33.333% fill;
	border-image-repeat: repeat;
	box-shadow:
		0 2px 6px rgba(0,0,0,.15),
		0 12px 36px rgba(0,0,0,.18);
	position: relative;
	line-height: 0;
}
/* Subtle inner shadow cast by the frame onto the photo — gives realism. */
.msfc-frame::before {
	content: '';
	position: absolute;
	inset: 0;
	box-shadow: inset 0 0 8px rgba(0,0,0,.35);
	pointer-events: none;
	z-index: 2;
}
.msfc-frame__img {
	display: block;
	width: 100%;
	height: auto;
	user-select: none;
	-webkit-user-drag: none;
}

/* ───── Toast ───── */
.msfc-toast {
	position: absolute;
	top: 16px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(30,25,20,.92);
	color: #fff;
	padding: 10px 20px;
	border-radius: 100px;
	font-size: 13px;
	font-weight: 500;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s;
	z-index: 10;
	box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.msfc-toast.is-visible { opacity: 1; }
.msfc-toast.is-error { background: rgba(180,40,40,.95); }
.msfc-toast.is-success { background: rgba(50,130,70,.95); }

/* ───── Mobile ───── */
@media (max-width: 780px) {
	.msfc-layout { grid-template-columns: 1fr; }
	.msfc-app { padding: 14px; }
	.msfc-preview-stage { min-height: 280px; padding: 24px 12px; }
	.msfc-materials { grid-template-columns: 1fr 1fr 1fr; }
}
