/**
 * MPESA Payment by Kings Consolidated — checkout & order UI.
 * Theme-friendly: inherits fonts and text colour, uses brand green for accents only.
 */
.kcmpesa-fields,
.kcmpesa-panel,
.kcmpesa-receipt-card {
	--kcm-green: #15803d;
	--kcm-green-strong: #166534;
	--kcm-brand: #4cb848;
	--kcm-red: #b91c1c;
	--kcm-amber: #92400e;
	--kcm-line: rgba(100, 116, 139, 0.32);
	--kcm-soft: rgba(76, 184, 72, 0.1);
	--kcm-radius: 12px;
	--kcm-ease: cubic-bezier(0.2, 0, 0, 1);
	box-sizing: border-box;
}

.kcmpesa-fields *,
.kcmpesa-panel *,
.kcmpesa-receipt-card * {
	box-sizing: border-box;
}

/* Gateway logo in the payment method list */
.wc_payment_method .kcmpesa-gateway-logo,
img.kcmpesa-gateway-logo {
	display: inline-block;
	height: 26px !important;
	width: auto !important;
	max-height: 26px !important;
	margin: 0 0 0 8px !important;
	vertical-align: middle;
	float: none !important;
}

/* ---------- Classic & block payment fields ---------- */
.kcmpesa-fields {
	display: grid;
	gap: 12px;
	padding-top: 4px;
}

.kcmpesa-fields__desc {
	margin: 0;
}

.kcmpesa-fields .kcmpesa-field {
	margin: 0 !important;
	padding: 0 !important;
}

.kcmpesa-fields label {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
}

.kcmpesa-input {
	position: relative;
	display: block;
}

.kcmpesa-input__prefix {
	position: absolute;
	inset-inline-start: 12px;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	color: var(--kcm-green);
	pointer-events: none;
}

.kcmpesa-input__field,
.kcmpesa-fields input[type="tel"] {
	width: 100%;
	min-height: 48px;
	font-size: 16px !important; /* prevents iOS zoom */
	letter-spacing: 0.02em;
	font-variant-numeric: tabular-nums;
}

.kcmpesa-input .kcmpesa-input__field {
	padding-inline-start: 40px !important;
}

.kcmpesa-input__field:focus-visible,
.kcmpesa-panel input:focus-visible {
	outline: 2px solid var(--kcm-green);
	outline-offset: 2px;
}

.kcmpesa-input__field[aria-invalid="true"],
.kcmpesa-panel input[aria-invalid="true"] {
	border-color: var(--kcm-red) !important;
}

.kcmpesa-help {
	display: block;
	margin-top: 6px;
	font-size: 0.875em;
	opacity: 0.85;
}

.kcmpesa-error {
	display: block;
	margin: 6px 0 0;
	color: var(--kcm-red);
	font-size: 0.875em;
	font-weight: 600;
}

.kcmpesa-error[hidden] {
	display: none;
}

.kcmpesa-amount {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	padding: 12px 14px;
	border: 1px solid var(--kcm-line);
	border-radius: 10px;
	background: var(--kcm-soft);
}

.kcmpesa-amount strong {
	font-size: 1.125em;
	font-variant-numeric: tabular-nums;
}

.kcmpesa-steps {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
	display: grid;
	gap: 8px;
	font-size: 0.9em;
}

.kcmpesa-steps li {
	display: flex !important;
	align-items: center;
	gap: 10px;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	background: none !important;
}

/* WooCommerce's payment-method clearfix (`#payment ul.payment_methods li::before`) also matches these items. */
.kcmpesa-steps li::before,
.kcmpesa-steps li::after {
	content: none !important;
	display: none !important;
}

.kcmpesa-steps__n {
	flex: 0 0 24px;
	height: 24px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 700;
	color: #fff;
	background: var(--kcm-green);
}

.kcmpesa-note {
	margin: 0;
	padding: 8px 12px;
	border-radius: 8px;
	font-size: 0.875em;
	border: 1px solid var(--kcm-line);
}

.kcmpesa-note--sandbox {
	border-color: rgba(180, 83, 9, 0.4);
	background: rgba(251, 191, 36, 0.12);
}

/* Logo sizing: specific enough to beat theme/WooCommerce rules such as `.woocommerce img { height: auto }`. */
.kcmpesa-panel img.kcmpesa-panel__logo,
.kcmpesa-receipt-card img.kcmpesa-receipt-card__logo,
.kcmpesa-block-label img.kcmpesa-block-label__logo {
	width: auto !important;
	max-width: none !important;
	border: 0;
	box-shadow: none;
}

