/* Чекаут Loviks — дизайн 1c «Конверсійна». Пересобрано под макет.
   Классы, которые создаёт app.js (cart__*, upsell-card__*, qty*, suggestions__item…),
   сохранены и стилизованы здесь. */

:root {
  --navy: #2E3350;
  --navy-hover: #232743;
  --ink: #23283C;
  --muted: #7A7D8C;
  --faint: #9A9DAB;
  --coral: #F04E5A;
  --coral-hover: #d63b47;
  --coral-light: #FF8C94;
  --coral-bg: #FFF6F6;
  --coral-border: #FAD3D6;
  --green: #16A34A;
  --green-bg: #EAF6EE;
  --line: #EAEAE8;
  --line-input: #E4E4E2;
  --page: #E9E9E6;
  --surface: #FFFFFF;
  --error: #dc2626;
  --font: 'Golos Text', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.4;
}
input, textarea, select, button { font-family: inherit; }
/* Спрятанное должно быть спрятано всегда: любое наше display (flex/grid)
   перебивает встроенный hidden, и блок вылезает наружу. */
[hidden] { display: none !important; }

/* Контейнер: одна колонка, по центру (как в макете) */
.checkout {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 0 16px;
}

/* Шапка */
.checkout__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--surface);
  border-bottom: 1px solid #EEEEEC;
}
.checkout__brand { font-size: 18px; font-weight: 900; letter-spacing: .04em; color: var(--navy); }
.checkout__secure { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--green); }

.checkout__title { margin: 16px 18px; font-size: 21px; font-weight: 800; letter-spacing: -.01em; }

.checkout__grid { padding: 0 14px; display: flex; flex-direction: column; gap: 14px; }
.checkout__side { display: contents; }
.checkout__fields { display: contents; }

/* Карточка */
.form__section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px;
}
.form__heading,
.card-label {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
}
.subhead { margin: 4px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink); }

