/**
 * Checkout UX — modern SaaS layout (theme branding only).
 */

body.fsa-checkout-ux,
body.edd-checkout.fsa-checkout-ux {
	background: linear-gradient(180deg, #f7f9fb 0%, #ffffff 42%);
}

body.fsa-checkout-ux .fsa-content--page .fsa-prose,
body.fsa-checkout-ux .fsa-page-layout--no-sidebar .fsa-prose {
	max-width: 1120px;
	margin-left: auto;
	margin-right: auto;
}

/* —— Shell grid: form left, sticky summary right —— */
.fsa-checkout-shell,
#edd_checkout_wrap.fsa-checkout-shell {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
	gap: 1.15rem 1.5rem;
	align-items: start;
	margin: 0.5rem 0 2.5rem;
}

.fsa-checkout-shell > #edd_checkout_cart_form,
.fsa-checkout-shell > .fsa-checkout-summary {
	grid-column: 2;
	grid-row: 1;
	position: sticky;
	top: calc(var(--fsa-sticky-header-height, 7rem) + 1rem);
	z-index: 2;
}

.fsa-checkout-shell > #edd_checkout_form_wrap,
.fsa-checkout-shell > .fsa-checkout-main {
	grid-column: 1;
	grid-row: 1;
}

/* —— EDD Checkout block: force 2 columns (form left, cart sticky right) —— */
@media (min-width: 48rem) {
	body.fsa-checkout-ux #edd_checkout_form_wrap.wp-block-edd-checkout,
	body.fsa-checkout-ux .wp-block-edd-checkout.edd-blocks__checkout {
		display: grid !important;
		grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr) !important;
		gap: 1rem 1.35rem;
		align-items: start;
	}

	body.fsa-checkout-ux #edd_checkout_form_wrap.wp-block-edd-checkout > .edd-blocks__cart,
	body.fsa-checkout-ux .wp-block-edd-checkout > .edd-blocks__cart {
		grid-column: 2 !important;
		grid-row: 1 / span 40;
		position: sticky;
		top: calc(var(--fsa-sticky-header-height, 7rem) + 0.75rem);
		align-self: start;
		z-index: 2;
	}

	body.fsa-checkout-ux #edd_checkout_form_wrap.wp-block-edd-checkout > *:not(.edd-blocks__cart),
	body.fsa-checkout-ux .wp-block-edd-checkout > *:not(.edd-blocks__cart) {
		grid-column: 1 !important;
		min-width: 0;
	}

	body.fsa-checkout-ux #edd_checkout_form_wrap.wp-block-edd-checkout > .edd-blocks__logged-in,
	body.fsa-checkout-ux .wp-block-edd-checkout > .edd-blocks__logged-in {
		grid-column: 1 / -1 !important;
	}
}

@media (max-width: 47.99875rem) {
	body.fsa-checkout-ux #edd_checkout_form_wrap.wp-block-edd-checkout,
	body.fsa-checkout-ux .wp-block-edd-checkout.edd-blocks__checkout {
		grid-template-columns: 1fr !important;
	}

	body.fsa-checkout-ux #edd_checkout_form_wrap.wp-block-edd-checkout > .edd-blocks__cart,
	body.fsa-checkout-ux .wp-block-edd-checkout > .edd-blocks__cart {
		grid-column: 1 !important;
		grid-row: auto;
		position: static;
		order: 99;
	}
}

body.fsa-checkout-ux .edd-blocks__cart .fsa-checkout-section-label--order {
	margin: 0 0 0.5rem;
}

body.fsa-checkout-ux .edd-blocks__cart #edd_checkout_cart_form,
body.fsa-checkout-ux .edd-blocks__cart .edd-blocks-form__cart {
	background: var(--fsa-background);
	border: 1px solid rgba(51, 51, 51, 0.12);
	border-radius: 12px;
	padding: 0.85rem 1rem;
	box-shadow: 0 8px 28px rgba(51, 51, 51, 0.07);
}

