/* =========================================================
   Decidio · Конструктор макета — интерфейс
   Наследует дизайн-токены из style.css (:root).
   Двухколоночная раскладка: слева панель, справа предпросмотр.
   ========================================================= */

.builder {
  padding-top: 88px; /* под фиксированную шапку */
  padding-bottom: 3rem;
}
.builder__head {
  max-width: var(--maxw);
  margin: 0 auto 1.5rem;
  padding-inline: var(--gutter);
}
.builder__head h1 { font-size: var(--fs-h2); font-weight: 700; letter-spacing: -0.02em; }
.builder__head p { color: var(--text-muted); margin-top: 0.5rem; max-width: 60ch; }

.builder__layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 860px) {
  /* minmax(0,1fr), а не 1fr: у грид-колонки минимум по умолчанию — ширина
     содержимого, из-за чего панель предпросмотра распирала страницу вширь
     и на телефоне блоки уезжали за край экрана. */
  .builder__layout { grid-template-columns: minmax(0, 1fr); }
  .builder__panel, .builder__preview { min-width: 0; }
  .builder__preview { position: static !important; height: 60vh; }
}

/* ---------- Панель управления ---------- */
.builder__panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.panel-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
}
.panel-card > h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--warm);
  margin-bottom: 0.9rem;
}

.field { margin-bottom: 0.85rem; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.field input[type="text"],
.field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  transition: border-color var(--dur) var(--ease);
}
.field input[type="text"]:focus,
.field textarea:focus { outline: none; border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 68px; }

/* Выбор темы и акцента */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 0.88rem;
  background: var(--surface);
  transition: all var(--dur) var(--ease);
}
.chip.is-active { color: #fff; background: var(--accent-deep); border-color: transparent; }

.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active { border-color: var(--text); }

/* ---------- Блоки ---------- */
.blocks-list { display: flex; flex-direction: column; gap: 0.75rem; }
.block-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.block-item__head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  user-select: none;
}
.block-item__main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.block-item__title {
  font-weight: 600; font-size: 0.92rem; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.block-item__hint {
  color: var(--text-dim); font-size: 0.75rem; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.block-item__toggle { color: var(--text-dim); flex-shrink: 0; transition: transform var(--dur) var(--ease); }
.block-item.is-open .block-item__toggle { transform: rotate(180deg); }

.drag-handle { flex-shrink: 0; }
.block-actions { display: flex; gap: 0.2rem; flex-shrink: 0; }
.icon-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  transition: all var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.icon-btn--danger:hover { color: #fff; background: var(--danger-deep); border-color: transparent; }

.block-item__body { padding: 0 0.9rem; }
.block-item.is-open .block-item__body { padding: 0.4rem 0.9rem 1rem; }

/* Повторяющиеся элементы (услуги/отзывы/плитки) */
.list-item {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.7rem;
  margin-bottom: 0.6rem;
  position: relative;
}
.list-item__del {
  position: absolute; top: 0.4rem; right: 0.4rem;
  width: 22px; height: 22px; line-height: 1;
  border-radius: 6px; font-size: 0.8rem;
  color: var(--text-dim);
}
.list-item__del:hover { color: var(--danger); }
.btn-add-item {
  width: 100%;
  padding: 0.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  transition: all var(--dur) var(--ease);
}
.btn-add-item:hover { color: var(--accent); border-color: var(--accent); }

/* Добавить блок */
.add-block__menu { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.add-block__btn {
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 0.86rem;
  background: var(--surface);
  transition: all var(--dur) var(--ease);
}
.add-block__btn:hover { color: var(--accent); border-color: var(--accent); }
.add-block__btn::before { content: "+ "; color: var(--accent); }

/* ---------- Предпросмотр ---------- */
.builder__preview {
  position: sticky;
  top: 88px;
  height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.preview__bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.preview__bar .dots { display: flex; gap: 0.35rem; }
.preview__bar .dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--surface); }
.preview__bar .url {
  flex: 1; min-width: 0;               /* даём подписи сжиматься на узком экране */
  text-align: center; font-size: 0.8rem; color: var(--text-dim);
  background: var(--surface); border-radius: 999px; padding: 0.25rem 0.75rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preview__frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------- Нижняя панель отправки ---------- */
.submit-card { border-color: var(--accent-deep); }
.submit-card .field input { margin-bottom: 0; }

.result-box {
  margin-top: 0.85rem;
  display: none;
}
.result-box.is-shown { display: block; }
.result-box textarea {
  width: 100%; font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.72rem; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem; resize: vertical; min-height: 70px;
}
.form-note { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.6rem; }
.form-note--ok { color: var(--accent); }

/* =========================================================
   v2 — новые компоненты
   ========================================================= */

/* select как input */
.field select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit; font-size: 0.95rem;
  padding: 0.55rem 0.75rem;
}
.field select:focus { outline: none; border-color: var(--accent); }

.mini-hint { font-size: 0.78rem; color: var(--text-dim); margin: -0.2rem 0 0.7rem; line-height: 1.45; }

/* Палитра: color picker + пресеты */
.color-row { display: flex; align-items: center; gap: 0.75rem; }
.color-input {
  width: 44px; height: 34px; padding: 0; border: 1px solid var(--border-strong);
  border-radius: 10px; background: none; cursor: pointer; flex-shrink: 0;
}
.color-input::-webkit-color-swatch-wrapper { padding: 3px; }
.color-input::-webkit-color-swatch { border: none; border-radius: 6px; }

/* Переключатель (switch) */
.switch { display: flex; align-items: flex-start; gap: 0.65rem; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.switch__title { font-size: 0.92rem; font-weight: 600; line-height: 1.3; }
.switch__hint { font-size: 0.78rem; color: var(--text-dim); line-height: 1.4; }
.switch__track {
  width: 42px; height: 24px; border-radius: 999px; background: var(--surface); margin-top: 1px;
  border: 1px solid var(--border-strong); position: relative; transition: background var(--dur) var(--ease); flex-shrink: 0;
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--text-muted); transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--accent-deep); border-color: transparent; }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: #fff; }

/* Вкладки страниц */
.ptabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0; }
.ptab {
  padding: 0.4rem 0.8rem; border-radius: 999px; font-size: 0.85rem;
  border: 1px solid var(--border-strong); color: var(--text-muted); background: var(--surface);
  transition: all var(--dur) var(--ease);
}
.ptab.is-active { color: #fff; background: var(--accent-deep); border-color: transparent; }
.ptab--add { border-style: dashed; color: var(--accent); }
.prow { display: flex; gap: 0.5rem; }
.prow input { flex: 1; }

/* Ручка перетаскивания + состояние drop */
.drag-handle { color: var(--text-dim); cursor: grab; font-size: 1rem; line-height: 1; letter-spacing: -2px; }
.block-item__head:active .drag-handle { cursor: grabbing; }
.block-item.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-deep) inset; }

