/**
 * Stitch Payments checkout styles.
 *
 * All themeable values are exposed as --stitch-* design tokens. Style presets
 * (see includes/Payments/class-style-presets.php) and themes override these
 * tokens instead of redeclaring selectors.
 */

:root {
	--stitch-accent: #3b82f6;
	--stitch-accent-soft: #eff6ff;
	--stitch-focus-ring: rgba(59, 130, 246, 0.15);
	--stitch-success: #16a34a;
	--stitch-error: #dc2626;
	--stitch-error-ring: rgba(220, 38, 38, 0.12);
	--stitch-surface: #fff;
	--stitch-surface-soft: #f8fafc;
	--stitch-form-bg: transparent;
	--stitch-form-padding: 0px;
	--stitch-form-text: inherit;
	--stitch-text-body: #475569;
	--stitch-text-muted: #64748b;
	--stitch-field-text: inherit;
	--stitch-field-placeholder: #9ca3af;
	--stitch-field-border: #cbd5e1;
	--stitch-border-soft: #e2e8f0;
	--stitch-saved-border: #dbe3ea;
	--stitch-header-bg: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
	--stitch-header-padding: 1.5rem;
	--stitch-radius-sm: 8px;
	--stitch-radius-md: 10px;
	--stitch-radius-lg: 12px;
	--stitch-field-height: 48px;
	--stitch-field-padding: 0.75rem;
	--stitch-row-gap: 1rem;
	--stitch-card-preview-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 55%, #0f3460 100%);
}

#wc-stitch-form {
	background: var(--stitch-form-bg);
	border: 0;
	border-radius: var(--stitch-radius-lg);
	color: var(--stitch-form-text);
	margin: 1.5em 0;
	padding: var(--stitch-form-padding);
}

#wc-stitch-form input[type="radio"],
#wc-stitch-form input[type="checkbox"] {
	accent-color: var(--stitch-accent);
}

.stitch-payment-header {
	align-items: center;
	background: var(--stitch-header-bg);
	border: 1px solid var(--stitch-border-soft);
	border-radius: var(--stitch-radius-lg);
	display: flex;
	flex-direction: column;
	gap: 1rem;
	justify-content: space-between;
	margin-bottom: 1rem;
	padding: var(--stitch-header-padding);
}

.stitch-logo {
	align-items: center;
	display: flex;
	justify-content: center;
}

.stitch-logo img {
	height: auto;
	max-width: 100%;
	width: 120px;
}

.stitch-accepted-cards {
	align-items: center;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.stitch-accepted-label {
	color: var(--stitch-text-muted);
	font-size: 0.75rem;
	font-weight: 500;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.stitch-payment-description {
	color: var(--stitch-text-body);
	font-size: 0.92rem;
	line-height: 1.55;
	margin: 0;
	max-width: 36rem;
	text-align: center;
}

.stitch-card-icons-row {
	align-items: center;
	display: flex;
	gap: 0.5rem;
}

.stitch-card-icon {
	align-items: center;
	display: flex;
	justify-content: center;
	transition: transform 0.2s ease;
}

.stitch-card-icon:hover {
	transform: translateY(-2px);
}

.stitch-card-icon svg {
	border-radius: 4px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	height: 28px;
	width: 42px;
}

.stitch-saved-card-info {
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
}

.stitch-saved-card-expiry {
	color: var(--stitch-text-muted);
	display: block;
	font-size: 0.8rem;
}

@media (min-width: 480px) {
	.stitch-payment-header {
		flex-direction: row;
		padding: 1rem var(--stitch-header-padding);
	}

	.stitch-accepted-cards {
		flex-direction: row;
		gap: 0.75rem;
	}
}

.wc-stitch-saved-methods {
	margin-bottom: 1rem;
}

.wc-stitch-saved-method {
	align-items: center;
	background: var(--stitch-surface);
	border: 1px solid var(--stitch-saved-border);
	border-radius: var(--stitch-radius-md);
	cursor: pointer;
	display: flex;
	gap: 0.75rem;
	margin-bottom: 0.75rem;
	padding: 0.875rem 1rem;
}

.wc-stitch-saved-method:has(input:checked) {
	background: var(--stitch-accent-soft);
	border-color: var(--stitch-accent);
}

.wc-stitch-saved-method small {
	color: var(--stitch-text-muted);
	display: block;
	font-size: 0.8rem;
	margin-top: 0.125rem;
}

.stitch-form-row {
	margin-bottom: var(--stitch-row-gap);
}

.stitch-form-row label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.35rem;
}

.stitch-form-row input[type="text"],
.stitch-input-wrapper input[type="text"] {
	background: var(--stitch-surface);
	border: 1px solid var(--stitch-field-border);
	border-radius: var(--stitch-radius-sm);
	box-sizing: border-box;
	color: var(--stitch-field-text);
	font-size: 1rem;
	line-height: 1.5;
	min-height: var(--stitch-field-height);
	padding: var(--stitch-field-padding);
	width: 100%;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.stitch-form-row input[type="text"]::placeholder,
.stitch-input-wrapper input[type="text"]::placeholder {
	color: var(--stitch-field-placeholder);
}

#stitch-card-number-container {
	position: relative;
}

.stitch-card-brand-inline {
	align-items: center;
	bottom: calc((var(--stitch-field-height) - 22px) / 2);
	display: flex;
	height: 22px;
	opacity: 0;
	pointer-events: none;
	position: absolute;
	right: 12px;
	transition: opacity 0.2s ease;
}

.stitch-card-brand-inline.is-visible {
	opacity: 1;
}

/* Checkout icons use a 48x32 (3:2) card-shaped viewBox. */
.stitch-card-brand-inline svg {
	border-radius: 3px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	display: block;
	height: 22px;
	width: 33px;
}

.stitch-tokenizer-frame {
	background: var(--stitch-surface);
	border: 1px solid var(--stitch-field-border);
	border-radius: var(--stitch-radius-sm);
	box-sizing: border-box;
	min-height: var(--stitch-field-height);
	overflow: hidden;
	padding: 0;
	width: 100%;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.stitch-tokenizer-frame iframe,
#stitch-tokenizer-iframe {
	border: 0;
	display: block;
	height: var(--stitch-field-height);
	width: 100%;
}

.stitch-input-wrapper input[type="text"]:focus,
.stitch-tokenizer-frame:focus-within {
	border-color: var(--stitch-accent);
	box-shadow: 0 0 0 3px var(--stitch-focus-ring);
	outline: none;
}

.stitch-input-wrapper.valid input[type="text"],
#stitch-card-number-iframe.valid {
	border-color: var(--stitch-success);
}

