/*
 * Редизайн корзины: оформление заказа в один экран, окно «Товар добавлен в корзину»,
 * окно «Спасибо! Заказ принят», липкая плашка на мобильном.
 * Макет: Figma «Белорусские двери» → «Оформление заказа ПК и Моб» (node 129:12013).
 * Подключается в common/header.twig на всех страницах (окно добавления — на любой странице).
 */
:root {
  --ck-dark: #121a27;
  --ck-dark-300: #727985;
  --ck-dark-200: #a5abb4;
  --ck-dark-100: #d6dadf;
  --ck-dark-50: #edeff2;
  --ck-white: #fff;
  --ck-green: #009640;
  --ck-green-100: #d5f5da;
  --ck-green-50: #eafcec;
  --ck-green-800: #00491c;
  --ck-muted: #8b9ca6;
  --ck-red: #e90606;
  --ck-font: "Segoe", "Segoe UI", Arial, sans-serif;
}

/* ---------- Кнопки и общие элементы ---------- */
.ck-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border: 1px solid var(--ck-green);
  border-radius: 8px;
  font: 600 13px/16px var(--ck-font);
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s, color .2s, opacity .2s;
}
.ck-btn--primary { background: var(--ck-green); color: var(--ck-white); }
.ck-btn--primary:hover { background: #00853a; color: var(--ck-white); }
.ck-btn--secondary { background: var(--ck-white); color: var(--ck-green); }
.ck-btn--secondary:hover { background: var(--ck-green-50); color: var(--ck-green); }
.ck-btn[disabled] { opacity: .6; cursor: default; }

.ck-divider { width: 100%; height: 1px; margin: 0; border: 0; background: var(--ck-dark-100); }

/* ---------- Страница оформления ---------- */
.ck-page { background: var(--ck-dark-50); font-family: var(--ck-font); color: var(--ck-dark); }
.main.ck-page { padding-top: 0; padding-bottom: 0; } /* отступы задаёт .ck-container, как в макете */
.ck-page *, .ck-modal * { box-sizing: border-box; }
.ck-container { max-width: 1208px; margin: 0 auto; padding: 29px 20px 100px; }

.ck-breadcrumbs { display: flex; align-items: center; gap: 12px; margin: 0 0 24px; font: 400 13px/16px var(--ck-font); }
.ck-breadcrumbs a { color: var(--ck-dark); text-decoration: none; }
.ck-breadcrumbs a:hover { color: var(--ck-green); }
.ck-breadcrumbs span { color: var(--ck-muted); }
.ck-breadcrumbs__sep { display: block; width: 5px; height: 9px; transform: rotate(180deg); }

.ck-title { margin: 0 0 24px; font: 700 32px/40px var(--ck-font); text-transform: uppercase; color: var(--ck-dark); }

.ck-columns { display: flex; align-items: flex-start; gap: 24px; }
.ck-left { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.ck-card { display: flex; flex-direction: column; align-items: flex-start; padding: 24px; border-radius: 12px; background: var(--ck-white); }
.ck-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 28px; }
.ck-card__title { margin: 0; font: 600 20px/22px var(--ck-font); color: var(--ck-dark); }
.ck-items { gap: 8px; }
.ck-contacts { gap: 16px; }

.ck-badge { flex: none; padding: 4px 10px; border-radius: 14px; background: var(--ck-green-100); font: 600 14px/20px var(--ck-font); color: var(--ck-green-800); white-space: nowrap; }

/* Строка товара */
.ck-list { width: 100%; }
.ck-item { position: relative; display: flex; align-items: center; gap: 20px; width: 100%; padding: 16px 0; }
.ck-item + .ck-item { border-top: 1px solid var(--ck-dark-100); }
.ck-item__image { flex: none; display: block; width: 88px; height: 110px; border-radius: 8px; background: var(--ck-dark-50); overflow: hidden; }
.ck-item__image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ck-item__info { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ck-item__name { font: 600 16px/22px var(--ck-font); color: var(--ck-dark); text-decoration: none; }
.ck-item__name:hover { color: var(--ck-green); }
.ck-item__meta { font: 400 12px/16px var(--ck-font); color: var(--ck-dark-300); }
.ck-item__controls { flex: none; display: flex; align-items: center; gap: 59px; }
.ck-item__row { display: contents; }
.ck-item__total { min-width: 110px; font: 700 22px/26px var(--ck-font); text-align: right; white-space: nowrap; color: var(--ck-dark); }
.ck-item__remove { flex: none; display: flex; align-items: center; justify-content: center; position: absolute; top: 8px; right: -6px; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; opacity: .45; transition: opacity .2s, background-color .2s; }
.ck-item__remove:hover { opacity: 1; background: var(--ck-dark-50); }
.ck-item__remove img { display: block; width: 16px; height: 16px; }

.ck-counter { display: flex; align-items: center; justify-content: space-between; width: 104px; height: 40px; padding: 0 4px; border: 1px solid var(--ck-dark-100); border-radius: 8px; background: var(--ck-white); }
.ck-counter__btn { width: 28px; height: 100%; padding: 0; border: 0; background: none; font: 600 16px/22px var(--ck-font); color: var(--ck-dark-300); cursor: pointer; }
.ck-counter__btn:hover { color: var(--ck-green); }
.ck-counter__btn[disabled] { opacity: .4; cursor: default; }
.ck-counter__value { font: 600 16px/22px var(--ck-font); color: var(--ck-dark); }
.ck-list.is-loading { opacity: .5; pointer-events: none; }

/* Поля формы */
.ck-field { display: flex; flex-direction: column; gap: 6px; width: 100%; margin: 0; }
.ck-field__label { font: 600 14px/20px var(--ck-font); color: var(--ck-dark); }
.ck-req { color: var(--ck-red); }
.ck-field__input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--ck-dark-100); border-radius: 8px; background: var(--ck-dark-50); font: 400 16px/20px var(--ck-font); color: var(--ck-dark); outline: none; transition: border-color .2s, background-color .2s; -webkit-appearance: none; appearance: none; }
.ck-field__input::placeholder { color: var(--ck-dark-300); opacity: 1; }
.ck-field__input:focus { border-color: var(--ck-green); background: var(--ck-white); }
textarea.ck-field__input { height: 88px; padding-top: 12px; resize: vertical; }
.ck-field.has-error .ck-field__input { border-color: var(--ck-red); }
.ck-error { font: 400 13px/18px var(--ck-font); color: var(--ck-red); }

