/* ==========================================================================
   imotigreece-design — Формуляри
   Обхват: Gravity Forms (.gform_*), Essential Real Estate (контакт и запитване
   към имот), Fluent Forms, Mailster, WP коментари.
   Извън обхвата: търсенето и филтрите в хедъра — те са на отделен слой.
   Всички визуални стойности идват от tokens.css — без hardcoded цветове.
   Спецификация: design/DESIGN.md §4 (Inputs, Buttons), §8.

   Забележка за селекторите: ползва се :is(<form-контейнер>) :is(<контрола>),
   за да се скоупват полетата САМО в контекст на форма — иначе бихме презаписали
   филтрите и търсенето на имоти (друг слой).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Полета — споделен вид (фон, рамка, радиус, 16px, min-height 48px)
   -------------------------------------------------------------------------- */
:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .fluentform, .frm-fluent-form)
:is(input[type="text"], input[type="search"], input[type="email"], input[type="url"],
    input[type="password"], input[type="tel"], input[type="number"], input[type="date"],
    input[type="month"], input[type="time"], input:not([type]), textarea, select) {
	width: 100%;
	box-sizing: border-box;
	min-height: 48px;
	padding: 14px 16px;
	font-family: var(--ig-font-body);
	font-size: 16px;              /* 16px минимум — иначе iOS увеличава при фокус */
	line-height: 1.4;
	color: var(--ig-text);
	background-color: var(--ig-surface-card);
	border: 1px solid var(--ig-border);
	border-radius: var(--ig-radius);
	box-shadow: none;
	transition: border-color var(--ig-t-base) ease,
	            box-shadow var(--ig-t-base) ease;
}

:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .fluentform, .frm-fluent-form)
:is(input, textarea)::placeholder {
	color: var(--ig-text-muted);
	opacity: 1;
}

/* Mailster задава собствен фон на полетата от редактора на формата (inline CSS
   в тялото на страницата, след нашия stylesheet) — затова тук !important е
   необходим, за да върнем белия фон и нормалния цвят на текста. */
.imotigreece-design .mailster-form .input {
	color: var(--ig-text) !important;
	background-color: var(--ig-surface-card) !important;
	border: 1px solid var(--ig-border) !important;
}

/* Многоредовите полета растат по съдържание. */
:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .frm-fluent-form) textarea {
	min-height: 120px;
	height: auto;
	resize: vertical;
}

/* --- Фокус: рамка primary + мек пръстен ---------------------------------- */
:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .fluentform, .frm-fluent-form)
:is(input, textarea, select):focus {
	border-color: var(--ig-primary);
	box-shadow: 0 0 0 3px var(--ig-focus-ring-soft);
	outline: none;
}

/* Клавиатурен фокус за всичко интерактивно (темата нулира outline). */
:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .fluentform, .frm-fluent-form) :is(a, button, input, textarea, select,
    [tabindex]):focus-visible {
	outline: 2px solid var(--ig-primary-light);
	outline-offset: 2px;
}

/* --- 1б. Gravity Forms 2.x (`gravity-theme`) — надпечатване на чуждото правило
   `gravity-theme` носи `.gform_wrapper.gravity-theme input[type="text"], …`
   (0,3,1) и бие нашия :is() селектор по-горе (0,2,2). Затова полетата оставаха
   с 15px шрифт и 8px отстъп: под 16px Safari на iOS зуумва при фокус, а текстът
   залепва за ръба. Тук се обръщаме по контейнера `.ginput_container` → (0,4,1).
   Декларираме само височината, отстъпа и шрифта (не цвят/рамка/фон) — иначе
   бихме надделели и над правилата за грешка/валидация по-долу, които са с
   по-ниска специфичност. */
.gform_wrapper .gfield .ginput_container input.large,
.gform_wrapper .gfield .ginput_container input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="image"]):not([type="file"]),
.gform_wrapper .gfield .ginput_container textarea {
	height: auto;                /* темата фиксира `input { height: 44px }` */
	padding: 14px 16px;
	font-size: 16px;
}

