/**
 * Zakat Funds — frontend styles
 * Modern, responsive, glassmorphism, dark mode, RTL-aware.
 */

.zf-wrap {
	--zf-primary: #1f9d78;
	--zf-primary-dark: #157a5d;
	--zf-primary-soft: rgba(31, 157, 120, 0.1);
	--zf-bg: #ffffff;
	--zf-surface: #f7faf9;
	--zf-border: #e3e9e7;
	--zf-text: #1a2420;
	--zf-muted: #6b7772;
	--zf-error: #d64545;
	--zf-radius: 16px;
	--zf-radius-sm: 10px;
	--zf-shadow: 0 20px 45px -20px rgba(16, 40, 32, 0.35);

	max-width: 620px;
	margin: 0 auto;
	color: var(--zf-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	line-height: 1.5;
	box-sizing: border-box;
}

.zf-wrap *,
.zf-wrap *::before,
.zf-wrap *::after {
	box-sizing: border-box;
}

.zf-wrap.zf-dark {
	--zf-bg: #14201b;
	--zf-surface: #1c2b25;
	--zf-border: #2a3d35;
	--zf-text: #eaf3ef;
	--zf-muted: #93a49d;
	--zf-primary-soft: rgba(46, 204, 158, 0.14);
	--zf-shadow: 0 20px 45px -18px rgba(0, 0, 0, 0.6);
}

.zf-form {
	background: var(--zf-bg);
	border: 1px solid var(--zf-border);
	border-radius: var(--zf-radius);
	padding: clamp(20px, 4vw, 36px);
	box-shadow: var(--zf-shadow);
	backdrop-filter: blur(10px);
}

/* Header */
.zf-form__head {
	text-align: center;
	margin-bottom: 26px;
}

.zf-form__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--zf-primary-soft);
	color: var(--zf-primary);
	margin-bottom: 14px;
}

.zf-form__title {
	font-size: clamp(22px, 4vw, 28px);
	font-weight: 700;
	margin: 0 0 6px;
	color: var(--zf-text);
}

.zf-form__subtitle {
	margin: 0;
	color: var(--zf-muted);
	font-size: 15px;
}

/* Fieldsets */
.zf-fieldset {
	border: none;
	padding: 0;
	margin: 0 0 22px;
}

.zf-legend {
	font-size: 13px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--zf-muted);
	margin-bottom: 12px;
	padding: 0;
}

/* Presets */
.zf-presets {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 10px;
	margin-bottom: 16px;
}

.zf-preset {
	appearance: none;
	border: 1.5px solid var(--zf-border);
	background: var(--zf-surface);
	color: var(--zf-text);
	border-radius: var(--zf-radius-sm);
	padding: 13px 8px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.18s ease;
}

.zf-preset:hover {
	border-color: var(--zf-primary);
	transform: translateY(-1px);
}

.zf-preset.is-active {
	border-color: var(--zf-primary);
	background: var(--zf-primary);
	color: #fff;
	box-shadow: 0 8px 18px -8px var(--zf-primary);
}

/* Inputs */
.zf-field {
	margin-bottom: 16px;
}

.zf-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px 16px;
}

.zf-field--full {
	grid-column: 1 / -1;
}

.zf-label {
	display: block;
	font-size: 13.5px;
	font-weight: 600;
	margin-bottom: 6px;
	color: var(--zf-text);
}

.zf-req { color: var(--zf-error); }
.zf-optional { color: var(--zf-muted); font-weight: 400; }

.zf-input {
	width: 100%;
	padding: 12px 14px;
	border: 1.5px solid var(--zf-border);
	border-radius: var(--zf-radius-sm);
	background: var(--zf-surface);
	color: var(--zf-text);
	font-size: 15px;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.zf-input::placeholder { color: var(--zf-muted); }

.zf-input:focus {
	outline: none;
	border-color: var(--zf-primary);
	box-shadow: 0 0 0 3px var(--zf-primary-soft);
}

.zf-input.is-invalid {
	border-color: var(--zf-error);
	box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.12);
}

