/* SD M-Pesa Gateway — front-end checkout, ticketing & support forms.
 *
 * Theming: every colour/shape is a CSS variable declared on .sdmg-checkout.
 * Override globally in your theme, or per-form via the shortcode `accent`,
 * `button_color`, `button_text_color` and `radius` attributes (which set the
 * matching --sdmg-* variables inline on the wrapper).
 */

.sdmg-checkout {
	/* Customisable design tokens */
	--sdmg-accent: #00a651;              /* M-Pesa green */
	--sdmg-accent-dark: #008a44;
	--sdmg-btn-bg: var(--sdmg-accent);
	--sdmg-btn-hover: var(--sdmg-accent-dark);
	--sdmg-btn-text: #ffffff;
	--sdmg-radius: 8px;
	--sdmg-field-bg: #ffffff;
	--sdmg-field-border: #c3c4c7;
	--sdmg-field-text: #1d2327;
	--sdmg-choice-selected-bg: #f0f7f2;
	--sdmg-choice-selected-bg: color-mix(in srgb, var(--sdmg-accent) 8%, transparent);
	/* Shared by the checkout, support and ticket forms so they always match.
	   Override globally here, or per form via the shortcode `width` attribute. */
	--sdmg-form-width: 460px;

	max-width: var(--sdmg-form-width);
	width: 100%;
	font-size: 1rem;
	box-sizing: border-box;
}

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