/* --------------------------------------------------------------------------
   2. Select — визия като полетата; стрелката е чист CSS (два градиента),
      не шрифтова икона и не SVG.
   -------------------------------------------------------------------------- */
:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .frm-fluent-form) select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	padding-right: 44px;
	/* Темата налага `select { height:44px !important; padding:0 5px !important }`
	   (assets/sass/_typography.scss) — затова тук !important е необходим, за да
	   се презапише чужд !important, а не да се печели специфичност. */
	min-height: 48px !important;
	height: auto !important;
	padding: 14px 44px 14px 16px !important;
	background-image:
		linear-gradient(45deg, transparent 50%, var(--ig-ink-600) 50%),
		linear-gradient(135deg, var(--ig-ink-600) 50%, transparent 50%);
	background-position:
		calc(100% - 21px) calc(50% + 1px),
		calc(100% - 16px) calc(50% + 1px);
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
}

/* --------------------------------------------------------------------------
   3. Label, описания, задължителни полета
   -------------------------------------------------------------------------- */
:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .frm-fluent-form)
:is(label, .gfield_label, .ff-el-input--label label) {
	display: block;
	margin-bottom: var(--ig-s-2);
	font-family: var(--ig-font-body);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.01em;
	color: var(--ig-text-secondary);
}

:is(.gform_wrapper, .ere__form, .ere__contact-form, .mailster-form, .comment-form)
:is(.gfield_description, .help-block, .form-text, .description) {
	margin-top: var(--ig-s-1);
	font-size: 13px;
	color: var(--ig-text-tertiary);
}

:is(.gform_wrapper, .mailster-form) :is(.gfield_required, .mailster-required) {
	color: var(--ig-error);
}

/* --------------------------------------------------------------------------
   4. Групи / вертикален ритъм
   -------------------------------------------------------------------------- */
:is(.ere__contact-form, .ere__account-login-wrap, .comment-form,
    .mailster-form) :is(.form-group, .comment-form-author, .comment-form-email,
    .comment-form-url, .comment-form-comment, .mailster-wrapper) {
	margin-bottom: var(--ig-s-4);
}

.gform_wrapper :is(.gfield, .gform-field) {
	margin-bottom: var(--ig-s-4);
}

/* --------------------------------------------------------------------------
   5. Грешка / валидация
   -------------------------------------------------------------------------- */
/* Рамка в цвят на грешка при невалидно поле (ERE ползва :invalid + novalidate). */
:is(.ere__form, .ere__contact-form, .comment-form, .gform_wrapper, .mailster-form)
:is(input, textarea, select).is-invalid,
:is(.ere__form, .ere__contact-form, .comment-form)
:is(input, textarea, select):invalid:not(:placeholder-shown) {
	border-color: var(--ig-error);
	box-shadow: 0 0 0 3px rgba(168, 56, 47, .18);
}

/* Текстово съобщение за грешка на полето (Gravity Forms, ERE). */
:is(.gform_wrapper, .ere__form, .ere__contact-form, .comment-form, .mailster-form)
:is(.validation_message, .error-message, .ere-message-error) {
	display: block;
	margin-top: var(--ig-s-2);
	font-family: var(--ig-font-body);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.45;
	color: var(--ig-error);
}

/* Bootstrap .invalid-feedback е скрит по подразбиране — не го показваме насила. */
:is(.ere__form, .ere__contact-form, .comment-form, .gform_wrapper, .mailster-form)
.invalid-feedback {
	display: none;
	margin-top: var(--ig-s-2);
	font-family: var(--ig-font-body);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.45;
	color: var(--ig-error);
}

:is(.ere__form, .ere__contact-form)
:is(input, textarea, select).is-invalid ~ .invalid-feedback,
:is(.ere__form, .ere__contact-form).was-validated
:is(input, textarea, select):invalid ~ .invalid-feedback {
	display: block;
}

/* Обобщени съобщения от формата (успех / грешка / обработка).
   :not(:empty) — иначе празният контейнер рисува кутия. */
