/* Constructor-specific styles */

/* Button icons */
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* Обводка у иконок (триминг, палитра, обновление, скачать раскладку) и согласованный вид с основной кнопкой экспорта */
.btn-icon-outline {
  border: 1px solid var(--border);
  background: #fff;
  box-sizing: border-box;
}
.btn-icon-outline:hover {
  background: #eef0f4;
}
.toolbar .btn-icon.btn-trim--active,
.mobile-footer .btn-icon.btn-trim--active {
  border-color: var(--green);
  color: #15803d;
  background: #ecfdf5;
}
.toolbar .btn-icon.btn-trim--active:hover,
.mobile-footer .btn-icon.btn-trim--active:hover {
  background: #d1fae5;
  border-color: var(--green);
}
.toolbar .btn-success.btn-icon-outline,
.mobile-footer .btn-success.btn-icon-outline {
  border-color: var(--green);
  color: #15803d;
  background: #fff;
}
.toolbar .btn-success.btn-icon-outline:hover,
.mobile-footer .btn-success.btn-icon-outline:hover {
  background: #ecfdf5;
}
.toolbar .btn-danger.btn-icon-outline,
.mobile-footer .btn-danger.btn-icon-outline {
  border-color: var(--red);
  color: var(--red);
  background: #fff;
}
.toolbar .btn-danger.btn-icon-outline:hover,
.mobile-footer .btn-danger.btn-icon-outline:hover {
  background: #fef2f2;
}

/* Drop hint */
.drop-hint__text {
  display: block;
  line-height: 1.5;
  white-space: normal;
}

.drop-hint__important {
  font-size: 2em;
  font-weight: 700;
  display: block;
  margin: 0.3em 0;
  color: #c85a5a;
}

.drop-hint__link {
  display: inline-flex;
  align-items: center;
  color: #2563eb;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
  margin-top: 0.5em;
}

.drop-hint__link:hover {
  color: #1d4ed8;
}

.drop-hint__link svg {
  margin-left: 6px;
  flex-shrink: 0;
}

.drop-hint__copies {
  display: block;
  margin: 0.5em 0;
}

.drop-hint__copies-mobile {
  display: none;
}

@media (max-width: 1100px) {
  .drop-hint__copies-desktop {
    display: none;
  }

  .drop-hint__copies-mobile {
    display: block;
  }
}

/* Export confirmation modal */
.export-confirm-modal {
  text-align: center;
  width: 750px;
  min-width: 550px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.export-confirm__body {
  flex: 1;
  overflow-y: auto;
  line-height: 1.6;
}

.export-confirm__body--centered {
  display: flex;
  align-items: center;
  justify-content: center;
}

.export-confirm__text {
  margin-bottom: 1em;
}

.export-confirm__attention {
  color: #c00;
  font-weight: 700;
  text-align: center;
  margin: 1em 0 0.5em;
}

.export-confirm__block {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 0.8em 0;
  text-align: left;
}

.export-confirm__block-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 0.5em;
  text-align: center;
}

.export-confirm__dpi-list {
  margin: 0.5em 0;
  text-align: left;
  font-size: 13px;
}

.export-confirm__dpi-warn {
  margin-top: 1em;
  font-size: 13px;
}

.export-confirm__recommend {
  font-weight: 700;
}

.export-confirm__risks {
  margin-top: 1em;
  font-weight: 600;
  text-align: center;
}

.export-confirm__actions {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 1em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
}

.export-confirm__actions .btn-small {
  font-size: 12px;
  padding: 5px 12px;
}

.export-confirm__submit {
  min-width: 160px;
  padding: 10px 24px;
}

