/* =========================================================
   Stamps Attribute Picker — frontend styles
   Scoped under .sap-* (our UI) and .fpd-* overrides
   ========================================================= */

/* ─── Instructions block ─────────────────────────────────── */

.sap-stamp-instructions {
	margin: 0 0 1.35rem;
	padding: 0.95rem 1.1rem;
	border: 1px solid rgba(15, 23, 42, 0.1);
	border-left: 3px solid currentColor;
	background: rgba(15, 23, 42, 0.035);
	border-radius: 8px;
	font-size: 0.95em;
	line-height: 1.5;
}

.sap-stamp-instructions p:last-child {
	margin-bottom: 0;
}


/* ─── Hide FPD interactive UI, keep only the canvas ─────── */

/*
  The FPD container (.fpd-container) holds the whole designer.
  We hide everything except the canvas stage itself so it becomes
  a clean live preview. The canvas still renders and FPD still
  serializes to fpd_product for cart/checkout — we just remove all
  the click-to-edit chrome.
*/

/* Top action bar */
.fpd-container .fpd-topbar,
/* Bottom view-navigation */
.fpd-container .fpd-bottom-nav,
/* Left/right sidebars and module tabs */
.fpd-container .fpd-sidebar,
.fpd-container .fpd-toolbar-sidebar,
.fpd-container .fpd-main-bar-container,
/* Module navigation tabs strip */
.fpd-container .fpd-module-tabs,
.fpd-container .fpd-navigation,
.fpd-container .fpd-nav-icon,
/* Element properties / tools bars */
.fpd-container .fpd-tools-nav,
.fpd-container .fpd-primary-tools,
.fpd-container .fpd-secondary-tools,
.fpd-container .fpd-panel-tabs,
/* Sub-panels and color panels */
.fpd-container .fpd-sub-panel,
.fpd-container .fpd-panel-color,
.fpd-container .fpd-panel-font-family,
/* Toolbar that floats over selected elements */
.fpd-container .fpd-toolbar-visible,
/* Fullscreen toggle */
.fpd-container .fpd-fullscreen-toggle,
/* Zoom controls */
.fpd-container .fpd-zoom-wrapper,
/* Stage pan indicator */
.fpd-container .fpd-stage-pan,
/* Guided tour overlay */
.fpd-container .fpd-gt-step {
	display: none !important;
}

/* Canvas itself: block pointer events so customers can't
   click/drag elements directly. Our JS changes bypass this. */
.fpd-container .fpd-view-stage canvas {
	pointer-events: none !important;
	cursor: default !important;
}

/* Give the canvas a subtle "preview" visual treatment */
.fpd-container .fpd-product-stage {
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 6px;
	overflow: hidden;
}


/* ─── Custom panel ───────────────────────────────────────── */

.sap-panel {
	--sap-border: rgba(15, 23, 42, 0.12);
	--sap-border-strong: rgba(15, 23, 42, 0.24);
	--sap-text-muted: rgba(15, 23, 42, 0.55);
	--sap-accent: #111827;
	--sap-focus: #2271b1;
	--sap-error: #b42318;

	display: grid;
	gap: 0.55rem;
	margin: 1.35rem 0 1.15rem;
	color: inherit;
}

.sap-line-block {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	padding: 0.85rem;
	border: 1px solid var(--sap-border);
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
	position: relative;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sap-line-block:hover {
	border-color: rgba(15, 23, 42, 0.22);
	box-shadow: 0 2px 6px rgba(15, 23, 42, 0.07);
}

.sap-line-block:focus-within {
	border-color: var(--sap-focus);
	box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.sap-line-block:last-child {
	margin-bottom: 0;
}

.fpd-container + .sap-panel {
	margin-top: 1rem;
}

.sap-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding-bottom: 0.5rem;
	margin-bottom: 0.15rem;
	border-bottom: 1px solid var(--sap-border);
}

.sap-panel-title {
	margin: 0;
	font-size: 0.85rem;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: rgba(15, 23, 42, 0.55);
}

/* Text input — primary element, previews its own formatting */
.sap-text-field {
	position: relative;
	flex: 1;
	min-width: 140px;
}

.sap-text-input {
	display: block;
	width: 100%;
	height: 44px;
	font: inherit;
	font-size: 1.05em;
	padding: 0 0.85rem;
	border: 1px solid var(--sap-border-strong);
	border-radius: 6px;
	background: Canvas;
	color: CanvasText;
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.sap-text-input::placeholder {
	color: rgba(15, 23, 42, 0.38);
	opacity: 1;
}

.sap-text-input:focus,
.sap-text-input:focus-visible {
	outline: none;
	border-color: var(--sap-focus);
	box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.14);
}

.sap-text-input.is-invalid {
	border-color: var(--sap-error);
}

.sap-text-input.is-invalid:focus,
.sap-text-input.is-invalid:focus-visible {
	border-color: var(--sap-error);
	box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.14);
}

