/*
 * Zakat Calculator front-end styles.
 *
 * Uses CSS custom properties so a theme can restyle by overriding --zc-* vars,
 * or disable this stylesheet entirely and target the .zc- classes directly.
 *
 * Each section carries its own pastel accent (--zc-accent*) so Assets and
 * Liabilities are visually distinct; the accent cascades to the section header,
 * card tint, input focus ring and tooltip.
 */

.zc-calculator {
	/* Base palette */
	--zc-primary: #0b7a4b;
	--zc-primary-hover: #096a41;
	--zc-text: #1f2937;
	--zc-muted: #6b7280;
	--zc-border: #e5e7eb;
	--zc-bg: #ffffff;
	--zc-bg-subtle: #f9fafb;

	/* Neutral accent fallback (sections override these) */
	--zc-accent: #64748b;
	--zc-accent-soft: #f8fafc;
	--zc-accent-border: #e2e8f0;
	--zc-accent-text: #334155;

	--zc-radius: 14px;
	--zc-radius-sm: 10px;
	--zc-gap: 18px;
	--zc-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.04);

	max-width: 780px;
	margin: 0 auto;
	color: var(--zc-text);
	font-size: 1rem;
	line-height: 1.5;
}

.zc-calculator *,
.zc-calculator *::before,
.zc-calculator *::after {
	box-sizing: border-box;
}

/*
 * The [hidden] attribute must always win inside the calculator.
 * Author rules such as `.zc-button { display: inline-block }` otherwise beat
 * the user-agent `[hidden] { display: none }`, which would leave the pay button
 * on screen after a completed payment.
 */
.zc-calculator [hidden] {
	display: none !important;
}

.zc-title {
	margin: 0 0 var(--zc-gap);
	letter-spacing: -0.02em;
}

/* ------------------------------------------------------------- Mode chooser */

.zc-mode-question {
	margin: 0 0 12px;
	font-weight: 600;
	font-size: 1.02rem;
}

.zc-mode-options {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-bottom: var(--zc-gap);
}

/*
 * Card-sized choices rather than radio buttons: this is the first thing on the
 * page and the two paths lead somewhere quite different, so each gets a title
 * and a line explaining what happens next.
 */
.zc-calculator .zc-mode-option {
	display: flex;
	flex-direction: column;
	gap: 5px;
	width: 100%;
	height: 100%;
	text-align: left;
	padding: 18px;
	border: 1px solid var(--zc-border);
	border-radius: var(--zc-radius);
	background: var(--zc-bg);
	box-shadow: var(--zc-shadow);
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}

.zc-calculator .zc-mode-option:hover {
	border-color: var(--zc-primary);
	box-shadow: 0 2px 4px rgba(16, 24, 40, 0.06), 0 8px 20px rgba(16, 24, 40, 0.07);
}

.zc-calculator .zc-mode-option:active {
	transform: translateY(1px);
}

.zc-calculator .zc-mode-option:focus-visible {
	outline: 3px solid rgba(11, 122, 75, 0.4); /* fallback */
	outline: 3px solid color-mix(in srgb, var(--zc-primary) 35%, transparent);
	outline-offset: 2px;
}

.zc-mode-option-title {
	font-weight: 700;
	font-size: 1rem;
	line-height: 1.35;
	color: var(--zc-text);
}

.zc-mode-option-desc {
	font-size: 0.85rem;
	line-height: 1.45;
	color: var(--zc-muted);
}

/* Back link out of a panel and into the chooser. */
.zc-calculator .zc-back {
	display: inline-block;
	width: auto;
	margin: 0 0 12px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--zc-muted);
	font-size: 0.88rem;
	cursor: pointer;
}

.zc-calculator .zc-back:hover {
	color: var(--zc-primary);
	text-decoration: underline;
}

/* --------------------------------------------------------- Direct payment */

/* Donor details — neutral slate, distinct from Assets/Liabilities. */
.zc-section--direct {
	--zc-accent: #0b7a4b;
	--zc-accent-soft: #f6faf8;
	--zc-accent-border: #cfe7db;
	--zc-accent-text: #0b5c39;
}

.zc-field-help {
	margin: 6px 0 0;
	font-size: 0.82rem;
	color: var(--zc-muted);
}

.zc-error {
	margin-bottom: 12px;
	padding: 10px 12px;
	border-radius: var(--zc-radius-sm);
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
	font-size: 0.9rem;
}

