/*
 * Project edit page (page-projectedit.php) — mobile-first UX.
 * Главное:
 *  - inputs 16px → iOS не зумит
 *  - touch targets ≥ 44px
 *  - sticky action bar над bottom-nav на мобиле
 *  - SVG-иконки вместо эмодзи
 */

body.newui .project-edit-page { padding-bottom: 24px; }
body.newui .project-edit-page .wrap { display: block; max-width: 1320px; }

/* Header: оставляем дыхание + чёткая иерархия */
body.newui .project-edit-header {
  display: flex; flex-direction: column; gap: 4px;
  margin: 8px 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
body.newui .project-edit-header h1 {
  margin: 0; font-size: 26px; font-weight: 700;
  line-height: 1.2; letter-spacing: -0.01em;
}
body.newui .project-edit-id {
  margin: 0; color: var(--text2); font-size: 13px;
  font-variant-numeric: tabular-nums;
}

body.newui .project-edit-form {
  display: flex; flex-direction: column; gap: 18px;
}

body.newui .project-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

body.newui .project-edit-main,
body.newui .project-edit-meta {
  display: flex; flex-direction: column; gap: 18px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
}
[data-theme="dark"] body.newui .project-edit-main,
[data-theme="dark"] body.newui .project-edit-meta {
  box-shadow: 0 1px 3px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.02);
}

/* Внутренние разделители между секциями в основной колонке */
body.newui .project-edit-main > .pe-field + .pe-field {
  position: relative;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* Заголовок meta-сайдбара */
body.newui .pe-meta-title {
  margin: 0 0 4px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text2);
}

/* Sticky meta на десктопе: остаётся видна при скролле редактора */
@media (min-width: 901px) {
  body.newui .project-edit-meta {
    position: sticky;
    top: 76px; /* над topbar (~60px) + запас */
    max-height: calc(100vh - 96px);
    overflow-y: auto;
  }
  body.newui .project-edit-meta::-webkit-scrollbar { width: 6px; }
  body.newui .project-edit-meta::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
}

/* Fields */
body.newui .pe-field { display: flex; flex-direction: column; gap: 8px; }
body.newui .pe-field > label {
  font-size: 12px; font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.04em; text-transform: uppercase;
}
body.newui .pe-input {
  width: 100%; box-sizing: border-box;
  font: inherit; font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px; min-height: 46px;
  transition: border-color 120ms, background 120ms, box-shadow 120ms;
  -webkit-appearance: none; appearance: none;
}
body.newui select.pe-input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}
body.newui .pe-input:hover { border-color: var(--border2); }
body.newui .pe-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* WP-editor wrap */
body.newui .pe-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  transition: border-color 120ms, box-shadow 120ms;
}
body.newui .pe-editor:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
body.newui .pe-editor .wp-editor-wrap,
body.newui .pe-editor .wp-editor-container { background: var(--bg); border: 0; }
body.newui .pe-editor textarea {
  font-size: 15px !important;
  line-height: 1.55;
  min-height: 240px;
  padding: 14px 16px;
  background: var(--bg);
  color: var(--text);
  border: 0;
}
body.newui .pe-editor iframe { min-height: 320px; }
@media (min-width: 901px) {
  body.newui .pe-editor textarea { min-height: 320px; }
  body.newui .pe-editor iframe { min-height: 380px; }
}
body.newui .pe-editor .mce-toolbar-grp,
body.newui .pe-editor .mce-edit-area { border-color: var(--border) !important; }
body.newui .pe-editor .mce-toolbar-grp { background: var(--bg2) !important; }
body.newui .pe-editor .quicktags-toolbar {
  background: var(--bg2);
  border-color: var(--border);
  padding: 8px 8px 4px;
}
body.newui .pe-editor .quicktags-toolbar input.button {
  font-size: 13px; padding: 6px 11px; min-height: 32px;
  margin-bottom: 4px;
}