/* Поля */
.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field__input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line-input);
  border-radius: 12px;
  padding: 0 14px;
  /* 16px обязательно: при меньшем шрифте iOS Safari сам приближает страницу,
     когда покупатель тыкает в поле, и назад она не отъезжает */
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}
.field__input::placeholder { color: var(--faint); }
.field__input:focus { border-color: var(--navy); }
.field__input.is-invalid { border-color: var(--error); }
textarea.field__input { height: auto; min-height: 60px; padding: 12px 14px; resize: vertical; line-height: 1.4; }
select.field__input {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%239A9DAB' stroke-width='1.6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
.field__error { display: block; min-height: 15px; font-size: 12px; color: var(--error); margin-top: 4px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 2px 2px 6px; }

/* Телефон с кодом страны */
.phone-row { display: flex; gap: 10px; margin-bottom: 10px; }
.country-select { flex: 0 0 auto; width: auto; min-width: 98px; padding-right: 30px; font-weight: 600; cursor: pointer; }
.phone-row .field { flex: 1; margin-bottom: 0; }

/* Сегмент «Я / Інший отримувач» */
.seg { display: flex; background: #F1F1EF; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg__opt { flex: 1; text-align: center; cursor: pointer; }
.seg__opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg__opt span { display: block; padding: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-radius: 9px; transition: background .15s, color .15s; }
.seg__opt input:checked + span { background: var(--navy); color: #fff; font-weight: 700; }

.inset { background: #FBFBFC; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.inset .subhead { margin-top: 0; }

/* Чекбокс */
.checkbox { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; margin-top: 6px; }
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox__box { width: 20px; height: 20px; border: 1.5px solid #CFCFCC; border-radius: 6px; flex: 0 0 auto; position: relative; transition: .15s; }
.checkbox input:checked + .checkbox__box { border-color: var(--navy); background: var(--navy); }
.checkbox input:checked + .checkbox__box::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* Согласие с офертой — перед кнопкой оплаты */
.consent { display: flex; align-items: flex-start; gap: 9px; margin: 0 0 12px; font-size: 12.5px; line-height: 1.4; color: var(--muted); cursor: pointer; }
.consent input { position: absolute; opacity: 0; pointer-events: none; }
.consent__box { width: 20px; height: 20px; border: 1.5px solid #CFCFCC; border-radius: 6px; flex: 0 0 auto; position: relative; transition: .15s; margin-top: 1px; }
.consent input:checked + .consent__box { border-color: var(--navy); background: var(--navy); }
.consent input:checked + .consent__box::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.consent input:focus-visible + .consent__box { outline: 2px solid var(--navy); outline-offset: 2px; }
.consent.is-invalid .consent__box { border-color: var(--error); }
.consent a { color: var(--navy); font-weight: 600; }

/* Карточки выбора: доставка / оплата */
.options { display: flex; flex-direction: column; gap: 10px; }
.option { display: block; cursor: pointer; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option__box {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid #E9E9E7; border-radius: 13px; padding: 13px 14px; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.option input:checked + .option__box { border: 2px solid var(--navy); background: #FBFBFC; padding: 12px 13px; }
.option__icon { flex: 0 0 auto; display: flex; }
.option__icon img { width: 34px; height: 34px; border-radius: 9px; display: block; }
.option__text { flex: 1; min-width: 0; }
.option__label { display: block; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.option__sub { display: block; font-size: 12px; color: #8A8D9A; margin-top: 1px; }
.option__check { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #CFCFCC; }
.option input:checked + .option__box .option__check { border: 6px solid var(--navy); }

/* Оплата картой + иконки — одна цельная карточка */
.option--pay .option__box { flex-direction: column; align-items: stretch; gap: 0; }
.option__row { display: flex; align-items: center; gap: 12px; }
.option--pay .pay-icons--row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-input); justify-content: center; }

.delivery-note { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid #F2F2F0; font-size: 12.5px; font-weight: 600; color: var(--muted); }

/* Доставка: службы друг под другом, поля раскрываются внутри выбранной карточки */
.ships { display: flex; flex-direction: column; gap: 10px; }
.ship {
  border: 1px solid #E9E9E7; border-radius: 13px; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.ship.is-active { border: 2px solid var(--navy); background: #FBFBFC; }
.ship__head { display: flex; align-items: center; gap: 12px; padding: 13px 14px; cursor: pointer; }
.ship.is-active .ship__head { padding: 12px 13px; }
.ship__head input { position: absolute; opacity: 0; pointer-events: none; }
.ship__radio { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #CFCFCC; }
.ship.is-active .ship__radio { border: 6px solid var(--navy); }
.ship__icon { flex: 0 0 auto; display: flex; }
.ship__icon img { width: 34px; height: 34px; border-radius: 9px; display: block; }
.ship__text { flex: 1; min-width: 0; }
.ship__name { display: block; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.ship__sub { display: block; font-size: 12px; color: #8A8D9A; margin-top: 1px; }
.ship__price { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.ship__body { padding: 13px; border-top: 1px solid var(--line-input); }

/* Выпадающий список с поиском (город / отделение) */
.combo { position: relative; }
.combo__input { padding-right: 38px; }
.combo__chev {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer;
}
.combo__chev::before {
  content: ''; position: absolute; left: 10px; top: 10px; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .15s;
}
.combo.is-open .combo__chev::before { top: 13px; transform: rotate(-135deg); }
.combo__list {
  list-style: none; margin: 6px 0 0; padding: 4px 0; position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  background: #fff; border: 1px solid var(--line-input); border-radius: 12px; box-shadow: 0 12px 30px -10px rgba(30,34,60,.28);
  max-height: 260px; overflow-y: auto;
}
.combo__item { padding: 9px 14px; cursor: pointer; }
.combo__item:hover { background: #F6F6F5; }
.combo__item-main { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.combo__item-sub { display: block; font-size: 12px; color: var(--faint); margin-top: 1px; }
.combo__empty { padding: 11px 14px; font-size: 13px; color: var(--muted); }

/* Иконки оплат — выезжают при онлайн-оплате */
.pay-icons { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.pay-icons img { height: 22px; width: auto; display: block; }

/* Полоска бесплатной доставки */
.freeship { background: var(--navy); border-radius: 14px; padding: 13px 15px; }
.freeship__text { margin: 0 0 9px; font-size: 13px; font-weight: 600; color: #EDEDF2; }
.freeship__text b { color: var(--coral-light); }
.freeship__track { height: 8px; border-radius: 99px; background: rgba(255,255,255,.16); overflow: hidden; }
.freeship__fill { height: 100%; background: linear-gradient(90deg, var(--coral), var(--coral-light)); border-radius: 99px; transition: width .3s; }

/* Корзина */
.cart .form__heading, .cart-head { display: flex; align-items: center; justify-content: space-between; }
.cart__item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid #F2F2F0; }
.cart__item:first-child { padding-top: 4px; }
.cart__item:last-of-type { border-bottom: none; }
.cart__img { flex: 0 0 auto; width: 60px; height: 60px; border-radius: 12px; object-fit: contain; padding: 5px; background: #F2F2F0; border: 1px solid var(--line); }
.cart__info { flex: 1; min-width: 0; }
.cart__name { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.cart__meta { font-size: 12px; color: var(--faint); margin-top: 3px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-input); border-radius: 10px; overflow: hidden; margin-top: 9px; }
.qty__btn { width: 30px; height: 30px; border: none; background: #fff; color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.qty__btn:hover { background: #F6F6F5; }
.qty__btn:disabled { color: #CFCFCC; cursor: default; background: #FAFAF9; }
.qty__btn:disabled:hover { background: #FAFAF9; }
.qty--locked { opacity: .85; }
.qty__num { min-width: 30px; text-align: center; font-size: 13px; font-weight: 700; }
.cart__right { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.cart__line-price { font-size: 14px; font-weight: 800; white-space: nowrap; }
.cart__remove { width: 28px; height: 28px; border: none; border-radius: 8px; background: #F6F6F5; color: #B0424C; font-size: 16px; line-height: 1; cursor: pointer; }
.cart__remove:hover { background: #F1E3E4; }
/* Зелёная плашка экономии — только когда скидка есть */
.cart__save {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-top: 14px; padding: 10px 14px; border-radius: 12px;
  background: #EAF7EE; font-size: 13.5px; font-weight: 700; color: var(--green);
}
.cart__save-value { white-space: nowrap; }
.cart__total { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 16px; font-weight: 800; padding-top: 14px; margin-top: 4px; border-top: 1px solid #F2F2F0; }
.cart__total-right { display: flex; align-items: baseline; gap: 10px; }
.cart__total-right .was { font-size: 14px; font-weight: 600; color: var(--faint); text-decoration: line-through; }
.cart__total-right .now { font-size: 22px; font-weight: 800; color: var(--ink); white-space: nowrap; }

/* Допродажи — корал-хиро с горизонтальной каруселью */
.upsell { border-color: var(--coral-border); background: linear-gradient(160deg, #FFF1F1, #FFF7F0); }
.upsell__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.upsell__title { font-size: 13px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; color: var(--coral); }
.upsell__pill { background: var(--coral); color: #fff; font-size: 12px; font-weight: 800; border-radius: 99px; padding: 5px 13px; white-space: nowrap; }
.upsell-scroller { position: relative; }
/* Стрелки прокрутки — только на ПК: на телефоне карточки листают пальцем */
.upsell-nav { display: none; }
.upsell-grid { display: flex; gap: 12px; overflow-x: auto; align-items: stretch; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.upsell-grid::-webkit-scrollbar { height: 0; }
.upsell-card { flex: 0 0 168px; display: flex; flex-direction: column; background: #fff; border: 1px solid #F1DBDD; border-radius: 16px; padding: 12px; }
.upsell-card__imgwrap { position: relative; }
.upsell-card__img { width: 100%; height: 132px; border-radius: 12px; object-fit: contain; background: transparent; display: block; }
div.upsell-card__img { background: #F4F4F3; }
.upsell-card__name {
  font-size: 13px; font-weight: 600; line-height: 1.3; margin-top: 12px;
  height: 34px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.upsell-card__price { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.upsell-card__price .now { font-size: 17px; font-weight: 800; color: var(--coral); }
.upsell-card__price .was { font-size: 12px; color: var(--faint); text-decoration: line-through; }
.upsell-card__add { width: 100%; height: 40px; margin-top: 12px; border: none; border-radius: 11px; background: var(--coral); color: #fff; font-size: 13px; font-weight: 700; cursor: pointer; }
.upsell-card__add:hover { background: var(--coral-hover); }
.upsell-card__add:disabled { background: #E9C7CA; cursor: default; }
.badge-hit { position: absolute; top: 8px; left: 8px; background: var(--navy); color: #fff; font-size: 10px; font-weight: 700; border-radius: 6px; padding: 3px 8px; letter-spacing: .02em; }

/* Цена со скидкой в корзине и итоге (зачёркнутая старая) */
.cart__line-price .now { display: block; }
.cart__line-price .was { display: block; font-size: 11px; color: var(--faint); text-decoration: line-through; font-weight: 500; margin-top: 1px; }

/* Липкая нижняя панель */
.checkout__summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px;
}
/* Итоги: сума замовлення → знижка → до сплати, одной подложкой */
.summary__box { background: #F7F7F6; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.summary__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.summary__row + .summary__row { margin-top: 7px; }
.summary__label { font-size: 14px; font-weight: 600; color: var(--muted); }
.summary__value { font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.summary__row--sub .summary__value { color: var(--faint); text-decoration: line-through; }
.summary__row--discount .summary__label,
.summary__row--discount .summary__value { color: var(--green); font-weight: 700; }
.summary__row--total { margin-top: 12px; }
.summary__row--total .summary__label { font-size: 15px; font-weight: 800; color: var(--ink); }
.summary__row--total .summary__value { font-size: 22px; font-weight: 800; color: var(--ink); }
/* Сколько сэкономил покупатель */
.submit-btn {
  width: 100%; min-height: 54px; padding: 8px 12px; border: none; border-radius: 14px;
  background: var(--coral); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
  line-height: 1.2; box-shadow: 0 8px 20px -8px rgba(240,78,90,.6); transition: background .15s, transform .1s;
}
.submit-btn:hover { background: var(--coral-hover); }
.submit-btn:active { transform: scale(.99); }
.trust { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; margin-top: 10px; font-size: 11px; color: var(--faint); }
.trust__item { display: flex; align-items: center; gap: 4px; }
.form-message { text-align: center; font-size: 13px; margin: 0; min-height: 0; }
.form-message.is-success, .form-message.is-error { margin-top: 10px; }
.form-message.is-success { color: var(--green); }
.form-message.is-error { color: var(--error); }

/* Планшет: та же одна колонка, просто шире */
@media (min-width: 720px) {
  .checkout { max-width: 520px; }
  .checkout__summary > * { max-width: 520px; }
}

/* ПК: две колонки — слева поля, справа замовлення (корзина, допродажі, кнопка).
   Мобильные стили выше не трогаем — они утверждены. */
@media (min-width: 980px) {
  .checkout { max-width: 1060px; padding-bottom: 28px; }
  .checkout__header { padding: 18px 22px; }
  .checkout__title { margin: 22px 22px 16px; font-size: 26px; }

  .checkout__grid {
    display: grid;
    padding: 0 22px;
    grid-template-columns: minmax(0, 1fr) 392px;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "fields side"
      "fields summary"
      "fields summary";
    gap: 14px 20px;
    align-items: start;
  }
  .checkout__fields { display: flex; flex-direction: column; gap: 14px; grid-area: fields; }
  .checkout__side { display: flex; flex-direction: column; gap: 14px; grid-area: side; }
  /* Блок «До сплати» едет за прокруткой — кнопка всегда на виду.
     Только на ПК: на мобильном липких элементов нет. */
  .checkout__summary { grid-area: summary; align-self: start; position: sticky; top: 14px; }
  .checkout__summary > * { max-width: none; }

  /* Стрелки допродаж — показываем, только пока есть куда прокручивать */
  .upsell-nav:not([hidden]) {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 61px; z-index: 5;
    width: 34px; height: 34px; padding: 0; border-radius: 50%;
    border: 1px solid var(--coral-border); background: #fff; cursor: pointer;
    box-shadow: 0 4px 14px -4px rgba(30, 34, 60, .3);
  }
  .upsell-nav--prev { left: -6px; }
  .upsell-nav--next { right: -6px; }
  .upsell-nav::before {
    content: ''; width: 8px; height: 8px;
    border-right: 2px solid var(--navy); border-bottom: 2px solid var(--navy);
  }
  .upsell-nav--next::before { transform: translateX(-2px) rotate(-45deg); }
  .upsell-nav--prev::before { transform: translateX(2px) rotate(135deg); }
  .upsell-nav:hover { background: #FFF6F6; }
}

/* Превью мобильного вида на компьютере (ссылка с &view=mobile).
   Возвращает всё к мобильной раскладке независимо от ширины окна.
   Идёт последним, чтобы перебить блоки для ПК выше. */
html.view-mobile .checkout { max-width: 460px; padding-bottom: 16px; }
html.view-mobile .checkout__header { padding: 16px 18px; }
html.view-mobile .checkout__title { margin: 16px 18px; font-size: 21px; }
/* align-items/align-self обязательно вернуть: иначе карточки перестают
   растягиваться на всю ширину колонки и блок допродаж вылезает наружу */
html.view-mobile .checkout__grid { display: flex; flex-direction: column; gap: 14px; padding: 0 14px; align-items: stretch; }
html.view-mobile .checkout__fields,
html.view-mobile .checkout__side { display: contents; }
html.view-mobile .checkout__summary { position: static; align-self: stretch; }
html.view-mobile .checkout__summary > * { max-width: none; }
html.view-mobile .upsell-nav { display: none; }