:is(.gform_wrapper, .ere__contact-form, .ere__account-login-wrap, .mailster-form,
    .frm-fluent-form)
:is(.ere__message, .ere_messages, .mailster-form-info,
    .ff-message-success, .ff-message-error):not(:empty) {
	margin-top: var(--ig-s-4);
	padding: var(--ig-s-3) var(--ig-s-4);
	border: 1px solid var(--ig-border);
	border-radius: var(--ig-radius);
	font-size: 15px;
	line-height: 1.5;
	color: var(--ig-text-secondary);
	background-color: var(--ig-surface-alt);
}

:is(.ere__contact-form, .ere__account-login-wrap, .frm-fluent-form)
:is(.ere__message.success, .ere_messages.success, .ff-message-success) {
	color: var(--ig-success);
	border-color: var(--ig-success);
	background-color: var(--ig-surface-card);
}

/* Gravity Forms — обобщена грешка при подаване. */
.gform_wrapper .gform_validation_errors {
	margin: 0 0 var(--ig-s-5);
	padding: var(--ig-s-4) var(--ig-s-5);
	border: 1px solid var(--ig-error);
	border-left-width: 4px;
	border-radius: var(--ig-radius);
	background-color: var(--ig-surface-card);
	box-shadow: none;
}

.gform_wrapper .gform_validation_errors .gform_submission_error,
.gform_wrapper .validation_message {
	margin: 0;
	font-family: var(--ig-font-body);
	font-size: 14px;
	font-weight: 500;
	color: var(--ig-error);
}

.gform_wrapper .gfield_error :is(input, select, textarea) {
	border-color: var(--ig-error);
}

/* --------------------------------------------------------------------------
   6. Чекбокси и радио — акцент в primary, достъпна цел за натиск
   -------------------------------------------------------------------------- */
:is(.ere__form, .ere__contact-form, .ere__account-login-wrap, .comment-form,
    .gform_wrapper, .mailster-form) :is(input[type="checkbox"], input[type="radio"]) {
	width: 20px;
	height: 20px;
	min-height: 0;
	margin: 0 var(--ig-s-2) 0 0;
	padding: 0;
	vertical-align: middle;
	accent-color: var(--ig-primary);
}

:is(.ere__form, .ere__contact-form, .ere__account-login-wrap, .comment-form,
    .gform_wrapper, .mailster-form)
:is(.form-check, .form-check-label, .gfield--type-consent, .mailster-_gdpr-wrapper) {
	font-size: 15px;
	line-height: 1.5;
	color: var(--ig-text-secondary);
}

:is(.ere__form, .ere__contact-form, .comment-form, .mailster-form)
:is(.form-check, .gfield--type-consent) {
	display: flex;
	align-items: flex-start;
	gap: var(--ig-s-2);
	min-height: 44px;            /* цел за натиск ≥44px */
	padding: var(--ig-s-2) 0;
}

/* --------------------------------------------------------------------------
   7. Бутони за подаване (Submit / Изпращане / Абонирай се)
   -------------------------------------------------------------------------- */
:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .frm-fluent-form)
:is(.gform_button, .ere__btn-submit-contact-form, .ere-login-button,
    .ere-register-button, .ere_forgetpass, .submit-button, .ff-btn-submit,
    button[type="submit"], input[type="submit"], .submit) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 16px 32px;
	font-family: var(--ig-font-body);
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.02em;
	text-align: center;
	color: var(--ig-text-on-dark);
	background-color: var(--ig-primary);
	border: 0;
	border-radius: var(--ig-radius);
	box-shadow: var(--ig-shadow-1);
	cursor: pointer;
	transition: background-color var(--ig-t-base) ease,
	            transform var(--ig-t-fast) ease,
	            box-shadow var(--ig-t-base) ease;
}

:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .frm-fluent-form)
:is(.gform_button, .ere__btn-submit-contact-form, .ere-login-button,
    .ere-register-button, .ere_forgetpass, .submit-button, .ff-btn-submit,
    button[type="submit"], input[type="submit"], .submit):hover {
	color: var(--ig-text-on-dark);
	background-color: var(--ig-primary-dark);
	transform: translateY(-1px);
	box-shadow: var(--ig-shadow-2);
}

:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .frm-fluent-form)
:is(.gform_button, .ere__btn-submit-contact-form, .ere-login-button,
    .ere-register-button, .ere_forgetpass, .submit-button, .ff-btn-submit,
    button[type="submit"], input[type="submit"], .submit):active {
	background-color: var(--ig-primary-darker);
	transform: translateY(1px);
	box-shadow: var(--ig-shadow-1);
}

:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
    .mailster-form, .comment-form, .frm-fluent-form)
:is(.gform_button, .submit-button, .ff-btn-submit, button[type="submit"],
    input[type="submit"]):disabled,
:is(.gform_wrapper, .ere__form, .ere__contact-form, .mailster-form)
:is(.gform_button, .submit-button, .ff-btn-submit, button[type="submit"]).disabled {
	color: var(--ig-text-muted);
	background-color: var(--ig-border);
	box-shadow: none;
	transform: none;
	cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   8. Обвивка — бяла карта, рамка, радиус 3px, padding 40px, сянка-1.
      Не бива да изглежда като generic widget.
   -------------------------------------------------------------------------- */
:is(.gform_wrapper, .fluentform_wrapper, .frm-fluent-form, .comment-respond,
    .ere__contact-form, .mailster-form, .property-contact-agent) {
	box-sizing: border-box;
	max-width: 100%;
	padding: 40px;
	background-color: var(--ig-surface-card);
	border: 1px solid var(--ig-border);
	border-radius: var(--ig-radius);
	box-shadow: var(--ig-shadow-1);
}

/* Формата за запитване към имот е вътре в картата на агента — без вложена карта. */
.property-contact-agent .ere__contact-form {
	padding: 0;
	background-color: transparent;
	border: 0;
	box-shadow: none;
}

/* Заглавие на секцията-карта (ERE: „Свържете се“). */
.property-contact-agent .ere-heading-style2 h2,
.ere__contact-form .ere-heading-style2 h2 {
	margin: 0 0 var(--ig-s-5);
	font-family: var(--ig-font-body);
	font-size: var(--ig-fs-section);
	font-weight: 600;
	line-height: var(--ig-lh-heading);
	letter-spacing: 0.01em;
	color: var(--ig-text);
}

/* Етикетите в ERE идват с чуждо подчертаване/долен ръб при някои скинове. */
.ere__form label {
	text-decoration: none;
}

/* --------------------------------------------------------------------------
   9. Адаптив — една колона под 768px; бутон на цяла ширина под 576px
   -------------------------------------------------------------------------- */
/* ERE ползва само .col-md-4 без базов .col-12 → под 768px не се стаква сам. */
@media (max-width: 767px) {
	:is(.ere__contact-form, .ere__account-login-wrap) .row > [class*="col-"] {
		flex: 0 0 100%;
		max-width: 100%;
	}
}

@media (max-width: 575px) {
	:is(.gform_wrapper, .ere__contact-form, .fluentform_wrapper, .frm-fluent-form,
	    .comment-respond, .mailster-form, .property-contact-agent) {
		padding: 24px;
	}

	:is(.ere__contact-form, .ere__account-login-wrap, .mailster-form, .comment-form,
	    .gform_wrapper, .frm-fluent-form) :is(
	    .ere__btn-submit-contact-form, .gform_button, .submit-button, .ff-btn-submit,
	    button[type="submit"], input[type="submit"], .submit) {
		width: 100%;
	}
}

/* --------------------------------------------------------------------------
   10. prefers-reduced-motion — без движения
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	:is(.gform_wrapper, .ere__form, .ere__contact-form, .ere__account-login-wrap,
	    .mailster-form, .comment-form, .frm-fluent-form) :is(
	    input, textarea, select, button, .gform_button, .submit-button, .ff-btn-submit) {
		transition: none !important;
		transform: none !important;
	}
}
