/* Shared Forminator styling is scoped to the single server-rendered Contact System owner on each page. */
/* Leadform already had this sizing reset; keep the extracted controls and secondary links identical on content templates too. */
.tqo-contact-surface,
.tqo-contact-surface *,
.tqo-contact-surface::before,
.tqo-contact-surface::after,
.tqo-contact-surface *::before,
.tqo-contact-surface *::after {
  box-sizing: border-box;
}

/* Keep the bridge in normal document flow before the footer, using the existing standalone panel dimensions. */
.tqo-contact-surface--inline {
  padding-block: 64px;
  color: var(--color-foreground);
  scroll-margin-top: 120px;
}

.tqo-contact-panel {
  max-width: 780px;
  margin-inline: auto;
  padding: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--color-background);
}

/* The approved introduction leads straight into the form, with booking and direct channels after it. */
.tqo-contact-intro {
  max-width: 640px;
  margin: 0 auto 32px;
  text-align: center;
}

.tqo-contact-intro h2 {
  margin: 0 0 12px;
  font: 32px/1.25 'Roboto Thin', sans-serif;
}

.tqo-contact-intro p {
  margin: 0;
  font: 18px/1.6 'Raleway Regular', sans-serif;
}

/* Let the shared scenario class own booking interaction states and keep the ordinary links tertiary. */
.tqo-contact-alternatives {
  margin-top: 32px;
  text-align: center;
}

.tqo-contact-booking { max-width: 100%; min-height: 48px; }
.tqo-contact-direct { margin-top: 24px; font: 0.95rem/1.5 'Raleway Regular', sans-serif; }
.tqo-contact-direct p { margin: 0 0 8px; }

.tqo-contact-direct ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.tqo-contact-direct a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-block: 6px;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.tqo-contact-direct a:hover,
.tqo-contact-direct a:focus-visible,
.tqo-contact-direct a:active { color: var(--color-accent); }

/* Include the extracted submit focus ring and every inline alternative in the component's keyboard contract. */
.tqo-contact-surface .forminator-button-submit:focus-visible,
.tqo-contact-booking:focus-visible,
.tqo-contact-direct a:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 4px;
}

/* Forminator already renders validated POST error text; expose its summary visually without requiring the plugin's JS error renderer. */
.tqo-contact-native-error {
  max-width: 640px;
  margin: 0 auto 24px;
  color: var(--color-error);
}

.tqo-contact-surface--inline .tqo-contact-error-list {
  margin: 12px 0 0;
  padding-inline-start: 20px;
  white-space: normal;
  text-align: left;
  font-size: 1rem;
}

/* Match the existing panel's canonical mobile gutters without importing Leadform's body or page layout. */
@media (max-width: 768px) {
  .tqo-contact-surface--inline { padding-block: 48px; }
  .tqo-contact-panel { padding: 32px 24px; }
  .tqo-contact-intro h2 { font-size: 28px; }
}

@media (max-width: 480px) {
  .tqo-contact-surface--inline { padding-block: 40px; scroll-margin-top: 96px; }
  .tqo-contact-panel { padding: 28px 16px; }
  .tqo-contact-intro h2 { font-size: 24px; }
  .tqo-contact-intro p { font-size: 17px; }
}

/* === СТИЛИ ДЛЯ ФОРМЫ === */

.tqo-contact-surface .forminator-custom-form {
  /* Оставляем 640px только как special-purpose контейнер для lead form на leadform.php, чтобы длинные поля и textarea сохраняли читаемую длину строки без превращения этого лимитера в общий page-level стандарт. */
  max-width: 640px;
  margin: 0 auto;
}

/* Заголовки, подписи */
.tqo-contact-surface .forminator-custom-form label {
  font-family: 'Raleway Regular', sans-serif;
  /* Текстовые цвета формы переводим на глобальный foreground token для устранения локального color-alias слоя. */
  color: var(--color-foreground);
  margin-bottom: 0.5rem;
  display: block;
  font-size: 1rem;
}