/* Пожелания + подсказка «?» */
.wish { display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0; cursor: pointer; }
.wish input { width: auto; flex-shrink: 0; accent-color: var(--accent); }
.wish__label { flex: 1; font-size: 0.92rem; }
.hint-q {
  width: 20px; height: 20px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 0.72rem; font-weight: 700;
  color: var(--accent); border: 1px solid var(--accent); cursor: help; position: relative;
}
.hint-q::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); right: -6px; width: 240px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0.7rem 0.8rem; font-size: 0.8rem; font-weight: 400;
  line-height: 1.45; box-shadow: var(--shadow); z-index: 20;
  opacity: 0; visibility: hidden; transform: translateY(4px); transition: all 0.18s var(--ease); pointer-events: none;
}
.hint-q:hover::after, .hint-q:focus::after { opacity: 1; visibility: visible; transform: translateY(0); }

/* Переключатель ПК/телефон в предпросмотре */
.preview__modes { display: flex; gap: 0.3rem; }
.preview__modes button {
  width: 30px; height: 26px; border-radius: 7px; font-size: 0.85rem;
  color: var(--text-dim); border: 1px solid var(--border); background: var(--surface);
}
.preview__modes button.is-active { color: var(--text); border-color: var(--accent); }
.builder__preview.is-mobile { align-items: center; }
.builder__preview.is-mobile .preview__frame {
  width: 390px; max-width: 100%; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}

/* Кнопка «во весь экран» */
.preview__full {
  width: 30px; height: 26px; border-radius: 7px; font-size: 0.85rem;
  color: var(--text-dim); border: 1px solid var(--border); background: var(--surface);
}
.preview__full:hover, .preview__full.is-active { color: var(--text); border-color: var(--accent); }

/* Полноэкранный предпросмотр */
.builder__preview:fullscreen {
  width: 100vw; height: 100vh; max-height: none; top: 0;
  border: 0; border-radius: 0; background: var(--bg-elevated);
}
.builder__preview:-webkit-full-screen { width: 100vw; height: 100vh; border: 0; border-radius: 0; }
.builder__preview:fullscreen.is-mobile .preview__frame {
  width: 390px; max-width: 100%; height: 100%;
}
