/* Макеты и печать: плитки макетов, конструктор листа и предпросмотр.
   Свой файл, а не общий app.css: раздел можно выключить вместе с модулем,
   и в общей таблице стилей не остаётся мусора. */

/* ---------- Плитки макетов в карточке изделия ---------- */

.maket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 12px;
}

.maket-tile {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 8px;
  min-width: 0;
}

.maket-tile__img {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 92px;
  border-radius: 5px;
  /* Шахматка под прозрачностью: макет с прозрачным фоном на белом
     выглядит готовой картинкой, а он ею ещё не стал. */
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eef1f6 25%, transparent 25%, transparent 75%, #eef1f6 75%),
    linear-gradient(45deg, #eef1f6 25%, transparent 25%, transparent 75%, #eef1f6 75%);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px;
  overflow: hidden;
}

.maket-tile__img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.maket-tile__title {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.maket-tile__size {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.maket-tile__form {
  position: absolute;
  top: 4px;
  right: 4px;
}

.maket-tile__hide {
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

.maket-tile__hide:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.maket-add summary,
.maket-settings summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
}

.maket-add summary:hover,
.maket-settings summary:hover { text-decoration: underline; }

.maket-add__form,
.maket-settings__form { margin-top: 10px; }

.maket-add__form .form-grid,
.maket-settings__form .form-grid {
  grid-template-columns: 1fr 1fr;
}

.maket-settings__form select { width: 100%; }

/* Кнопка «Печать листа» на рабочем месте производства. Блок приходит
   из модуля макетов в карточку операции и живёт рядом с «В работу». */
.work-card__extra { display: flex; align-items: center; }

.work-print {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Конструктор: выбор макетов ---------- */

.maket-pick { display: flex; flex-direction: column; }

.maket-pick__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.maket-pick__row:last-child { border-bottom: 0; }
.maket-pick__row:hover { background: var(--surface-2); }

/* Отмеченная строка подсвечивается сразу, а не после перерисовки
   предпросмотра: галочка и подсветка — одно действие. */
.maket-pick__row:has(input[type="checkbox"]:checked) { background: var(--accent-soft); }
.maket-pick__row.is-on { background: var(--accent-soft); }

.maket-pick__row.is-on .maket-pick__name { font-weight: 500; }
.maket-pick__row:has(input[type="checkbox"]:checked) .maket-pick__name { font-weight: 500; }

.maket-pick__thumb {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px;
  flex: none;
}

.maket-pick__name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.maket-pick__copies {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Предпросмотр листа ---------- */

.preview__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

.preview__summary {
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

/* Каждая страница тиража — отдельный лист. Лист в миллиметрах шире
   экрана на A3 и на узком ноутбуке — прокрутка честнее, чем уменьшение:
   на уменьшенном листе не видно, где именно пройдёт резка. */
.preview__page {
  overflow: auto;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: #e7ebf1;
  border: 1px solid var(--border);
}

.preview__page:last-child { margin-bottom: 0; }

.preview__page-label {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Лист — настоящие миллиметры: браузер сам переводит их в точки,
   поэтому 210 мм на экране и 210 мм на бумаге — одно и то же место. */
.sheet {
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .18);
  overflow: hidden;
}

.sheet__item {
  position: absolute;
  display: block;
  /* object-fit не даёт картинке растянуться, если её пропорции
     не совпали с заявленным размером: на бумагу пойдёт именно
     заявленный прямоугольник. */
  object-fit: contain;
}

.sheet__empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Кнопка «Отправить на печать» стоит рядом со «Скачать PDF»: поле копий
   и кнопка в одну строку, иначе форма ломает ряд кнопок в шапке. */
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.inline-form__field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.inline-form input[type="number"] {
  width: 66px;
  padding: 7px 8px;
}

/* Две кнопки сборки рядом: «Скачать PDF» и «Собрать и напечатать».
   На узком экране они встают друг под друга, а не сжимаются в точку. */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Список макетов: таблица, а не галерея — миниатюра размером с букву. */
.maket-thumb {
  display: inline-block;
  width: 40px;
  height: 40px;
  margin-right: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  object-fit: cover;
  vertical-align: middle;
  background: #fff;
}

/* Превью листа: маленькое в строке таблицы и крупное в карточке.
   Соотношение сторон у листа разное (A4, 10×15), поэтому обе картинки
   вписываются в рамку, а не растягиваются. */
.sheet-thumb {
  display: block;
  width: 64px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 4px;
  object-fit: contain;
  background: #fff;
}

.sheet-shot {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 3px rgb(16 24 40 / 8%);
}

/* «Печатается сейчас» на странице очереди: лист слева, ход справа. */
.now-print {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.now-print__shot {
  flex: 0 0 180px;
  display: block;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.now-print__shot img {
  display: block;
  width: 100%;
  height: auto;
}

.now-print__info { flex: 1 1 auto; min-width: 0; }
.now-print__info h4 { margin: 0 0 4px; }
.now-print__info .bar { margin: 10px 0 6px; }

@media (max-width: 700px) {
  .now-print { flex-direction: column; }
  .now-print__shot { flex: none; width: 100%; max-width: 240px; }
}

/* Поля и зазоры: мелкие числа в ряд. Шесть отдельных полей во всю ширину
   карточки — это стена, в которой не видно, что к чему относится. */
.mm-grid {
  display: grid;
  /* Две колонки, а не четыре: форма живёт в узкой колонке карточки,
     и четыре поля в ряд превращаются в нечитаемую мелочь. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.bok .mm-grid, .card__body .mm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.mm-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.mm-grid__cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.mm-grid__cell input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
}

.mm-grid__cell input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.field__label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 13px; }

@media (max-width: 560px) {
  .mm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Правка листа руками: поля, зазоры, формат.

   Строкой под предпросмотром, а не отдельной страницей: человек меняет
   числа, глядя на тот же лист, — иначе он правит вслепую. */
.sheet-controls__box summary {
  cursor: pointer;
  user-select: none;
}

.sheet-controls {
  margin-top: 10px;
}

.sheet-controls__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.sheet-controls .field {
  gap: 3px;
}

.sheet-controls .field .input,
.sheet-controls .field select {
  width: 84px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
}

.sheet-controls .field select {
  width: auto;
  min-width: 130px;
}

.sheet-controls__grid > .field:has(button) {
  align-self: flex-end;
}

@media (max-width: 560px) {
  .sheet-controls .field .input { width: 64px; }
}

/* Правка листа: превью макетов в таблице и в выборе добавления. */
.sheet-edit__maket {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sheet-edit__thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  flex: none;
}

.sheet-edit__maket-select {
  width: auto;
  min-width: 68px;
  max-width: 180px;
  padding: 4px 6px;
}

.maket-picker {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.maket-picker__group {
  display: grid;
  gap: 6px;
}

.maket-picker__title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
}

.maket-picker__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.maket-picker__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 104px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  line-height: 1.25;
}

.maket-picker__item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.maket-picker__item img {
  width: 76px;
  height: 76px;
  object-fit: contain;
}

.maket-picker__item:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.maket-picker__item--none {
  width: auto;
  min-width: 160px;
  flex-direction: row;
  justify-content: center;
  min-height: 44px;
}

.maket-picker__none {
  color: var(--text-muted);
}