.zf-textarea { resize: vertical; min-height: 76px; }
.zf-select { appearance: none; background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D'http://www.w3.org/2000/svg'%20viewBox%3D'0%200%2020%2020'%3E%3Cpath%20fill%3D'%236b7772'%20d%3D'M5%208l5%205%205-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

.zf-amount-input {
	display: flex;
	align-items: center;
	border: 1.5px solid var(--zf-border);
	border-radius: var(--zf-radius-sm);
	background: var(--zf-surface);
	overflow: hidden;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.zf-amount-input:focus-within {
	border-color: var(--zf-primary);
	box-shadow: 0 0 0 3px var(--zf-primary-soft);
}

.zf-amount-symbol {
	padding: 0 14px;
	font-weight: 700;
	color: var(--zf-muted);
	white-space: nowrap;
}

.zf-amount {
	border: none !important;
	box-shadow: none !important;
	background: transparent;
	font-size: 20px;
	font-weight: 700;
	padding-left: 0;
}

.zf-error {
	color: var(--zf-error);
	font-size: 12.5px;
	margin: 5px 0 0;
	min-height: 0;
}

/* Checkbox */
.zf-check {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 14.5px;
	margin: 4px 0 20px;
	user-select: none;
}

.zf-check input { position: absolute; opacity: 0; width: 0; height: 0; }

.zf-check__box {
	width: 20px;
	height: 20px;
	border: 1.5px solid var(--zf-border);
	border-radius: 6px;
	background: var(--zf-surface);
	flex-shrink: 0;
	position: relative;
	transition: all 0.18s ease;
}

.zf-check input:checked + .zf-check__box {
	background: var(--zf-primary);
	border-color: var(--zf-primary);
}

.zf-check input:checked + .zf-check__box::after {
	content: "";
	position: absolute;
	left: 6px;
	top: 2px;
	width: 5px;
	height: 10px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.zf-check input:focus-visible + .zf-check__box {
	box-shadow: 0 0 0 3px var(--zf-primary-soft);
}

/* Gateways */
.zf-gateways {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	gap: 10px;
}

.zf-gateway { cursor: pointer; }
.zf-gateway input { position: absolute; opacity: 0; }

.zf-gateway__card {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px 10px;
	border: 1.5px solid var(--zf-border);
	border-radius: var(--zf-radius-sm);
	background: var(--zf-surface);
	font-weight: 600;
	text-align: center;
	transition: all 0.18s ease;
}

.zf-gateway:hover .zf-gateway__card { border-color: var(--zf-primary); }

.zf-gateway input:checked + .zf-gateway__card {
	border-color: var(--zf-primary);
	background: var(--zf-primary-soft);
	color: var(--zf-primary-dark);
}

.zf-gateway input:focus-visible + .zf-gateway__card {
	box-shadow: 0 0 0 3px var(--zf-primary-soft);
}

/* Summary */
.zf-summary {
	background: var(--zf-surface);
	border: 1px solid var(--zf-border);
	border-radius: var(--zf-radius-sm);
	padding: 16px 18px;
	margin: 22px 0;
}

.zf-summary__row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 15px;
}

.zf-summary__row + .zf-summary__row { margin-top: 8px; }
.zf-summary__row--muted { color: var(--zf-muted); font-size: 13.5px; }
.zf-summary__amount { font-size: 22px; color: var(--zf-primary); }

/* Submit */
.zf-submit {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 15px;
	border: none;
	border-radius: var(--zf-radius-sm);
	background: linear-gradient(135deg, var(--zf-primary), var(--zf-primary-dark));
	color: #fff;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	box-shadow: 0 12px 26px -12px var(--zf-primary);
}

.zf-submit:hover { transform: translateY(-1px); }
.zf-submit:active { transform: translateY(0); }
.zf-submit:disabled { opacity: 0.7; cursor: not-allowed; }
.zf-submit:focus-visible { outline: 3px solid var(--zf-primary-soft); outline-offset: 2px; }

.zf-spinner {
	display: none;
	width: 18px;
	height: 18px;
	border: 2.5px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: zf-spin 0.7s linear infinite;
}

.zf-submit.is-loading .zf-spinner { display: inline-block; }

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

.zf-secure {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin: 14px 0 0;
	font-size: 12.5px;
	color: var(--zf-muted);
}

/* Alerts */
.zf-alert {
	border-radius: var(--zf-radius-sm);
	padding: 14px 16px;
	margin-bottom: 18px;
	font-size: 14.5px;
	font-weight: 500;
	animation: zf-slide 0.3s ease;
}

.zf-alert--success { background: var(--zf-primary-soft); color: var(--zf-primary-dark); border: 1px solid var(--zf-primary); }
.zf-alert--error { background: rgba(214, 69, 69, 0.1); color: var(--zf-error); border: 1px solid rgba(214, 69, 69, 0.4); }

@keyframes zf-slide {
	from { opacity: 0; transform: translateY(-6px); }
	to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 520px) {
	.zf-grid { grid-template-columns: 1fr; }
	.zf-presets { grid-template-columns: repeat(2, 1fr); }
}

/* RTL support */
.zf-wrap[dir="rtl"] .zf-check input:checked + .zf-check__box::after { left: auto; right: 6px; }
.rtl .zf-select { background-position: left 12px center; padding-right: 14px; padding-left: 34px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.zf-preset, .zf-submit, .zf-input, .zf-gateway__card { transition: none; }
	.zf-spinner { animation-duration: 1.4s; }
}