/* —— Cards —— */
.fsa-checkout-ux #edd_checkout_user_info,
.fsa-checkout-ux #tc-company-fields,
.fsa-checkout-ux #edd_cc_address,
.fsa-checkout-ux #edd_payment_mode_select,
.fsa-checkout-ux #edd_purchase_form_wrap,
.fsa-checkout-ux .fsa-checkout-billing-mode,
.fsa-checkout-ux #edd_terms_agreement,
.fsa-checkout-ux #edd-privacy-policy-agreement,
.fsa-checkout-ux #edd_purchase_submit,
.fsa-checkout-ux .edd-bt-checkout-details,
.fsa-checkout-ux .edd-bt-checkout-notice {
	background: var(--fsa-background);
	border: 1px solid rgba(51, 51, 51, 0.12);
	border-radius: 10px;
	padding: 0.85rem 0.95rem;
	margin: 0 0 0.75rem;
	box-shadow: 0 1px 2px rgba(51, 51, 51, 0.04);
}

.fsa-checkout-ux #edd_checkout_user_info legend,
.fsa-checkout-ux #tc-company-fields legend,
.fsa-checkout-ux #edd_cc_address legend,
.fsa-checkout-ux #edd_payment_mode_select legend {
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--fsa-secondary);
	padding: 0 0.25rem;
}

/* —— Section labels —— */
.fsa-checkout-section-label {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin: 0.15rem 0 0.5rem;
	font-size: 0.95rem;
	font-weight: 700;
	letter-spacing: 0.01em;
	color: var(--fsa-secondary);
}

.fsa-checkout-section-label__icon {
	display: inline-flex;
	width: 1.75rem;
	height: 1.75rem;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	background: rgba(3, 169, 244, 0.12);
	font-size: 0.95rem;
}

/* —— Order summary card —— */
.fsa-checkout-ux #edd_checkout_cart_form,
.fsa-checkout-ux .fsa-checkout-summary {
	background: var(--fsa-background);
	border: 1px solid rgba(51, 51, 51, 0.12);
	border-radius: 14px;
	padding: 1.15rem 1.2rem 1.25rem;
	box-shadow: 0 8px 28px rgba(51, 51, 51, 0.07);
}

.fsa-checkout-ux #edd_checkout_cart {
	width: 100%;
	border-collapse: collapse;
	margin: 0;
}

.fsa-checkout-ux #edd_checkout_cart th,
.fsa-checkout-ux #edd_checkout_cart td {
	border: 0;
	border-bottom: 1px solid rgba(51, 51, 51, 0.08);
	padding: 0.7rem 0.35rem;
	text-align: left;
	vertical-align: top;
	font-size: 0.92rem;
}

.fsa-checkout-ux #edd_checkout_cart thead th {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: rgba(51, 51, 51, 0.62);
	font-weight: 700;
}

.fsa-checkout-ux #edd_checkout_cart .edd_cart_footer_row th,
.fsa-checkout-ux #edd_checkout_cart .edd_cart_footer_row td {
	border-bottom: 0;
	padding-top: 0.85rem;
}

.fsa-checkout-ux #edd_checkout_cart .edd_cart_total {
	font-size: 1.15rem;
	font-weight: 800;
	color: var(--fsa-secondary);
}

.fsa-checkout-ux .edd_cart_remove_item_btn {
	color: var(--fsa-primary);
	font-size: 0.8rem;
}

.fsa-checkout-ux .fsa-summary-payment {
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
	margin-top: 0.85rem;
	padding-top: 0.85rem;
	border-top: 1px dashed rgba(51, 51, 51, 0.14);
	font-size: 0.88rem;
}

.fsa-checkout-ux .fsa-summary-payment__label {
	color: rgba(51, 51, 51, 0.65);
}

.fsa-checkout-ux .fsa-summary-payment__value {
	font-weight: 700;
	text-align: right;
}

/* —— Company Details: compact 2-col grid (CSS only, no ID/name changes) —— */
.fsa-checkout-ux #tc-company-fields {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: 0.75rem;
	row-gap: 0.45rem;
	align-items: stretch;
}

.fsa-checkout-ux #tc-company-fields > legend {
	grid-column: 1 / -1;
	margin: 0 0 0.15rem;
	float: none;
	width: auto;
}

.fsa-checkout-ux #tc-company-fields > p {
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	margin: 0;
	min-width: 0;
	height: 100%;
}