.duplicate-list-modal {
  width: min(520px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.duplicate-list-modal__title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
  text-align: center;
  flex-shrink: 0;
}
.duplicate-list-modal__body {
  flex: 1;
  min-height: 0;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text, #1a1d26);
  border: 1px solid var(--border, #e0e4ea);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fafbfc;
}
.duplicate-list-modal__row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border, #e0e4ea);
  word-break: break-word;
}
.duplicate-list-modal__row:last-child {
  border-bottom: none;
}
.duplicate-list-modal .modal-actions {
  flex-shrink: 0;
  margin-top: 12px;
}
.toast.toast-orange .toast-duplicate-btn {
  margin-top: 12px;
  font-weight: 600;
}

.export-confirm__submit.btn--disabled,
.export-confirm__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Info modal */
.info-modal {
  text-align: center;
  max-width: 380px;
}

.info-modal__text {
  line-height: 1.6;
  margin-bottom: 1em;
}

.info-modal .modal-actions {
  justify-content: center;
}

/* Sheet limits block */
.sheet-limits-block {
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Mobile responsive */
@media (max-width: 1100px) {
  .export-confirm-modal {
    width: auto;
    min-width: 350px;
    max-width: 92vw;
    height: 100vh;
    max-height: 100vh;
  }
}

/* Cart button - blue */
.btn-cart {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
  transition: all 0.2s;
  border: 1px solid #1e40af;
  box-sizing: border-box;
}
.btn-cart:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
  border-color: #1e3a8a;
}

@media (max-width: 1100px) {
  .mobile-footer .btn-cart {
    padding: 8px 12px;
    font-size: 18px;
  }
}

/* Green success button */
.btn-success {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  border-color: #16a34a;
}
.btn-success:hover {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  border-color: #15803d;
}

.toolbar .hdr-ctrl--cost .hdr-input {
  width: 72px;
}

/* Crop modal */
.modal.crop-modal {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(96vh, 920px);
  width: 100%;
  max-width: min(96vw, 920px);
  text-align: center;
}
.crop-modal__head {
  position: relative;
  flex-shrink: 0;
  z-index: 6;
  padding: 16px 48px 12px 20px;
  margin: 0;
  text-align: center;
  background: #fff;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.crop-modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  padding: 0 8px;
}
.modal.crop-modal .crop-modal__title {
  margin-bottom: 0;
}
.crop-modal__help-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 50%;
  background: var(--bg-soft, #f4f5f7);
  color: var(--muted, #6b7280);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.crop-modal__help-btn:hover {
  border-color: var(--accent, #4a6cf7);
  color: var(--accent, #4a6cf7);
  background: #fff;
}
.crop-modal__help-btn--close {
  position: static;
  transform: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 22px;
  font-weight: 400;
}
.crop-modal__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 20px 8px;
  text-align: center;
  -webkit-overflow-scrolling: touch;
}
/* Блочный overflow — иначе у flex-вьюпорта часто занижается scrollHeight, pan обрывается сверху/снизу. */
.crop-modal__viewport {
  position: relative;
  display: block;
  width: 100%;
  height: min(65vh, 640px);
  max-height: min(65vh, 640px);
  margin: 0 auto 12px;
  overflow: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  min-height: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.crop-modal__viewport.crop-modal__viewport--panning {
  cursor: grabbing;
}
/* Не меньше окна превью и не меньше картинки — корректные scrollWidth/scrollHeight; flex только внутри. */
.crop-modal__viewport-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  width: max-content;
  min-height: 100%;
  height: max-content;
  box-sizing: border-box;
}
.crop-modal__zoom-inner {
  position: relative;
  display: block;
  flex: 0 0 auto;
}
.crop-modal__viewport img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  user-select: none;
  pointer-events: none;
  vertical-align: top;
}
/* Сайт: img { max-width: 100% } — жёстко фиксируем превью, чтобы рамка обрезки совпадала с расчётом в JS */
body.constructor-page #cropModal img#cropImg {
  max-width: none !important;
}
.crop-modal__frame {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  box-sizing: border-box;
  border: 1px solid #52525b;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.48);
  cursor: move;
  touch-action: none;
}
.crop-modal__handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fafafa;
  border: 1px solid #52525b;
  border-radius: 2px;
  z-index: 2;
  box-sizing: border-box;
}
.crop-modal__handle[data-h="nw"] { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-modal__handle[data-h="ne"] { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-modal__handle[data-h="sw"] { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-modal__handle[data-h="se"] { right: -8px; bottom: -8px; cursor: nwse-resize; }
.crop-modal__footer {
  flex-shrink: 0;
  z-index: 6;
  margin: 0;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border, #e5e7eb);
  background: #fff;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}
.crop-modal__footer-row--trim {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
}
.crop-modal__footer-left,
.crop-modal__footer-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.crop-modal__footer-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #6b7280);
  margin-right: 2px;
}

#cropHelpModal.modal-overlay {
  z-index: 210;
}
#constructorHelpModal.modal-overlay {
  z-index: 208;
}

/*
 * В site style.css модалки показываются классом .active и по умолчанию имеют opacity:0/visibility:hidden.
 * Конструктор открывает окна классом .open — принудительно переопределяем видимость для его модалок.
 */
body.constructor-page #infoModal.modal-overlay,
body.constructor-page #exportConfirmModal.modal-overlay,
body.constructor-page #cropModal.modal-overlay,
body.constructor-page #cropHelpModal.modal-overlay,
body.constructor-page #constructorHelpModal.modal-overlay,
body.constructor-page #cropPreviewColorModal.modal-overlay,
body.constructor-page #colorModal.modal-overlay,
body.constructor-page #duplicateListModal.modal-overlay {
  opacity: 1;
  visibility: visible;
  transition: none;
}
body.constructor-page #infoModal.modal-overlay:not(.open),
body.constructor-page #exportConfirmModal.modal-overlay:not(.open),
body.constructor-page #cropModal.modal-overlay:not(.open),
body.constructor-page #cropHelpModal.modal-overlay:not(.open),
body.constructor-page #constructorHelpModal.modal-overlay:not(.open),
body.constructor-page #cropPreviewColorModal.modal-overlay:not(.open),
body.constructor-page #colorModal.modal-overlay:not(.open),
body.constructor-page #duplicateListModal.modal-overlay:not(.open) {
  display: none !important;
  pointer-events: none;
}
body.constructor-page #infoModal.modal-overlay.open,
body.constructor-page #exportConfirmModal.modal-overlay.open,
body.constructor-page #cropModal.modal-overlay.open,
body.constructor-page #cropHelpModal.modal-overlay.open,
body.constructor-page #constructorHelpModal.modal-overlay.open,
body.constructor-page #cropPreviewColorModal.modal-overlay.open,
body.constructor-page #colorModal.modal-overlay.open,
body.constructor-page #duplicateListModal.modal-overlay.open {
  display: flex !important;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.toolbar .constructor-help-btn.crop-modal__help-btn {
  position: static;
  transform: none;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  font-size: 18px;
}