.kcmpesa-panel img.kcmpesa-panel__logo {
	height: 36px !important;
}

.kcmpesa-receipt-card img.kcmpesa-receipt-card__logo {
	height: 32px !important;
}

.kcmpesa-block-label img.kcmpesa-block-label__logo {
	height: 24px !important;
}

/* Block checkout label */
.kcmpesa-block-label {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	width: 100%;
}

.kcmpesa-block-label__logo {
	height: 24px;
	width: auto;
	margin-inline-start: auto;
}

/* ---------- Status panel (waiting / thank-you / account) ---------- */
.kcmpesa-panel {
	max-width: 600px;
	margin: 24px auto;
	padding: 20px;
	border: 1px solid var(--kcm-line);
	border-radius: var(--kcm-radius);
	display: grid;
	gap: 16px;
}

.kcmpesa-panel--account,
.kcmpesa-panel--thankyou {
	margin-inline: 0;
}

.kcmpesa-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--kcm-line);
}

.kcmpesa-panel__logo {
	height: 30px;
	width: auto;
}

.kcmpesa-panel__amount {
	font-size: 1.25em;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.kcmpesa-status {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 16px;
	align-items: center;
}

.kcmpesa-status__icon {
	position: relative;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--kcm-green);
	background: var(--kcm-soft);
}

.kcmpesa-icon {
	display: none;
	line-height: 0;
}

.kcmpesa-panel[data-status="pending"] .kcmpesa-icon--wait,
.kcmpesa-panel[data-status="initiated"] .kcmpesa-icon--wait,
.kcmpesa-panel[data-status="processing"] .kcmpesa-icon--wait,
.kcmpesa-panel[data-status="expired"] .kcmpesa-icon--wait,
.kcmpesa-panel[data-status="none"] .kcmpesa-icon--wait,
.kcmpesa-panel[data-status="successful"] .kcmpesa-icon--ok,
.kcmpesa-panel[data-status="failed"] .kcmpesa-icon--bad,
.kcmpesa-panel[data-status="cancelled"] .kcmpesa-icon--bad,
.kcmpesa-panel[data-status="timeout"] .kcmpesa-icon--bad,
.kcmpesa-panel[data-status="partial"] .kcmpesa-icon--bad {
	display: block;
}

.kcmpesa-panel[data-status="successful"] .kcmpesa-status__icon {
	color: #fff;
	background: var(--kcm-green);
}

.kcmpesa-panel[data-status="failed"] .kcmpesa-status__icon,
.kcmpesa-panel[data-status="cancelled"] .kcmpesa-status__icon,
.kcmpesa-panel[data-status="timeout"] .kcmpesa-status__icon {
	color: var(--kcm-red);
	background: rgba(220, 38, 38, 0.1);
}

.kcmpesa-panel[data-status="partial"] .kcmpesa-status__icon,
.kcmpesa-panel[data-status="expired"] .kcmpesa-status__icon {
	color: var(--kcm-amber);
	background: rgba(251, 191, 36, 0.16);
}

/* Pulsing ring while waiting */
.kcmpesa-panel[data-status="pending"] .kcmpesa-status__icon::after,
.kcmpesa-panel[data-status="processing"] .kcmpesa-status__icon::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--kcm-brand);
	animation: kcmpesa-pulse 1.8s var(--kcm-ease) infinite;
}

@keyframes kcmpesa-pulse {
	0% {
		transform: scale(1);
		opacity: 0.7;
	}
	100% {
		transform: scale(1.35);
		opacity: 0;
	}
}

.kcmpesa-status__title {
	margin: 0 0 4px;
	font-size: 1.2em;
	line-height: 1.3;
}

.kcmpesa-status__msg,
.kcmpesa-status__phone {
	margin: 0;
	line-height: 1.5;
}

.kcmpesa-status__phone {
	margin-top: 4px;
	font-size: 0.9em;
	opacity: 0.85;
	font-variant-numeric: tabular-nums;
}

.kcmpesa-progress {
	grid-column: 1 / -1;
	display: flex;
	align-items: center;
	gap: 12px;
}

.kcmpesa-progress[hidden] {
	display: none;
}

.kcmpesa-progress__bar {
	flex: 1;
	height: 6px;
	border-radius: 999px;
	background: var(--kcm-line);
	overflow: hidden;
}

.kcmpesa-progress__bar span {
	display: block;
	height: 100%;
	width: 100%;
	background: var(--kcm-green);
	transform-origin: left center;
	transition: transform 1s linear;
}

.kcmpesa-progress__time {
	min-width: 6ch;
	text-align: end;
	font-size: 0.875em;
	font-variant-numeric: tabular-nums;
}