/* Full width only: Address + Notes */
.fsa-checkout-ux #tc-company-fields > p:has(#tc_company_address),
.fsa-checkout-ux #tc-company-fields > p:has(#tc_company_notes),
.fsa-checkout-ux #tc-company-fields > p:has([name="tc_company_address"]),
.fsa-checkout-ux #tc-company-fields > p:has([name="tc_company_notes"]),
.fsa-checkout-ux #tc-company-fields .fsa-field--full {
	grid-column: 1 / -1;
}

.fsa-checkout-ux #tc-company-fields .fsa-field {
	margin: 0;
}

/* —— Fields —— */
.fsa-checkout-ux #edd_purchase_form label,
.fsa-checkout-ux #tc-company-fields label {
	display: block;
	margin: 0 0 0.2rem;
	font-size: 0.75rem;
	font-weight: 650;
	line-height: 1.25;
	color: rgba(51, 51, 51, 0.88);
}

.fsa-checkout-ux #edd_purchase_form .edd-input,
.fsa-checkout-ux #edd_purchase_form input[type="text"],
.fsa-checkout-ux #edd_purchase_form input[type="email"],
.fsa-checkout-ux #edd_purchase_form input[type="tel"],
.fsa-checkout-ux #edd_purchase_form input[type="password"],
.fsa-checkout-ux #edd_purchase_form input[type="number"],
.fsa-checkout-ux #edd_purchase_form select,
.fsa-checkout-ux #edd_purchase_form textarea,
.fsa-checkout-ux #tc-company-fields input,
.fsa-checkout-ux #tc-company-fields select,
.fsa-checkout-ux #tc-company-fields textarea {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	border: 1px solid rgba(51, 51, 51, 0.18);
	border-radius: 7px;
	padding: 0.45rem 0.6rem;
	font-size: 0.875rem;
	line-height: 1.3;
	background: #fff;
	color: var(--fsa-text, #333);
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.fsa-checkout-ux #tc-company-fields input,
.fsa-checkout-ux #tc-company-fields select,
.fsa-checkout-ux #tc-company-fields textarea {
	flex: 1 1 auto;
	min-height: 2.15rem;
}

.fsa-checkout-ux #tc-company-fields textarea {
	min-height: 4.25rem;
	resize: vertical;
}

.fsa-checkout-ux #edd_purchase_form .edd-input:hover,
.fsa-checkout-ux #tc-company-fields input:hover,
.fsa-checkout-ux #edd_purchase_form select:hover {
	border-color: rgba(3, 169, 244, 0.45);
}

.fsa-checkout-ux #edd_purchase_form .edd-input:focus,
.fsa-checkout-ux #edd_purchase_form input:focus,
.fsa-checkout-ux #edd_purchase_form select:focus,
.fsa-checkout-ux #edd_purchase_form textarea:focus,
.fsa-checkout-ux #tc-company-fields input:focus,
.fsa-checkout-ux #tc-company-fields select:focus,
.fsa-checkout-ux #tc-company-fields textarea:focus,
.fsa-checkout-ux .fsa-field-focus {
	outline: none;
	border-color: var(--fsa-primary);
	box-shadow: 0 0 0 3px rgba(3, 169, 244, 0.18);
}

.fsa-checkout-ux .fsa-field-invalid,
.fsa-checkout-ux .edd-invalid {
	border-color: #d64545 !important;
	box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.14) !important;
}

.fsa-checkout-ux .fsa-field-valid {
	border-color: #2f9e6b !important;
	box-shadow: 0 0 0 3px rgba(47, 158, 107, 0.12) !important;
}

.fsa-checkout-ux .edd-description {
	display: block;
	margin: 0.2rem 0 0.45rem;
	font-size: 0.78rem;
	color: rgba(51, 51, 51, 0.58);
}

/* —— Billing mode —— */
.fsa-checkout-billing-mode .fsa-billing-mode-fieldset {
	border: 0;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.55rem;
}

