/* =============================================================
   Bazaid Academy - classic checkout
   RTL-first. Uses CSS logical properties so it also works in LTR.
   Scoped to .bz-checkout / body.bz-checkout-page so it does not leak
   into the other Blocksy WooCommerce pages.
   ============================================================= */

.bz-checkout {
	--bz-navy:      #293B66;
	--bz-navy-700:  #1F2D4F;
	--bz-ink:       #263B67;
	--bz-cyan:      #0BA4C2;
	--bz-cyan-700:  #077F98;
	--bz-red:       #E0384A;
	--bz-gold:      #E0A32E;
	--bz-bg:        #F7F9FC;
	--bz-card:      #FFFFFF;
	--bz-line:      #DDE3EE;
	--bz-line-soft: #E6EAF2;
	--bz-muted:     #6B7A99;

	/* Primary CTA. Navy on white text is about 10:1, comfortably AA.
	   To switch to the brand red use #C92B3D (about 5.4:1). The lighter
	   #E0384A only reaches 4.35:1 and fails AA for button text. */
	--bz-cta:       var(--bz-navy);
	--bz-cta-hover: var(--bz-navy-700);

	--bz-radius:    14px;
	--bz-radius-sm: 10px;
	--bz-shadow:    0 1px 2px rgba(41,59,102,.06), 0 8px 24px rgba(41,59,102,.07);
	--bz-focus:     0 0 0 3px rgba(11,164,194,.28);

	font-family: "Cairo", system-ui, -apple-system, sans-serif;
	color: var(--bz-ink);

	/* Full-bleed: Blocksy's own container controls the page width. */
	max-width: unset;
	margin: 0;
	padding: 0;
}

.bz-checkout *,
.bz-checkout *::before,
.bz-checkout *::after { box-sizing: border-box; }

/* ---------- Fit inside the Blocksy container ---------- */
.ct-order-review { padding: 0; border: 0; }
.woocommerce-checkout-payment { margin-inline: 0 !important; }
.woocommerce-privacy-policy-text { margin-top: 15px; }

/* ---------- Steps ---------- */
.bz-steps {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 22px;
	list-style: none;
	margin: 0 0 22px;
	padding: 0;
	font-size: 14px;
	font-weight: 600;
	color: var(--bz-muted);
}
.bz-steps__item { display: flex; align-items: center; gap: 8px; }