.sdmg-form {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.sdmg-field {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	min-width: 0;
}

.sdmg-field > span {
	font-weight: 600;
	font-size: 0.9em;
}

.sdmg-field input,
.sdmg-field select {
	padding: 0.7em 0.85em;
	border: 1px solid var(--sdmg-field-border);
	border-radius: var(--sdmg-radius);
	background: var(--sdmg-field-bg);
	color: var(--sdmg-field-text);
	font-size: 1em;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.sdmg-field input:focus,
.sdmg-field select:focus {
	outline: 2px solid var(--sdmg-accent);
	outline-offset: 1px;
	border-color: var(--sdmg-accent);
}

/* Fixed-amount display (locked shortcode amount) */
.sdmg-amount-display {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.75rem;
	margin: 0;
	padding: 0.75em 1em;
	background: var(--sdmg-choice-selected-bg);
	border: 1px solid var(--sdmg-accent);
	border-radius: var(--sdmg-radius);
}

.sdmg-amount-label {
	font-size: 0.9em;
	opacity: 0.8;
}

.sdmg-amount-value {
	font-weight: 700;
	font-size: 1.2em;
	white-space: nowrap;
}

/* Suggested-amount presets (support / donation forms) */
.sdmg-amount-presets {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.sdmg-amount-preset {
	flex: 1 1 auto;
	min-width: 4.5rem;
	padding: 0.6em 0.5em;
	border: 1px solid var(--sdmg-field-border);
	border-radius: var(--sdmg-radius);
	background: var(--sdmg-field-bg);
	color: var(--sdmg-field-text);
	font-size: 1em;
	font-weight: 600;
	cursor: pointer;
	text-align: center;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.sdmg-amount-preset.is-active {
	border-color: var(--sdmg-accent);
	background: var(--sdmg-choice-selected-bg);
	color: var(--sdmg-accent);
}

.sdmg-button {
	display: block;
	width: 100%;
	background: var(--sdmg-btn-bg);
	color: var(--sdmg-btn-text);
	border: 0;
	border-radius: var(--sdmg-radius);
	padding: 0.9em 1.4em;
	font-size: 1em;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.sdmg-button:hover,
.sdmg-button:focus {
	background: var(--sdmg-btn-hover);
	color: var(--sdmg-btn-text);
}

.sdmg-button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Status / result banner */
.sdmg-status {
	display: flex;
	align-items: center;
	gap: 0.6em;
	margin-top: 1rem;
	padding: 0.8em 1em;
	border-radius: var(--sdmg-radius);
	border: 1px solid transparent;
}

.sdmg-status-pending,
.sdmg-status-warn {
	background: #fdf6e7;
	border-color: #f0d9a8;
	color: #6b4e10;
}

.sdmg-status-success {
	background: #edf7ef;
	border-color: #b7dfc0;
	color: #14532d;
}

.sdmg-status-fail {
	background: #fcf0f1;
	border-color: #ecbcc0;
	color: #7a1f26;
}

.sdmg-spinner {
	width: 1em;
	height: 1em;
	flex: 0 0 auto;
	border: 2px solid rgba(0, 0, 0, 0.15);
	border-top-color: var(--sdmg-accent);
	border-radius: 50%;
	animation: sdmg-spin 0.8s linear infinite;
}

@keyframes sdmg-spin {
	to {
		transform: rotate(360deg);
	}
}

.sdmg-error {
	color: #b32d2e;
}

/* WooCommerce order-received poller */
.sdmg-wc-poll {
	margin: 1.5rem 0;
}

.sdmg-wc-poll .sdmg-status {
	margin-top: 0;
}

.sdmg-wc-retry {
	margin: 1rem 0 0;
}

.sdmg-wc-retry .sdmg-button {
	display: inline-block;
	width: auto;
	text-decoration: none;
}

.sdmg-wc-rounding {
	font-size: 0.9em;
	opacity: 0.85;
}

/* Event ticketing form */
.sdmg-event-header {
	margin-bottom: 1rem;
}

.sdmg-event-name {
	margin: 0 0 0.25rem;
}

.sdmg-event-meta {
	margin: 0;
	opacity: 0.75;
	font-size: 0.95em;
}

.sdmg-type-choices {
	border: 0;
	padding: 0;
	margin: 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.sdmg-type-choices legend {
	font-weight: 600;
	font-size: 0.9em;
	margin-bottom: 0.35rem;
	padding: 0;
}

.sdmg-type-choice {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.85em 1em;
	border: 1px solid var(--sdmg-field-border);
	border-radius: var(--sdmg-radius);
	cursor: pointer;
}

.sdmg-type-choice:has(input:checked) {
	border-color: var(--sdmg-accent);
	background: var(--sdmg-choice-selected-bg);
}

/*
 * Critical: many themes force `input { width: 100% }`, which stretches the
 * radio and shoves the label text off the right edge. Pin the radio to a
 * fixed box (with !important to beat theme rules) so the layout is stable.
 */
.sdmg-type-choice input[type="radio"] {
	flex: 0 0 auto !important;
	width: 20px !important;
	min-width: 20px !important;
	height: 20px !important;
	margin: 0 !important;
	padding: 0 !important;
	accent-color: var(--sdmg-accent);
}

.sdmg-type-name {
	flex: 1 1 auto;
	min-width: 0;
	font-weight: 600;
	text-align: left;
	overflow-wrap: break-word;
}

.sdmg-type-price {
	flex: 0 0 auto;
	font-weight: 700;
	text-align: right;
	white-space: nowrap;
}

.sdmg-type-price small {
	display: block;
	font-weight: 400;
	font-size: 0.8em;
	color: #8a6116;
}

.sdmg-type-soldout {
	opacity: 0.55;
	cursor: not-allowed;
}

.sdmg-sales-closed {
	padding: 0.8em 1em;
	background: #fdf6e7;
	border: 1px solid #f0d9a8;
	border-radius: var(--sdmg-radius);
}

/* Support / donation intro */
.sdmg-support-heading {
	margin: 0 0 0.25rem;
}

.sdmg-support-intro {
	margin: 0 0 0.25rem;
	opacity: 0.8;
	font-size: 0.95em;
}

/* Responsive */
@media (max-width: 480px) {
	.sdmg-checkout {
		max-width: 100%;
	}

	.sdmg-type-choice {
		gap: 0.6rem;
		padding: 0.75em 0.85em;
	}

	.sdmg-amount-preset {
		min-width: 3.75rem;
	}
}