/* Include the standalone form's native reply-channel select in the existing control styling without relying on its dynamic ID. */
.tqo-contact-surface .forminator-custom-form input[type="text"],
.tqo-contact-surface .forminator-custom-form input[type="email"],
.tqo-contact-surface .forminator-custom-form input[type="url"],
.tqo-contact-surface .forminator-custom-form input[type="tel"],
.tqo-contact-surface .forminator-custom-form textarea,
.tqo-contact-surface #forminator-module-900115 select[name="select-1"] {
  /* Привязываем фон/текст/границу полей к global.css color tokens, чтобы убрать дублирующие :root aliases без изменения визуального контракта полей. */
  background: var(--color-background);
  color: var(--color-foreground);
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  /* Нормализуем высоту текстовых контролов до единого tap-target, чтобы input/textarea/button были визуально согласованы в leadform.php. */
  min-height: 52px;
  /* Контракт плотности form-controls: padding 0.75rem/1rem + margin-bottom 1.5rem формируют baseline вертикального шага между контролами. */
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  width: 100%;
  font-family: 'Raleway Regular', sans-serif;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

/* Give both contact presentations a token-colored chevron inset from the edge, while retaining the native select/picker and room for its label. */
.tqo-contact-surface #forminator-module-900115 select[name="select-1"] {
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 48px;
  background-image:
    linear-gradient(45deg, transparent 35%, var(--color-foreground) 35%, var(--color-foreground) 65%, transparent 65%),
    linear-gradient(135deg, transparent 35%, var(--color-foreground) 35%, var(--color-foreground) 65%, transparent 65%);
  background-position: right 21px center, right 16px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* Native arrows remain visible when forced colors suppress the decorative backgrounds. */
@media (forced-colors: active) {
  .tqo-contact-surface #forminator-module-900115 select[name="select-1"] {
    -webkit-appearance: auto;
    appearance: auto;
    background-image: none;
  }
}

/* Give only the shared context field multiline space without fixing its height or changing the floating panel's viewport constraints. */
.tqo-contact-surface #forminator-module-900115 textarea[name="textarea-1"] {
  min-height: 128px;
}

/* Explicit option colors cover both the disabled placeholder and selectable reply channels. */
.tqo-contact-surface #forminator-module-900115 select[name="select-1"] option {
  background-color: var(--color-background);
  color: var(--color-foreground);
}

/* Match the neighboring controls' accent border while retaining an explicit keyboard-focus ring for the native select. */
.tqo-contact-surface #forminator-module-900115 select[name="select-1"]:focus {
  border-color: var(--color-accent);
}

.tqo-contact-surface #forminator-module-900115 select[name="select-1"]:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 4px;
}

.tqo-contact-surface .forminator-custom-form input:focus,
.tqo-contact-surface .forminator-custom-form textarea:focus {
  /* Оставляем прежний акцент фокуса через глобальный accent token после удаления локального alias. */
  border-color: var(--color-accent);
  outline: none;
}

/* Подсказки под полями */
.tqo-contact-surface .forminator-custom-form .forminator-description,
.tqo-contact-surface .forminator-custom-form .forminator-label-description {
  color: #bfbfbf;
  font-size: 0.85rem;
  margin-top: -0.5rem;
  margin-bottom: 1.25rem;
}

/* Чекбоксы и радио */
.tqo-contact-surface .forminator-custom-form input[type="checkbox"],
.tqo-contact-surface .forminator-custom-form input[type="radio"] {
  /* Синхронизируем цвет control-accent с глобальным primary token для единообразия brand palette. */
  accent-color: var(--color-primary);
  width: 18px;
  height: 18px;
  margin-right: 10px;
  cursor: pointer;
}

/* Обёртка чекбокса и радио */
.tqo-contact-surface .forminator-custom-form .forminator-checkbox,
.tqo-contact-surface .forminator-custom-form .forminator-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  /* Текст состояний checkbox/radio остаётся на глобальном foreground token, как и в остальных текстовых элементах формы. */
  color: var(--color-foreground);
  font-size: 1rem;
  font-family: 'Raleway Regular', sans-serif;
}

/* Кнопка отправки */
.tqo-contact-surface .forminator-custom-form .forminator-button-submit {
  /* Мигрируем submit-button на глобальные primary/foreground tokens и удаляем зависимость от локальных color aliases. */
  background-color: var(--color-primary);
  /* Use the dark foundation text on both filled brand states so the primary action stays readable on orange and pale-accent hover. */
  color: var(--color-background);
  border: none;
  /* Синхронизируем высоту submit-кнопки с input-элементами и direct-contact CTA, чтобы интерактивные элементы имели единый вертикальный модуль. */
  min-height: 52px;
  /* Сохраняем горизонтальную плотность CTA через inline-padding без раздувания высоты кнопки. */
  padding: 0 28px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  font-family: 'Raleway Regular', sans-serif;
  /* Respect Forminator's approved mixed-case Send context label instead of visually rewriting it. */
  text-transform: none;
  font-size: 1rem;
  transition: background-color 0.3s ease;
}

