/* ==== Checkout Terms Modal — UI v2 ==== */

/* 觸發連結 */
.wpbr-ct-label .wpbr-ct-open-modal,
.wpbr-ct-label a {
	cursor: pointer;
	color: #2271b1;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
	transition: color 0.15s ease;
}
.wpbr-ct-label .wpbr-ct-open-modal:hover,
.wpbr-ct-label a:hover {
	color: #135e96;
	text-decoration-thickness: 2px;
}

.wpbr-ct-field .required {
	color: #b32d2e;
	text-decoration: none;
}

/* ===== Modal 容器 ===== */
.wpbr-ct-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 99999;
	align-items: center;
	justify-content: center;
	padding: 24px;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
}

.wpbr-ct-modal.is-open {
	display: flex;
	animation: wpbrCtFadeIn 0.2s ease-out;
}

@keyframes wpbrCtFadeIn {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes wpbrCtSlideUp {
	from {
		opacity: 0;
		transform: translateY(20px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* ===== 遮罩 ===== */
.wpbr-ct-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.7);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
}

/* ===== Dialog ===== */
.wpbr-ct-modal__dialog {
	position: relative;
	background: #fff;
	width: min(760px, 100%);
	max-height: calc(100vh - 48px);
	border-radius: 14px;
	box-shadow:
		0 10px 25px rgba(0, 0, 0, 0.15),
		0 30px 80px rgba(0, 0, 0, 0.25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: wpbrCtSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== Header（漸層頂條） ===== */
.wpbr-ct-modal__header {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 22px 26px;
	background: linear-gradient(135deg, #ff8a3c 0%, #e67e22 100%);
	color: #fff;
	flex: 0 0 auto;
}

.wpbr-ct-modal__title {
	margin: 0;
	font-size: 1.2rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	line-height: 1.4;
}

.wpbr-ct-modal__close {
	background: rgba(255, 255, 255, 0.18);
	border: 0;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	color: #fff;
	padding: 0;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, transform 0.15s ease;
}

.wpbr-ct-modal__close:hover {
	background: rgba(255, 255, 255, 0.32);
	transform: rotate(90deg);
}

.wpbr-ct-modal__close:active {
	transform: rotate(90deg) scale(0.92);
}

/* ===== 滾動進度條 ===== */
.wpbr-ct-modal__progress {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 3px;
	background: rgba(255, 255, 255, 0.85);
	width: 0;
	transition: width 0.08s linear;
	box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* ===== Body wrap + body ===== */
.wpbr-ct-modal__body-wrap {
	position: relative;
	flex: 1 1 auto;
	min-height: 0; /* 關鍵：讓 flex item 可以縮小，內部 overflow 才有意義 */
	display: flex;
	overflow: hidden;
}

.wpbr-ct-modal__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 26px 30px;
	-webkit-overflow-scrolling: touch;
	line-height: 1.8;
	color: #2d3748;
	font-size: 0.95rem;
	box-sizing: border-box;
	width: 100%;
	scroll-behavior: smooth;
}

/* 自訂滾動條 */
.wpbr-ct-modal__body::-webkit-scrollbar {
	width: 10px;
}
.wpbr-ct-modal__body::-webkit-scrollbar-track {
	background: #f5f5f5;
}
.wpbr-ct-modal__body::-webkit-scrollbar-thumb {
	background: #cbd5e0;
	border-radius: 5px;
}
.wpbr-ct-modal__body::-webkit-scrollbar-thumb:hover {
	background: #a0aec0;
}

/* 底部漸層遮罩 — 提示「下面還有」 */
.wpbr-ct-modal__body-wrap::after {
	content: "";
	position: absolute;
	left: 0;
	right: 10px;
	bottom: 0;
	height: 30px;
	background: linear-gradient(to top, rgba(255, 255, 255, 0.95) 30%, transparent);
	pointer-events: none;
	opacity: 1;
	transition: opacity 0.25s ease;
}
.wpbr-ct-modal.is-at-bottom .wpbr-ct-modal__body-wrap::after {
	opacity: 0;
}

/* 內文排版 */
.wpbr-ct-modal__body h1,
.wpbr-ct-modal__body h2,
.wpbr-ct-modal__body h3,
.wpbr-ct-modal__body h4 {
	margin: 1.5em 0 0.6em;
	color: #1a202c;
	font-weight: 700;
	line-height: 1.4;
}

.wpbr-ct-modal__body h1 { font-size: 1.4rem; }
.wpbr-ct-modal__body h2 { font-size: 1.15rem; padding-left: 12px; border-left: 4px solid #e67e22; }
.wpbr-ct-modal__body h3 { font-size: 1.05rem; }

.wpbr-ct-modal__body h1:first-child,
.wpbr-ct-modal__body h2:first-child,
.wpbr-ct-modal__body h3:first-child {
	margin-top: 0;
}

.wpbr-ct-modal__body p {
	margin: 0.7em 0;
}

.wpbr-ct-modal__body ul,
.wpbr-ct-modal__body ol {
	padding-left: 1.6em;
	margin: 0.7em 0;
}

.wpbr-ct-modal__body li {
	margin: 0.35em 0;
}

.wpbr-ct-modal__body a {
	color: #2271b1;
	text-decoration: underline;
}

.wpbr-ct-modal__body strong {
	color: #1a202c;
	font-weight: 700;
}

.wpbr-ct-modal__body blockquote {
	margin: 1em 0;
	padding: 0.6em 1em;
	border-left: 4px solid #cbd5e0;
	background: #f7fafc;
	color: #4a5568;
}

/* ===== Footer ===== */
.wpbr-ct-modal__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 16px 22px;
	background: #f8f9fa;
	border-top: 1px solid #e2e8f0;
	flex: 0 0 auto;
	flex-wrap: wrap;
}

.wpbr-ct-modal__hint {
	margin: 0;
	font-size: 0.85rem;
	color: #718096;
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 1 1 auto;
}

.wpbr-ct-modal__hint::before {
	content: "↓";
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	background: #e2e8f0;
	color: #4a5568;
	border-radius: 50%;
	font-size: 0.75rem;
	font-weight: bold;
	flex-shrink: 0;
	animation: wpbrCtBounce 1.6s ease-in-out infinite;
}

@keyframes wpbrCtBounce {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(3px); }
}

.wpbr-ct-modal__hint.is-ok {
	color: #2f855a;
}
.wpbr-ct-modal__hint.is-ok::before {
	content: "✓";
	background: #2f855a;
	color: #fff;
	animation: none;
}

/* ===== Agree button ===== */
.wpbr-ct-modal__agree {
	background: linear-gradient(135deg, #ff8a3c 0%, #e67e22 100%);
	color: #fff;
	border: 0;
	padding: 11px 28px;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 700;
	font-size: 0.95rem;
	letter-spacing: 0.03em;
	transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
	box-shadow: 0 2px 6px rgba(230, 126, 34, 0.35);
}

.wpbr-ct-modal__agree:hover:not(:disabled) {
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(230, 126, 34, 0.5);
}

.wpbr-ct-modal__agree:active:not(:disabled) {
	transform: translateY(0);
}

.wpbr-ct-modal__agree:disabled {
	background: #cbd5e0;
	box-shadow: none;
	cursor: not-allowed;
	opacity: 0.7;
}

/* Body scroll lock */
body.wpbr-ct-modal-open {
	overflow: hidden;
}

/* ===== Checkbox 強調 ===== */
.wpbr-ct-field {
	background: #fff8f0;
	border: 1px solid #f4d3a8;
	border-radius: 6px;
	padding: 12px 14px;
	margin-top: 12px !important;
	margin-bottom: 12px !important;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.wpbr-ct-field .wpbr-ct-label {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	line-height: 1.5;
}

.wpbr-ct-field .wpbr-ct-checkbox {
	margin-top: 3px;
	cursor: pointer;
	flex-shrink: 0;
}

/* ===== 未勾錯誤狀態 ===== */
.wpbr-ct-field--error {
	background: #fff5f5;
	border-color: #fc8181;
	box-shadow: 0 0 0 3px rgba(252, 129, 129, 0.18);
}

@keyframes wpbrCtShake {
	0%, 100% { transform: translateX(0); }
	15%      { transform: translateX(-8px); }
	30%      { transform: translateX(8px); }
	45%      { transform: translateX(-6px); }
	60%      { transform: translateX(6px); }
	75%      { transform: translateX(-3px); }
	90%      { transform: translateX(3px); }
}

.wpbr-ct-shake {
	animation: wpbrCtShake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* ===== 警告泡泡 ===== */
.wpbr-ct-warning {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 10px;
	padding: 10px 14px;
	background: #fff5f5;
	border: 1.5px solid #fc8181;
	border-radius: 6px;
	color: #c53030;
	font-size: 0.92rem;
	font-weight: 600;
	animation: wpbrCtFadeIn 0.25s ease-out;
	flex-wrap: wrap;
}

.wpbr-ct-warning__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	background: #c53030;
	color: #fff;
	border-radius: 50%;
	font-size: 0.85rem;
	flex-shrink: 0;
	font-weight: bold;
}

.wpbr-ct-warning__text {
	flex: 1 1 auto;
	line-height: 1.5;
}

.wpbr-ct-warning__cta {
	background: #c53030;
	color: #fff;
	border: 0;
	padding: 6px 14px;
	border-radius: 4px;
	font-weight: 600;
	font-size: 0.88rem;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s ease;
	white-space: nowrap;
}

.wpbr-ct-warning__cta:hover {
	background: #9b2c2c;
}

.wpbr-ct-warning__cta:active {
	transform: scale(0.97);
}

/* Loading state for terms body */
.wpbr-ct-modal__loader {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 60px 20px;
	color: #718096;
	min-height: 200px;
}

.wpbr-ct-modal__spinner {
	width: 36px;
	height: 36px;
	border: 3px solid #e2e8f0;
	border-top-color: #e67e22;
	border-radius: 50%;
	animation: wpbrCtSpin 0.8s linear infinite;
}

@keyframes wpbrCtSpin {
	to { transform: rotate(360deg); }
}

.wpbr-ct-modal__error {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 40px 24px;
	color: #c53030;
	text-align: center;
	min-height: 200px;
}

.wpbr-ct-modal__error-icon {
	font-size: 2.5rem;
}

.wpbr-ct-modal__error-msg {
	font-size: 0.95rem;
	line-height: 1.6;
}

.wpbr-ct-modal__error-retry {
	background: #fff;
	color: #e67e22;
	border: 1.5px solid #e67e22;
	padding: 8px 18px;
	border-radius: 6px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.15s ease;
}

.wpbr-ct-modal__error-retry:hover {
	background: #e67e22;
	color: #fff;
}

/* ===== 手機調整 ===== */
@media (max-width: 600px) {
	.wpbr-ct-modal {
		padding: 12px;
	}
	.wpbr-ct-modal__dialog {
		max-height: calc(100vh - 24px);
		border-radius: 10px;
	}
	.wpbr-ct-modal__header {
		padding: 16px 18px;
	}
	.wpbr-ct-modal__title {
		font-size: 1.05rem;
	}
	.wpbr-ct-modal__body {
		padding: 18px 20px;
		font-size: 0.92rem;
	}
	.wpbr-ct-modal__footer {
		padding: 12px 16px;
	}
	.wpbr-ct-modal__hint {
		flex: 1 1 100%;
		order: 1;
		justify-content: center;
	}
	.wpbr-ct-modal__agree {
		order: 2;
		width: 100%;
		padding: 13px 20px;
	}
}
