/*
 * Форма заявки. Встраивается в любую вёрстку.
 *
 * Значения взяты из исходников shadcn/ui (new-york v4) — Input, Button, Checkbox:
 * радиус rounded-md, рамка 1px, кольцо фокуса 3px с прозрачностью 50%,
 * gap-2 между иконкой и текстом, disabled = opacity .5,
 * ошибка = aria-invalid + кольцо цвета destructive.
 * Отличие одно: высота полей 44px вместо 36px — минимальный размер
 * зоны нажатия на телефоне (иначе в палец не попадают).
 *
 * Перекраска под сайт — только переменные в блоке ЦВЕТ. Правила не трогать.
 */

.ss-form {
  /* --- ЦВЕТ: единственное, что меняется под сайт --- */
  --ss-primary: #2563eb;
  --ss-primary-hover: #1d4ed8;          /* у shadcn это primary/90 */
  --ss-primary-foreground: #ffffff;
  --ss-ring: rgba(37, 99, 235, 0.5);    /* ring/50 */

  --ss-foreground: #0f172a;
  --ss-muted-foreground: #64748b;
  --ss-background: #ffffff;
  --ss-input: #d4d4d8;                  /* цвет рамки полей */
  --ss-destructive: #dc2626;
  --ss-destructive-ring: rgba(220, 38, 38, 0.2);

  /* --- размеры (shadcn: --radius .625rem, rounded-md = radius - 2px) --- */
  --ss-radius: 8px;
  --ss-control-height: 44px;
  --ss-shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --ss-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 420px;
  width: 100%;
  font-family: var(--ss-font);
  color: var(--ss-foreground);
  box-sizing: border-box;
}

.ss-form *,
.ss-form *::before,
.ss-form *::after { box-sizing: inherit; }

.ss-form__title {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ss-form__subtitle {
  margin: -8px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ss-muted-foreground);
}

.ss-field { display: flex; flex-direction: column; gap: 8px; }

.ss-label {
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
}

/* --- поле ввода (shadcn Input) --- */
.ss-input {
  width: 100%;
  min-width: 0;
  height: var(--ss-control-height);
  padding: 0 12px;
  font: inherit;
  font-size: 16px; /* меньше 16px — iOS зумит страницу при фокусе */
  color: var(--ss-foreground);
  background: transparent;
  border: 1px solid var(--ss-input);
  border-radius: var(--ss-radius);
  box-shadow: var(--ss-shadow-xs);
  outline: none;
  transition: color .15s ease, box-shadow .15s ease, border-color .15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.ss-input::placeholder { color: var(--ss-muted-foreground); opacity: 1; }

/* --- телефон: IMask управляет вводом, этот слой только показывает оставшиеся позиции --- */
.ss-phone-shell {
  position: relative;
  width: 100%;
}

.ss-phone-shell .ss-input {
  position: relative;
  z-index: 1;
  font-variant-numeric: tabular-nums;
}

.ss-phone-mask {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  overflow: hidden;
  color: var(--ss-muted-foreground);
  font: inherit;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  visibility: hidden;
}

.ss-phone-shell[data-mask-ready="true"] .ss-phone-mask { visibility: visible; }
.ss-phone-mask [data-phone-mask-fixed],
.ss-phone-mask [data-phone-mask-digit][data-filled="true"] { color: transparent; }

.ss-input:focus-visible,
.ss-input:focus {
  border-color: var(--ss-primary);
  box-shadow: 0 0 0 3px var(--ss-ring);
}

.ss-input[aria-invalid="true"] {
  border-color: var(--ss-destructive);
  box-shadow: 0 0 0 3px var(--ss-destructive-ring);
}

.ss-input:disabled { pointer-events: none; opacity: .5; }

/* --- согласие (shadcn Checkbox) --- */
.ss-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ss-muted-foreground);
  cursor: pointer;
  user-select: none;
}

.ss-consent input[type="checkbox"] {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
  border-radius: 4px;
  accent-color: var(--ss-primary);
  cursor: pointer;
}

.ss-consent input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ss-ring);
  border-radius: 4px;
}

.ss-consent a { color: inherit; text-decoration: underline; text-underline-offset: 4px; }
.ss-consent a:hover { color: var(--ss-primary); }

.ss-consent[data-invalid="true"] {
  color: var(--ss-destructive);
}

.ss-consent[data-invalid="true"] input[type="checkbox"] {
  outline: 2px solid var(--ss-destructive);
  outline-offset: 2px;
}

/* --- кнопка (shadcn Button, variant default) --- */
.ss-button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: var(--ss-control-height);
  padding: 0 16px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--ss-primary-foreground);
  background: var(--ss-primary);
  border: 1px solid transparent;
  border-radius: var(--ss-radius);
  cursor: pointer;
  transition: all .15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.ss-button:hover:not(:disabled) { background: var(--ss-primary-hover); }
.ss-button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ss-ring); }
.ss-button:disabled { pointer-events: none; opacity: .5; }

.ss-button__spinner {
  width: 16px; height: 16px;
  flex-shrink: 0;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ss-spin .7s linear infinite;
  display: none;
}
.ss-button[data-loading="true"] .ss-button__spinner { display: block; }
@keyframes ss-spin { to { transform: rotate(360deg); } }

/* --- сообщение об ошибке --- */
.ss-error {
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ss-destructive);
  background: rgba(220, 38, 38, 0.07);
  border: 1px solid var(--ss-destructive-ring);
  border-radius: var(--ss-radius);
}

/* ловушка для ботов: человек её не видит и не сфокусирует */
.ss-trap {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .ss-form * { transition: none !important; animation: none !important; }
}