.fsa-billing-mode-option {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	margin: 0;
	padding: 0.75rem 0.85rem;
	border: 1px solid rgba(51, 51, 51, 0.14);
	border-radius: 10px;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.fsa-billing-mode-option:hover {
	border-color: rgba(3, 169, 244, 0.45);
	background: rgba(3, 169, 244, 0.04);
}

.fsa-billing-mode-option:has(input:checked) {
	border-color: var(--fsa-primary);
	background: rgba(3, 169, 244, 0.08);
}

.fsa-billing-mode-option input {
	margin-top: 0.2rem;
	accent-color: var(--fsa-primary);
}

.fsa-billing-mode-option__text {
	font-size: 0.92rem;
	font-weight: 600;
	line-height: 1.35;
}

.fsa-billing-mode-hint {
	margin: 0.75rem 0 0;
	font-size: 0.82rem;
	color: rgba(51, 51, 51, 0.62);
}

/* Billing details: hidden by default (company), smooth open when different */
body.fsa-billing-mode-company #edd_cc_address,
.fsa-checkout-billing-mode.is-company #edd_cc_address {
	max-height: 0;
	opacity: 0;
	margin: 0 !important;
	padding: 0 !important;
	border-width: 0 !important;
	overflow: hidden;
	pointer-events: none;
	transform: translateY(-4px);
	transition: max-height 0.3s ease, opacity 0.22s ease, margin 0.22s ease, padding 0.22s ease, transform 0.22s ease;
}

body.fsa-billing-mode-different #edd_cc_address,
.fsa-checkout-billing-mode.is-different #edd_cc_address,
#edd_cc_address.fsa-billing-panel-open {
	max-height: 1600px;
	opacity: 1;
	pointer-events: auto;
	margin-top: 0.85rem !important;
	padding: 1.15rem 1.2rem !important;
	border-width: 1px !important;
	overflow: visible;
	transform: none;
}

/* —— Payment method cards —— */
.fsa-checkout-ux #edd-payment-mode-wrap,
.fsa-checkout-ux #edd_payment_mode_select .edd-gateway-option,
.fsa-checkout-ux #edd-payment-mode-wrap {
	display: grid;
	gap: 0.65rem;
}

.fsa-checkout-ux #edd-payment-mode-wrap {
	grid-template-columns: 1fr;
}

.fsa-checkout-ux .fsa-gateway-card,
.fsa-checkout-ux label.edd-gateway-option {
	display: grid !important;
	grid-template-columns: auto 1fr;
	align-items: start;
	gap: 0.55rem 0.75rem;
	margin: 0 !important;
	padding: 0.95rem 1rem !important;
	border: 1px solid rgba(51, 51, 51, 0.14);
	border-radius: 12px;
	background: #fff;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
	position: relative;
}

.fsa-checkout-ux .fsa-gateway-card:hover,
.fsa-checkout-ux label.edd-gateway-option:hover {
	border-color: rgba(3, 169, 244, 0.5);
	box-shadow: 0 4px 14px rgba(51, 51, 51, 0.06);
}

.fsa-checkout-ux .fsa-gateway-card.is-selected,
.fsa-checkout-ux label.edd-gateway-option:has(input:checked) {
	border-color: var(--fsa-primary);
	background: rgba(3, 169, 244, 0.07);
	box-shadow: 0 0 0 3px rgba(3, 169, 244, 0.12);
}

.fsa-checkout-ux .fsa-gateway-card input,
.fsa-checkout-ux label.edd-gateway-option input {
	margin-top: 0.2rem;
	accent-color: var(--fsa-primary);
}

.fsa-checkout-ux .fsa-gateway-card__desc {
	grid-column: 2;
	display: block;
	margin-top: 0.15rem;
	font-size: 0.8rem;
	line-height: 1.4;
	color: rgba(51, 51, 51, 0.62);
	font-weight: 400;
}

.fsa-checkout-ux .fsa-gateway-card[data-gateway="viva_wallet"]::after,
.fsa-checkout-ux .fsa-gateway-card[data-gateway="bank_transfer"]::after {
	content: "";
	position: absolute;
	top: 0.95rem;
	right: 0.95rem;
	width: 1.65rem;
	height: 1.65rem;
	border-radius: 8px;
	background: rgba(3, 169, 244, 0.14);
}

.fsa-checkout-ux .fsa-gateway-card[data-gateway="bank_transfer"]::after {
	background: rgba(51, 51, 51, 0.1);
}

/* —— Terms / GDPR —— */
.fsa-checkout-ux #edd_terms_agreement,
.fsa-checkout-ux #edd-privacy-policy-agreement {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 0.55rem;
}

.fsa-checkout-ux #edd_terms_agreement input,
.fsa-checkout-ux #edd-privacy-policy-agreement input {
	margin-top: 0.2rem;
	accent-color: var(--fsa-primary);
	width: 1.05rem;
	height: 1.05rem;
}