/* Телефон: выбор кода страны + номер. Незаполненная часть маски — серая подложка под полем.
   Разметку строит phone-field.js (корзина и формы-заявки) */
.ck-phone { display: flex; width: 100%; height: 48px; border: 1px solid var(--ck-dark-100); border-radius: 8px; background: var(--ck-dark-50); transition: border-color .2s, background-color .2s; }
.ck-phone:focus-within { border-color: var(--ck-green); background: var(--ck-white); }
.ck-field.has-error .ck-phone { border-color: var(--ck-red); }
.ck-phone__country { position: relative; flex: none; display: flex; border-right: 1px solid var(--ck-dark-100); }
.ck-phone__trigger { display: flex; align-items: center; gap: 6px; height: 100%; padding: 0 10px 0 14px; border: 0; border-radius: 8px 0 0 8px; background: none; font: 400 16px/20px var(--ck-font); color: var(--ck-dark); cursor: pointer; transition: background-color .2s; }
.ck-phone__trigger:hover, .ck-phone__trigger[aria-expanded="true"] { background: rgba(18, 26, 39, .04); }
.ck-phone__trigger:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ck-green-100); }
.ck-phone__flag { flex: none; display: block; width: 20px; height: 15px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(18, 26, 39, .12); }
.ck-phone__code { transition: color .2s; }
.ck-phone__trigger:hover .ck-phone__code { color: var(--ck-green); }
.ck-phone__arrow { flex: none; display: block; width: 12px; height: 12px; transition: transform .2s; }
.ck-phone__trigger[aria-expanded="true"] .ck-phone__arrow { transform: rotate(180deg); }
/* Выпадающий список стран с флагами */
.ck-phone__list { position: absolute; z-index: 20; top: calc(100% + 6px); left: -1px; width: 260px; max-width: calc(100vw - 40px); margin: 0; padding: 6px; border: 1px solid var(--ck-dark-100); border-radius: 12px; background: var(--ck-white); box-shadow: 0 8px 24px rgba(18, 26, 38, .12); list-style: none; outline: none; animation: ck-pop .15s ease-out; }
.ck-phone__list[hidden] { display: none; }
.ck-phone__option { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; font: 400 16px/20px var(--ck-font); color: var(--ck-dark); cursor: pointer; }
.ck-phone__option.is-active { background: var(--ck-dark-50); }
.ck-phone__option[aria-selected="true"] { font-weight: 600; }
.ck-phone__option[aria-selected="true"]::after { content: ""; flex: none; width: 16px; height: 16px; margin-left: 2px; background: var(--ck-green); -webkit-mask: url(/front/dist/images/checkout/radio-check.svg) center / 14px no-repeat; mask: url(/front/dist/images/checkout/radio-check.svg) center / 14px no-repeat; }
.ck-phone__name { flex: 1 1 0; min-width: 0; }
.ck-phone__dial { color: var(--ck-dark-300); font-variant-numeric: tabular-nums; }
@keyframes ck-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ck-phone__list { animation: none; } }
.ck-phone__box { position: relative; flex: 1 1 0; min-width: 0; }
.ck-phone__input, .ck-phone__ghost { padding: 0 14px 0 12px; font: 400 16px/20px var(--ck-font); }
.ck-phone__input { position: relative; display: block; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0 8px 8px 0; background: transparent; color: var(--ck-dark); outline: none; box-shadow: none; -webkit-appearance: none; appearance: none; }
.ck-phone__ghost { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; overflow: hidden; color: var(--ck-dark-300); white-space: pre; pointer-events: none; }
.ck-phone__ghost i { font-style: normal; visibility: hidden; }
/* Телефон в формах-заявках сайта: обёртка .ck-phone-field получает классы исходного поля (.input-style, .ck-field__input…) —
   размер, фон, скругление и шрифт как у соседних полей; рамка фокуса — по :focus-within */