/* Files */
body.newui .pe-files-actions {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}
body.newui .add_files_edit {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border-style: dashed;
  font-weight: 600;
}
body.newui .add_files_edit:hover { border-style: solid; }
body.newui .add_files_edit svg { flex-shrink: 0; }
body.newui .pe-files-status { color: var(--text2); font-size: 13px; }
body.newui .pe-files-upstatus { min-height: 18px; font-size: 13px; }
body.newui .pe-up-info  { color: var(--accent); }
body.newui .pe-up-ok    { color: #28a745; }
body.newui .pe-up-warn  { color: #d99a1f; }
body.newui .pe-up-err   { color: var(--danger); }

body.newui .pe-upload-form { display: none; }

body.newui .pe-file-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
body.newui .pe-file-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 10px 10px 14px;
  transition: border-color 120ms, background 120ms;
}
body.newui .pe-file-item:hover {
  border-color: var(--border2);
  background: var(--bg3);
}
body.newui .pe-file-link {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--text); text-decoration: none;
  flex: 1; min-width: 0;
  padding: 4px 0;
}
body.newui .pe-file-ico {
  color: var(--accent);
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 8px;
}
body.newui .pe-file-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px; font-weight: 500;
}
body.newui .pe-file-link:hover { color: var(--accent); }
body.newui .pe-file-link:hover .pe-file-name { text-decoration: underline; }

body.newui .pe-file-remove {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--danger);
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
body.newui .pe-file-remove:hover {
  background: rgba(220,53,69,0.1);
  border-color: rgba(220,53,69,0.4);
}
body.newui .pe-file-remove:active { transform: scale(0.94); }
body.newui .pe-file-remove:disabled { opacity: 0.5; cursor: progress; }
body.newui .pe-file-empty {
  color: var(--text2); font-style: italic; font-size: 13px;
  margin: 8px 0 0;
}

/* Action bar */
body.newui .project-edit-actions {
  display: flex; gap: 12px; justify-content: flex-end; align-items: center;
  padding: 16px 22px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
}
body.newui .project-edit-actions .btn {
  min-height: 46px; min-width: 140px;
  font-size: 15px; font-weight: 600;
  padding: 0 22px;
}
body.newui .project-edit-actions .btn-primary { min-width: 180px; }
body.newui .pe-btn-cancel {
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Sticky action bar на десктопе: всегда видна в нижней части viewport.
   Контент уже имеет padding-bottom через .project-edit-page. */
@media (min-width: 901px) {
  body.newui .project-edit-page { padding-bottom: 96px; }
  body.newui .project-edit-actions {
    position: sticky;
    bottom: 16px;
    z-index: 5;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

/* ── Mobile (<= 900px): single column ────────────────── */
@media (max-width: 900px) {
  body.newui .project-edit-grid { grid-template-columns: 1fr; gap: 14px; }
}

/* ── Mobile (<= 768px): action bar просто внизу страницы, без fixed ── */
@media (max-width: 768px) {
  body.newui .project-edit-page { padding-bottom: 24px; }

  body.newui .project-edit-main,
  body.newui .project-edit-meta { padding: 14px; }

  body.newui .project-edit-header h1 { font-size: 20px; }

  body.newui .project-edit-actions {
    padding: 12px 14px;
  }
  body.newui .project-edit-actions .btn {
    flex: 1; min-width: 0; min-height: 48px;
  }

  body.newui .pe-files-actions { gap: 6px; }
  body.newui .add_files_edit { width: 100%; justify-content: center; }
  body.newui .pe-files-status { width: 100%; }
}

@media (max-width: 480px) {
  body.newui .project-edit-main,
  body.newui .project-edit-meta { padding: 12px; }
  body.newui .pe-field > label { font-size: 12px; }
  body.newui .pe-file-name { font-size: 13px; }
}

/* Dark-theme tweaks для wp-editor */
[data-theme="dark"] body.newui .pe-editor textarea {
  background: var(--bg); color: var(--text);
}
[data-theme="dark"] body.newui .pe-editor .quicktags-toolbar { background: var(--bg2); }