.tqo-contact-surface .forminator-custom-form .forminator-button-submit:hover {
  /* Hover-контракт кнопки сохраняем через глобальный accent token, чтобы визуальное поведение осталось прежним. */
  background-color: var(--color-accent);
}

/* Центрируем кнопку */
.tqo-contact-surface .forminator-custom-form .forminator-button-submit {
  display: block;
  margin: 20px auto 0;
}

/* Выравнивание строк и колонок */
.tqo-contact-surface .forminator-custom-form .forminator-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.tqo-contact-surface .forminator-custom-form .forminator-col {
  flex: 1 1 100%;
  min-width: 100%;
}

/* Сообщение после отправки */
.tqo-contact-surface .forminator-custom-form .forminator-response-message {
  /* Сообщение after-submit переводим на global foundation tokens, чтобы закрыть локальный color-alias anomaly в leadform.css. */
  background: var(--color-background);
  color: var(--color-foreground);
  border: 1px solid var(--color-primary);
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  margin-top: 30px;
  text-align: center;
  font-size: 1.1rem;
  font-family: 'Raleway Regular', sans-serif;
  animation: tqoContactFeedback 0.6s ease-out;
}

/* Плавное появление */
@keyframes tqoContactFeedback {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tqo-contact-surface .forminator-ui-preview-wrapper {
  display: none;
}
.tqo-contact-surface .forminator-custom-form .forminator-response-message[aria-hidden="true"] {
  display: none;
}

/* Override the feedback rule at its own specificity; shared secondary buttons already have their global reduced-motion fallback. */
@media (prefers-reduced-motion: reduce) {
  .tqo-contact-surface .forminator-custom-form .forminator-response-message {
    animation: none;
  }
}

/* Floating enhancement is inline-only and opt-in; missing JS/plugin readiness leaves the existing SSR form in normal flow. */
#tqo-contact-surface {
  --tqo-contact-gap: max(16px, env(safe-area-inset-bottom));
  --tqo-contact-viewport-height: 100vh;
  --tqo-contact-viewport-bottom: 0px;
}

@supports (height: 100dvh) {
  #tqo-contact-surface { --tqo-contact-viewport-height: 100dvh; }
}

/* Explicit hidden rules beat shared display declarations, keeping closed controls and fields out of both pointer and keyboard navigation. */
#tqo-contact-surface [data-contact-toggle][hidden],
#tqo-contact-surface [data-contact-panel-controls][hidden],
#tqo-contact-surface .tqo-contact-panel[hidden] { display: none; }

#tqo-contact-surface[data-contact-presentation="floating"] > .section-container {
  min-height: var(--tqo-contact-inline-height, 0px);
}

/* Keep the disclosure at bottom-left, below the existing menu (998+) and consent (9999+) layers; Back-to-top stays at bottom-right. */
#tqo-contact-surface .tqo-contact-toggle {
  /* Disclosure controls stay still under the pointer; inline booking keeps its existing shared hover scale. */
  --scenario-hover-scale: 1;
  position: fixed;
  left: max(24px, env(safe-area-inset-left));
  bottom: calc(var(--tqo-contact-viewport-bottom) + var(--tqo-contact-gap));
  z-index: 990;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  background: var(--surface-solid-1);
  box-shadow: var(--shadow-neutral-2);
}

#tqo-contact-surface .tqo-contact-toggle:hover {
  background: var(--color-primary);
}

#tqo-contact-surface .tqo-contact-toggle svg { flex: 0 0 auto; }
/* Keep Ask us pointer clicks on the named button, including clicks on its decorative SVG path; other icons retain their hit targets. */
#tqo-contact-surface .tqo-contact-toggle svg,
#tqo-contact-surface .tqo-contact-toggle svg * { pointer-events: none; }
#tqo-contact-surface .tqo-contact-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Only positioning changes: form parents, IDs, field values and plugin handlers remain the same in floating and inline modes. */
#tqo-contact-surface[data-contact-presentation="floating"] .tqo-contact-panel {
  position: fixed;
  left: max(24px, env(safe-area-inset-left));
  bottom: calc(var(--tqo-contact-viewport-bottom) + var(--tqo-contact-gap) + 60px);
  z-index: 990;
  width: min(480px, calc(100vw - 48px));
  max-height: calc(var(--tqo-contact-viewport-height) - var(--tqo-contact-gap) - 88px - env(safe-area-inset-top));
  padding: 0 24px 24px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-padding-block: 72px 20px;
  background: var(--surface-solid-1);
  box-shadow: var(--shadow-neutral-3);
}

