.customthings-customizer-root {
	margin-top: 12px;
}

.customthings-customizer-button {
	display: inline-block;
	position: relative;
	min-height: 44px;
	padding: 12px 24px;
	font-size: 16px;
	font-weight: 600;
	color: #111;
	background: #fff;
	border: none;
	cursor: pointer;
	transition: all 0.3s ease;
	overflow: visible;
	box-sizing: border-box;
	z-index: 1;
}

.customthings-customizer-button--loading {
	opacity: 0.8;
}

.customthings-customizer-button--active {
	position: relative;
	z-index: 1;
}

.customthings-customizer-button--active::before {
	content: "";
	position: absolute;
	inset: -3px;
	border-radius: 12px;
	background: linear-gradient(
		90deg,
		#4f46e5 0%,
		#7c3aed 25%,
		#ec4899 50%,
		#f59e0b 75%,
		#eab308 100%
	);
	z-index: -2;
}

.customthings-customizer-button--active::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 8px;
	background: #fff;
	z-index: -1;
}

.customthings-customizer-button--active:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.customthings-customizer-button--active:active {
	transform: translateY(0);
}

.customthings-customizer-button--inactive {
	opacity: 0.4;
	color: #111;
	cursor: not-allowed;
	filter: contrast(0.4);
}

.customthings-customizer-button--inactive:hover {
	opacity: 0.5;
}

/* 必填附加字段未完成：视觉置灰，但仍可点击以触发字段定位提示。 */
.customthings-customizer-button--blocked {
	opacity: 0.45;
	cursor: not-allowed;
	filter: grayscale(1);
}

.customthings-customizer-button--blocked:hover {
	transform: none;
	box-shadow: none;
}

.customthings-required-message {
	margin-top: 8px;
	font-size: 13px;
	line-height: 1.4;
	color: #b32d2e;
}

.customthings-required-message[hidden] {
	display: none !important;
}

.customthings-customizer-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	/* 中和主题/区块（如 wp-block-add-to-cart-form）给子元素加的间距，
	   否则 fixed 容器会被 margin 顶偏、底部溢出视口。 */
	margin: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	/* 高度跟随动态视口：dvh 会随移动端地址栏/工具栏显隐实时变化，
	   且在 DevTools 设备模拟与真机下都能正确反映可视高度（优于 visualViewport 实测）。 */
	height: 100vh;
	height: 100dvh;
	/* 预留刘海/状态栏安全区，避免 standalone/PWA 下顶部内容被遮。 */
	padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
		env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
	box-sizing: border-box;
}

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

/* 登录态下避开 WordPress 后台管理栏（移动端 46px / 桌面 ≥783px 时 32px）。
   普通顾客无管理栏，不受影响。 */
body.admin-bar .customthings-customizer-modal {
	top: 46px;
	height: calc(100vh - 46px);
	height: calc(100dvh - 46px);
}

@media screen and (min-width: 783px) {
	body.admin-bar .customthings-customizer-modal {
		top: 32px;
		height: calc(100vh - 32px);
		height: calc(100dvh - 32px);
	}
}

.customthings-customizer-modal__backdrop {
	/* 固定铺满整屏：覆盖地址栏等可视区域外的部分，保证遮罩无缝。 */
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
}

.customthings-customizer-modal__panel {
	position: relative;
	/* 尺寸相对动态可视区域（容器高度 = dvh）计算，上下左右各留 16px 间距，
	   保证 iframe 顶部的“加入购物车”工具栏完整可见、不贴边、不被遮挡。 */
	width: min(1100px, calc(100% - 32px));
	height: min(760px, calc(100% - 32px));
	background: #fff;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
	z-index: 1;
}

.customthings-customizer-modal__iframe {
	width: 100%;
	height: 100%;
	border: 0;
}

/* iframe 加载期间覆盖在面板上的加载层，避免长时间纯白屏。 */
.customthings-customizer-modal__loading {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	background: #fff;
	transition: opacity 0.25s ease;
}

/* iframe 加载完成后由 JS 加上该类淡出并移除。 */
.customthings-customizer-modal__loading--hidden {
	opacity: 0;
	pointer-events: none;
}

.customthings-customizer-modal__loading[hidden] {
	display: none !important;
}

.customthings-customizer-modal__spinner {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 3px solid rgba(0, 0, 0, 0.12);
	border-top-color: #4f46e5;
	animation: customthings-spin 0.8s linear infinite;
}

.customthings-customizer-modal__loading-text {
	font-size: 14px;
	color: #666;
}

@keyframes customthings-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.customthings-customizer-modal__spinner {
		animation-duration: 1.6s;
	}
}

.customthings-modal-open {
	overflow: hidden;
}