.fsa-checkout-ux #edd_terms_agreement label,
.fsa-checkout-ux #edd-privacy-policy-agreement label {
	font-size: 0.9rem;
	font-weight: 500;
	margin: 0;
}

/* —— Purchase button —— */
.fsa-checkout-ux #edd_purchase_submit,
.fsa-checkout-ux #edd_purchase_form input[type="submit"],
.fsa-checkout-ux #edd_purchase_form button[type="submit"],
.fsa-checkout-ux #edd-purchase-button,
.fsa-checkout-ux .edd-submit {
	width: 100%;
	border: 0;
	border-radius: 10px;
	padding: 0.9rem 1.2rem;
	font-size: 1rem;
	font-weight: 750;
	cursor: pointer;
	background: var(--fsa-primary);
	color: #fff;
	transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.fsa-checkout-ux #edd_purchase_form input[type="submit"]:hover,
.fsa-checkout-ux #edd-purchase-button:hover,
.fsa-checkout-ux .edd-submit:hover {
	background: #0290d1;
	box-shadow: 0 8px 20px rgba(3, 169, 244, 0.28);
}

.fsa-checkout-ux #edd_purchase_form input[type="submit"]:focus-visible,
.fsa-checkout-ux #edd-purchase-button:focus-visible {
	outline: 3px solid rgba(3, 169, 244, 0.35);
	outline-offset: 2px;
}

.fsa-checkout-ux #edd_purchase_form input[type="submit"]:active {
	transform: translateY(1px);
}

/* Errors */
.fsa-checkout-ux .edd_errors,
.fsa-checkout-ux .edd-alert {
	border-radius: 10px;
	padding: 0.85rem 1rem;
	margin-bottom: 1rem;
}

/* Hide unused empty space from EDD default */
.fsa-checkout-ux #edd_checkout_form_wrap > *:empty {
	display: none;
}

.fsa-checkout-ux .edd-no-js {
	display: none;
}

/* —— Mobile: summary below + company 1-col —— */
@media (max-width: 61.99875rem) {
	.fsa-checkout-shell,
	#edd_checkout_wrap.fsa-checkout-shell {
		grid-template-columns: 1fr;
		gap: 1rem;
	}

	.fsa-checkout-shell > #edd_checkout_cart_form,
	.fsa-checkout-shell > .fsa-checkout-summary {
		grid-column: 1;
		grid-row: 2;
		position: static;
		order: 2;
	}

	.fsa-checkout-shell > #edd_checkout_form_wrap,
	.fsa-checkout-shell > .fsa-checkout-main {
		grid-column: 1;
		grid-row: 1;
		order: 1;
	}

	.fsa-checkout-ux #tc-company-fields,
	.fsa-checkout-ux #tc-company-fields.fsa-company-grid {
		grid-template-columns: 1fr;
		column-gap: 0;
		row-gap: 0.4rem;
	}

	.fsa-checkout-ux #tc-company-fields > p:has(#tc_company_address),
	.fsa-checkout-ux #tc-company-fields > p:has(#tc_company_notes),
	.fsa-checkout-ux #tc-company-fields > p:has([name="tc_company_address"]),
	.fsa-checkout-ux #tc-company-fields > p:has([name="tc_company_notes"]),
	.fsa-checkout-ux #tc-company-fields .fsa-field--full {
		grid-column: 1;
	}
}

@media (max-width: 35.99875rem) {
	.fsa-checkout-ux #edd_checkout_user_info,
	.fsa-checkout-ux #tc-company-fields,
	.fsa-checkout-ux #edd_cc_address,
	.fsa-checkout-ux .fsa-checkout-billing-mode,
	.fsa-checkout-ux #edd_payment_mode_select {
		padding: 0.7rem 0.75rem;
		border-radius: 10px;
	}

	.fsa-checkout-section-label {
		font-size: 0.9rem;
	}
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
	body.fsa-billing-mode-company #edd_cc_address,
	body.fsa-billing-mode-different #edd_cc_address,
	.fsa-checkout-ux * {
		transition: none !important;
	}
}

/* Screen reader */
.fsa-checkout-ux .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.is-hidden {
	display: none !important;
}
