/**
 * Redsys Express Pay Product Buttons Styles
 * Following WooCommerce UX Guidelines for Payment Buttons
 *
 * @package WooCommerce Redsys Gateway
 * @since 25.0.0
 * @see https://developer.woocommerce.com/docs/user-experience-guidelines/ux-guidelines-payments/payment-button-layout/
 */

/* ==========================================================================
   Main Container
   Position: Below "Add to Cart" button
   ========================================================================== */

.redsys-express-pay-buttons {
	margin-top: 16px;
	clear: both;
	width: 100%;
	max-width: 100%;
}

/* ==========================================================================
   Buttons Wrapper - Horizontal Layout
   Equal hierarchy and consistent spacing between buttons
   ========================================================================== */

.redsys-express-buttons-wrapper {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	gap: 10px;
	align-items: stretch;
	width: 100%;
	max-width: 400px;
}

/* Single button */
.redsys-express-buttons-wrapper.single-button {
	max-width: 200px;
}

/* Multiple buttons: equal width */
.redsys-express-buttons-wrapper.multiple-buttons .redsys-express-button {
	flex: 1 1 50%;
	width: 50%;
}

/* ==========================================================================
   Individual Button Container
   Fixed height for consistency
   ========================================================================== */

.redsys-express-button {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 44px;
	min-height: 44px;
	max-height: 44px;
	border-radius: 4px;
	overflow: hidden;
	box-sizing: border-box;
}

.redsys-express-button.disabled {
	opacity: 0.4;
	pointer-events: none;
	cursor: not-allowed;
}

/* ==========================================================================
   Apple Pay Button - Force same size
   ========================================================================== */

.redsys-applepay-button {
	background-color: #000;
	padding: 0;
}

.redsys-applepay-button apple-pay-button {
	--apple-pay-button-width: 100%;
	--apple-pay-button-height: 44px;
	--apple-pay-button-border-radius: 4px;
	width: 100% !important;
	height: 44px !important;
	max-height: 44px !important;
	display: block;
}

/* ==========================================================================
   Google Pay Button - Force same size and center content
   ========================================================================== */

.redsys-googlepay-button {
	background: transparent;
	padding: 0;
}

.redsys-googlepay-button .gpay-button-container,
.redsys-googlepay-button > div {
	width: 100% !important;
	height: 44px !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
}

.redsys-googlepay-button .gpay-button,
.redsys-googlepay-button button.gpay-button,
.redsys-googlepay-button .gpay-button-fill {
	width: 100% !important;
	min-width: 100% !important;
	height: 44px !important;
	min-height: 44px !important;
	max-height: 44px !important;
	border-radius: 4px !important;
	padding: 0 12px !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
}

/* Center the internal content of Google Pay button */
.redsys-googlepay-button .gpay-button > div,
.redsys-googlepay-button button.gpay-button > div {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
}

/* ==========================================================================
   One-Click Buy Button Compatibility
   Make the orange Visa button consistent with Apple/Google Pay
   ========================================================================== */

/* When express buttons are present, show compact text and hide full text */
#one-click-buy-button.compact-mode .one-click-full-text {
	display: none !important;
}

#one-click-buy-button.compact-mode .one-click-compact-text {
	display: inline !important;
}

/* Compact styling ONLY when express buttons are present (compact-mode class added by JS) */
#one-click-buy-button.compact-mode {
	height: 44px !important;
	min-height: 44px !important;
	max-height: 44px !important;
	padding: 0 20px 0 50px !important;
	font-size: 14px !important;
	border-radius: 4px !important;
	box-sizing: border-box !important;
	min-width: 197px !important;
	width: auto !important;
	background-size: 36px 18px !important;
	background-position: 10px center !important;
	line-height: 44px !important;
	white-space: nowrap !important;
	overflow: hidden !important;
	text-overflow: ellipsis !important;
	margin: 10px 0 0 0 !important;
	vertical-align: top !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: flex-start !important;
}

/* Reset line-height for spans inside button when compact */
#one-click-buy-button.compact-mode span {
	line-height: 1 !important;
}

/* ==========================================================================
   Variation Notice Message
   ========================================================================== */

.redsys-express-variation-notice {
	font-size: 13px;
	color: #646970;
	margin: 0 0 12px 0;
	padding: 10px 14px;
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	text-align: center;
	line-height: 1.5;
	max-width: 400px;
}

/* ==========================================================================
   Mobile Styles
   ========================================================================== */

@media screen and (max-width: 480px) {
	.redsys-express-pay-buttons {
		margin-top: 12px;
	}

	.redsys-express-buttons-wrapper,
	.redsys-express-buttons-wrapper.single-button,
	.redsys-express-buttons-wrapper.multiple-buttons {
		max-width: 100%;
		flex-wrap: wrap;
	}

	.redsys-express-buttons-wrapper.multiple-buttons .redsys-express-button {
		flex: 1 1 100%;
		width: 100%;
	}

	.redsys-express-variation-notice {
		max-width: 100%;
	}

	#one-click-buy-button {
		max-width: 100% !important;
		width: 100% !important;
	}
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

@media (prefers-contrast: high) {
	.redsys-express-button {
		border: 2px solid currentColor;
	}
}

@media (prefers-reduced-motion: reduce) {
	.redsys-express-button {
		transition: none;
	}
}

.redsys-express-button:focus-within {
	outline: 2px solid #007cba;
	outline-offset: 2px;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.redsys-express-button.loading {
	position: relative;
	pointer-events: none;
}

.redsys-express-button.loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	border: 2px solid transparent;
	border-top-color: #fff;
	border-radius: 50%;
	animation: redsys-express-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Theme Compatibility
   ========================================================================== */

.redsys-express-pay-buttons {
	position: relative;
	z-index: 10;
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .redsys-express-buttons-wrapper {
	flex-direction: row-reverse;
}