.zc-payment-amount {
	margin: 0 0 14px;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--zc-text);
}

/* ---------------------------------------------------------------- Price chips */

.zc-prices {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 8px;
}

.zc-price-chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	background: var(--zc-bg-subtle);
	border: 1px solid var(--zc-border);
	border-radius: 999px;
	padding: 6px 14px;
	font-size: 0.85rem;
	color: var(--zc-muted);
	white-space: nowrap;
}

.zc-price-chip strong {
	color: inherit;
	font-weight: 700;
}

.zc-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.85;
	flex: none;
}

/* Gold: warm amber. Silver: cool grey. Nisab: the plugin's green. */
.zc-price-chip--gold {
	background: #fffbeb;
	border-color: #fde68a;
	color: #92400e;
}

.zc-price-chip--gold .zc-dot {
	background: linear-gradient(135deg, #fbbf24, #d97706);
}

.zc-price-chip--silver {
	background: #f8fafc;
	border-color: #cbd5e1;
	color: #475569;
}

.zc-price-chip--silver .zc-dot {
	background: linear-gradient(135deg, #e2e8f0, #94a3b8);
}

.zc-price-chip--nisab {
	background: #ecfdf5;
	border-color: #a7f3d0;
	color: #065f46;
}

.zc-price-chip--nisab .zc-dot {
	background: linear-gradient(135deg, #34d399, #059669);
}

.zc-price-updated {
	margin: 0 0 var(--zc-gap);
	font-size: 0.78rem;
	color: var(--zc-muted);
}

/* ------------------------------------------------------------------- Sections */

/*
 * The whole card carries the section's pastel tint, so Assets and Liabilities
 * are identifiable at a glance. Inputs stay white so they lift off the tint.
 * (A tinted card is used rather than a header band because <legend> positioning
 * inside a <fieldset> is inconsistent across browsers.)
 */
.zc-section {
	border: 1px solid var(--zc-accent-border);
	border-radius: var(--zc-radius);
	padding: var(--zc-gap);
	margin: 0 0 var(--zc-gap);
	background: var(--zc-accent-soft);
	box-shadow: var(--zc-shadow);
}

.zc-section-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 700;
	font-size: 0.9rem;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--zc-accent-text);
	background: var(--zc-bg);
	border: 1px solid var(--zc-accent-border);
	border-radius: 999px;
	padding: 5px 14px;
	margin-bottom: 2px;
	width: auto;
}

.zc-section-title::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--zc-accent);
	flex: none;
}

/* Assets — blue hue */
.zc-section--assets {
	--zc-accent: #3b82f6;
	--zc-accent-soft: #eff6ff;
	--zc-accent-border: #bfdbfe;
	--zc-accent-text: #1d4ed8;
}

/* Liabilities — red hue */
.zc-section--liabilities {
	--zc-accent: #ef4444;
	--zc-accent-soft: #fef2f2;
	--zc-accent-border: #fecaca;
	--zc-accent-text: #b91c1c;
}

/* --------------------------------------------------------------------- Fields */

.zc-field {
	position: relative;
	margin-bottom: 14px;
}

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

.zc-label-row {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 6px;
}

.zc-label {
	font-weight: 600;
	font-size: 0.92rem;
	color: var(--zc-text);
	margin: 0;
}

/* ------------------------------------------------------------------- Tooltips */

.zc-tip-wrap {
	position: relative;
	display: inline-flex;
	line-height: 0;
}

.zc-tip-btn {
	width: 18px;
	height: 18px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--zc-accent-border);
	color: var(--zc-accent-text);
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	cursor: help;
	transition: background 0.15s ease, color 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.zc-tip-btn:hover,
.zc-tip-btn:focus-visible {
	background: var(--zc-accent);
	color: #fff;
	outline: none;
}

.zc-tip-bubble {
	position: absolute;
	bottom: calc(100% + 10px);
	left: 50%;
	transform: translateX(-50%) translateY(4px);
	z-index: 20;
	width: max-content;
	max-width: min(320px, 78vw);
	padding: 10px 12px;
	border-radius: var(--zc-radius-sm);
	background: #111827;
	color: #f9fafb;
	font-size: 0.82rem;
	font-weight: 400;
	line-height: 1.45;
	text-align: left;
	white-space: normal;
	box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
	pointer-events: none;
}