/* Скриншоты панели и строки статистики в «Справка: Конструктор» */
.constructor-help-toolbar-demo.crop-help-figure,
.constructor-help-statistics-line.crop-help-figure {
  margin: 0 0 14px;
  padding: 0;
  max-width: 100%;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-sizing: border-box;
}
/* Чуть уже модалки «Обработка изображения» (.modal.crop-modal: min(96vw, 920px)) */
.crop-help-modal {
  max-width: min(95vw, 880px);
  width: 100%;
  text-align: left;
  container-type: inline-size;
  container-name: crophelp;
}
.crop-help-modal__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  padding: 0 40px;
  min-height: 36px;
}
.crop-help-modal__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  flex: 1;
}
.crop-help-modal__head .crop-modal__help-btn--close {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}
.crop-help-modal__body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text, #1a1d26);
  max-height: min(62vh, 520px);
  overflow-y: auto;
  padding-right: 4px;
}
.crop-help-modal__body ul {
  margin: 0 0 12px;
  padding-left: 1.15em;
  color: var(--muted, #4b5563);
}
.crop-help-modal__body li {
  margin-bottom: 6px;
}
.crop-help-modal__body li:last-child {
  margin-bottom: 0;
}
.crop-help-modal__body .crop-help-btn-img {
  height: 42px;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
  margin: 0 6px 2px 0;
  object-fit: contain;
  display: inline-block;
}
.crop-help-modal__body .crop-help-btn-img--wide {
  height: auto;
  max-height: 52px;
  width: auto;
  max-width: min(100%, 300px);
  vertical-align: middle;
}
.crop-help-modal__body .crop-help-btn-img--field {
  height: auto;
  max-height: 36px;
  width: auto;
  max-width: min(100%, 260px);
  margin: 0 4px 3px 0;
}
.crop-help-modal__body .crop-help-btn-img--field-inline {
  max-height: 26px;
  max-width: 200px;
  margin: 0 3px 1px 0;
  vertical-align: text-bottom;
}
.crop-help-modal__sec .crop-help-figure + .crop-help-modal__h5 {
  margin-top: 12px;
}
.crop-help-modal__body .crop-help-btns-pair {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  vertical-align: middle;
  margin-right: 4px;
}
.crop-help-modal__body .crop-help-btns-pair .crop-help-btn-img {
  margin: 0 0 2px 0;
}
.crop-help-modal__ul--tight {
  margin-top: -4px !important;
}
.crop-help-modal__body li > .crop-help-modal__ul--tight {
  margin-top: 6px !important;
  margin-bottom: 4px;
}
.crop-help-modal__h5 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #1a1d26);
}
.crop-help-modal__sec--hotkeys .crop-help-modal__h5 {
  margin: 12px 0 6px;
}
.crop-help-modal__sec--hotkeys > .crop-help-modal__h5:first-of-type {
  margin-top: 4px;
}
.crop-help-modal__hotkeys-note {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted, #6b7280);
}
.crop-help-modal__sec--hotkeys > ul:last-of-type {
  margin-bottom: 0;
}

