/**
 * WC Event Registration — Frontend Styles
 *
 * RTL-first, responsive, theme-neutral.
 * Uses CSS custom properties for easy theming.
 */

/* ───── Custom Properties ───── */
:root {
	--wcer-font-family: inherit;
	--wcer-primary: #2563eb;
	--wcer-primary-hover: #1d4ed8;
	--wcer-primary-light: #eff6ff;
	--wcer-danger: #dc2626;
	--wcer-danger-light: #fef2f2;
	--wcer-success: #16a34a;
	--wcer-success-light: #f0fdf4;
	--wcer-warning: #f59e0b;
	--wcer-warning-light: #fffbeb;
	--wcer-text: #1e293b;
	--wcer-text-muted: #64748b;
	--wcer-border: #e2e8f0;
	--wcer-border-focus: #93c5fd;
	--wcer-bg: #ffffff;
	--wcer-bg-subtle: #f8fafc;
	--wcer-radius: 12px;
	--wcer-radius-sm: 8px;
	--wcer-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
	--wcer-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
	--wcer-transition: 0.2s ease;
}

/* ───── Form Wrapper ───── */
.wcer-form-wrapper {
	font-family: var(--wcer-font-family);
	max-width: 520px;
	margin: 0 auto;
	direction: rtl;
}

/* ───── Form ───── */
.wcer-form {
	background: var(--wcer-bg);
	border: 1px solid var(--wcer-border);
	border-radius: var(--wcer-radius);
	padding: 32px;
	box-shadow: var(--wcer-shadow);
	transition: box-shadow var(--wcer-transition);
}

.wcer-form:hover {
	box-shadow: var(--wcer-shadow-lg);
}

/* ───── Header ───── */
.wcer-form__header {
	margin-bottom: 28px;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--wcer-border);
}

.wcer-form__title {
	font-size: 1.35rem;
	font-weight: 700;
	color: var(--wcer-text);
	margin: 0 0 16px 0;
	line-height: 1.4;
}

.wcer-form__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.wcer-form__price,
.wcer-form__capacity {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--wcer-bg-subtle);
	border: 1px solid var(--wcer-border);
	border-radius: var(--wcer-radius-sm);
	padding: 8px 14px;
	font-size: 0.9rem;
}

.wcer-form__price-label,
.wcer-form__capacity-label {
	color: var(--wcer-text-muted);
}

.wcer-form__price-value {
	font-weight: 700;
	color: var(--wcer-primary);
}

/* WooCommerce price HTML overrides */
.wcer-form__price-value .woocommerce-Price-amount {
	font-weight: 700;
	color: var(--wcer-primary);
}

.wcer-form__capacity-value {
	font-weight: 600;
	color: var(--wcer-text);
}

.wcer-form__capacity-value--low {
	color: var(--wcer-danger);
	animation: wcer-pulse 2s infinite;
}

@keyframes wcer-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.6; }
}

/* ───── Fields ───── */
.wcer-form__fields {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.wcer-form__group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.wcer-form__label {
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--wcer-text);
	line-height: 1.4;
}

.wcer-form__required {
	color: var(--wcer-danger);
	margin-right: 2px;
}

.wcer-form__input {
	display: block;
	width: 100%;
	padding: 12px 16px;
	font-family: var(--wcer-font-family);
	font-size: 0.95rem;
	color: var(--wcer-text);
	background: var(--wcer-bg);
	border: 1.5px solid var(--wcer-border);
	border-radius: var(--wcer-radius-sm);
	outline: none;
	transition: border-color var(--wcer-transition), box-shadow var(--wcer-transition);
	direction: rtl;
	box-sizing: border-box;
	-webkit-appearance: none;
}

.wcer-form__input::placeholder {
	color: var(--wcer-text-muted);
	opacity: 0.6;
}

