/* ---------- Layout ---------- */
.bfw-grid {
	display: flex;
	flex-wrap: wrap;
	column-gap: 18px;
	row-gap: 18px;
}

.bfw-field {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 0 0 100%;
	max-width: 100%;
}

.bfw-w-100 { flex-basis: 100%; max-width: 100%; }
.bfw-w-75  { flex-basis: calc(75% - var(--bfw-gap, 18px) * .25); max-width: calc(75% - var(--bfw-gap, 18px) * .25); }
.bfw-w-66  { flex-basis: calc(66.666% - var(--bfw-gap, 18px) * .34); max-width: calc(66.666% - var(--bfw-gap, 18px) * .34); }
.bfw-w-50  { flex-basis: calc(50% - var(--bfw-gap, 18px) * .5); max-width: calc(50% - var(--bfw-gap, 18px) * .5); }
.bfw-w-33  { flex-basis: calc(33.333% - var(--bfw-gap, 18px) * .67); max-width: calc(33.333% - var(--bfw-gap, 18px) * .67); }
.bfw-w-25  { flex-basis: calc(25% - var(--bfw-gap, 18px) * .75); max-width: calc(25% - var(--bfw-gap, 18px) * .75); }

/* ---------- Labels ---------- */
.bfw-label {
	margin-bottom: 6px;
	font-weight: 600;
	line-height: 1.3;
}

.bfw-req { color: #d63638; }

/* ---------- Inputs ---------- */
.bfw-input {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid #d8d8d8;
	border-radius: 6px;
	background: #fff;
	font: inherit;
	line-height: 1.4;
	transition: border-color .2s ease, box-shadow .2s ease;
}

.bfw-input:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(0, 0, 0, .07);
}

.bfw-input:disabled {
	opacity: .55;
	cursor: not-allowed;
}

textarea.bfw-input { resize: vertical; }

select.bfw-input {
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	padding-right: 38px;
}

select.bfw-input[multiple] {
	background-image: none;
	padding-right: 14px;
	min-height: 120px;
}

.bfw-field.has-error .bfw-input {
	border-color: #d63638;
}

/* ---------- Radio / checkbox ---------- */
.bfw-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 20px;
	padding-top: 4px;
}

.bfw-choice {
	display: inline-flex;
	align-items: flex-start;
	gap: 8px;
	cursor: pointer;
	line-height: 1.45;
	font-weight: 400;
}

.bfw-choice input {
	margin-top: 3px;
	flex: 0 0 auto;
}

.bfw-acceptance { padding-top: 4px; }
.bfw-acceptance a { text-decoration: underline; }

/* ---------- HTML block ---------- */
.bfw-html > :last-child { margin-bottom: 0; }

/* ---------- Button ---------- */
.bfw-submit {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	padding: 14px 28px;
	border: none;
	border-radius: 6px;
	background: #111;
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background-color .2s ease, color .2s ease, opacity .2s ease;
}

.bfw-submit:disabled { opacity: .7; cursor: wait; }

.bfw-spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: bfw-spin .7s linear infinite;
}

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

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

/* ---------- Messages ---------- */
.bfw-response { margin-top: 16px; }

.bfw-response.is-success,
.bfw-response.is-error {
	padding: 12px 16px;
	border-radius: 6px;
	line-height: 1.5;
}

