/* ============================================================================
 * Калькулятор растаможки авто — дизайн-система «Активные элементы»
 * (Figma: Артём Родионов • Онлайн-калькуляторы, node 3683-35315).
 * Монохром #000/#FFF/#DDD, шрифт Unbounded, карточки-поля radius 16,
 * чипы radius 8, чекбоксы radius 4. Namespace: .av-calc
 * ========================================================================== */

.av-calc {
  --av-black: #000;
  --av-white: #fff;
  --av-grey: #ddd;
  --av-grey-text: #808080;
  font-family: 'Unbounded', system-ui, sans-serif;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  color: var(--av-black);
}

.av-calc *,
.av-calc *::before,
.av-calc *::after { box-sizing: border-box; }

/* на ПК — два столбца, блоки в ряд; на мобиле — один столбец */
.av-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  align-items: start;
}
.av-form > .av-col-full,
.av-actions { grid-column: 1 / -1; }

/* недоступный блок: виден, но приглушён и неактивен (нельзя выбрать) */
.av-off { opacity: .5; pointer-events: none; }
.av-off .av-field__input::placeholder { opacity: .5; }

/* строка из трёх блоков (последовательный тип · кто ввозит · проходимость) */
.av-row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-items: stretch; }
.av-row3 > * { min-width: 0; }
/* тоглы растягиваются на высоту самого высокого блока в строке */
.av-celltoggle { display: flex; }
.av-celltoggle > .av-toggle { flex: 1 1 auto; width: 100%; }
.av-row3 .av-toggle__label { white-space: normal; }

/* ---- карточка-поле (label сверху, значение/контрол снизу) -------------- */
.av-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--av-white);
  border: 1px solid var(--av-grey);
  border-radius: 16px;
  padding: 16px;
  transition: border-color .15s ease;
  cursor: text;
}
.av-field:focus-within { border-color: var(--av-black); }
.av-field--select { cursor: pointer; }

.av-field__label {
  font-size: 10px;
  line-height: 1;
  opacity: .5;
  font-weight: 400;
}

.av-field__input,
.av-field__select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.25;
  color: var(--av-black);
  width: 100%;
  padding: 0;
  margin: 0;
}
.av-field__input::placeholder { color: var(--av-black); opacity: .5; }

/* стрелка для select */
.av-field__select {
  cursor: pointer;
  padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23000' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}

/* поле + единицы/валюта в строку */
.av-field__row { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.av-field__row .av-field__input { flex: 1 1 auto; min-width: 0; }
/* единицы (л.с./кВт) в поле — всегда в одну строку, не переносить */
.av-field__row .av-chips { flex: 0 0 auto; flex-wrap: nowrap; }

/* ---- группа с заголовком (для чипов/тоглов) ---------------------------- */
.av-group { display: flex; flex-direction: column; gap: 8px; }
.av-group__label { font-size: 10px; line-height: 1; opacity: .5; padding: 0 2px; }

/* ---- чипы (radio как «быстрый параметр») ------------------------------- */
.av-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.av-chip { display: inline-flex; cursor: pointer; }
.av-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.av-chip > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--av-white);
  border: 1px solid var(--av-grey);
  border-radius: 8px;
  padding: 8px;
  font-size: 10px;
  line-height: 1;
  color: var(--av-black);
  transition: background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.av-chip input:checked + span { background: var(--av-grey); border-color: var(--av-grey); }
.av-chip input:focus-visible + span { border-color: var(--av-black); }

/* ---- переключатель (checkbox как switch) ------------------------------- */
.av-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--av-white);
  border: 1px solid var(--av-grey);
  border-radius: 16px;
  padding: 8px 16px 8px 8px;
  cursor: pointer;
}
.av-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.av-toggle__track {
  flex: 0 0 auto;
  width: 56px; height: 32px;
  border: 1px solid var(--av-grey);
  border-radius: 16px;
  background: var(--av-white);
  position: relative;
  transition: background .15s ease;
}
.av-toggle__dot {
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 16px;
  background: var(--av-grey);
  transition: transform .15s ease, background .15s ease;
}
.av-toggle input:checked + .av-toggle__track { background: var(--av-grey); }
.av-toggle input:checked + .av-toggle__track .av-toggle__dot { transform: translateX(24px); background: var(--av-black); }
.av-toggle__label { font-size: 10px; line-height: 1.2; }
.av-toggle.is-disabled { opacity: .5; cursor: not-allowed; }

/* ---- кнопки ------------------------------------------------------------ */
.av-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.av-btn {
  flex: 1 1 auto;
  height: 48px;
  border-radius: 16px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
  border: 1px solid transparent;
}
.av-btn--primary { background: var(--av-black); color: var(--av-white); }
.av-btn--primary:hover { opacity: .85; }
.av-btn--secondary { background: var(--av-white); color: var(--av-black); border-color: var(--av-grey); }
.av-btn--secondary:hover { background: #f5f5f5; }

/* ---- ошибка ------------------------------------------------------------ */
.av-error {
  display: none;
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px solid var(--av-black);
  border-radius: 16px;
  font-size: 11px;
  line-height: 1.4;
}
.av-error.is-visible { display: block; }

/* ---- результат --------------------------------------------------------- */
.av-result { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.av-result[hidden] { display: none; }

.av-result__card {
  background: var(--av-white);
  border: 1px solid var(--av-grey);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.av-rrow { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.av-rrow__name { display: flex; flex-direction: column; gap: 4px; }
.av-rrow__title { font-size: 11px; line-height: 1.25; }
.av-rrow__rate { font-size: 10px; line-height: 1.2; opacity: .5; }
.av-rrow__val { font-size: 11px; line-height: 1.25; white-space: nowrap; text-align: right; }

.av-total {
  background: var(--av-black);
  color: var(--av-white);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.av-total__label { font-size: 11px; opacity: .8; }
.av-total__sum { font-size: 14px; line-height: 1.2; text-align: right; }
.av-total__sum small { display: block; font-size: 10px; opacity: .6; margin-top: 3px; }

.av-note { font-size: 10px; line-height: 1.5; color: var(--av-grey-text); padding: 0 2px; }
.av-note a { color: var(--av-grey-text); }

/* ---- мобайл ------------------------------------------------------------ */
@media (max-width: 640px) {
  .av-form { grid-template-columns: 1fr; }
  .av-row3 { grid-template-columns: 1fr; }
}