/* Little arrow */
.zc-tip-bubble::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 6px solid transparent;
	border-top-color: #111827;
}

/* Show on hover and on keyboard/tap focus of the button. */
.zc-tip-wrap:hover .zc-tip-bubble,
.zc-tip-btn:focus + .zc-tip-bubble,
.zc-tip-btn:focus-visible + .zc-tip-bubble {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0);
}

/*
 * On narrow viewports, anchor the bubble to the full-width field instead of the
 * icon, so it spans the field and can never overflow the screen regardless of
 * how far right the icon sits.
 */
@media (max-width: 560px) {
	.zc-tip-wrap {
		position: static;
	}

	.zc-tip-bubble {
		left: 0;
		right: 0;
		bottom: calc(100% + 6px);
		width: auto;
		max-width: none;
		transform: translateX(0) translateY(4px);
	}

	.zc-tip-wrap:hover .zc-tip-bubble,
	.zc-tip-btn:focus + .zc-tip-bubble,
	.zc-tip-btn:focus-visible + .zc-tip-bubble {
		transform: translateX(0) translateY(0);
	}

	.zc-tip-bubble::after {
		left: 18px;
		transform: none;
	}
}

/* --------------------------------------------------------------------- Inputs */

.zc-input-wrap {
	display: flex;
	align-items: stretch;
	border: 1px solid var(--zc-border);
	border-radius: var(--zc-radius-sm);
	overflow: hidden;
	background: var(--zc-bg);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.zc-input-wrap:hover {
	border-color: var(--zc-accent-border);
}

.zc-input-wrap:focus-within {
	border-color: var(--zc-accent);
	box-shadow: 0 0 0 3px var(--zc-accent-border); /* fallback */
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--zc-accent) 18%, transparent);
}

.zc-affix {
	display: flex;
	align-items: center;
	padding: 0 13px;
	/* Slightly deeper than the card tint so it reads as part of the input. */
	background: var(--zc-accent-soft); /* fallback */
	background: color-mix(in srgb, var(--zc-accent) 9%, #ffffff);
	color: var(--zc-accent-text);
	font-size: 0.88rem;
	font-weight: 600;
}

.zc-input-wrap--suffix {
	flex-direction: row-reverse;
}

/*
 * Shared input typography/box metrics.
 *
 * These rules are scoped under .zc-calculator on purpose. Many themes style
 * bare element selectors such as `input:not([type=submit])`, whose specificity
 * (0,1,1) beats a lone `.zc-input` class (0,1,0) and would otherwise paint a
 * stray border inside our wrapper.
 */
.zc-calculator .zc-input {
	padding: 11px 13px;
	font-size: 1rem;
	line-height: 1.4;
	color: var(--zc-text);
	width: 100%;
	min-width: 0;
	margin: 0;
	height: auto;
}

.zc-calculator .zc-input::placeholder {
	color: #b6bcc6;
	opacity: 1;
}

/*
 * The visible border and radius belong to .zc-input-wrap, so the control inside
 * it must be completely chrome-free. !important is used only on these
 * structural properties, because a theme drawing its own border/background here
 * breaks the component's layout rather than merely restyling it.
 */
.zc-calculator .zc-input-wrap .zc-input {
	flex: 1;
	border: 0 !important;
	border-radius: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	outline: 0;
}

.zc-calculator .zc-input-wrap .zc-input:focus,
.zc-calculator .zc-input-wrap .zc-input:focus-visible {
	border: 0 !important;
	box-shadow: none !important;
	outline: 0;
}

/* Standalone inputs (donor fields) draw their own border. */
.zc-calculator .zc-donor .zc-input,
.zc-calculator .zc-input--plain {
	border: 1px solid var(--zc-border) !important;
	border-radius: var(--zc-radius-sm) !important;
	background: var(--zc-bg) !important;
	box-shadow: none;
}

.zc-calculator .zc-donor .zc-input:focus,
.zc-calculator .zc-input--plain:focus {
	border-color: var(--zc-primary) !important;
	outline: 0;
	box-shadow: 0 0 0 3px rgba(11, 122, 75, 0.2); /* fallback */
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--zc-primary) 18%, transparent);
}

/* -------------------------------------------------------------------- Results */

