/**
 * Redsys Express Custom Fields Modal Styles
 *
 * @package WooCommerce Redsys Gateway
 * @since 30.0.0
 */

/* Prevent body scroll when modal is open */
body.redsys-modal-open {
	overflow: hidden;
}

/* Modal Overlay */
.redsys-modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 999999;
	padding: 20px;
	box-sizing: border-box;
}

/* Modal Container */
.redsys-modal {
	background: #fff;
	border-radius: 12px;
	max-width: 480px;
	width: 100%;
	max-height: 90vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
	animation: redsys-modal-appear 0.2s ease-out;
}

@keyframes redsys-modal-appear {
	from {
		opacity: 0;
		transform: scale(0.95) translateY(-10px);
	}
	to {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

/* Modal Header */
.redsys-modal-header {
	padding: 24px 24px 16px;
	border-bottom: 1px solid #e5e7eb;
	background: #fff;
}

.redsys-modal-title {
	margin: 0 0 8px;
	font-size: 1.25rem;
	font-weight: 600;
	color: #111827;
	line-height: 1.3;
}

.redsys-modal-subtitle {
	margin: 0;
	font-size: 0.875rem;
	color: #6b7280;
	line-height: 1.5;
}

/* Modal Body */
.redsys-modal-body {
	padding: 24px;
	overflow-y: auto;
	flex: 1;
}

/* Form Fields */
.redsys-modal-field {
	margin-bottom: 20px;
}

.redsys-modal-field:last-child {
	margin-bottom: 0;
}

.redsys-modal-field > label {
	display: block;
	margin-bottom: 6px;
	font-size: 0.875rem;
	font-weight: 500;
	color: #374151;
}

.redsys-modal-field label .required {
	color: #dc2626;
	margin-left: 2px;
}

.redsys-modal-field input[type="text"],
.redsys-modal-field input[type="email"],
.redsys-modal-field input[type="tel"],
.redsys-modal-field input[type="number"],
.redsys-modal-field input[type="date"],
.redsys-modal-field textarea,
.redsys-modal-field select {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font-size: 1rem;
	color: #111827;
	background: #fff;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	box-sizing: border-box;
	font-family: inherit;
}

.redsys-modal-field input:focus,
.redsys-modal-field textarea:focus,
.redsys-modal-field select:focus {
	outline: none;
	border-color: #3b82f6;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.redsys-modal-field textarea {
	min-height: 80px;
	resize: vertical;
}

.redsys-modal-field select {
	cursor: pointer;
	appearance: none;
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
	background-position: right 10px center;
	background-repeat: no-repeat;
	background-size: 20px;
	padding-right: 40px;
}

/* Checkbox */
.redsys-checkbox-wrapper {
	display: flex;
	align-items: flex-start;
	gap: 8px;
}

.redsys-checkbox-wrapper input[type="checkbox"] {
	width: 18px;
	height: 18px;
	margin: 2px 0 0 0;
	cursor: pointer;
	flex-shrink: 0;
}

.redsys-checkbox-label {
	font-size: 0.875rem;
	color: #374151;
	cursor: pointer;
	line-height: 1.4;
}

/* Radio Group */
.redsys-radio-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.redsys-radio-label {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-size: 0.875rem;
	color: #374151;
}

.redsys-radio-label input[type="radio"] {
	width: 18px;
	height: 18px;
	margin: 0;
	cursor: pointer;
}

/* Error State */
.redsys-modal-field.has-error input,
.redsys-modal-field.has-error textarea,
.redsys-modal-field.has-error select {
	border-color: #dc2626;
}

.redsys-modal-field.has-error input:focus,
.redsys-modal-field.has-error textarea:focus,
.redsys-modal-field.has-error select:focus {
	box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.redsys-field-error {
	display: block;
	margin-top: 6px;
	font-size: 0.8125rem;
	color: #dc2626;
	min-height: 1em;
}

.redsys-field-error:empty {
	display: none;
}

/* Modal Footer */
.redsys-modal-footer {
	padding: 16px 24px;
	border-top: 1px solid #e5e7eb;
	display: flex;
	justify-content: flex-end;
	gap: 12px;
	background: #f9fafb;
}

/* Buttons */
.redsys-modal-btn {
	padding: 10px 20px;
	font-size: 0.9375rem;
	font-weight: 500;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.15s ease;
	border: none;
	font-family: inherit;
	line-height: 1.4;
}

.redsys-modal-btn-primary {
	background: #111827;
	color: #fff;
}

.redsys-modal-btn-primary:hover {
	background: #1f2937;
}

.redsys-modal-btn-primary:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.3);
}

.redsys-modal-btn-primary:disabled {
	background: #9ca3af;
	cursor: not-allowed;
}

.redsys-modal-btn-secondary {
	background: #fff;
	color: #374151;
	border: 1px solid #d1d5db;
}

.redsys-modal-btn-secondary:hover {
	background: #f3f4f6;
}

.redsys-modal-btn-secondary:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.2);
}

/* Responsive */
@media (max-width: 540px) {
	.redsys-modal-overlay {
		padding: 10px;
		align-items: flex-end;
	}

	.redsys-modal {
		max-height: 95vh;
		border-radius: 16px 16px 0 0;
		max-width: 100%;
	}

	.redsys-modal-header,
	.redsys-modal-body {
		padding: 20px;
	}

	.redsys-modal-footer {
		padding: 16px 20px;
		flex-direction: column-reverse;
		gap: 10px;
	}

	.redsys-modal-btn {
		width: 100%;
		text-align: center;
		padding: 12px 20px;
	}
}