#tqo-contact-surface[data-contact-presentation="floating"] .tqo-contact-intro h2 { font-size: 24px; }
#tqo-contact-surface[data-contact-presentation="floating"] .tqo-contact-intro p { font-size: 16px; }

/* A sticky control row keeps Collapse reachable even after scrolling through long text, errors or the direct alternatives. */
#tqo-contact-surface .tqo-contact-panel-controls {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  padding-block: 12px;
  margin-bottom: 8px;
  background: var(--surface-solid-1);
}
#tqo-contact-surface .tqo-contact-collapse { --scenario-hover-scale: 1; min-height: 44px; padding: 8px 12px; }
#tqo-contact-surface .tqo-contact-toggle:focus-visible,
#tqo-contact-surface .tqo-contact-collapse:focus-visible,
#tqo-contact-surface #tqo-contact-heading:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* Immediate CSS suppression covers the interval before the attribute observer runs, including the mobile menu's fixed-body scroll lock. */
body.menu-open #tqo-contact-surface[data-contact-presentation="floating"] .tqo-contact-panel,
body.menu-open #tqo-contact-surface .tqo-contact-toggle,
#tqo-contact-surface[data-contact-suppressed] .tqo-contact-panel,
#tqo-contact-surface[data-contact-suppressed] .tqo-contact-toggle { visibility: hidden; pointer-events: none; }

/* Measure the live panel at its natural inline width in a single synchronous JS layout read; this state is never painted. */
#tqo-contact-surface[data-contact-measuring] .tqo-contact-panel {
  position: static;
  display: block;
  width: auto;
  max-height: none;
  padding: 40px;
  overflow: visible;
  visibility: hidden;
}
#tqo-contact-surface[data-contact-measuring] .tqo-contact-panel-controls { display: none; }
#tqo-contact-surface[data-contact-measuring] .tqo-contact-intro h2 { font-size: 32px; }
#tqo-contact-surface[data-contact-measuring] .tqo-contact-intro p { font-size: 18px; }

/* Viewport-safe mobile sheet retains native inputs/select and independent scrolling; software-keyboard geometry comes from VisualViewport. */
@media (max-width: 768px) {
  #tqo-contact-surface .tqo-contact-toggle { left: max(16px, env(safe-area-inset-left)); }
  /* Expanded mobile sheets use their sticky Collapse control, freeing the navigator row for keyboard-safe field space. */
  #tqo-contact-surface .tqo-contact-toggle[aria-expanded="true"] { display: none; }
  #tqo-contact-surface[data-contact-presentation="floating"] .tqo-contact-panel {
    left: max(12px, env(safe-area-inset-left));
    width: calc(100% - max(12px, env(safe-area-inset-left)) - max(12px, env(safe-area-inset-right)));
    max-width: 540px;
    /* The mobile header is fixed above this layer, so reserve its measured height as well as the disclosure and keyboard space. */
    bottom: calc(var(--tqo-contact-viewport-bottom) + var(--tqo-contact-gap));
    max-height: calc(var(--tqo-contact-viewport-height) - var(--tqo-contact-gap) - 28px - var(--header-height, 120px) - env(safe-area-inset-top));
    padding-inline: 16px;
  }
  /* Measure the taller textarea's full inline height even after reopening; the on-screen sheet keeps its existing viewport limit above. */
  #tqo-contact-surface[data-contact-measuring] .tqo-contact-panel { width: auto; max-width: 780px; max-height: none; padding: 32px 24px; }
  #tqo-contact-surface[data-contact-measuring] .tqo-contact-intro h2 { font-size: 28px; }
}
@media (max-width: 480px) {
  #tqo-contact-surface[data-contact-measuring] .tqo-contact-panel { padding: 28px 16px; }
  #tqo-contact-surface[data-contact-measuring] .tqo-contact-intro h2 { font-size: 24px; }
  #tqo-contact-surface[data-contact-measuring] .tqo-contact-intro p { font-size: 17px; }
}

/* Motion remains decorative: disclosure/docking never animates field geometry, and reduced-motion removes inherited button transitions. */
@media (prefers-reduced-motion: reduce) {
  #tqo-contact-surface .scenario-button-base { --scenario-hover-scale: 1; transition: none; }
}