.zc-results {
	background: linear-gradient(180deg, #ffffff, var(--zc-bg-subtle));
	border: 1px solid var(--zc-border);
	border-radius: var(--zc-radius);
	padding: var(--zc-gap);
	margin-bottom: var(--zc-gap);
	box-shadow: var(--zc-shadow);
}

.zc-result-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	padding: 8px 0;
	font-size: 0.94rem;
	color: var(--zc-muted);
}

.zc-result-row strong {
	color: var(--zc-text);
	font-variant-numeric: tabular-nums;
}

.zc-result-row + .zc-result-row {
	border-top: 1px solid var(--zc-border);
}

.zc-result-row--total {
	margin-top: 6px;
	padding-top: 14px;
	border-top: 2px solid var(--zc-primary) !important;
	font-size: 1.18rem;
	color: var(--zc-text);
	font-weight: 600;
}

.zc-result-row--total strong {
	color: var(--zc-primary);
	font-size: 1.35rem;
	letter-spacing: -0.02em;
}

.zc-below-nisab {
	margin: 12px 0 0;
	padding: 10px 12px;
	border-radius: var(--zc-radius-sm);
	background: #ecfdf5;
	color: #065f46;
	font-size: 0.88rem;
}

/* Donor fields */
.zc-donor {
	margin-bottom: var(--zc-gap);
}

.zc-donor .zc-field {
	margin-bottom: 12px;
}

/* -------------------------------------------------------------------- Buttons */

.zc-button {
	display: inline-block;
	width: 100%;
	border: 0;
	border-radius: var(--zc-radius-sm);
	background: var(--zc-primary);
	color: #fff;
	font-size: 1.05rem;
	font-weight: 600;
	padding: 14px 20px;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.08s ease;
}

.zc-button:hover:not(:disabled) {
	background: var(--zc-primary-hover);
}

.zc-button:active:not(:disabled) {
	transform: translateY(1px);
}

.zc-button:focus-visible {
	outline: 3px solid rgba(11, 122, 75, 0.4); /* fallback */
	outline: 3px solid color-mix(in srgb, var(--zc-primary) 35%, transparent);
	outline-offset: 2px;
}

/* Disabled: e.g. the pay button before any Zakat is actually due. */
.zc-calculator .zc-button:disabled {
	background: #cbd5e1;
	color: #64748b;
	opacity: 1;
	cursor: not-allowed;
	box-shadow: none;
}

.zc-calculator .zc-button:disabled:hover {
	background: #cbd5e1;
}

.zc-calculator .zc-button:disabled:active {
	transform: none;
}

.zc-confirm-button {
	margin-top: var(--zc-gap);
}

/*
 * Paid state: the form is frozen after a completed payment so the figures on
 * screen keep matching what was actually charged.
 */
.zc-calculator.zc-is-paid .zc-section {
	opacity: 0.7;
}

.zc-calculator.zc-is-paid .zc-input {
	cursor: not-allowed;
}

.zc-calculator.zc-is-paid .zc-input-wrap:hover {
	border-color: var(--zc-border);
}

/* -------------------------------------------------------------- Payment/notice */

.zc-payment {
	margin-top: var(--zc-gap);
	padding: var(--zc-gap);
	border: 1px solid var(--zc-border);
	border-radius: var(--zc-radius);
	background: var(--zc-bg);
	box-shadow: var(--zc-shadow);
}

.zc-payment-message {
	margin-top: 12px;
	padding: 10px 12px;
	border-radius: var(--zc-radius-sm);
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
	font-size: 0.9rem;
}

.zc-success {
	margin-top: var(--zc-gap);
	padding: 18px;
	border-radius: var(--zc-radius);
	background: #ecfdf5;
	border: 1px solid #a7f3d0;
	color: #065f46;
	font-weight: 600;
	text-align: center;
}

.zc-notice {
	padding: 12px 16px;
	border-radius: var(--zc-radius-sm);
	border: 1px solid var(--zc-border);
	background: var(--zc-bg-subtle);
}

.zc-notice--warning {
	background: #fffbeb;
	border-color: #fde68a;
	color: #92400e;
}

/* ----------------------------------------------------------------- Responsive */

@media (max-width: 600px) {
	.zc-mode-options {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 480px) {
	.zc-calculator {
		--zc-gap: 15px;
	}

	.zc-result-row--total {
		font-size: 1.05rem;
	}

	.zc-result-row--total strong {
		font-size: 1.2rem;
	}
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
	.zc-calculator * {
		transition: none !important;
	}
}
