/* WT39 Checkout — traditional checkout field visibility */

/* Representative fields: hidden by default, shown only when AADE method selected */
.wt39-repr-field,
.wt39-otp-field {
	display: none;
}

/* Suppress WC's auto-appended "(optional)" on repr fields — they're contextually required */
#billing_repr_identity_type_field .optional,
#billing_repr_identity_no_field .optional,
#billing_repr_mobile_field .optional {
	display: none;
}

/* OTP field: the WC-rendered wrapper is hidden — visible section is injected by JS */
#billing_repr_otp_field {
	display: none !important;
}

body.webexpert-39a-active.webexpert-39a-method-aade .wt39-repr-field {
	display: block;
}

body.webexpert-39a-otp-required .wt39-otp-field {
	display: block;
}

/* 39a checkbox: visible when invoice=y (invoice-only JS + blocks fallback) */
#billing_39a_field {
	display: none;
}

body.webexpert-invoice-active #billing_39a_field {
	display: block;
}

/* 39a info box: only visible when 39a checkbox is actually checked */
#billing_39a_info_field {
	display: none !important;
}

body.webexpert-39a-active #billing_39a_info_field {
	display: block !important;
}

/* ── Validate button + result ────────────────────────────────────────────── */

.wt39-verify-btn,
.wt39-upload-btn {
	background-color: #333 !important;
	color: #fff !important;
	border-color: #333 !important;
}

.wt39-verify-btn {
	display: inline-flex !important;
	align-items: center;
	gap: 6px;
}

.wt39-verify-spinner {
	display: none;
	width: 12px;
	height: 12px;
	border: 2px solid rgba(0,0,0,.2);
	border-top-color: #555;
	border-radius: 50%;
	animation: wt39-spin .6s linear infinite;
	flex-shrink: 0;
}

.wt39-verify-btn.is-loading .wt39-verify-spinner {
	display: inline-block;
}

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

.wt39-verify-wrap {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	clear: both;
	width: 100%;
	margin-top: 8px;
}

.wt39-verify-msg {
	padding: 5px 10px;
	border-radius: 3px;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.4;
}

.wt39-verify-msg.success {
	background: #edfaef;
	border: 1px solid #b8e6be;
	color: #0a7a1e;
}

.wt39-verify-msg.error {
	background: #fcf0f1;
	border: 1px solid #f0b8b8;
	color: #a10b0d;
}

/* ── Floating label fix for injected AADE repr fields (blocks checkout) ──── */

.wt39-aade-section .wc-block-components-text-input {
	position: relative;
}

.wt39-aade-section .wc-block-components-text-input label {
	position: absolute;
	top: 50%;
	left: 0;
	transform: translateY(-50%);
	font-size: 1em;
	color: #757575;
	pointer-events: none;
	margin: 0;
	padding: 0 0 0 1px;
	transition: top .1s ease, font-size .1s ease, transform .1s ease;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

.wt39-aade-section .wc-block-components-text-input.has-text label,
.wt39-aade-section .wc-block-components-text-input.is-active label,
.wt39-aade-section .wc-block-components-text-input input:not(:placeholder-shown) + label {
	top: 0;
	transform: translateY(-50%);
	font-size: 0.72em;
	background: #fff;
	padding: 0 4px;
}

.wt39-aade-section .wc-block-components-text-input input {
	padding-top: 20px !important;
	padding-bottom: 6px !important;
}

/* ── OTP section (injected dynamically after verification) ───────────────── */

.wt39-otp-section {
	margin-top: 12px;
	padding: 12px 14px;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 4px;
	clear: both;
	float: left;
	width: 100%;
	box-sizing: border-box;
}

.wt39-otp-section__title {
	font-weight: 600;
	font-size: 13px;
	margin: 0 0 2px;
	color: #1e1e1e;
}

.wt39-otp-section__hint {
	font-size: 12px;
	color: #757575;
	margin: 0 0 8px;
}

.wt39-otp-input {
	width: 140px !important;
	max-width: 100%;
	font-size: 15px !important;
	letter-spacing: 2px;
	text-align: center;
	padding: 8px 10px !important;
	display: inline-block !important;
}

/* ── OTP check button & result ───────────────────────────────────────────── */

.wt39-otp-check-wrap {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	margin-top: 8px;
}

.wt39-otp-check-btn {
	font-size: 13px !important;
	padding: 6px 12px !important;
	height: auto !important;
	line-height: 1.4 !important;
}

.wt39-otp-check-msg {
	padding: 5px 9px;
	border-radius: 3px;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.4;
}

.wt39-otp-check-msg.success {
	background: #edfaef;
	border: 1px solid #b8e6be;
	color: #0a7a1e;
}

.wt39-otp-check-msg.error {
	background: #fcf0f1;
	border: 1px solid #f0b8b8;
	color: #a10b0d;
}

/* Legacy inline result (kept for backwards compat) */
.wt39-verify-result {
	display: inline-block;
	margin-left: 8px;
	font-size: 13px;
}
.wt39-verify-result.success { color: #46b450; }
.wt39-verify-result.error   { color: #dc3232; }

/* ── Terms description block (above 39a checkbox) ────────────────────────── */

.wt39-terms-desc {
	display: block;
	margin: 10px 0;
	padding: 12px 16px;
	background: #f6f2fb;
	border: 1px solid #c9b3e0;
	border-radius: 4px;
	font-size: 13px;
	line-height: 1.6;
	color: #333;
	clear: both;
	float: left;
	width: 100%;
	box-sizing: border-box;
}

.wt39-terms-desc a {
	color: #7f54b3;
	text-decoration: underline;
}

.wt39-terms-desc a:hover {
	color: #6a4499;
}

/* ── Terms modal ─────────────────────────────────────────────────────────── */

.wt39-modal-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .55);
	z-index: 99999;
	align-items: center;
	justify-content: center;
	padding: 20px;
	box-sizing: border-box;
}

.wt39-modal-overlay.is-open {
	display: flex;
}

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

.wt39-modal__box {
	background: #fff;
	border-radius: 8px;
	max-width: 640px;
	width: 100%;
	max-height: 80vh;
	display: flex;
	flex-direction: column;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}

.wt39-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid #e0e0e0;
	flex-shrink: 0;
}

