/* ======================================================================
   shared/report/editor.css
   Стили редактора шаблона отчёта и HTML-превью страниц.
   ====================================================================== */

/* ——— превью страниц ——— */
.rpt-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: #e8eaee;
}
.rpt-page {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  overflow: hidden;
  color: #222;
}
.rpt-preview--edit .rpt-page {
  box-shadow: 0 2px 8px rgba(0,0,0,0.10), 0 0 0 1px #c0c6d2;
}
.rpt-page__margins {
  position: absolute;
  border: 1px dashed #b0c4de;
  pointer-events: none;
}
.rpt-page__header,
.rpt-page__footer,
.rpt-page__body {
  position: absolute;
  overflow: hidden;
}
.rpt-page__body { /* для прокрутки превью не нужно — обрезается */ }

.rpt-zone--edit {
  outline: 1px dashed #8ab4f8;
  outline-offset: -1px;
  background: rgba(138,180,248,0.04);
}
.rpt-body--edit {
  outline: 1px dashed #c0c6d2;
  outline-offset: -1px;
}
.rpt-page__label {
  position: absolute;
  bottom: 4px; left: 50%;
  transform: translateX(-50%);
  font: 10px/1 -apple-system, "Segoe UI", sans-serif;
  color: #6b7280;
  background: rgba(255,255,255,0.9);
  padding: 1px 6px;
  border-radius: 3px;
  pointer-events: none;
}

.rpt-logo {
  position: absolute;
  object-fit: contain;
}
.rpt-overlay {
  position: absolute;
  white-space: pre-wrap;
  box-sizing: border-box;
  padding: 0;
}
.rpt-overlay--edit {
  outline: 1px dotted #c0c6d2;
  outline-offset: -1px;
}
.rpt-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2mm 0;
}
.rpt-hr { border: none; }
.rpt-list { margin: 0; padding-left: 7mm; }

/* ——— модальное окно редактора ——— */
.rpt-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,25,35,0.55);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rpt-modal {
  width: min(1200px, 95vw);
  height: min(820px, 92vh);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font: 14px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1f2430;
}
.rpt-modal__hdr {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #e0e3ea;
  background: #fafbfc;
}
.rpt-modal__title { font-size: 16px; font-weight: 600; }
.rpt-modal__hdr button {
  background: #eef0f4;
  border: 1px solid #d0d5de;
  color: #1f2430;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  margin-left: 6px;
}
.rpt-modal__hdr button.primary {
  background: #1976d2;
  border-color: #1976d2;
  color: #fff;
}
.rpt-modal__hdr button:hover { filter: brightness(0.96); }

.rpt-modal__body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.rpt-modal__tabs {
  flex: none;
  width: 180px;
  border-right: 1px solid #e0e3ea;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}
.rpt-modal__tabs button {
  text-align: left;
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 13px;
  color: #1f2430;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.rpt-modal__tabs button:hover { background: #eef0f4; }
.rpt-modal__tabs button.active {
  background: #fff;
  border-left-color: #1976d2;
  font-weight: 600;
}

.rpt-modal__main {
  flex: 1;
  display: flex;
  min-width: 0;
}
.rpt-modal__form {
  flex: none;
  width: 360px;
  overflow-y: auto;
  padding: 16px 18px;
  border-right: 1px solid #e0e3ea;
  background: #fff;
}
.rpt-modal__preview {
  flex: 1;
  overflow: auto;
  background: #e8eaee;
}

/* ——— формы ——— */
.rpt-field { margin-bottom: 12px; }
.rpt-field > label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}
.rpt-field input[type="text"],
.rpt-field input[type="number"],
.rpt-field select,
.rpt-field textarea {
  width: 100%;
  border: 1px solid #d0d5de;
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  color: #1f2430;
  background: #fff;
}
.rpt-field input[type="color"] {
  width: 44px;
  height: 28px;
  padding: 0;
  border: 1px solid #d0d5de;
  border-radius: 6px;
  background: #fff;
}
.rpt-field textarea { min-height: 80px; resize: vertical; }
.rpt-row { display: flex; gap: 8px; }
.rpt-row > .rpt-field { flex: 1; }
.rpt-field label.chk {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #1f2430;
  font-size: 13px;
}
.rpt-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin: 16px 0 8px;
  padding-top: 8px;
  border-top: 1px solid #e8eaee;
}
.rpt-section-title:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.rpt-style-card {
  background: #f7f8fa;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.rpt-style-card h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #1f2430;
}

