/* ART-GSM — мобильное оформление заказа (12.11.2026). Скрипт: ../js/mcheckout.js.
   Всё внутри @media (max-width:768px) — граница мобильной раскладки сайта (таб-бар, .sticky-cta); на ПК файл ничего не меняет.
   Откат: убрать две строки (link + script) из header.php, файлы можно не удалять. */

/* панель создаётся скриптом; вне мобильной раскладки она никогда не видна */
.ag-mcta { display: none !important; }
.ag-mc-incart { display: none; }
.ag-mc-chips { display: none; }

@media (max-width: 768px) {

  /* ---------- 1. Липкая панель на /basket/ и /order/ ----------
     База (позиция над таб-баром, фон, тень, z-index 55) — от .sticky-cta в product.css;
     чат-виджет поднимает свою кнопку над ним по селектору .sticky-cta (data-avoid в footer.php). */
  .ag-mcta.is-on { display: flex !important; padding: 10px var(--s-16, 16px); }
  .ag-mcta__btn {
    flex: 1 1 auto; width: 100%; min-height: 48px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 16px; font-weight: 700; line-height: 1.1; white-space: nowrap;
    text-transform: none; border-radius: var(--r-md, 14px);
  }
  .ag-mcta__sep { opacity: .7; }
  .ag-mcta__s { font-variant-numeric: tabular-nums; }
  /* конец страницы не прячется под панелью (таб-бар 60 + панель ~68) */
  html.ag-mcta-on body { padding-bottom: calc(132px + env(safe-area-inset-bottom)) !important; }

  /* ---------- 2. Карточка товара: «В корзине · Оформить» ---------- */
  .sticky-cta .ag-mc-hide { display: none !important; }
  .sticky-cta .ag-mc-incart {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    flex: 1; min-height: 48px; font-size: 15px; font-weight: 700; line-height: 1.1;
    white-space: nowrap; text-decoration: none; text-transform: none;
  }
  .sticky-cta .ag-mc-incart svg { width: 18px; height: 18px; flex: none; }
  .sticky-cta .ag-mc-incart svg use { stroke: currentColor; }

  /* ---------- 3. /order/: блок согласий над кнопкой «Оформить заказ» ----------
     Компонент кладёт .bx-soa-cart-conditions СИБЛИНГОМ после .bx-soa-cart-total (внутри .bx-soa-total-wrapper),
     а кнопка лежит внутри .bx-soa-cart-total — просто так согласие над кнопкой не поставить, а переносить узлы
     нельзя: компонент перерисовывает .bx-soa-cart-total при каждом пересчёте. Поэтому на телефоне карточкой
     становится сам .bx-soa-total-wrapper, а .bx-soa-cart-total — display:contents: его дети (строки, «Итого»,
     кнопка) и блок согласий выстраиваются одним столбцом по order. Разметка и обработчики компонента не тронуты. */
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-total-wrapper {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); box-shadow: var(--shadow-md);
    padding: var(--s-20);
  }
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-total-wrapper .bx-soa-cart-total {
    display: contents;
  }
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-total-wrapper:has(.bx-soa-cart-conditions) .bx-soa-cart-total {
    border-radius: 0;
  }
  /* «Итого» и согласия — order 8 (по порядку в DOM: сначала «Итого»), кнопка — order 9 (checkout.css) */
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-cart-conditions {
    order: 8; background: transparent; border: 0; box-shadow: none; border-radius: 0;
    margin: var(--s-12) 0 var(--s-12); padding: 0;
  }
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-cart-conditions .label_block {
    font-size: 13.5px; line-height: 1.45; color: var(--ink-2);
  }
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-cart-conditions .label_block + .label_block {
    margin-top: var(--s-12);
  }
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-cart-conditions label.license,
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-cart-conditions label.offer_pub {
    min-height: 28px;
  }
  /* ошибка согласия: заметный красный текст рядом с переключателем (раньше — мелкая строка под кнопкой) */
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-cart-conditions label.error:not(.hidden) {
    /* у Aspro label.error абсолютно позиционирован поверх текста согласия — возвращаем в поток */
    position: static !important; inset: auto !important; transform: none !important; width: auto !important; float: none !important;
    display: block; margin: 0 0 var(--s-8); padding: 9px 12px;
    font-size: 14px; font-weight: 700; line-height: 1.3; color: #b42318;
    background: #fef3f2; border: 1px solid #fda29b; border-radius: var(--r-sm);
  }
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-cart-conditions .label_block:has(label.error:not(.hidden)) label.license,
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-cart-conditions .label_block:has(label.error:not(.hidden)) label.offer_pub {
    color: #b42318; font-weight: 600;
  }
  /* общий стек: кнопка под согласиями, отступ перед ней */
  body.ag-styleb[data-cur="/order/"] #bx-soa-total .bx-soa-cart-total-button-container { margin-top: 0; }

  /* приглашение чата не закрывает сводку заказа: класс ставит скрипт, пока сводка видна на экране */
  html.ag-mc-noinv .agc-inv { display: none !important; }

  /* ---------- 4. /order/: чипы доменов под e-mail ---------- */
  .ag-mc-chips { display: none; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
  .ag-mc-chips.is-on { display: flex; }
  .ag-mc-chip {
    appearance: none; -webkit-appearance: none;
    min-height: 36px; padding: 0 10px; border-radius: 999px;
    border: 1px solid var(--line-2, #d5d9e2); background: var(--surface-2, #f4f6fa);
    color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .ag-mc-chip:active { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: var(--accent); }
}