.kcmpesa-retry,
.kcmpesa-receipt {
	display: grid;
	gap: 6px;
}

.kcmpesa-retry[hidden],
.kcmpesa-receipt[hidden],
.kcmpesa-help-toggle[hidden],
.kcmpesa-manual[hidden] {
	display: none;
}

.kcmpesa-retry label,
.kcmpesa-receipt label {
	font-weight: 600;
}

.kcmpesa-retry__row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.kcmpesa-retry__row input {
	flex: 1 1 200px;
	min-height: 48px;
	font-size: 16px;
	font-variant-numeric: tabular-nums;
}

.kcmpesa-btn,
.kcmpesa-panel .button.kcmpesa-btn {
	min-height: 48px;
	padding-inline: 20px;
	cursor: pointer;
	touch-action: manipulation;
	white-space: nowrap;
}

.kcmpesa-btn[disabled] {
	opacity: 0.55;
	cursor: progress;
}

.kcmpesa-btn--secondary {
	background: transparent;
}

.kcmpesa-help-toggle,
.kcmpesa-manual {
	border: 1px solid var(--kcm-line);
	border-radius: 10px;
	padding: 0 14px;
}

.kcmpesa-help-toggle summary,
.kcmpesa-manual summary {
	cursor: pointer;
	min-height: 48px;
	display: flex;
	align-items: center;
	font-weight: 600;
	list-style-position: inside;
}

.kcmpesa-help-toggle summary:focus-visible,
.kcmpesa-manual summary:focus-visible,
.kcmpesa-link:focus-visible,
.kcmpesa-copy:focus-visible {
	outline: 2px solid var(--kcm-green);
	outline-offset: 2px;
	border-radius: 4px;
}

.kcmpesa-help-toggle ul,
.kcmpesa-manual__steps {
	margin: 0 0 12px 18px;
	padding: 0;
}

.kcmpesa-link {
	background: none;
	border: 0;
	padding: 8px 0 14px;
	color: var(--kcm-green);
	font: inherit;
	font-weight: 600;
	text-decoration: underline;
	cursor: pointer;
}

.kcmpesa-manual__grid {
	margin: 0 0 12px;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 10px;
}

.kcmpesa-manual__grid > div {
	padding: 10px 12px;
	border-radius: 8px;
	background: var(--kcm-soft);
}

.kcmpesa-manual__grid dt {
	font-size: 0.8em;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	opacity: 0.85;
}

.kcmpesa-manual__grid dd {
	margin: 2px 0 0;
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	font-variant-numeric: tabular-nums;
	font-size: 1.05em;
}

.kcmpesa-copy {
	border: 1px solid var(--kcm-line);
	background: transparent;
	color: inherit;
	border-radius: 6px;
	padding: 4px 10px;
	min-height: 32px;
	font-size: 0.8em;
	cursor: pointer;
}

.kcmpesa-receipt {
	padding: 12px 0 14px;
	border-top: 1px solid var(--kcm-line);
}

.kcmpesa-receipt input {
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

/* ---------- Paid receipt card ---------- */
.kcmpesa-receipt-card {
	margin: 0 0 24px;
	padding: 16px 20px;
	border: 1px solid var(--kcm-line);
	border-inline-start: 4px solid var(--kcm-brand);
	border-radius: var(--kcm-radius);
}

.kcmpesa-receipt-card__head {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 12px;
}

.kcmpesa-receipt-card__head h2 {
	margin: 0;
	font-size: 1.1em;
}

.kcmpesa-receipt-card__check {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--kcm-green);
	color: #fff;
	flex: 0 0 32px;
}

.kcmpesa-receipt-card__logo {
	margin-inline-start: auto;
	height: 26px;
	width: auto;
}

.kcmpesa-receipt-card__grid {
	margin: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 12px 20px;
}

.kcmpesa-receipt-card__grid dt {
	font-size: 0.8em;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	opacity: 0.85;
}

.kcmpesa-receipt-card__grid dd {
	margin: 2px 0 0;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}

.kcmpesa-receipt-card__note {
	margin: 12px 0 0;
}

@media (max-width: 480px) {
	.kcmpesa-panel {
		padding: 16px;
		margin: 16px 0;
	}

	.kcmpesa-status {
		grid-template-columns: 1fr;
		justify-items: center;
		text-align: center;
	}

	.kcmpesa-retry__row .kcmpesa-btn {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.kcmpesa-panel .kcmpesa-status__icon::after {
		animation: none;
		opacity: 0.4;
	}

	.kcmpesa-progress__bar span {
		transition: none;
	}
}