.wcer-form__input:focus {
	border-color: var(--wcer-border-focus);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Input types that should be LTR */
.wcer-form__input[type="email"],
.wcer-form__input[type="tel"],
.wcer-form__input[type="url"] {
	direction: ltr;
	text-align: right;
}

/* Error state */
.wcer-form__group.wcer-field-error .wcer-form__input {
	border-color: var(--wcer-danger);
	box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.wcer-form__error-text {
	font-size: 0.8rem;
	color: var(--wcer-danger);
	min-height: 0;
	overflow: hidden;
	transition: all var(--wcer-transition);
	line-height: 1.4;
}

.wcer-form__group.wcer-field-error .wcer-form__error-text {
	min-height: 1.2em;
}

/* ───── Message Box ───── */
.wcer-form__message {
	margin-top: 16px;
	padding: 0;
	border-radius: var(--wcer-radius-sm);
	font-size: 0.9rem;
	line-height: 1.5;
	overflow: hidden;
	max-height: 0;
	opacity: 0;
	transition: all 0.3s ease;
}

.wcer-form__message.wcer-message--visible {
	padding: 14px 16px;
	margin-top: 16px;
	max-height: 200px;
	opacity: 1;
}

.wcer-form__message.wcer-message--error {
	background: var(--wcer-danger-light);
	color: var(--wcer-danger);
	border: 1px solid rgba(220, 38, 38, 0.15);
}

.wcer-form__message.wcer-message--success {
	background: var(--wcer-success-light);
	color: var(--wcer-success);
	border: 1px solid rgba(22, 163, 74, 0.15);
}

/* ───── Submit Button ───── */
.wcer-form__submit {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	margin-top: 24px;
	padding: 14px 24px;
	font-family: var(--wcer-font-family);
	font-size: 1rem;
	font-weight: 700;
	color: #ffffff;
	background: var(--wcer-primary);
	border: none;
	border-radius: var(--wcer-radius-sm);
	cursor: pointer;
	transition: background var(--wcer-transition), transform var(--wcer-transition), box-shadow var(--wcer-transition);
	-webkit-appearance: none;
}

.wcer-form__submit:hover:not(:disabled) {
	background: var(--wcer-primary-hover);
	box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
	transform: translateY(-1px);
}

.wcer-form__submit:active:not(:disabled) {
	transform: translateY(0);
	box-shadow: none;
}

.wcer-form__submit:disabled {
	opacity: 0.65;
	cursor: not-allowed;
	transform: none;
}

/* Loading state */
.wcer-form__submit-loading {
	display: none;
	align-items: center;
	gap: 8px;
}

.wcer-form.wcer-form--loading .wcer-form__submit-text {
	display: none;
}

.wcer-form.wcer-form--loading .wcer-form__submit-loading {
	display: inline-flex;
}

/* Spinner */
.wcer-spinner {
	animation: wcer-spin 1s linear infinite;
}

@keyframes wcer-spin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}

/* ───── Capacity Full ───── */
.wcer-capacity-full {
	text-align: center;
	padding: 48px 32px;
	background: var(--wcer-bg);
	border: 1px solid var(--wcer-border);
	border-radius: var(--wcer-radius);
	box-shadow: var(--wcer-shadow);
}

.wcer-capacity-full__icon {
	color: var(--wcer-text-muted);
	margin-bottom: 16px;
}

.wcer-capacity-full__title {
	font-size: 1.2rem;
	font-weight: 700;
	color: var(--wcer-text);
	margin: 0 0 8px 0;
}

.wcer-capacity-full__text {
	font-size: 0.95rem;
	color: var(--wcer-text-muted);
	margin: 0;
}

/* ───── Thank You Page Confirmation ───── */
.wcer-confirmation {
	text-align: center;
	padding: 24px;
	border-radius: var(--wcer-radius-sm);
	margin-bottom: 24px;
}

.wcer-confirmation__icon {
	font-size: 2rem;
	display: block;
	margin-bottom: 12px;
}

.wcer-confirmation--success {
	background: var(--wcer-success-light);
	border: 1px solid rgba(22, 163, 74, 0.15);
}

.wcer-confirmation--pending {
	background: var(--wcer-warning-light);
	border: 1px solid rgba(245, 158, 11, 0.15);
}

.wcer-confirmation--failed {
	background: var(--wcer-danger-light);
	border: 1px solid rgba(220, 38, 38, 0.15);
}

.wcer-confirmation h3 {
	margin: 0 0 8px 0;
	font-size: 1.15rem;
}

.wcer-confirmation p {
	margin: 0;
	font-size: 0.9rem;
	color: var(--wcer-text-muted);
}

/* ───── Select & Radio ───── */
.wcer-form__select {
	appearance: none;
	-moz-appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
	background-repeat: no-repeat;
	background-position: left 12px center;
	background-size: 16px;
	padding-left: 40px; /* space for arrow */
}

.wcer-form__radio-group {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 6px;
}

.wcer-form__radio-label {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-size: 0.95rem;
	color: var(--wcer-text);
}

.wcer-form__radio {
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: var(--wcer-primary);
	cursor: pointer;
}

.wcer-form__radio-text {
	line-height: 1.4;
}

/* Fix error border for radio/select */
.wcer-form__group.wcer-field-error .wcer-form__select {
	border-color: var(--wcer-danger);
	box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}
.wcer-form__group.wcer-field-error .wcer-form__radio {
	outline: 2px solid var(--wcer-danger);
	outline-offset: 2px;
	border-radius: 50%;
}

/* ───── Error Box (shortcode misconfiguration) ───── */
.wcer-error-box {
	background: var(--wcer-danger-light);
	color: var(--wcer-danger);
	padding: 16px;
	border-radius: var(--wcer-radius-sm);
	border: 1px solid rgba(220, 38, 38, 0.15);
	font-size: 0.9rem;
	direction: rtl;
}

/* ───── Responsive ───── */
@media (max-width: 600px) {
	.wcer-form {
		padding: 20px 16px;
		border-radius: var(--wcer-radius-sm);
	}

	.wcer-form__title {
		font-size: 1.15rem;
	}

	.wcer-form__meta {
		flex-direction: column;
		gap: 8px;
	}

	.wcer-form__price,
	.wcer-form__capacity {
		width: 100%;
		justify-content: space-between;
	}

	.wcer-form__input {
		padding: 10px 14px;
	}

	.wcer-form__submit {
		padding: 12px 20px;
	}
}