/* Step 1 links back to the cart */
.bz-steps__link {
	display: flex; align-items: center; gap: 8px;
	color: inherit;
	text-decoration: none;
	border-radius: 6px;
	transition: color .15s ease;
}
.bz-steps__link:hover { color: var(--bz-navy); text-decoration: underline; text-underline-offset: 3px; }
.bz-steps__link:hover .bz-steps__num { background: var(--bz-navy); color: #fff; }
.bz-steps__link:focus-visible { outline: none; box-shadow: var(--bz-focus); }
.bz-steps__num {
	inline-size: 24px; block-size: 24px;
	display: grid; place-items: center;
	border-radius: 50%;
	background: var(--bz-line-soft);
	color: var(--bz-muted);
	font-size: 13px;
}
.bz-steps__item.is-done { color: var(--bz-cyan-700); }
.bz-steps__item.is-done .bz-steps__num { background: var(--bz-cyan); color: #fff; }
.bz-steps__item.is-current { color: var(--bz-navy); }
.bz-steps__item.is-current .bz-steps__num { background: var(--bz-navy); color: #fff; }

/* ---------- Layout ---------- */
.bz-grid { display: grid; gap: 24px; grid-template-columns: 1fr; align-items: start; }

@media (min-width: 992px) {
	.bz-grid { grid-template-columns: minmax(0, 1fr) 372px; gap: 28px; }
	.bz-aside { position: sticky; top: 24px; }
}

/* ---------- Cards ---------- */
.bz-card {
	background: var(--bz-card);
	border: 1px solid var(--bz-line);
	border-radius: var(--bz-radius);
	box-shadow: var(--bz-shadow);
	padding: 22px;
	margin-block-end: 20px;
}
.bz-card__title {
	display: flex; align-items: center; gap: 10px;
	margin: 0 0 6px;
	font-size: 19px; font-weight: 700;
	color: var(--bz-navy);
}
.bz-card__step {
	inline-size: 28px; block-size: 28px;
	display: grid; place-items: center;
	border-radius: 50%;
	background: var(--bz-navy); color: #fff;
	font-size: 14px; font-weight: 700;
}
.bz-card__hint { margin: 0 0 18px; font-size: 14px; color: var(--bz-muted); }

/* ---------- Fields (Checkout Field Editor Pro markup) ---------- */
.bz-fields__wrapper { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 680px) {
	.bz-fields__wrapper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.bz-fields__wrapper > .form-row { grid-column: 1 / -1; }
	.bz-fields__wrapper > .form-row-first,
	.bz-fields__wrapper > .form-row-last { grid-column: span 1; }
}

/* The name field is set to "Full" in Checkout Field Editor Pro, so it now emits
   form-row-wide and the generic .form-row rule above already spans it across
   both columns. The previous #billing_first_name_field override was removed as
   redundant - the plugin is the single source of truth for field width. */

.bz-checkout .form-row { margin: 0; padding: 0; float: none !important; width: auto !important; }

/* Inline field errors.
   WooCommerce 11 renders these itself (checkout.js -> show_inline_errors) as
   <p class="checkout-inline-error-message"> inside the .form-row. We only style
   them - do NOT generate them, or every message appears twice. The phone check
   in bazaid-checkout.js deliberately reuses this same class. */
.bz-checkout .checkout-inline-error-message {
	display: block;
	margin: 6px 0 0;
	font-size: 12.5px;
	font-weight: 600;
	line-height: 1.6;
	color: var(--bz-red);
}

.bz-checkout .woocommerce-invalid .input-text,
.bz-checkout .woocommerce-invalid select,
.bz-checkout .woocommerce-invalid textarea { border-color: var(--bz-red); }

.bz-checkout .woocommerce-invalid .woocommerce-input-wrapper::before { border-right-color: var(--bz-red); }

/* Terms checkbox has no .input-text to colour */
.bz-checkout .form-row.woocommerce-invalid > label { color: var(--bz-red); }

/* Kept for the errors that stay at the top - gateway declines and anything
   with no field to attach to. */
.bz-checkout .woocommerce-NoticeGroup { margin-block-end: 18px; }

.bz-checkout .form-row > label {
	display: block;
	margin-block-end: 7px;
	font-size: 14px; font-weight: 600;
	color: var(--bz-ink);
}
.bz-checkout .form-row .required { color: var(--bz-red); text-decoration: none; border: 0; }
.bz-checkout .optional { color: var(--bz-muted); font-weight: 400; }

.bz-checkout .input-text,
.bz-checkout select,
.bz-checkout textarea {
	inline-size: 100%;
	padding: 13px 15px;
	font-family: inherit;
	font-size: 15.5px;
	color: var(--bz-ink);
	background: #fff;
	border: 1.5px solid var(--bz-line);
	border-radius: var(--bz-radius-sm);
	transition: border-color .15s ease, box-shadow .15s ease;
	-webkit-appearance: none;
	appearance: none;
}
.bz-checkout .input-text::placeholder { color: #A6B0C6; }
.bz-checkout .input-text:focus,
.bz-checkout select:focus,
.bz-checkout textarea:focus {
	outline: none;
	border-color: var(--bz-cyan);
	box-shadow: var(--bz-focus);
}
.bz-checkout .woocommerce-invalid .input-text { border-color: var(--bz-red); }
.bz-checkout .woocommerce-validated .input-text { border-color: #27C08A; }

/* Latin content inside an RTL page reads better left-to-right */
.bz-checkout #billing_email,
.bz-checkout #billing_phone { direction: ltr; text-align: start; }

/* ---------- Phone: fixed +966 prefix ----------
   Display only - the prefix is NOT part of the input value. The server still
   accepts 05…, 5…, +966… and 00966… (see bazaid-phone-validation.php) so a
   pasted full number is not rejected; the JS rewrites it to the 9-digit form
   on blur so what is shown matches what is stored.

   Physical left/border-right on purpose: the input is dir="ltr" inside an RTL
   page, so its digits always begin at the left edge regardless of page
   direction. Logical properties would flip the prefix to the wrong side. */
.bz-checkout #billing_phone_field .woocommerce-input-wrapper {
	position: relative;
	display: block;
}
.bz-checkout #billing_phone_field .woocommerce-input-wrapper::before {
	content: "+966";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	display: flex;
	align-items: center;
	padding: 0 13px;
	direction: ltr;
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	color: var(--bz-muted);
	background: var(--bz-bg);
	border-right: 1.5px solid var(--bz-line);
	/* Prefix sits at the LEFT edge, so only the left corners are rounded. */
	border-radius: var(--bz-radius-sm) 0 0 var(--bz-radius-sm);
	pointer-events: none;
}
.bz-checkout #billing_phone { padding-left: 78px; }

/* Keep the divider in step with the input's own border colour */
.bz-checkout #billing_phone_field:focus-within .woocommerce-input-wrapper::before { border-right-color: var(--bz-cyan); }
/* Invalid state for the prefix divider is handled by the generic
   .woocommerce-invalid rule in the field-errors section below. */

.bz-check { display: flex; align-items: center; gap: 9px; font-size: 14.5px; cursor: pointer; }
.bz-check input { inline-size: 18px; block-size: 18px; accent-color: var(--bz-cyan); }
.bz-account-fields { margin-block-start: 16px; }

/* ---------- Payment ---------- */
.bz-payment__lead { margin: 0 0 14px; font-size: 14px; color: var(--bz-muted); }

.bz-checkout ul.bz-gateways { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.bz-checkout li.wc_payment_method {
	position: relative;
	border: 1.5px solid var(--bz-line);
	border-radius: var(--bz-radius-sm);
	background: #fff;
	transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
	overflow: hidden;
}
.bz-checkout li.wc_payment_method:hover { border-color: #BFCBE0; }

.bz-checkout li.wc_payment_method > input[type="radio"] {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}
.bz-checkout li.wc_payment_method > label {
	display: flex !important;
	align-items: center;
	gap: 11px;
	margin: 0;
	padding: 15px 17px;
	font-size: 15.5px;
	font-weight: 600;
	color: var(--bz-ink);
	cursor: pointer;
	line-height: 1.6;
}
/* Custom radio dot */
.bz-checkout li.wc_payment_method > label::before {
	content: "";
	flex: 0 0 auto;
	inline-size: 20px; block-size: 20px;
	border-radius: 50%;
	border: 2px solid #C3CDE0;
	background: #fff;
	transition: border-color .15s ease, border-width .15s ease, box-shadow .15s ease;
}
.bz-checkout li.wc_payment_method > label img {
	max-block-size: 26px;
	inline-size: auto;
	margin-inline-start: auto;
	display: inline-block;
}

/* Selected state. :has() where supported, .bz-selected is the JS fallback. */
.bz-checkout li.wc_payment_method:has(input[type="radio"]:checked),
.bz-checkout li.wc_payment_method.bz-selected {
	border-color: var(--bz-cyan);
	background: #F4FCFD;
	box-shadow: var(--bz-focus);
}
.bz-checkout li.wc_payment_method:has(input[type="radio"]:checked) > label::before,
.bz-checkout li.wc_payment_method.bz-selected > label::before {
	border-color: var(--bz-cyan);
	border-width: 6px;
}
.bz-checkout li.wc_payment_method > input[type="radio"]:focus-visible + label::before {
	box-shadow: var(--bz-focus);
}

.bz-checkout .payment_box {
	margin: 0;
	padding: 0 17px 16px;
	background: transparent !important;
	border: 0;
	font-size: 14px;
	line-height: 1.85;
	color: var(--bz-muted);
}
.bz-checkout .payment_box::before { display: none !important; }
.bz-checkout .payment_box p:last-child { margin-block-end: 0; }

/* ---------- Terms and place order ---------- */
.bz-place-order { margin-block-start: 20px; padding: 0; }

.bz-checkout .woocommerce-terms-and-conditions-wrapper { margin-block-end: 16px; font-size: 14px; }
.bz-checkout .woocommerce-terms-and-conditions-wrapper .form-row { margin-block-start: 10px; }

.bz-checkout #place_order {
	inline-size: 100%;
	padding: 16px 22px;
	font-family: inherit;
	font-size: 17px;
	font-weight: 700;
	color: #fff;
	background: var(--bz-cta);
	border: 0;
	border-radius: var(--bz-radius-sm);
	cursor: pointer;
	transition: background .15s ease, transform .06s ease, box-shadow .15s ease;
	box-shadow: 0 6px 18px rgba(41,59,102,.22);
}
.bz-checkout #place_order:hover { background: var(--bz-cta-hover); }
.bz-checkout #place_order:active { transform: translateY(1px); }
.bz-checkout #place_order:focus-visible { outline: none; box-shadow: var(--bz-focus), 0 6px 18px rgba(41,59,102,.22); }
.bz-checkout #place_order:disabled { opacity: .6; cursor: not-allowed; }

.bz-place-order__note {
	display: flex; align-items: flex-start; gap: 8px;
	margin: 13px 0 0;
	font-size: 13px; line-height: 1.75;
	color: var(--bz-muted);
}
.bz-place-order__note svg { flex: 0 0 auto; inline-size: 16px; block-size: 16px; fill: var(--bz-cyan-700); margin-block-start: 3px; }

/* ---------- Order summary ---------- */
.bz-summary {
	background: var(--bz-card);
	border: 1px solid var(--bz-line);
	border-radius: var(--bz-radius);
	box-shadow: var(--bz-shadow);
	overflow: hidden;
	margin-block-end: 16px;
}
.bz-summary__toggle { display: none; }
.bz-summary__body { padding: 20px; }
.bz-summary__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.bz-summary__title { margin: 0; font-size: 17px; font-weight: 700; color: var(--bz-navy); }
.bz-summary__edit {
	font-size: 13px; font-weight: 700;
	color: var(--bz-cyan-700);
	text-decoration: underline;
	text-underline-offset: 3px;
	white-space: nowrap;
}
.bz-summary__edit:hover { color: var(--bz-navy); }

.bz-checkout table.bz-order-table { inline-size: 100%; border-collapse: collapse; margin: 0; font-size: 15px; }
.bz-checkout table.bz-order-table thead { display: none; }
.bz-checkout table.bz-order-table th,
.bz-checkout table.bz-order-table td { border: 0; padding: 0; background: transparent; }

.bz-checkout table.bz-order-table tbody tr.cart_item { display: block; padding-block-end: 14px; }
.bz-checkout table.bz-order-table tbody tr.cart_item + tr.cart_item {
	padding-block-start: 14px;
	border-block-start: 1px solid var(--bz-line-soft);
}
.bz-checkout table.bz-order-table tbody td.product-name { display: block; }
.bz-checkout table.bz-order-table tbody td.product-total {
	display: block;
	margin-block-start: 8px;
	font-weight: 700;
	color: var(--bz-navy);
	text-align: start;
}

.bz-item { display: flex; align-items: flex-start; gap: 12px; }
.bz-item__media { flex: 0 0 auto; inline-size: 56px; block-size: 56px; border-radius: 9px; overflow: hidden; background: var(--bz-bg); }
.bz-item__media img.bz-item__img { inline-size: 100%; block-size: 100%; object-fit: cover; display: block; }
.bz-item__body { min-inline-size: 0; }
.bz-item__name { display: block; font-size: 14.5px; font-weight: 600; line-height: 1.65; color: var(--bz-ink); }
.bz-item__qty { display: inline-block; margin-block-start: 3px; font-size: 13px; font-weight: 600; color: var(--bz-muted); }

/* Totals */
.bz-checkout table.bz-order-table tfoot { display: block; margin-block-start: 14px; padding-block-start: 14px; border-block-start: 1px solid var(--bz-line); }
.bz-checkout table.bz-order-table tfoot tr { display: flex; justify-content: space-between; gap: 12px; padding-block: 5px; font-size: 14.5px; }
.bz-checkout table.bz-order-table tfoot th { font-weight: 500; color: var(--bz-muted); text-align: start; }
.bz-checkout table.bz-order-table tfoot td { font-weight: 600; color: var(--bz-ink); text-align: end; }
.bz-checkout table.bz-order-table tfoot tr.cart-discount th,
.bz-checkout table.bz-order-table tfoot tr.cart-discount td { color: #12996B; }
.bz-checkout table.bz-order-table tfoot tr.order-total {
	margin-block-start: 8px; padding-block-start: 12px;
	border-block-start: 1px dashed var(--bz-line);
	font-size: 18px;
}
.bz-checkout table.bz-order-table tfoot tr.order-total th { font-weight: 700; color: var(--bz-navy); }
.bz-checkout table.bz-order-table tfoot tr.order-total td { font-weight: 800; color: var(--bz-navy); }
.bz-checkout table.bz-order-table tfoot tr.order-total .includes_tax { display: block; font-size: 12px; font-weight: 500; color: var(--bz-muted); }

/* ---------- Coupon (always visible - no toggle) ---------- */
.bz-coupon {
	margin-block-start: 16px;
	padding-block-start: 14px;
	border-block-start: 1px solid var(--bz-line-soft);
}
.bz-coupon__label {
	display: block;
	margin-block-end: 9px;
	font-size: 13.5px;
	font-weight: 700;
	color: var(--bz-navy);
}
/* Overrides the inline display:none WooCommerce normally ships on this form. */
.bz-checkout form.bz-coupon__form { display: block !important; margin: 0; }
.bz-coupon__row { display: flex; gap: 8px; align-items: stretch; }
.bz-checkout .bz-coupon__input { flex: 1 1 auto; padding: 11px 13px; font-size: 14.5px; }
.bz-checkout .bz-coupon__btn {
	flex: 0 0 auto;
	padding: 11px 18px;
	font-family: inherit; font-size: 14.5px; font-weight: 700;
	color: #fff; background: var(--bz-cyan-700);
	border: 0; border-radius: var(--bz-radius-sm);
	cursor: pointer; transition: background .15s ease;
}
.bz-checkout .bz-coupon__btn:hover { background: var(--bz-navy); }

/* ---------- Trust (compact icon tiles) ----------
   2x2 at every breakpoint. Four stacked text blocks ate too much vertical
   space right where the pay button needs to be - the long copy now lives in
   the title= attribute instead. */
.bz-trust {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}
.bz-trust__item {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	gap: 7px;
	padding: 12px 8px;
	text-align: center;
	background: var(--bz-bg);
	border: 1px solid var(--bz-line-soft);
	border-radius: var(--bz-radius-sm);
}
.bz-trust__item svg {
	flex: 0 0 auto;
	inline-size: 22px;
	block-size: 22px;
	fill: var(--bz-cyan-700);
}
.bz-trust__item span {
	font-size: 12.5px;
	font-weight: 700;
	line-height: 1.45;
	color: var(--bz-navy);
	text-wrap: balance;
}
.bz-trust__item--gold { background: #FFF9EC; border-color: #F3E2BC; }
.bz-trust__item--gold svg { fill: var(--bz-gold); }
.bz-trust__item--gold span { color: #8A6417; }

/* ---------- Login and notices ---------- */
/* Was constrained to the old 1180px container; now that .bz-checkout is
   full-bleed this must not be padded, or the login bar sits misaligned. */
body.bz-checkout-page .woocommerce-form-login-toggle { margin-inline: 0; padding-inline: 0; }

body.bz-checkout-page .woocommerce-info,
body.bz-checkout-page .woocommerce-message,
body.bz-checkout-page .woocommerce-error {
	font-family: "Cairo", system-ui, sans-serif;
	border-radius: 10px;
	font-size: 14.5px;
}

/* The pay bar is injected into <body> by JS, so it must be hidden by default -
   it is only ever shown inside the mobile media query below. */
.bz-paybar { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 991px) {
	.bz-grid > .bz-aside { order: -1; }

	.bz-summary__toggle {
		display: flex;
		inline-size: 100%;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		padding: 15px 18px;
		font-family: inherit; font-size: 15px; font-weight: 700;
		color: var(--bz-navy);
		background: #fff;
		border: 0;
		cursor: pointer;
	}
	.bz-summary__toggle-label::after {
		content: "";
		display: inline-block;
		inline-size: 8px; block-size: 8px;
		margin-inline-start: 8px;
		border-inline-end: 2px solid currentColor;
		border-block-end: 2px solid currentColor;
		transform: rotate(45deg);
		transition: transform .2s ease;
		vertical-align: middle;
	}
	.bz-summary__toggle[aria-expanded="true"] .bz-summary__toggle-label::after { transform: rotate(-135deg); }
	.bz-summary__toggle-total { color: var(--bz-cyan-700); font-weight: 800; }

	.bz-summary__body { display: none; border-block-start: 1px solid var(--bz-line-soft); }
	.bz-summary.is-open .bz-summary__body { display: block; }
	.bz-summary__title { display: none; }

	.bz-card { padding: 18px; }
	.bz-steps { font-size: 13px; gap: 6px 14px; }

	/* Sticky pay bar */
	.bz-paybar {
		position: fixed;
		inset-inline: 0;
		inset-block-end: 0;
		z-index: 90;
		display: flex;
		align-items: center;
		gap: 12px;
		padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
		background: rgba(255,255,255,.97);
		-webkit-backdrop-filter: blur(8px);
		backdrop-filter: blur(8px);
		border-block-start: 1px solid var(--bz-line);
		box-shadow: 0 -6px 20px rgba(41,59,102,.10);
		transform: translateY(110%);
		transition: transform .22s ease;
	}
	.bz-paybar.is-visible { transform: translateY(0); }
	.bz-paybar__total { display: flex; flex-direction: column; line-height: 1.3; }
	.bz-paybar__total span { font-size: 11.5px; color: var(--bz-muted); }
	.bz-paybar__total strong { font-size: 17px; font-weight: 800; color: var(--bz-navy); }
	.bz-paybar__btn {
		flex: 1 1 auto;
		padding: 14px 18px;
		font-family: inherit; font-size: 16px; font-weight: 700;
		color: #fff; background: var(--bz-cta, #293B66);
		border: 0; border-radius: 10px;
		cursor: pointer;
	}
	body.bz-checkout-page { padding-block-end: 84px; }
}

@media (prefers-reduced-motion: reduce) {
	.bz-checkout *, .bz-paybar { transition: none !important; }
}
