/**
 * Nellava Checkout Mobile
 *
 * Everything here is scoped to body.ncm-checkout / body.ncm-cart, and the mobile treatment is
 * gated on 699px — the same width at which WooCommerce Blocks collapses the
 * checkout to a single column (`@container (max-width: 699px)`).
 *
 * The page is served from LiteSpeed's cache, so nothing may depend on
 * server-side device detection; width is decided here and in matchMedia only.
 */

body.ncm-checkout,
body.ncm-cart {
	--ncm-accent: var(--ast-global-color-0, #1e1e1e);
	--ncm-accent-text: #fff;
	--ncm-line: color-mix(in srgb, currentColor 20%, transparent);
	--ncm-radius: 8px;
	--ncm-bar-height: 76px;
}

/* ---------------------------------------------------------------------------
 * 0. Tata letak — blok keranjang & checkout yang mepet ke kiri
 *
 * Astra lets an .alignwide block escape the container padding with negative
 * side margins below 1200px:
 *
 *   .entry-content[data-ast-blocks-layout] > .alignwide {
 *       margin-left: calc(-1 * min(var(--ast-container-default-xlg-padding), 20px));
 *       margin-right: same;
 *   }
 *
 * That works for a block whose width is auto, because it grows into them. But
 * WooCommerce declares an explicit width on both blocks:
 *
 *   .wp-block-woocommerce-cart,
 *   .wp-block-woocommerce-checkout { width: 100% }
 *
 * so the box cannot widen. The negative left margin just slides it 20px to the
 * left and the right one becomes slack — measured on a 414px viewport, the
 * block lands at left:0 right:374, flush against the left edge with a 40px hole
 * on the right. Above 1200px Astra already uses auto margins; this restores the
 * same thing below it.
 *
 * The body class carries the extra specificity needed to beat Astra's rule.
 * ------------------------------------------------------------------------- */

@media (max-width: 1200px) {
	body.ncm-center .entry-content[data-ast-blocks-layout] > .wp-block-woocommerce-cart.alignwide,
	body.ncm-center .entry-content[data-ast-blocks-layout] > .wp-block-woocommerce-checkout.alignwide,
	body.ncm-center .wp-block-woocommerce-cart.alignwide,
	body.ncm-center .wp-block-woocommerce-checkout.alignwide {
		margin-left: auto;
		margin-right: auto;
	}
}

/* ---------------------------------------------------------------------------
 * 1. Kolom voucher — dikeluarkan dari ringkasan order yang tertutup
 * ------------------------------------------------------------------------- */

.ncm-coupon {
	border: 1px solid var(--ncm-line);
	border-radius: var(--ncm-radius);
	padding: 14px;
	margin: 0 0 20px;
	/* The theme ships a trial display font that watermarks headings — never
	   inherit a heading face here. */
	font-family: inherit;
	display: none;
}

.ncm-coupon__head {
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
	margin: 0 0 10px;
}

.ncm-coupon__row {
	display: flex;
	gap: 8px;
	align-items: stretch;
}

.ncm-coupon__input {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 48px;
	font-size: 16px; /* < 16px makes iOS Safari zoom the whole page on focus */
	font-family: inherit;
	padding: 0 12px;
	border: 1px solid var(--ncm-line);
	border-radius: var(--ncm-radius);
	background: #fff;
	color: inherit;
	text-transform: uppercase;
}

.ncm-coupon__btn {
	flex: 0 0 auto;
	min-height: 48px;
	padding: 0 18px;
	font-size: 15px;
	font-weight: 600;
	font-family: inherit;
	line-height: 1;
	border: 0;
	border-radius: var(--ncm-radius);
	background: var(--ncm-accent);
	color: var(--ncm-accent-text);
	cursor: pointer;
}

.ncm-coupon__btn[disabled] {
	opacity: .55;
	cursor: default;
}

.ncm-coupon__msg {
	font-size: 14px;
	line-height: 1.4;
	margin-top: 8px;
	display: none;
}

.ncm-coupon__msg.is-error,
.ncm-coupon__msg.is-ok,
.ncm-coupon__msg.is-busy {
	display: block;
}

.ncm-coupon__msg.is-error {
	color: #b32d2e;
}

.ncm-coupon__msg.is-ok {
	color: #1a7f45;
}

.ncm-coupon__msg.is-busy {
	opacity: .7;
}

.ncm-coupon__list {
	list-style: none;
	margin: 10px 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ncm-coupon__list:empty {
	margin: 0;
}

.ncm-coupon__chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	padding: 8px 8px 8px 12px;
	border: 1px solid var(--ncm-line);
	border-radius: 999px;
}

.ncm-coupon__remove {
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
	line-height: 1;
	/* keep the hit area near 44px without visually inflating the chip */
	padding: 12px;
	margin: -12px -8px -12px -6px;
	opacity: .65;
}

.ncm-coupon__remove:hover {
	opacity: 1;
}

/* Ours is shown on mobile only unless "juga di desktop" is on. */
@media (max-width: 699px) {
	body.ncm-coupon-promoted .ncm-coupon.is-ready {
		display: block;
	}

	body.ncm-coupon-promoted .wp-block-woocommerce-checkout-order-summary-coupon-form-block,
	body.ncm-coupon-promoted .wp-block-woocommerce-cart-order-summary-coupon-form-block {
		display: none;
	}
}

@media (min-width: 700px) {
	body.ncm-coupon-promoted.ncm-coupon-desktop .ncm-coupon.is-ready {
		display: block;
	}

	body.ncm-coupon-promoted.ncm-coupon-desktop .wp-block-woocommerce-checkout-order-summary-coupon-form-block,
	body.ncm-coupon-promoted.ncm-coupon-desktop .wp-block-woocommerce-cart-order-summary-coupon-form-block {
		display: none;
	}
}

/* ---------------------------------------------------------------------------
 * 2. Form yang enak diisi di HP
 * ------------------------------------------------------------------------- */

@media (max-width: 699px) {
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-text-input input,
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-textarea,
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-blocks-components-select__select,
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-combobox input {
		font-size: 16px !important; /* beats Astra's own checkout overrides */
	}

	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-text-input input,
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-blocks-components-select__select {
		min-height: 54px;
	}

	/* Give every tappable row a thumb-sized target. */
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-radio-control__option,
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-panel__button,
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-address-form__address_2-toggle {
		min-height: 52px;
	}

	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-checkbox__label,
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-address-form__address_2-toggle {
		font-size: 15px;
		line-height: 1.5;
	}

	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-checkbox {
		padding: 6px 0;
	}

	/* Breathing room between fields — Blocks packs them tight for desktop. */
	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-address-form > * {
		margin-top: 14px;
	}

	body.ncm-form-polish .wp-block-woocommerce-checkout .wc-block-components-checkout-step__heading {
		margin-bottom: 12px;
	}
}

/* ---------------------------------------------------------------------------
 * 3. Ringkasan order ringkas
 * ------------------------------------------------------------------------- */

@media (max-width: 699px) {
	body.ncm-summary-compact .wp-block-woocommerce-checkout-order-summary-block .wc-block-components-panel__button {
		font-size: 16px;
		font-family: inherit;
		padding-top: 14px;
		padding-bottom: 14px;
	}

	/* The collapsed header is the only place the total is visible, so make it read like one. */
	body.ncm-summary-compact .wc-block-components-checkout-order-summary__title-price,
	body.ncm-summary-compact .wc-block-components-checkout-order-summary__title-price .wc-block-formatted-money-amount {
		font-size: 18px;
		font-weight: 700;
	}

	body.ncm-summary-compact .wp-block-woocommerce-checkout-order-summary-block .wc-block-components-checkout-order-summary__title .wc-block-components-checkout-order-summary__title-text {
		font-size: 17px;
	}

	body.ncm-summary-compact .wp-block-woocommerce-checkout-order-summary-block {
		margin-bottom: 20px;
	}
}

/* ---------------------------------------------------------------------------
 * 4. Sederhanakan — buang blok yang kosong / tidak relevan
 * ------------------------------------------------------------------------- */

body.ncm-simplify .ncm-is-empty {
	display: none !important;
}

/* Only one payment gateway is configured: the radio circle is a choice of one. */
body.ncm-simplify .ncm-single-payment .wc-block-components-radio-control__input {
	display: none;
}

body.ncm-simplify .ncm-single-payment .wc-block-components-radio-control__option {
	padding-left: 0;
}

/* ---------------------------------------------------------------------------
 * 5. Bar bayar sticky
 * ------------------------------------------------------------------------- */

.ncm-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 999;
	display: none;
	align-items: center;
	gap: 12px;
	box-sizing: border-box;
	padding: 10px 14px;
	padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
	background: #fff;
	border-top: 1px solid var(--ncm-line);
	box-shadow: 0 -2px 14px rgba(0, 0, 0, .12);
	font-family: inherit;
}