/* Превью в справке: скриншоты панелей (как раньше — рамка, max-height) */
.crop-help-visual {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.crop-help-figure {
  margin: 0 0 14px;
  padding: 0;
  min-width: 0;
}
.crop-help-figure img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 40px;
  object-fit: contain;
  object-position: left center;
  border-radius: 4px;
  border: 1px solid var(--border, #e5e7eb);
  box-sizing: border-box;
}
.constructor-help-toolbar-demo.crop-help-figure img,
.constructor-help-statistics-line.crop-help-figure img {
  max-height: none;
  width: 100%;
  height: auto;
  border-radius: 0;
  border: none;
}
.crop-help-img-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px dashed var(--border, #d1d5db);
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  vertical-align: middle;
}
.crop-help-img-fallback--wide {
  display: flex;
  width: 100%;
  min-height: 78px;
  padding: 12px;
  box-sizing: border-box;
}

.crop-help-badge-block {
  margin: 0 0 14px;
}
.crop-help-badge-block__line {
  margin: 0 0 10px;
  color: var(--muted, #4b5563);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.crop-help-badge-block__line:last-child {
  margin-bottom: 0;
}
.crop-help-badge-block__line .alpha-badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 7px;
  line-height: 1.35;
  vertical-align: text-bottom;
  white-space: nowrap;
}
.crop-help-badge-block .crop-help-btn-img--badge {
  height: 28px;
  width: auto;
  max-width: 100%;
  margin: 0 4px 0 2px;
  vertical-align: -6px;
  object-fit: contain;
}
.crop-help-modal__sec {
  margin-bottom: 16px;
}
.crop-help-modal__sec:last-child {
  margin-bottom: 0;
}
.crop-help-modal__sec h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text, #1a1d26);
}
.crop-help-modal__sec p {
  margin: 0 0 8px;
  color: var(--muted, #4b5563);
}
.crop-help-modal__sec p:last-child {
  margin-bottom: 0;
}
.crop-help-modal__actions {
  margin-top: 12px;
  justify-content: flex-end;
}

/* Кнопка обрезки — угол карточки (как × справа), не внутри превью */
.file-card__crop {
  position: absolute;
  z-index: 2;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border, #e0e4ea);
  border-radius: 6px;
  background: #fff;
  color: var(--text, #1a1d26);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}
.file-card__crop svg {
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  pointer-events: none;
}
.file-card__crop:hover {
  border-color: var(--accent, #4a6cf7);
  color: var(--accent, #4a6cf7);
}
.file-card--cropped .file-card__crop {
  border-color: #22c55e;
  background: #e8f5e9;
  color: #2e7d32;
}

@media (max-width: 1100px) {
  .crop-modal__viewport {
    height: 50vh;
    max-height: 50vh;
  }
  .crop-modal__footer-row--trim {
    flex-direction: column;
    align-items: stretch;
  }
  .crop-modal__footer-left,
  .crop-modal__footer-right {
    justify-content: flex-start;
  }
  .mobile-footer .constructor-help-btn.crop-modal__help-btn {
    position: static;
    transform: none;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

/* Тосты: типы session / oversize (предсказуемый фон поверх базового .toast) */
.toast.toast-session {
  background: #e8eef5;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  font-weight: 500;
}
.toast.toast-oversize {
  background: #fde8e8;
  color: #5c2222;
  border: 1px solid #e8b8b8;
  font-weight: 500;
}