/* ——— canvas-редактор ——— */
.rpt-modal--canvas {
  width: min(1280px, 96vw);
  height: min(880px, 94vh);
}
/* Полноэкранный режим: сохраняем flex-колонку, шапка с кнопкой
   «Свернуть» остаётся видимой (sticky сверху). */
.rpt-modal--full {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  z-index: 9100;
  display: flex !important;
  flex-direction: column !important;
}
.rpt-modal--full .rpt-modal__hdr {
  position: sticky;
  top: 0;
  z-index: 3;
}
.rpt-editor__sidebar {
  flex: none;
  width: 300px;
  border-right: 1px solid #e0e3ea;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rpt-editor__tabs {
  flex: none;
  display: flex;
  border-bottom: 1px solid #e0e3ea;
  background: #fff;
}
.rpt-editor__tabs button {
  flex: 1;
  background: none;
  border: none;
  padding: 9px 2px;
  font-size: 12px;
  white-space: nowrap;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.rpt-editor__tabs button:hover { background: #f1f3f7; color: #1f2430; }
.rpt-editor__tabs button.active {
  color: #1976d2;
  font-weight: 600;
  border-bottom-color: #1976d2;
  background: #fff;
}
.rpt-editor__tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}
.rpt-editor__canvas-wrap {
  flex: 1;
  min-width: 0;
  background: #e8eaee;
  overflow: auto;
  display: flex;
  align-items: flex-start;     /* верх страницы виден (center + overflow обрезал верх) */
  justify-content: center;
  padding: 24px;
}
.rpt-zone-add {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.rpt-canvas {
  position: relative;
}

/* страница и её элементы на холсте */
.rpt-cv-page {
  position: relative;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.rpt-cv-printarea {
  position: absolute;
  border: 1px dashed #b0c4de;
  pointer-events: none;
}
.rpt-cv-body-label {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b0b8c8;
  font: italic 13px/1.4 -apple-system, "Segoe UI", sans-serif;
  text-align: center;
  white-space: pre-line;
  pointer-events: none;
}
.rpt-cv-zone {
  position: absolute;
  outline: 1.5px solid rgba(25,118,210,0.55);
  background: rgba(25,118,210,0.06);
  cursor: move;
  user-select: none;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: hidden;
}
.rpt-cv-zone:hover { background: rgba(25,118,210,0.12); }
.rpt-cv-zone.selected {
  outline: 2px solid #1976d2;
  background: rgba(25,118,210,0.18);
  z-index: 5;
}
.rpt-cv-zone--logo {
  outline-color: rgba(46,125,50,0.55);
  background: rgba(46,125,50,0.06);
}
.rpt-cv-zone--logo:hover { background: rgba(46,125,50,0.12); }
.rpt-cv-zone--logo.selected {
  outline-color: #2e7d32;
  background: rgba(46,125,50,0.18);
}
.rpt-cv-zone__text {
  width: 100%;
  height: 100%;
  padding: 1px 3px;
  overflow: hidden;
  white-space: pre-wrap;
  pointer-events: none;
}
.rpt-cv-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  background: #1976d2;
  cursor: se-resize;
  border-top-left-radius: 2px;
}
.rpt-cv-zone--logo .rpt-cv-resize { background: #2e7d32; }

/* grid кнопок добавления зон */
.rpt-zone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.rpt-zone-add-btn {
  padding: 7px 10px;
  font-size: 12px;
  background: #fff;
  border: 1px solid #d0d5de;
  border-radius: 6px;
  color: #1f2430;
  cursor: pointer;
  text-align: left;
  width: 100%;
  margin-bottom: 4px;
}
.rpt-zone-add-btn:hover {
  background: #e3f2fd;
  border-color: #1976d2;
  color: #1976d2;
}

/* список зон */
.rpt-zone-list {
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}
.rpt-zone-list__item {
  padding: 7px 10px;
  border-bottom: 1px solid #f1f3f7;
  font-size: 12px;
  color: #1f2430;
  cursor: pointer;
}
.rpt-zone-list__item:last-child { border-bottom: none; }
.rpt-zone-list__item:hover { background: #f7f9fc; }
.rpt-zone-list__item.active {
  background: #e3f2fd;
  border-left: 3px solid #1976d2;
  padding-left: 7px;
  font-weight: 600;
}
.rpt-zone-list__empty {
  padding: 12px;
  color: #9aa3b5;
  font-size: 12px;
  text-align: center;
}

/* поля редактора */
.rpt-hint {
  font-size: 11px;
  color: #6b7280;
  margin: 4px 0 10px;
  line-height: 1.5;
}
.rpt-hint code {
  background: #f1f3f7;
  padding: 1px 4px;
  border-radius: 3px;
  font: 11px/1 Menlo, Consolas, monospace;
}
.rpt-logo-preview {
  max-width: 100%;
  max-height: 80px;
  border: 1px solid #e0e3ea;
  background: #fafbfc;
  padding: 4px;
  border-radius: 4px;
  margin-bottom: 10px;
  display: block;
}
button.danger {
  background: #fff;
  border: 1px solid #f3c0c0;
  color: #c62828;
  border-radius: 6px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 10px;
}
button.danger:hover { background: #fdecea; }

/* ——— picker шаблонов ——— */
.rpt-picker-modal {
  width: min(560px, 94vw);
  max-height: 84vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font: 14px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1f2430;
}
.rpt-picker-hdr {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e0e3ea;
  background: #fafbfc;
}
.rpt-picker-title { font-size: 15px; font-weight: 600; }
.rpt-picker-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 0 4px;
}
.rpt-picker-close:hover { color: #1f2430; }
.rpt-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.rpt-picker-empty {
  padding: 24px 18px;
  color: #9aa3b5;
  font-size: 13px;
  text-align: center;
}
.rpt-picker-item {
  padding: 10px 18px;
  border-bottom: 1px solid #f1f3f7;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rpt-picker-item:hover { background: #f7f9fc; }
.rpt-picker-item.active {
  background: #e3f2fd;
  border-left: 3px solid #1976d2;
  padding-left: 15px;
}
.rpt-picker-item__name {
  font-size: 14px;
  font-weight: 600;
  color: #1f2430;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rpt-picker-item__desc {
  font-size: 12px;
  color: #6b7280;
}
.rpt-picker-item__badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 10px;
}
.rpt-picker-item__badge.builtin { background: #e8f5e9; color: #2e7d32; }
.rpt-picker-item__badge.user    { background: #e3f2fd; color: #1976d2; }
.rpt-picker-item__badge.recommended {
  background: #fff3e0;
  color: #e65100;
  text-transform: none;
  letter-spacing: 0;
}
.rpt-picker-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #9aa3b5;
  padding: 10px 18px 4px;
  border-top: 1px solid #f1f3f7;
  background: #fafbfc;
}
.rpt-picker-section:first-child { border-top: none; }
.rpt-picker-footer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid #e0e3ea;
  background: #fafbfc;
}
.rpt-picker-link {
  flex: 1;
  font-size: 12px;
  color: #1976d2;
  text-decoration: none;
}
.rpt-picker-link:hover { text-decoration: underline; }
