/**
 * Contact Form 7 — ALHADAF theme integration.
 *
 * Scoped under .wpcf7 so it never leaks into other forms.
 * Uses the theme tokens, so light/dark mode work automatically.
 */

.wpcf7 {
	--alhadaf-cf7-gap: 18px;
	--alhadaf-cf7-radius: 12px;
	width: 100%;
	max-width: 760px;
	margin: 28px auto;
	padding: clamp(20px, 4vw, 34px);
	background: var(--alhadaf-surface);
	border: 1px solid var(--alhadaf-border);
	border-radius: 20px;
	box-shadow: 0 18px 45px rgba(7, 13, 30, 0.08);
	color: var(--alhadaf-text-main);
	direction: rtl;
}

[data-theme="dark"] .wpcf7 {
	box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.wpcf7 form {
	margin: 0;
}

.wpcf7-form {
	display: flex;
	flex-direction: column;
	gap: var(--alhadaf-cf7-gap);
	margin: 0;
}

.wpcf7-form > p {
	display: flex;
	flex-direction: column;
	gap: 7px;
	margin: 0;
	padding: 0;
}

.wpcf7-form > p:empty {
	display: none;
}

.wpcf7-form label {
	display: block;
	margin: 0;
	color: var(--alhadaf-text-main);
	font-size: 0.86rem;
	font-weight: 700;
	line-height: 1.6;
}

.wpcf7-form .wpcf7-required,
.wpcf7-form .wpcf7-list-item-label .wpcf7-required {
	color: var(--alhadaf-accent);
}

/* Field wrapper ---------------------------------------------------------- */
.wpcf7-form .wpcf7-form-control-wrap {
	display: block;
	width: 100%;
}

.wpcf7-form .wpcf7-form-control-wrap:has(.wpcf7-not-valid-tip) {
	margin-bottom: 2px;
}

/* Inputs, selects, textarea --------------------------------------------- */
.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 input[type="tel"],
.wpcf7 input[type="url"],
.wpcf7 input[type="number"],
.wpcf7 input[type="date"],
.wpcf7 input[type="time"],
.wpcf7 input[type="search"],
.wpcf7 select,
.wpcf7 textarea {
	display: block;
	width: 100%;
	min-height: 48px;
	margin: 0;
	padding: 12px 15px;
	background: var(--alhadaf-bg);
	border: 1px solid var(--alhadaf-border);
	border-radius: var(--alhadaf-cf7-radius);
	color: var(--alhadaf-text-main);
	font-family: inherit;
	font-size: 0.93rem;
	line-height: 1.6;
	text-align: right;
	box-shadow: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.wpcf7 textarea {
	min-height: 158px;
	padding-top: 13px;
	padding-bottom: 13px;
	resize: vertical;
}

.wpcf7 select {
	-webkit-appearance: none;
	appearance: none;
	padding-left: 42px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' 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/svg%3E");
	background-repeat: no-repeat;
	background-position: left 15px center;
	background-size: 16px;
}

.wpcf7 input::placeholder,
.wpcf7 textarea::placeholder {
	color: var(--alhadaf-text-light);
	opacity: 1;
}

.wpcf7 input:hover,
.wpcf7 select:hover,
.wpcf7 textarea:hover {
	border-color: color-mix(in srgb, var(--alhadaf-text-light) 55%, var(--alhadaf-border));
}

.wpcf7 input:focus,
.wpcf7 select:focus,
.wpcf7 textarea:focus,
.wpcf7 input:focus-visible,
.wpcf7 select:focus-visible,
.wpcf7 textarea:focus-visible {
	outline: none;
	border-color: var(--alhadaf-accent);
	box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.16);
}

/* File upload ----------------------------------------------------------- */
.wpcf7 input[type="file"] {
	display: block;
	width: 100%;
	padding: 10px 12px;
	background: var(--alhadaf-bg);
	border: 1px dashed var(--alhadaf-border);
	border-radius: var(--alhadaf-cf7-radius);
	color: var(--alhadaf-text-muted);
	font-size: 0.85rem;
	cursor: pointer;
}

.wpcf7 input[type="file"]::file-selector-button {
	margin-inline-end: 10px;
	padding: 7px 12px;
	background: var(--alhadaf-surface);
	border: 1px solid var(--alhadaf-border);
	border-radius: 8px;
	color: var(--alhadaf-text-main);
	font-family: inherit;
	font-weight: 600;
	cursor: pointer;
}

/* Checkboxes, radios, acceptance ---------------------------------------- */
.wpcf7 input[type="checkbox"],
.wpcf7 input[type="radio"] {
	width: 18px;
	height: 18px;
	margin: 2px 0 0;
	accent-color: var(--alhadaf-accent);
	cursor: pointer;
}

.wpcf7 .wpcf7-list-item {
	display: flex;
	align-items: flex-start;
	margin: 0 0 9px;
}

.wpcf7 .wpcf7-list-item:last-child {
	margin-bottom: 0;
}

.wpcf7 .wpcf7-list-item label {
	display: inline-flex;
	align-items: flex-start;
	gap: 9px;
	color: var(--alhadaf-text-muted);
	font-size: 0.88rem;
	font-weight: 500;
	line-height: 1.7;
	cursor: pointer;
}

.wpcf7 .wpcf7-list-item-label {
	color: var(--alhadaf-text-muted);
}

/* Quiz ------------------------------------------------------------------ */
.wpcf7 .wpcf7-quiz {
	text-align: right;
}

.wpcf7 .wpcf7-quiz-label {
	font-weight: 700;
}

.wpcf7 .wpcf7-quiz-label .wpcf7-quiz-label {
	color: var(--alhadaf-accent);
}

/* Submit ---------------------------------------------------------------- */
.wpcf7 .wpcf7-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: auto;
	min-width: 180px;
	min-height: 48px;
	margin: 4px 0 0;
	padding: 12px 30px;
	background: var(--alhadaf-accent) !important;
	border: 0 !important;
	border-radius: 999px;
	color: #fff !important;
	font-family: inherit;
	font-size: 0.92rem;
	font-weight: 800;
	line-height: 1.2;
	letter-spacing: 0.2px;
	cursor: pointer;
	box-shadow: 0 10px 24px rgba(230, 57, 70, 0.24);
	transition: background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.wpcf7 .wpcf7-submit:hover {
	background: var(--alhadaf-accent-hover) !important;
	color: #fff !important;
	transform: translateY(-1px);
	box-shadow: 0 14px 28px rgba(230, 57, 70, 0.3);
}

.wpcf7 .wpcf7-submit:focus-visible {
	outline: 2px solid var(--alhadaf-accent);
	outline-offset: 3px;
}

.wpcf7 .wpcf7-submit:disabled,
.wpcf7 form.submitting .wpcf7-submit {
	opacity: 0.68;
	cursor: wait;
	transform: none;
	box-shadow: none;
}

/* Spinner --------------------------------------------------------------- */
.wpcf7 .wpcf7-spinner {
	display: none;
	width: 18px;
	height: 18px;
	margin: 0 auto;
	background: none !important;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: alhadaf-cf7-spin 0.75s linear infinite;
}

.wpcf7 form.submitting .wpcf7-spinner {
	display: inline-block;
	visibility: visible !important;
}

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

/* Validation ------------------------------------------------------------ */
.wpcf7 .wpcf7-not-valid {
	border-color: var(--alhadaf-accent) !important;
	box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

.wpcf7 .wpcf7-not-valid-tip {
	display: block;
	margin-top: 5px;
	color: var(--alhadaf-accent);
	font-size: 0.78rem;
	font-weight: 600;
	line-height: 1.5;
}

.wpcf7 .wpcf7-not-valid-tip::before {
	content: "!";
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 15px;
	height: 15px;
	margin-inline-end: 5px;
	background: var(--alhadaf-accent);
	border-radius: 50%;
	color: #fff;
	font-size: 0.62rem;
	font-weight: 800;
	line-height: 1;
}

/* Response messages ----------------------------------------------------- */
.wpcf7 .wpcf7-response-output {
	width: 100%;
	margin: 0;
	padding: 13px 16px;
	background: var(--alhadaf-bg);
	border: 1px solid var(--alhadaf-border);
	border-radius: var(--alhadaf-cf7-radius);
	color: var(--alhadaf-text-main);
	font-size: 0.86rem;
	font-weight: 500;
	line-height: 1.75;
}

.wpcf7 form.sent .wpcf7-response-output,
.wpcf7 form[data-status="mail_sent"] .wpcf7-response-output {
	background: rgba(34, 197, 94, 0.1);
	border-color: rgba(34, 197, 94, 0.4);
	color: var(--alhadaf-text-main);
}

.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form[data-status="mail_failed"] .wpcf7-response-output,
.wpcf7 form[data-status="acceptance_missing"] .wpcf7-response-output,
.wpcf7 form[data-status="spam"] .wpcf7-response-output,
.wpcf7 form[data-status="aborted"] .wpcf7-response-output {
	background: rgba(230, 57, 70, 0.09);
	border-color: rgba(230, 57, 70, 0.38);
	color: var(--alhadaf-text-main);
}

.wpcf7 form[data-status="validation_failed"] .wpcf7-response-output,
.wpcf7 form.invalid .wpcf7-response-output {
	background: rgba(245, 158, 11, 0.1);
	border-color: rgba(245, 158, 11, 0.4);
	color: var(--alhadaf-text-main);
}

/* Hide CF7's built-in screen-reader response visually. */
.wpcf7 .screen-reader-response {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

.wpcf7 .screen-reader-response ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Two-column support for forms that use .alhadaf-cf7-two-col ----------- */
@media (min-width: 782px) {
	.wpcf7-form.alhadaf-cf7-two-col {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: 20px;
		row-gap: var(--alhadaf-cf7-gap);
	}

	.wpcf7-form.alhadaf-cf7-two-col > p:has(textarea),
	.wpcf7-form.alhadaf-cf7-two-col > p:has(.wpcf7-submit),
	.wpcf7-form.alhadaf-cf7-two-col > p:has(.wpcf7-response-output),
	.wpcf7-form.alhadaf-cf7-two-col > p:has(.wpcf7-acceptance) {
		grid-column: 1 / -1;
	}
}

/* Responsive ------------------------------------------------------------ */
@media (max-width: 600px) {
	.wpcf7 {
		margin: 18px auto;
		padding: 18px;
		border-radius: 16px;
	}

	.wpcf7 .wpcf7-submit {
		width: 100%;
		min-width: 0;
	}

	.wpcf7 textarea {
		min-height: 135px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wpcf7 *,
	.wpcf7 *::before,
	.wpcf7 *::after {
		transition: none !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
	}

	.wpcf7 .wpcf7-spinner {
		animation: none !important;
	}
}