.stitch-input-wrapper.invalid input[type="text"],
#stitch-card-number-iframe.invalid {
	border-color: var(--stitch-error);
}

.stitch-input-wrapper.invalid input[type="text"]:focus,
#stitch-card-number-iframe.invalid:focus-within {
	box-shadow: 0 0 0 3px var(--stitch-error-ring);
}

.stitch-field-error {
	color: var(--stitch-error);
	display: block;
	font-size: 0.8rem;
	line-height: 1.4;
	margin-top: 0.35rem;
}

.stitch-error-notice {
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-radius: var(--stitch-radius-sm);
	color: #991b1b;
	font-size: 0.875rem;
	margin-bottom: 1rem;
	padding: 0.75rem 1rem;
}

.stitch-error-notice ul {
	margin: 0.25rem 0 0;
	padding-left: 1.25rem;
}

.stitch-form-row--split {
	display: grid;
	gap: var(--stitch-row-gap);
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stitch-form-row--split p {
	margin: 0;
}

.stitch-checkbox-wrapper {
	align-items: center;
	display: flex;
	gap: 0.5rem;
	margin: 0.5rem 0 1rem;
}

.stitch-card-preview {
	margin-bottom: 1rem;
}

.stitch-card-inner {
	background: var(--stitch-card-preview-bg);
	border-radius: 16px;
	box-shadow: 0 18px 35px rgba(15, 23, 42, 0.25);
	color: #fff;
	display: grid;
	gap: 1rem;
	max-width: 380px;
	padding: 1.5rem;
}

#stitch-card-number-display {
	font-family: "Courier New", monospace;
	font-size: 1.25rem;
	letter-spacing: 0.12em;
}

.stitch-surcharge-disclosure td,
.stitch-surcharge-order-summary-note,
.stitch-surcharge-order-disclosure {
	color: var(--stitch-text-muted);
	font-size: 0.875rem;
	line-height: 1.5;
}

.stitch-surcharge-order-disclosure {
	background: var(--stitch-surface-soft);
	border: 1px solid var(--stitch-border-soft);
	border-radius: var(--stitch-radius-sm);
	margin-top: 1rem;
	padding: 0.875rem 1rem;
}

.stitch-surcharge-disclosure-blocks {
	border-top: 0;
	padding-top: 0;
}

#stitch-surcharge-notice {
	display: none;
	margin-top: 1rem;
	padding: 1rem;
	border-radius: var(--stitch-radius-sm);
	font-size: 0.9rem;
	line-height: 1.5;
}

#stitch-surcharge-notice.calculating {
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	color: #1d4ed8;
}

#stitch-surcharge-notice.has-fee {
	background: #fffbeb;
	border: 1px solid #fcd34d;
	color: #92400e;
}

#stitch-surcharge-notice.no-fee {
	background: #f0fdf4;
	border: 1px solid #86efac;
	color: #166534;
}

.stitch-surcharge-calculating,
.stitch-surcharge-fee,
.stitch-surcharge-none {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding-left: 2rem;
}

.stitch-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid #bfdbfe;
	border-top-color: #1d4ed8;
	border-radius: 50%;
	animation: stitch-spin 0.8s linear infinite;
}

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

@media (max-width: 480px) {
	.stitch-payment-header,
	.stitch-form-row--split {
		display: block;
	}

	.stitch-form-row--split p + p {
		margin-top: 1rem;
	}
}