.sap-character-count {
	position: absolute;
	z-index: 1;
	top: -0.55rem;
	left: 0.65rem;
	padding: 0.12rem 0.35rem;
	border: 1px solid var(--sap-border);
	border-radius: 999px;
	background: Canvas;
	color: var(--sap-text-muted);
	font-size: 0.75rem;
	font-variant-numeric: tabular-nums;
	line-height: 1;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sap-character-count.is-visible {
	opacity: 1;
}

.sap-character-count.is-invalid {
	border-color: var(--sap-error);
	color: var(--sap-error);
	font-weight: 700;
}

.sap-field-error {
	display: block;
	margin-top: 0.4rem;
	color: var(--sap-error);
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.35;
}

.sap-field-error[hidden] {
	display: none;
}

.single_add_to_cart_button.sap-validation-disabled {
	cursor: not-allowed;
	opacity: 0.55;
}

/* Controls group — pinned right, single strip */
.sap-line-controls {
	flex: none;
	display: flex;
	align-items: center;
	gap: 6px;
	margin-left: auto;
}

/* Font / size selectors */
.sap-font-select,
.sap-size-select {
	height: 36px;
	font: inherit;
	font-size: 0.85rem;
	padding: 0 0.5rem;
	border: 1px solid rgba(15, 23, 42, 0.18);
	border-radius: 6px;
	background-color: rgba(15, 23, 42, 0.03);
	color: rgba(15, 23, 42, 0.75);
	box-sizing: border-box;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.sap-font-select { width: 108px; }
.sap-size-select { width: 90px; }

.sap-font-select:focus,
.sap-size-select:focus,
.sap-font-select:focus-visible,
.sap-size-select:focus-visible {
	outline: none;
	border-color: var(--sap-focus);
	box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.14);
}

/* Shared button base */
.sap-btn {
	appearance: none;
	border: 1px solid rgba(15, 23, 42, 0.18);
	background: rgba(15, 23, 42, 0.03);
	color: rgba(15, 23, 42, 0.5);
	font: inherit;
	cursor: pointer;
	transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
	line-height: 1;
}

.sap-btn:hover {
	background: rgba(15, 23, 42, 0.06);
	border-color: rgba(15, 23, 42, 0.3);
	color: rgba(15, 23, 42, 0.75);
}

.sap-btn:focus,
.sap-btn:focus-visible {
	outline: none;
	border-color: var(--sap-focus);
	box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.14);
}

.sap-btn.is-active {
	background: rgba(15, 23, 42, 0.88);
	border-color: transparent;
	color: #fff;
}

/* Bold / Italic standalone toggle buttons */
.sap-btn--style {
	flex: none;
	width: 36px;
	height: 36px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
	font-size: 0.88rem;
}

.sap-btn--bold  { font-weight: 700; }
.sap-btn--italic { font-style: italic; }

/* Under ~640px: text input takes its own full-width line; the controls
   group wraps below it, right-aligned. */
@media (max-width: 640px) {
	.sap-panel {
		gap: 0.75rem;
	}

	.sap-line-block {
		padding: 0.9rem;
	}

	.sap-text-field {
		flex-basis: 100%;
	}
}


/* =========================================================
   Custom product-page layout (stamp products only)
   Active when <body> has .sap-custom-layout
   ========================================================= */

/* ─── ROW 1: shrink gallery ~10% ────────────────────────── */
/* Gallery is a flex item in .product-entry-wrapper (1290px).
   It naturally sizes to ~48% via image content; cap at ~43% to reduce by ~10%. */
.sap-custom-layout .woocommerce-product-gallery {
	max-width: 43% !important;
}

/* ─── Shared row base ────────────────────────────────────── */

.sap-custom-layout .sap-row {
	margin-top: 1.25rem;
	margin-left: auto;
	margin-right: auto;
	max-width: 1290px;
	width: 100%;
	box-sizing: border-box;
	padding-left: var(--theme-sides-spacing, 20px);
	padding-right: var(--theme-sides-spacing, 20px);
}

/* ─── ROW 2: price/description (left) + swatches (right) ── */

.sap-custom-layout .sap-row--swatches {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.5rem;
	align-items: center;
	padding: 1rem 1.25rem;
	background: rgba(15, 23, 42, 0.025);
	border: 1px solid rgba(15, 23, 42, 0.08);
	border-radius: 8px;
}

.sap-custom-layout .sap-swatches-col--price .price {
	font-size: 1.35rem;
	font-weight: 700;
	margin: 0 0 0.25rem;
	display: block;
}

.sap-custom-layout .sap-swatches-col--price
.woocommerce-product-details__short-description {
	margin: 0;
	font-size: 0.9em;
	color: rgba(15, 23, 42, 0.65);
}