.bfw-response.is-success { background: #e7f6ec; color: #0a6b2e; }
.bfw-response.is-error   { background: #fdeaea; color: #a4231f; }

/* ---------- Honeypot ---------- */
.bfw-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------- Calendar ---------- */
.flatpickr-calendar {
	border-radius: 10px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .14);
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
	.bfw-grid > .bfw-field {
		flex-basis: 100% !important;
		max-width: 100% !important;
	}
}

/* =========================================================
   Date & time fields
   ========================================================= */

/* Modern calendar icon (right side, flips in RTL) */
.bfw-input.bfw-date {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4.5' width='18' height='16' rx='4'/%3E%3Cpath d='M3 9.5h18'/%3E%3Cpath d='M8 2.5v3M16 2.5v3'/%3E%3Ccircle cx='8.5' cy='13.5' r='1.15' fill='%239aa0a6' stroke='none'/%3E%3Ccircle cx='12' cy='13.5' r='1.15' fill='%239aa0a6' stroke='none'/%3E%3Ccircle cx='15.5' cy='13.5' r='1.15' fill='%239aa0a6' stroke='none'/%3E%3Ccircle cx='8.5' cy='17' r='1.15' fill='%239aa0a6' stroke='none'/%3E%3Ccircle cx='12' cy='17' r='1.15' fill='%239aa0a6' stroke='none'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 19px 19px;
	padding-right: 44px;
	cursor: pointer;
}

/* Clock icon only on the fixed-slot dropdown (the native time input draws its own) */
.bfw-type-time select.bfw-input {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5.2l3.2 2'/%3E%3C/svg%3E");
	background-position: right 14px center;
	background-size: 19px 19px;
	padding-right: 44px;
}

/* Native time input: full width, own picker, comfortable tap target */
.bfw-input.bfw-time-native {
	cursor: pointer;
	min-height: 1.4em;
}

.bfw-input.bfw-time-native::-webkit-calendar-picker-indicator {
	cursor: pointer;
	opacity: .55;
	transition: opacity .2s ease;
}

.bfw-input.bfw-time-native:hover::-webkit-calendar-picker-indicator { opacity: 1; }

/* RTL - icons move to the left */
[dir="rtl"] .bfw-input.bfw-date,
[dir="rtl"] .bfw-type-time select.bfw-input,
.rtl .bfw-input.bfw-date,
.rtl .bfw-type-time select.bfw-input {
	background-position: left 14px center;
	padding-right: 14px;
	padding-left: 44px;
}

[dir="rtl"] select.bfw-input,
.rtl select.bfw-input {
	background-position: left 14px center;
	padding-right: 14px;
	padding-left: 38px;
}

/* =========================================================
   Phone number
   Empty + unfocused  -> inherits the page direction, so an Arabic
   placeholder sits on the right.
   Focused or filled  -> forced left to right, caret and digits on
   the left, whatever the page direction is.
   ========================================================= */
/* Language-based fallback: works even if the theme never sets dir="rtl".
   Every translation plugin sets <html lang="ar">, so we key off that. */
html[lang^="ar"] .bfw-input.bfw-ltr:placeholder-shown:not(:focus),
html[lang^="he"] .bfw-input.bfw-ltr:placeholder-shown:not(:focus),
html[lang^="fa"] .bfw-input.bfw-ltr:placeholder-shown:not(:focus),
html[lang^="ur"] .bfw-input.bfw-ltr:placeholder-shown:not(:focus) {
	direction: rtl !important;
	text-align: right !important;
}

.bfw-input.bfw-ltr.bfw-ph-rtl {
	direction: rtl !important;
	text-align: right !important;
}

.bfw-input.bfw-ltr.bfw-ltr-active {
	direction: ltr !important;
	text-align: left !important;
	unicode-bidi: isolate;
}

/* No JS? fall back to the CSS-only version of the same rule. */
.bfw-input.bfw-ltr:focus:not(.bfw-ph-rtl),
.bfw-input.bfw-ltr:not(:placeholder-shown):not(.bfw-ph-rtl) {
	direction: ltr;
	text-align: left;
	unicode-bidi: isolate;
}

/* =========================================================
   Country code field
   ========================================================= */
.bfw-cc { position: relative; }

.bfw-cc-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	text-align: start;
	cursor: pointer;
}

.bfw-cc-flag { font-size: 1.2em; line-height: 1; flex: 0 0 auto; }

.bfw-cc-name {
	flex: 1 1 auto;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bfw-cc-dial {
	flex: 0 0 auto;
	font-variant-numeric: tabular-nums;
	direction: ltr;
	unicode-bidi: isolate;
}

.bfw-cc-caret {
	flex: 0 0 auto;
	margin-inline-start: auto;
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
	opacity: .5;
}

/* Dropdown panel */
.bfw-cc-panel {
	position: absolute;
	z-index: 50;
	top: calc(100% + 6px);
	left: 0;
	min-width: 100%;
	width: 320px;
	max-width: 90vw;
	background: #fff;
	border: 1px solid #e2e2e2;
	border-radius: 10px;
	box-shadow: 0 12px 34px rgba(0, 0, 0, .14);
	overflow: hidden;
}

[dir="rtl"] .bfw-cc-panel,
.rtl .bfw-cc-panel { left: auto; right: 0; }

.bfw-cc-panel[hidden] { display: none; }

.bfw-cc-search {
	width: 100%;
	padding: 11px 14px;
	border: none;
	border-bottom: 1px solid #eee;
	font: inherit;
	outline: none;
}

.bfw-cc-list {
	list-style: none;
	margin: 0;
	padding: 4px 0;
	max-height: 260px;
	overflow-y: auto;
}

.bfw-cc-list li { margin: 0; }

.bfw-cc-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 9px 14px;
	border: none;
	background: none;
	font: inherit;
	text-align: start;
	cursor: pointer;
}

.bfw-cc-item:hover,
.bfw-cc-item:focus { background: #f4f4f4; outline: none; }

.bfw-cc-i-flag { font-size: 1.2em; line-height: 1; flex: 0 0 auto; }

.bfw-cc-i-name {
	flex: 1 1 auto;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bfw-cc-i-dial {
	flex: 0 0 auto;
	opacity: .6;
	font-variant-numeric: tabular-nums;
}

.bfw-cc-empty { padding: 14px; text-align: center; opacity: .6; }