/* RTL Support */
[dir="rtl"] .redsys-modal-field select {
	background-position: left 10px center;
	padding-right: 12px;
	padding-left: 40px;
}

[dir="rtl"] .redsys-modal-field label .required {
	margin-left: 0;
	margin-right: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
	.redsys-modal-field input,
	.redsys-modal-field textarea,
	.redsys-modal-field select {
		border-width: 2px;
	}

	.redsys-modal-btn-primary {
		background: #000;
	}

	.redsys-modal-btn-secondary {
		border-width: 2px;
	}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.redsys-modal {
		animation: none;
	}

	.redsys-modal-field input,
	.redsys-modal-field textarea,
	.redsys-modal-field select,
	.redsys-modal-btn {
		transition: none;
	}
}

/* ======================================
   1-Click Pay Shipping Modal Styles
   ====================================== */

/* Shipping Modal - Wider */
.redsys-shipping-modal {
	max-width: 520px;
}

/* Order Summary */
.redsys-modal-order-summary {
	background: #f9fafb;
	border-radius: 8px;
	padding: 16px;
	margin-bottom: 20px;
}

.redsys-order-summary-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 6px 0;
	font-size: 0.875rem;
	color: #374151;
}

.redsys-order-summary-row.total {
	border-top: 1px solid #e5e7eb;
	margin-top: 8px;
	padding-top: 12px;
	font-size: 1rem;
	font-weight: 600;
	color: #111827;
}

/* Shipping Methods List */
.redsys-shipping-methods-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.redsys-shipping-method-item {
	display: flex;
	align-items: center;
	padding: 14px 16px;
	border: 2px solid #e5e7eb;
	border-radius: 10px;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.redsys-shipping-method-item:hover {
	border-color: #9ca3af;
	background-color: #f9fafb;
}

.redsys-shipping-method-item.selected {
	border-color: #111827;
	background-color: #f3f4f6;
}

.redsys-shipping-method-item input[type="radio"] {
	width: 20px;
	height: 20px;
	margin: 0;
	margin-right: 14px;
	cursor: pointer;
	accent-color: #111827;
	flex-shrink: 0;
}

.redsys-shipping-method-details {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.redsys-shipping-method-label {
	font-size: 0.9375rem;
	font-weight: 500;
	color: #111827;
}

.redsys-shipping-method-description {
	font-size: 0.8125rem;
	color: #6b7280;
	margin-top: 2px;
}

.redsys-shipping-method-cost {
	font-size: 0.9375rem;
	font-weight: 600;
	color: #111827;
	margin-left: 12px;
	flex-shrink: 0;
}

/* Loading State */
.redsys-shipping-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	text-align: center;
}

.redsys-shipping-loading .spinner {
	width: 32px;
	height: 32px;
	border: 3px solid #e5e7eb;
	border-top-color: #111827;
	border-radius: 50%;
	animation: redsys-spin 0.8s linear infinite;
	margin-bottom: 12px;
}

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

.redsys-shipping-loading-text {
	font-size: 0.875rem;
	color: #6b7280;
}

/* No Shipping Available */
.redsys-no-shipping-message {
	text-align: center;
	padding: 24px 16px;
	color: #dc2626;
	font-size: 0.875rem;
	background: #fef2f2;
	border-radius: 8px;
}

/* Terms Message */
.redsys-terms-message {
	margin-bottom: 20px;
}

.redsys-terms-message p {
	margin: 0 0 10px;
	font-size: 0.9375rem;
	color: #374151;
	line-height: 1.5;
}

.redsys-terms-message p:last-child {
	margin-bottom: 0;
}

.redsys-terms-message a {
	color: #2563eb;
	text-decoration: underline;
}

.redsys-terms-message a:hover {
	color: #1d4ed8;
}

/* ======================================
   1-Click Pay Button Styles
   ====================================== */

/* Variation Selection Notice */
.redsys-one-click-variation-notice {
	background: #fef3c7;
	border: 1px solid #f59e0b;
	border-radius: 8px;
	padding: 12px 16px;
	margin-bottom: 12px;
	font-size: 0.875rem;
	color: #92400e;
	text-align: center;
}

/* Disabled button state for variable products */
#one-click-buy-button.disabled,
#one-click-buy-button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	pointer-events: none;
}

/* RTL Support for Shipping */
[dir="rtl"] .redsys-shipping-method-item input[type="radio"] {
	margin-right: 0;
	margin-left: 14px;
}

[dir="rtl"] .redsys-shipping-method-cost {
	margin-left: 0;
	margin-right: 12px;
}

/* Mobile Responsive for Shipping Modal */
@media (max-width: 540px) {
	.redsys-shipping-modal {
		max-width: 100%;
	}

	.redsys-shipping-method-item {
		padding: 12px 14px;
	}

	.redsys-shipping-method-item input[type="radio"] {
		width: 18px;
		height: 18px;
		margin-right: 12px;
	}

	.redsys-shipping-method-label {
		font-size: 0.875rem;
	}

	.redsys-shipping-method-cost {
		font-size: 0.875rem;
	}

	.redsys-modal-order-summary {
		padding: 12px;
	}

	.redsys-order-summary-row {
		font-size: 0.8125rem;
	}

	.redsys-order-summary-row.total {
		font-size: 0.9375rem;
	}
}