.sap-custom-layout .sap-swatches-col--price
.woocommerce-product-details__short-description p {
	margin: 0;
}

/* Hide single_variation_wrap while it lives inside the swatches column
   (before JS moves it to ROW 4). */
.sap-custom-layout .sap-swatches-col--attrs .single_variation_wrap {
	display: none !important;
}

/* Clean up the variations form inside the swatch column */
.sap-custom-layout .sap-swatches-col--attrs .variations_form,
.sap-custom-layout .sap-swatches-col--attrs .ct-product-add-to-cart {
	margin: 0;
}

/* Put Χρώμα Σφραγίδας and Χρώμα Λάστιχο side by side on one line.
   Must override table/tbody/tr display to escape table-layout context. */
.sap-custom-layout .sap-swatches-col--attrs table.variations,
.sap-custom-layout .sap-swatches-col--attrs table.variations tbody {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 1.5rem;
	flex-wrap: wrap;
	border: none;
	width: 100%;
}

/* Each attribute group: label above, swatches below — keeps the group narrow
   so both fit side-by-side in the available column width. */
.sap-custom-layout .sap-swatches-col--attrs table.variations tr {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.3rem;
}

.sap-custom-layout .sap-swatches-col--attrs table.variations th,
.sap-custom-layout .sap-swatches-col--attrs table.variations td {
	display: block;
	padding: 0;
	border: none;
	font-size: 0.85rem;
}

.sap-custom-layout .sap-swatches-col--attrs table.variations th label {
	font-weight: 600;
	white-space: nowrap;
}

/* Tuck the "Εκκαθάριση" reset link tighter */
.sap-custom-layout .sap-swatches-col--attrs .reset_variations {
	font-size: 0.8rem;
	margin-left: 0.5rem;
}

/* ─── ROW 3: controls (left) + FPD preview (right) ──────── */

.sap-custom-layout .sap-editor-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.5rem;
	align-items: start;
}

.sap-custom-layout .sap-editor-grid[hidden] {
	display: none;
}

/* ─── Custom-layout toggle + file uploader ──────────────── */

.sap-layout-toggle {
	margin: 0 0 1.25rem;
	padding: 0.85rem 1rem;
	border: 1px solid rgba(15, 23, 42, 0.12);
	border-radius: 8px;
	background: rgba(15, 23, 42, 0.025);
}

.sap-layout-toggle-label {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin: 0;
	font-weight: 600;
	cursor: pointer;
}

.sap-layout-toggle-input {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	cursor: pointer;
}

.sap-layout-toggle-sub {
	margin: 0.4rem 0 0 1.8rem;
	font-size: 0.85em;
	color: rgba(15, 23, 42, 0.6);
}

.sap-layout-uploader {
	margin-top: 1.25rem;
	padding: 1.5rem;
	border: 2px dashed rgba(15, 23, 42, 0.2);
	border-radius: 10px;
	background: rgba(15, 23, 42, 0.02);
	text-align: center;
}

.sap-layout-uploader[hidden] {
	display: none;
}

.sap-layout-uploader-label {
	margin: 0 0 1rem;
	font-size: 0.95em;
	color: rgba(15, 23, 42, 0.7);
}

.sap-uploader-drop {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.85rem;
}

/* Visually hide the native input; the styled <label> is the trigger. */
.sap-uploader-input {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.sap-uploader-btn {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 1.2rem;
	border-radius: 6px;
	background: rgba(15, 23, 42, 0.88);
	color: #fff;
	font-weight: 600;
	font-size: 0.9rem;
	cursor: pointer;
	transition: background 0.15s ease, box-shadow 0.15s ease;
}

.sap-uploader-btn:hover {
	background: rgba(15, 23, 42, 1);
}

.sap-uploader-input:focus-visible + .sap-uploader-btn {
	outline: none;
	box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.4);
}

.sap-uploader-status {
	font-size: 0.88rem;
	color: rgba(15, 23, 42, 0.6);
	word-break: break-all;
}

.sap-uploader-status.is-success {
	color: #1a7f37;
	font-weight: 600;
}

.sap-uploader-status.is-error {
	color: #b42318;
	font-weight: 600;
}

/* SAP panel margin reset — row gap provides the spacing */
.sap-custom-layout .sap-editor-col--controls .sap-panel {
	margin: 0;
}

/* FPD container: let it initialize at full width so the canvas gets proper
   dimensions. JS hides it after reading those dimensions. */
.sap-custom-layout .sap-editor-col--preview {
	position: relative;
	min-width: 0;
}
.sap-custom-layout .sap-editor-col--preview .fpd-container {
	width: 100% !important;
}

/* ─── Custom HTML stamp preview ───────────────────────────────── */