.ncm-bar.is-visible {
	display: flex;
}

.ncm-bar__total {
	flex: 0 1 auto;
	min-width: 0;
	line-height: 1.25;
}

.ncm-bar__total-label {
	display: block;
	font-size: 12px;
	opacity: .65;
}

.ncm-bar__total-value {
	display: block;
	font-size: 17px;
	font-weight: 700;
	white-space: nowrap;
}

.ncm-bar__btn {
	flex: 1 1 auto;
	min-height: 52px;
	padding: 0 16px;
	border: 0;
	border-radius: var(--ncm-radius);
	background: var(--ncm-accent);
	color: var(--ncm-accent-text);
	font-family: inherit;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
	cursor: pointer;
}

.ncm-bar__btn[disabled] {
	opacity: .55;
	cursor: default;
}

body.ncm-bar-on {
	padding-bottom: var(--ncm-bar-height);
}

@media (min-width: 700px) {
	.ncm-bar {
		display: none !important;
	}

	body.ncm-bar-on {
		padding-bottom: 0;
	}
}

/* ---------------------------------------------------------------------------
 * 6. Halaman keranjang (Basket)
 * ------------------------------------------------------------------------- */

@media (max-width: 699px) {
	/* The full product short description turns every cart line into a wall of
	   text on a phone; the shopper already chose the product. */
	body.ncm-cart-trim .wc-block-cart-item__wrap .wc-block-components-product-metadata__description {
		display: none;
	}

	/* Set by the script when the unit price and the line total render the same
	   string, i.e. quantity 1 — the price was simply printed twice. */
	body.ncm-cart .wc-block-cart-items__row.ncm-dup-price .wc-block-cart-item__prices {
		display: none;
	}

	/* Thumb-sized quantity stepper and remove button. */
	body.ncm-form-polish .wp-block-woocommerce-cart .wc-block-components-quantity-selector {
		min-height: 48px;
	}

	body.ncm-form-polish .wp-block-woocommerce-cart .wc-block-components-quantity-selector__button {
		min-width: 44px;
	}

	body.ncm-form-polish .wp-block-woocommerce-cart .wc-block-components-quantity-selector__input {
		font-size: 16px !important;
	}

	body.ncm-form-polish .wp-block-woocommerce-cart .wc-block-cart-item__remove-link {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 44px;
		min-height: 44px;
	}

	body.ncm-form-polish .wp-block-woocommerce-cart .wc-block-components-totals-item,
	body.ncm-form-polish .wp-block-woocommerce-cart .wc-block-components-panel__button {
		font-size: 15px;
	}
}

/*
 * WooCommerce already pins Proceed to Checkout to the bottom on small screens
 * (.wc-block-cart__submit-container--sticky, its own 782px query), so we add no
 * second bar here — only a thumb-sized button and room for the home indicator.
 */
@media (max-width: 782px) {
	body.ncm-cart .wc-block-cart__submit-container--sticky {
		padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	}
}

body.ncm-cart .wc-block-cart__submit-button {
	min-height: 54px;
	font-family: inherit;
	font-size: 16px;
}
