/**
 * Checkout — high-conversion layout.
 *
 * Theming via CSS custom properties (BTF-compatible):
 * --bcom-co-max-width: 1100px
 * --bcom-co-bg: #fff
 * --bcom-co-aside-bg: #fafafa
 * --bcom-accent: #111
 * --bcom-accent-hover: #333
 * --bcom-border: #e0e0e0
 * --bcom-text: #1a1a1a
 * --bcom-text-muted: #717171
 * --bcom-field-bg: #fff
 * --bcom-field-border: #d0d0d0
 * --bcom-field-focus: #111
 * --bcom-radius: 6px
 * --bcom-success: #27ae60
 * --bcom-error: #dc3232
 */

/* ─── Layout ─────────────────────────────────────────────────── */
.bcom-co {
	max-width: var(--bcom-co-max-width, 1100px);
	margin: 0 auto;
	padding: 40px 20px 60px;
	font-family: inherit;
	color: var(--boost-text, var(--bcom-text, #1a1a1a));
	-webkit-font-smoothing: antialiased;
	box-sizing: border-box;
}

/* Reset: prevent FSE/BTF theme global styles from breaking checkout */
#bcom-checkout input[type="text"],
#bcom-checkout input[type="email"],
#bcom-checkout input[type="tel"],
#bcom-checkout input[type="number"],
#bcom-checkout select {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--bcom-border, #e0e0e0);
	border-radius: var(--boost-radius, var(--bcom-radius, 6px));
	font-size: 15px;
	box-sizing: border-box;
	background: #fff;
	font-family: inherit;
	color: inherit;
}
.bcom-co__layout {
	display: grid;
	grid-template-columns: 1fr 380px;
	gap: 0;
}
.bcom-co__main {
	padding: 0 40px 0 0;
	border-right: 1px solid var(--bcom-border, #e0e0e0);
}
.bcom-co__aside {
	padding: 0 0 0 40px;
	position: relative;
}

/* ─── Errors ─────────────────────────────────────────────────── */
.bcom-co__errors:not(:empty) {
	background: #fef0f0;
	border: 1px solid var(--bcom-error, #dc3232);
	color: var(--bcom-error, #dc3232);
	padding: 12px 16px;
	border-radius: var(--bcom-radius, 6px);
	margin-bottom: 20px;
	font-size: 14px;
	line-height: 1.5;
}

/* ─── Express checkout ───────────────────────────────────────── */
.bcom-co__express {
	margin-bottom: 0;
}
.bcom-co__express-label {
	text-align: center;
	font-size: 13px;
	color: var(--bcom-text-muted, #717171);
	text-transform: uppercase;
	letter-spacing: .05em;
	margin-bottom: 12px;
}
.bcom-co__divider {
	display: flex;
	align-items: center;
	gap: 16px;
	margin: 24px 0;
	color: var(--bcom-text-muted, #717171);
	font-size: 13px;
}
.bcom-co__divider::before,
.bcom-co__divider::after {
	content: '';
	flex: 1;
	height: 1px;
	background: var(--bcom-border, #e0e0e0);
}

/* ─── Sections ───────────────────────────────────────────────── */
.bcom-co__section {
	margin-bottom: 28px;
}
.bcom-co__heading {
	font-size: 16px;
	font-weight: 600;
	color: var(--bcom-text, #1a1a1a);
	margin: 0 0 14px;
	letter-spacing: -.01em;
}

/* ─── Fields ─────────────────────────────────────────────────── */
.bcom-co__field {
	margin-bottom: 10px;
}
.bcom-co__field input,
.bcom-co__field select {
	display: block;
	width: 100%;
	padding: 12px 14px;
	font-size: 15px;
	border: 1px solid var(--bcom-field-border, #d0d0d0);
	border-radius: var(--bcom-radius, 6px);
	background: var(--bcom-field-bg, #fff);
	color: var(--bcom-text, #1a1a1a);
	outline: none;
	transition: border-color .2s, box-shadow .2s;
	box-sizing: border-box;
}
.bcom-co__field input::placeholder {
	color: var(--bcom-text-muted, #717171);
}
.bcom-co__field input:focus,
.bcom-co__field select:focus {
	border-color: var(--bcom-field-focus, #111);
	box-shadow: 0 0 0 1px var(--bcom-field-focus, #111);
}
.bcom-co__field input.bcom-co__field--error {
	border-color: var(--bcom-error, #dc3232);
	box-shadow: 0 0 0 1px var(--bcom-error, #dc3232);
}
/* ─── Inline field validation states ─────────────────────────── */
.bcom-co__field--error input,
.bcom-co__field--error select {
	border-color: var(--bcom-error, #dc3232) !important;
	box-shadow: 0 0 0 1px var(--bcom-error, #dc3232) !important;
}
/* Inline error message */
.bcom-co__field-error {
	font-size: 12px;
	line-height: 1.4;
	color: var(--bcom-error, #dc3232);
	margin-top: 4px;
	min-height: 0;
}
.bcom-co__field-error:empty {
	display: none;
}
/* Shake animation on error */
@keyframes bcom-shake {
	0%, 100% { transform: translateX(0); }
	20% { transform: translateX(-4px); }
	40% { transform: translateX(4px); }
	60% { transform: translateX(-3px); }
	80% { transform: translateX(2px); }
}
.bcom-co__field--shake {
	animation: bcom-shake .35s ease;
}

/* ─── Floating labels (Material Design pattern) ──────────────── */
.bcom-co__field--float {
	position: relative;
}
.bcom-co__field--float > input,
.bcom-co__field--float > select {
	padding: 42px 14px 8px;
}
/* Keep room for the custom dropdown arrow on selects */
.bcom-co__field--float > select {
	padding-right: 38px;
}
.bcom-co__field--float > label {
	position: absolute;
	left: 15px;
	top: 50%;
	transform: translateY(-50%);
	font-size: 15px;
	color: var(--bcom-text-muted, #717171);
	pointer-events: none;
	transition: all .15s ease;
	transform-origin: left top;
	line-height: 1;
}
/* Float up on focus */
.bcom-co__field--float > input:focus + label,
.bcom-co__field--float > select:focus + label {
	top: 4px;
	transform: translateY(0);
	font-size: 10px;
	color: var(--bcom-field-focus, #111);
}
/* Stay floated when field has content */
.bcom-co__field--float > input:not(:placeholder-shown) + label {
	top: 4px;
	transform: translateY(0);
	font-size: 10px;
	color: var(--bcom-text-muted, #717171);
}
/* Focus overrides the muted color when also filled */
.bcom-co__field--float > input:focus:not(:placeholder-shown) + label {
	color: var(--bcom-field-focus, #111);
}
/* Select filled state (toggled by JS — :placeholder-shown N/A for selects) */
.bcom-co__field--float.bcom-co__field--filled > label {
	top: 4px;
	transform: translateY(0);
	font-size: 10px;
	color: var(--bcom-text-muted, #717171);
}
.bcom-co__field--float > select:focus + label,
.bcom-co__field--float.bcom-co__field--filled > select:focus + label {
	color: var(--bcom-field-focus, #111);
}
/* Hide the space placeholder text */
.bcom-co__field--float > input::placeholder {
	color: transparent;
}
/* Error state — force label up + red even on empty fields */
.bcom-co__field--float.bcom-co__field--error > label {
	top: 4px;
	transform: translateY(0);
	font-size: 10px;
	color: var(--bcom-error, #dc3232) !important;
}

/* ─── Rows (2-col, 3-col) ────────────────────────────────────── */
.bcom-co__row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}
.bcom-co__row--3 {
	grid-template-columns: 1fr 1fr 1fr;
}

/* ─── Gateways ───────────────────────────────────────────────── */
.bcom-co__gateways {
	border: 1px solid var(--bcom-border, #e0e0e0);
	border-radius: var(--bcom-radius, 6px);
	overflow: hidden;
}
.bcom-co__gateway {
	display: block;
	cursor: pointer;
	border-bottom: 1px solid var(--bcom-border, #e0e0e0);
}
.bcom-co__gateway:last-child {
	border-bottom: 0;
}
.bcom-co__gateway--active {
	background: rgba(0,0,0,.015);
}
.bcom-co__gateway-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
}
.bcom-co__gateway-header input[type="radio"] {
	accent-color: var(--bcom-accent, #111);
	width: 18px;
	height: 18px;
	flex-shrink: 0;
}
.bcom-co__gateway-name {
	font-size: 14px;
	font-weight: 500;
	flex: 1;
}
.bcom-co__gateway-icon {
	height: 24px;
	width: auto;
}
.bcom-co__gateway-body {
	padding: 0 16px 16px 44px;
}
.bcom-co__gateway-desc {
	font-size: 13px;
	color: var(--bcom-text-muted, #717171);
	margin: 0 0 10px;
	line-height: 1.5;
}
.bcom-co__stripe-mount {
	padding: 12px;
	border: 1px solid var(--bcom-field-border, #d0d0d0);
	border-radius: var(--bcom-radius, 6px);
	background: var(--bcom-field-bg, #fff);
	min-height: 44px;
}

/* ─── Terms ──────────────────────────────────────────────────── */
.bcom-co__terms {
	margin: 18px 0;
	font-size: 14px;
	line-height: 1.5;
}
.bcom-co__terms label {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	cursor: pointer;
}
.bcom-co__terms input[type="checkbox"] {
	margin-top: 3px;
	accent-color: var(--bcom-accent, #111);
}

/* ─── Submit button ──────────────────────────────────────────── */
.bcom-co__btn {
	display: inline-block;
	padding: 14px 28px;
	font-size: 15px;
	font-weight: 600;
	border: none;
	border-radius: var(--bcom-radius, 6px);
	cursor: pointer;
	text-decoration: none;
	text-align: center;
	transition: background .2s, opacity .2s;
}
.bcom-co__btn--primary {
	background: var(--wp--preset--color--primary, var(--boost-btn-primary-bg, var(--bcom-accent, #111)));
	color: var(--wp--preset--color--white, var(--boost-btn-primary-text, #fff));
	border-radius: var(--boost-radius, var(--bcom-radius, 6px));
}
.bcom-co__btn--primary:hover {
	background: var(--boost-btn-primary-hover, var(--bcom-accent-hover, #333));
}
.bcom-co__btn--submit {
	width: 100%;
	padding: 16px;
	font-size: 16px;
	letter-spacing: .02em;
	margin-top: 4px;
}
.bcom-co__btn--submit:disabled {
	opacity: .5;
	cursor: not-allowed;
}

.bcom-co__secure {
	text-align: center;
	font-size: 12px;
	color: var(--bcom-text-muted, #717171);
	margin-top: 14px;
}

/* ─── Summary sidebar ────────────────────────────────────────── */
.bcom-co__summary-toggle {
	position: sticky;
	top: 24px;
}
.bcom-co__summary-toggle > summary {
	list-style: none;
	cursor: pointer;
	display: none; /* hidden on desktop — always open */
}
.bcom-co__summary-toggle > summary::-webkit-details-marker { display: none; }

.bcom-co__summary-item {
	display: grid;
	grid-template-columns: 56px 1fr auto;
	gap: 12px;
	align-items: center;
	padding: 10px 0;
	border-bottom: 1px solid var(--bcom-border, #e0e0e0);
}
.bcom-co__summary-thumb {
	position: relative;
	width: 56px;
	height: 56px;
	border-radius: var(--bcom-radius, 6px);
	background: #f0f0f0;
	border: 1px solid var(--bcom-border, #e0e0e0);
	flex-shrink: 0;
}
.bcom-co__summary-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: var(--bcom-radius, 6px);
}
.bcom-co__summary-qty {
	position: absolute;
	top: -6px;
	right: -6px;
	background: var(--bcom-text-muted, #717171);
	color: #fff;
	font-size: 10px;
	font-weight: 600;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}
.bcom-co__summary-name {
	font-size: 14px;
	font-weight: 500;
	line-height: 1.35;
}
.bcom-co__summary-variant {
	display: block;
	font-size: 12px;
	color: var(--bcom-text-muted, #717171);
	font-weight: 400;
}
.bcom-co__summary-price {
	font-size: 14px;
	font-weight: 500;
	white-space: nowrap;
}

/* ─── Summary totals ─────────────────────────────────────────── */
.bcom-co__summary-totals {
	padding-top: 14px;
}
.bcom-co__summary-row {
	display: flex;
	justify-content: space-between;
	font-size: 14px;
	padding: 4px 0;
	color: var(--bcom-text-muted, #717171);
}
.bcom-co__summary-row--discount {
	color: var(--bcom-success, #27ae60);
}
.bcom-co__summary-row--total {
	font-size: 17px;
	font-weight: 700;
	color: var(--bcom-text, #1a1a1a);
	padding: 12px 0 0;
	margin-top: 4px;
	border-top: 1px solid var(--bcom-border, #e0e0e0);
}
.bcom-co__summary-row--total small {
	font-weight: 400;
	font-size: 12px;
	color: var(--bcom-text-muted, #717171);
	margin-left: 4px;
}

/* ─── Mobile: summary becomes collapsible on top ─────────────── */
@media (max-width: 768px) {
	.bcom-co__layout {
		display: flex;
		flex-direction: column-reverse;
		gap: 0;
	}
	.bcom-co__main {
		padding: 0;
		border-right: none;
	}
	.bcom-co__aside {
		padding: 0;
		margin-bottom: 24px;
		border-bottom: 1px solid var(--bcom-border, #e0e0e0);
		padding-bottom: 20px;
	}
	.bcom-co__summary-toggle {
		position: static;
	}
	.bcom-co__summary-toggle > summary {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 14px 0;
		font-size: 15px;
		font-weight: 500;
		color: var(--bcom-accent, #111);
	}
	.bcom-co__summary-total {
		font-weight: 700;
	}
	.bcom-co__summary-toggle:not([open]) .bcom-co__summary {
		display: none;
	}
	.bcom-co__row--3 {
		grid-template-columns: 1fr 1fr;
	}
	.bcom-co__row--3 .bcom-co__field:first-child {
		grid-column: 1 / -1;
	}
	/* Prevent iOS auto-zoom on input focus (requires >= 16px) */
	.bcom-co__field input,
	.bcom-co__field select {
		font-size: 16px;
	}
}

@media (max-width: 480px) {
	.bcom-co {
		padding: 20px 16px 40px;
	}
	.bcom-co__row {
		grid-template-columns: 1fr;
	}
	.bcom-co__row--3 {
		grid-template-columns: 1fr;
	}
}

/* ─── Shipping method selector ───────────────────────────────── */
.bcom-co__shipping-methods {
	min-height: 48px;
}
.bcom-co__shipping-option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	border: 1px solid var(--bcom-border, #e0e0e0);
	border-radius: var(--bcom-radius, 6px);
	margin-bottom: 8px;
	cursor: pointer;
	transition: border-color .2s, background .2s;
}
.bcom-co__shipping-option:last-child { margin-bottom: 0; }
.bcom-co__shipping-option:hover { border-color: var(--bcom-field-focus, #111); }
.bcom-co__shipping-option--active {
	border-color: var(--bcom-field-focus, #111);
	background: rgba(0,0,0,.015);
}
.bcom-co__shipping-option input[type="radio"] {
	accent-color: var(--bcom-accent, #111);
	width: 18px;
	height: 18px;
	flex-shrink: 0;
}
.bcom-co__shipping-name {
	flex: 1;
	font-size: 14px;
	font-weight: 500;
}
.bcom-co__shipping-cost {
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
}
.bcom-co__muted {
	color: var(--bcom-text-muted, #717171);
	font-size: 14px;
}
.bcom-co__shipping-loading {
	padding: 8px 0;
}

/* ─── Coupon (checkout) ──────────────────────────────────────── */
.bcom-co__section--coupon {
	margin-bottom: 20px;
}
.bcom-co__coupon-toggle > summary {
	cursor: pointer;
	font-size: 14px;
	color: var(--bcom-accent, #111);
	text-decoration: underline;
	list-style: none;
	padding: 4px 0;
}
.bcom-co__coupon-toggle > summary::-webkit-details-marker { display: none; }
.bcom-co__coupon-toggle > summary::marker { display: none; content: ''; }
.bcom-co__coupon {
	padding: 12px 0 0;
}
.bcom-co__coupon-row {
	display: flex;
	gap: 8px;
}
.bcom-co__coupon-row input[type="text"] {
	flex: 1;
	padding: 10px 14px;
	font-size: 14px;
	border: 1px solid var(--bcom-field-border, #d0d0d0);
	border-radius: var(--bcom-radius, 6px);
	outline: none;
	transition: border-color .2s;
}
.bcom-co__coupon-row input:focus {
	border-color: var(--bcom-field-focus, #111);
}
.bcom-co__coupon-msg {
	font-size: 13px;
	margin-top: 4px;
	min-height: 18px;
}
.bcom-co__coupon-active {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 4px;
}
.bcom-co__coupon-badge {
	display: inline-block;
	background: var(--bcom-success, #27ae60);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	padding: 3px 10px;
	border-radius: 3px;
	text-transform: uppercase;
	letter-spacing: .03em;
}
.bcom-co__coupon-remove {
	background: none;
	border: none;
	font-size: 18px;
	color: #dc3232;
	cursor: pointer;
	padding: 0 4px;
}

/* ─── Ship to different address ──────────────────────────────── */
.bcom-co__diff-shipping {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 15px;
	font-weight: 500;
	color: var(--bcom-text, #1a1a1a);
	padding: 4px 0;
}
.bcom-co__diff-shipping input[type="checkbox"] {
	accent-color: var(--bcom-accent, #111);
	width: 18px;
	height: 18px;
}
.bcom-co__shipping-fields {
	margin-top: 16px;
}

/* ─── Country select ─────────────────────────────────────────── */
.bcom-co__field select {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--bcom-border, #e0e0e0);
	border-radius: var(--bcom-radius, 6px);
	background: var(--bcom-bg, #fff);
	font-size: 15px;
	color: var(--bcom-text, #1a1a1a);
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	cursor: pointer;
}