.sap-preview-wrapper {
	width: 100%;
	min-width: 0;
}

.sap-preview-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin: 0 0 0.75rem;
}

.sap-preview-label {
	margin: 0;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: rgba(15, 23, 42, 0.38);
}

.sap-ink-picker {
	display: inline-flex;
	align-items: center;
	gap: 0.42rem;
	flex: none;
}

.sap-ink-picker-label {
	margin-right: 0.12rem;
	font-size: 0.76rem;
	font-weight: 600;
	color: rgba(15, 23, 42, 0.56);
}

.sap-ink-swatch {
	appearance: none;
	width: 22px;
	height: 22px;
	padding: 0;
	border: 1px solid rgba(44, 50, 66, 0.25);
	border-radius: 50%;
	box-shadow: none;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.sap-ink-swatch:hover {
	transform: translateY(-1px);
	border-color: rgba(44, 50, 66, 0.55);
}

.sap-ink-swatch:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.sap-ink-swatch.is-selected {
	border-color: #2c3242;
	box-shadow: inset 0 0 0 2px #fff;
}

.sap-preview-paper {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 198px;
	padding: 40px 28px;
	border-radius: 14px;
	background: radial-gradient(120% 120% at 30% 20%, #fcfaf5, #f3efe6 60%, #ece7da);
	overflow: hidden;
	box-sizing: border-box;
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.7),
		0 18px 40px -22px rgba(40, 36, 28, 0.45),
		0 2px 6px rgba(40, 36, 28, 0.08);
}

.sap-preview-grain {
	position: absolute;
	inset: 0;
	background-image:
		radial-gradient(circle at 18% 32%, rgba(84, 72, 50, 0.08) 0 0.55px, transparent 0.8px),
		radial-gradient(circle at 72% 68%, rgba(84, 72, 50, 0.06) 0 0.45px, transparent 0.75px),
		radial-gradient(circle at 46% 84%, rgba(255, 255, 255, 0.5) 0 0.6px, transparent 0.9px);
	background-size: 7px 7px, 11px 11px, 9px 9px;
	mix-blend-mode: multiply;
	opacity: 0.5;
	pointer-events: none;
}

.sap-ink-impression {
	position: relative;
	z-index: 1;
	display: flex;
	justify-content: center;
	width: 100%;
	color: #1f3f86;
	opacity: 0.92;
	transform: rotate(-0.5deg);
	-webkit-mask-image: radial-gradient(140% 120% at 28% 22%, #000 70%, rgba(0, 0, 0, 0.82) 88%, rgba(0, 0, 0, 0.7) 100%);
	mask-image: radial-gradient(140% 120% at 28% 22%, #000 70%, rgba(0, 0, 0, 0.82) 88%, rgba(0, 0, 0, 0.7) 100%);
}

.sap-stamp-frame {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 118px;
	padding: 26px 34px;
	overflow: hidden;
	box-sizing: border-box;
}

.sap-stamp-lines {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-width: 0;
	color: currentColor;
	text-align: center;
}

.sap-preview-line {
	flex: none;
	min-height: 1.18em;
	max-width: 100%;
	color: currentColor;
	line-height: 1.18;
	letter-spacing: 0.02em;
	text-align: center;
	white-space: nowrap;
	user-select: none;
	box-sizing: border-box;
}

@media (max-width: 480px) {
	.sap-preview-header {
		align-items: flex-start;
		flex-direction: column;
		gap: 0.55rem;
	}

	.sap-preview-paper {
		padding: 32px 18px;
	}

	.sap-stamp-frame {
		padding: 24px 22px;
	}
}

/* ─── ROW 4: qty / add-to-cart / meta ───────────────────── */

.sap-custom-layout .sap-row--purchase {
	padding: 1rem 1.25rem;
	background: rgba(15, 23, 42, 0.025);
	border: 1px solid rgba(15, 23, 42, 0.08);
	border-radius: 8px;
}

/* Purchase row: meta on the left, qty+button on the right at 50% */
.sap-custom-layout .sap-row--purchase {
	display: flex;
	align-items: center;
	gap: 1.5rem;
}

.sap-custom-layout #sap-purchase-row .product_meta {
	flex: 1;
}

.sap-custom-layout #sap-purchase-row .single_variation_wrap {
	flex: 0 0 50%;
	display: flex;
	justify-content: flex-end;
	order: 2;
	margin-bottom: 0;
}

/* Meta: SKU / Category */
.sap-custom-layout #sap-purchase-row .product_meta {
	font-size: 0.85rem;
}

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

@media (max-width: 768px) {
	.sap-custom-layout .sap-row--swatches,
	.sap-custom-layout .sap-editor-grid {
		grid-template-columns: 1fr;
	}

	.sap-custom-layout .sap-swatches-col--attrs table.variations tbody {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.75rem;
	}
}