.ck-phone-field { position: relative; display: flex !important; align-items: stretch; padding: 0 !important; }
.ck-phone-field:focus-within { border-color: var(--ck-green); }
.ck-phone-field.input-style:focus-within { border-color: #009640 !important; }
.ck-phone-field.ck-field__input:focus-within { background: var(--ck-white); }
.ck-phone-field .ck-phone__trigger, .ck-phone-field .ck-phone__input, .ck-phone-field .ck-phone__ghost { font: inherit; letter-spacing: inherit; color: inherit; }
.ck-phone-field .ck-phone__ghost { color: var(--ck-dark-300); }
.ck-phone-field .ck-phone__list { text-transform: none; letter-spacing: normal; text-align: left; }
.ck-phone-field.input-style .ck-phone__ghost { color: var(--ck-muted); }
.ck-phone-field.input-style .ck-phone__country { border-right-color: #e6e8ea; }
.ck-phone-field.input-style .ck-phone__trigger { padding-left: 20px; }
.ck-phone-field.input-style .ck-phone__input, .ck-phone-field.input-style .ck-phone__ghost { padding-left: 14px; }

/* «Детали заказа (необязательно)» */
.ck-toggle { display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.ck-toggle__text { flex: 1 1 0; font: 600 16px/22px var(--ck-font); color: var(--ck-green); }
.ck-toggle__hint { display: none; }
.ck-toggle__icon { flex: none; display: block; width: 16px; height: 16px; transition: transform .2s; }
.ck-toggle[aria-expanded="true"] .ck-toggle__icon { transform: rotate(180deg); }

.ck-details { display: flex; flex-direction: column; gap: 28px; width: 100%; }
.ck-details[hidden] { display: none; }
.ck-group { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.ck-group--payment { gap: 10px; }
.ck-group__title { margin: 0; font: 600 16px/22px var(--ck-font); color: var(--ck-dark); }
.ck-group__row { display: flex; gap: 16px; }
.ck-hint { margin: 0; font: 400 13px/18px var(--ck-font); color: var(--ck-dark-300); }

/* Радиокнопки оплаты */
.ck-radio { display: inline-flex; align-items: center; gap: 10px; margin: 0; font: 400 16px/20px var(--ck-font); color: var(--ck-dark); cursor: pointer; }
.ck-radio input { position: absolute; opacity: 0; pointer-events: none; }
.ck-radio__box { flex: none; width: 20px; height: 20px; border: 1px solid var(--ck-dark-200); border-radius: 10px; background: var(--ck-white) center / 12px 12px no-repeat; transition: background-color .2s, border-color .2s; }
.ck-radio input:checked + .ck-radio__box { border-color: var(--ck-green); background-color: var(--ck-green); background-image: url(/front/dist/images/checkout/radio-check.svg); }
.ck-radio input:focus-visible + .ck-radio__box { box-shadow: 0 0 0 3px var(--ck-green-100); }

/* Итого */
.ck-summary { flex: 0 0 392px; position: sticky; top: 110px; display: flex; flex-direction: column; gap: 16px; padding: 24px; border-radius: 12px; background: var(--ck-white); }
.ck-summary__title { margin: 0; font: 700 20px/28px var(--ck-font); text-transform: uppercase; color: var(--ck-dark); }
.ck-summary__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; font: 400 16px/20px var(--ck-font); color: var(--ck-dark-300); }
.ck-summary__row b { font-weight: 600; font-size: 14px; color: var(--ck-dark); white-space: nowrap; }
.ck-summary__total { display: flex; align-items: center; justify-content: space-between; gap: 12px; font: 600 16px/22px var(--ck-font); color: var(--ck-dark); }
.ck-summary__total b { font: 700 28px/36px var(--ck-font); white-space: nowrap; }
.ck-summary__submit { width: 100%; }

.ck-consent { position: relative; display: flex; align-items: flex-start; gap: 10px; margin: 0; font: 400 13px/18px var(--ck-font); color: var(--ck-dark-300); cursor: pointer; }
.ck-consent input { position: absolute; opacity: 0; pointer-events: none; }
.ck-consent__box { flex: none; width: 20px; height: 20px; border: 1.5px solid var(--ck-dark-200); border-radius: 5px; background: var(--ck-white) center / 12px 12px no-repeat; transition: background-color .2s, border-color .2s; }
.ck-consent input:checked + .ck-consent__box { border-color: var(--ck-green); background-color: var(--ck-green); background-image: url(/front/dist/images/checkout/radio-check.svg); }
.ck-consent input:focus-visible + .ck-consent__box { box-shadow: 0 0 0 3px var(--ck-green-100); }
.ck-consent a { color: inherit; text-decoration: underline; }
.ck-consent a:hover { color: var(--ck-green); }
.ck-consent.has-error .ck-consent__box { border-color: var(--ck-red); }

.ck-send-error { margin: 0; font: 400 13px/18px var(--ck-font); color: var(--ck-red); }
.ck-send-error[hidden] { display: none; }

/* Липкая плашка «Итого / Оформить заказ» — только на телефоне */
.ck-bar { display: none; }

.ck-mobile { display: none; }

/* ---------- Окна ---------- */
.popup .ck-modal { position: relative; z-index: 1; }
.ck-modal { display: flex; flex-direction: column; gap: 16px; width: 520px; max-width: calc(100vw - 40px); max-height: calc(100vh - 40px); overflow: auto; padding: 32px; border-radius: 16px; background: var(--ck-white); box-shadow: 0 8px 40px rgba(18, 26, 38, .2); font-family: var(--ck-font); color: var(--ck-dark); }
.ck-modal__head { display: flex; align-items: center; gap: 10px; }
.ck-modal__title { flex: 1 1 0; margin: 0; font: 700 20px/28px var(--ck-font); text-transform: uppercase; color: var(--ck-dark); }
.ck-modal__close { flex: none; display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 999px; background: var(--ck-dark-50); cursor: pointer; }
.ck-modal__close img { display: block; width: 20px; height: 20px; }
.ck-modal__close:hover { background: var(--ck-dark-100); }
.ck-modal__product { display: flex; align-items: center; gap: 16px; }
.ck-modal__image { flex: none; width: 72px; height: 90px; border-radius: 8px; background: var(--ck-dark-50); overflow: hidden; }
.ck-modal__image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ck-modal__info { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ck-modal__name { font: 600 16px/22px var(--ck-font); }
.ck-modal__meta { font: 400 13px/18px var(--ck-font); color: var(--ck-dark-300); }
.ck-modal__meta:empty { display: none; }
.ck-modal__price { font: 700 22px/26px var(--ck-font); }
.ck-modal__price:empty { display: none; }
.ck-modal__buttons { display: flex; gap: 12px; }
.ck-modal__buttons .ck-btn { flex: 1 1 0; min-width: 0; }

.ck-modal--done { width: 480px; align-items: center; text-align: center; }
.ck-modal__ok { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 32px; background: var(--ck-green-50); }
.ck-modal__ok img { display: block; width: 28px; height: 28px; }
.ck-modal--done .ck-btn { width: 100%; }

/* ---------- Планшет ---------- */
@media (max-width: 1023px) {
  .ck-columns { flex-direction: column; align-items: stretch; }
  .ck-summary { position: static; flex-basis: auto; }
}

/* ---------- Телефон ---------- */
@media (max-width: 767px) {
  .ck-desktop { display: none; }
  .ck-mobile { display: inline; }

  .ck-container { padding: 20px 20px 40px; }
  .ck-breadcrumbs { display: none; }
  .ck-title { margin-bottom: 16px; font-size: 20px; line-height: 28px; }
  .ck-columns, .ck-left { gap: 16px; }
  .ck-card { padding: 16px; }
  .ck-items { gap: 10px; }
  .ck-contacts { gap: 14px; }
  .ck-card__title { font-size: 18px; }

  .ck-item { align-items: flex-start; gap: 12px; padding: 12px 0; }
  .ck-item__image { width: 72px; height: 90px; }
  .ck-item__info { gap: 5px; }
  .ck-item__name { font-size: 13px; line-height: 17px; padding-right: 28px; }
  .ck-item__controls { display: none; }
  .ck-item__row { display: flex; align-items: center; justify-content: space-between; padding-top: 6px; }
  .ck-item__total { min-width: 0; font-size: 16px; line-height: 20px; }
  .ck-counter { width: 81px; height: 33px; padding: 0 2px; border-radius: 6px; }
  .ck-counter__btn { width: 24px; }

  .ck-group__row { flex-direction: column; gap: 12px; }

  .ck-summary { padding: 24px; }
  .ck-summary__submit { display: none; }

  .ck-bar { position: fixed; z-index: 99; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 12px; height: 72px; padding: 0 16px; background: var(--ck-white); box-shadow: 0 -4px 16px rgba(18, 26, 38, .1); font-family: var(--ck-font); }
  .ck-bar__total { display: flex; flex-direction: column; white-space: nowrap; }
  .ck-bar__total span { font: 400 12px/16px var(--ck-font); color: var(--ck-dark-300); }
  .ck-bar__total b { font: 700 16px/20px var(--ck-font); color: var(--ck-dark); }
  .ck-bar .ck-btn { flex: 1 1 0; min-width: 0; }
  body.ck-has-bar { padding-bottom: 72px; }
  /* Кнопка квиза Envybox не должна закрывать плашку; масштабирующий режим виджета поднимает скрипт в common/footer.twig */
  body.ck-has-bar .ws-quiz-container.ws-quiz-mobile .ws-quiz-btn-el-container.envy-not-scalling { bottom: 84px !important; }

  .ck-modal { gap: 16px; padding: 24px 20px; }
  .ck-modal__head { padding-right: 24px; }
  .ck-modal__title { font-size: 16px; line-height: 22px; }
  .ck-modal__close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; }
  .ck-modal__close img { width: 18px; height: 18px; }
  .ck-modal__image { width: 64px; height: 80px; }
  .ck-modal__name { font-size: 13px; line-height: 17px; }
  .ck-modal__price { font-size: 16px; line-height: 20px; }
  .ck-modal__buttons { flex-direction: column-reverse; gap: 16px; }
  .ck-modal__buttons .ck-btn { flex: none; width: 100%; }
  .ck-modal--done { padding: 32px 20px 24px; }
  .ck-modal--done .ck-modal__title { font-size: 16px; line-height: 22px; }
}