.wt39-modal__title {
	font-size: 15px;
	font-weight: 600;
	margin: 0;
}

.wt39-modal__close {
	background: none;
	border: none;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	color: #555;
	padding: 0 0 0 12px;
	flex-shrink: 0;
}

.wt39-modal__close:hover {
	color: #000;
}

.wt39-modal__body {
	padding: 20px;
	overflow-y: auto;
	font-size: 14px;
	line-height: 1.6;
}

/* ── AADE section (blocks checkout — repr fields injected by JS) ─────────── */
/* Uses WC blocks native classes (wc-block-components-text-input,
   wc-blocks-components-select) — WC's own CSS handles field appearance */

.wt39-aade-section {
	clear: both;
	margin-bottom: 4px;
}

.wt39-repr-fields {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	margin-bottom: 8px;
}

.wt39-repr-fields .wt39-field-group {
	flex: 1 0 calc(50% - 8px);
	box-sizing: border-box;
	margin-bottom: 0;
}

/* Select (identity type) always full-width */
.wt39-repr-fields .wt39-field-group:first-child {
	flex: 0 0 100%;
}

/* ── Method selector ─────────────────────────────────────────────────────── */

.wt39-method-selector {
	width: 100%;
	float: left;
	clear: both;
	margin: 6px 0 14px;
	box-sizing: border-box;
}

.wt39-method-options {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 12px;
}

.wt39-method-option {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	background: #fff;
	font-weight: 400;
	transition: border-color 0.15s, background 0.15s;
}

/* Blocks checkout: match WC border style */
.wc-block-checkout .wt39-method-option {
	border-color: hsla(0, 0%, 7%, .8);
}

.wt39-method-option:has(input:checked) {
	border-color: #7f54b3;
	background: #f6f2fb;
}

.wt39-method-option input[type="radio"] {
	margin: 0;
	cursor: pointer;
}

/* ── Dropzone ─────────────────────────────────────────────────────────────── */

.wt39-upload-section {
	clear: both;
	margin-bottom: 12px;
}

.wt39-upload-desc {
	margin: 0 0 10px;
	font-size: 13px;
	color: #555;
	line-height: 1.5;
}

.wt39-dropzone {
	border: 2px dashed #c3c4c7;
	border-radius: 4px;
	padding: 28px 20px 20px;
	text-align: center;
	cursor: pointer;
	background: #fafafa;
	transition: border-color 0.2s, background 0.2s;
	user-select: none;
}

.wt39-dropzone:hover,
.wt39-dropzone--dragover {
	border-color: #7f54b3;
	background: #f6f2fb;
}

.wt39-dropzone--uploaded {
	border-color: #46b450;
	background: #f5fff6;
}

.wt39-dropzone-text {
	margin: 0 0 4px;
	font-weight: 500;
	color: #333;
}

.wt39-dropzone-hint {
	margin: 0 0 14px;
	font-size: 12px;
	color: #777;
}

.wt39-upload-btn {
	display: inline-block;
	pointer-events: auto;
}

.wt39-upload-status {
	display: block;
	margin-top: 10px;
	font-size: 13px;
}
.wt39-upload-status.success { color: #46b450; }
.wt39-upload-status.error   { color: #dc3232; }
