/* ============================================================
   admin.css — палитра и типографика витрины choonga-changa
   Источник: index.html (Tailwind @theme): фон #FFFFFF, текст #2F3A40,
   акцент #9FC6D8 (primary), вторичный фон #F1F4F5, доп. #C7E59A,
   граница #E1E8EA, радиус 0.75rem, шрифты Inter (текст) / Manrope (заголовки).
   Админка использует те же токены, чтобы не выглядеть чужим интерфейсом.
   ============================================================ */

:root {
  --bg: #F1F4F5;
  --card: #FFFFFF;
  --text: #2F3A40;
  --muted: #6A757B;
  --line: #E1E8EA;
  --accent: #9FC6D8;
  --accent-hover: #8FBACD;
  --accent-soft: #E8F5DE;
  --accent-text: #577B8C;
  --success: #C7E59A;
  --success-text: #465B3B;
  --danger: #D99B95;
  --danger-text: #A16762;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -8px rgba(59, 81, 91, .08);
  --font-sans: Inter, 'Segoe UI', system-ui, sans-serif;
  --font-heading: Manrope, Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, b, .logo { font-family: var(--font-heading); letter-spacing: -.01em; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- каркас ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .logo {
  font-weight: 800;
  font-size: 17px;
  line-height: 1.1;
  padding: 6px 12px 18px;
  color: var(--text);
}
.sidebar .logo small {
  display: block;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
}
.sidebar a {
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: background .15s, color .15s;
}
.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--accent); color: #26343A; font-weight: 600; }
.sidebar .logout { margin-top: auto; }

.main { flex: 1; min-width: 0; padding: 24px; max-width: 1400px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
h1 { font-size: 22px; margin: 0; font-weight: 700; }

/* ---------- карточки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.grid-stats .card { margin-bottom: 0; }
.stat label { display: block; font-size: 13px; color: var(--muted); }
.stat b { display: block; font-size: 26px; line-height: 1.2; margin: 4px 0 2px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #26343A; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { border-color: var(--danger); color: var(--danger-text); }
.btn-danger:hover { background: #FBEFEE; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  background: #F8FAFA;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #FBFCFC; }
.table tr.attr-disabled td { background: #ECEEF0; color: var(--muted); }
.table tr.attr-disabled td input[type=text], .table tr.attr-disabled td input[type=number] { background: #F5F6F7; color: var(--muted); }
.table td input[type=text], .table td input[type=number] { min-width: 90px; }
/* мастер-сетка: отмеченные строки и панель пакетных действий */
.table tr.picked td { background: #EFF6F9; }
.matrix-actions { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.matrix-actions [data-picked-count] { margin-right: 4px; min-width: 84px; }
.matrix-del-head { font-weight: 600; margin-bottom: 6px; }
.matrix-del-list { max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; background: #FBFCFC; }
.matrix-del-item { font-size: 13px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.matrix-del-item:last-child { border-bottom: 0; }
/* характеристики раздела в карточке товара: одна характеристика — одна строка */
.attr-table th { font-size: 12px; }
.attr-table td { padding: 6px 10px; }
.attr-table .attr-name { width: 45%; min-width: 180px; }
.attr-table .attr-name label { margin: 0; font-weight: 500; }
.attr-table .attr-unit { width: 70px; white-space: nowrap; }
.attr-table td input[type=text] { width: 100%; margin: 0; }
.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
}

/* ---------- бейджи ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}
.badge-new { background: var(--success); color: var(--success-text); }
.badge-work { background: var(--accent); color: #26343A; }
.badge-done { background: #EEF2F3; color: var(--muted); }
.badge-cancel { background: #FBEFEE; color: var(--danger-text); }

/* ---------- сообщения ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-ok { background: #F2FAE8; border-color: var(--success); color: var(--success-text); }
.alert-err { background: #FBEFEE; border-color: var(--danger); color: var(--danger-text); }

/* ---------- формы ---------- */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], input[type=email],
input[type=tel], input[type=file], input[type=search], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 120px; resize: vertical; }

/* ---------- визуальный редактор описания ---------- */
.editor { border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.editor-bar {
  display: flex; flex-wrap: wrap; gap: 2px; align-items: center;
  padding: 6px; border-bottom: 1px solid var(--line); background: #fff;
}
.editor-bar button {
  border: 1px solid transparent; background: #fff; border-radius: 4px;
  font: inherit; font-size: 13px; line-height: 1; padding: 6px 8px; color: var(--text);
  cursor: pointer;
}
.editor-bar button:hover { border-color: var(--line); }
/* «Картинка» — label вокруг скрытого input:file, выглядит как кнопка панели */
.editor-bar .ed-btn {
  display: inline-block; border: 1px solid transparent; background: #fff; border-radius: 4px;
  font: inherit; font-size: 13px; line-height: 1; padding: 6px 8px; color: var(--text);
  cursor: pointer; margin: 0;
}
.editor-bar .ed-btn:hover { border-color: var(--line); }
.editor-bar .ed-btn input[type=file] { display: none; }
.editor-bar button.ed-on { background: var(--accent); color: #26343A; }
.editor-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.ed-body {
  min-height: 200px; max-height: 60vh; overflow: auto;
  padding: 12px; outline: none; line-height: 1.65;
  font-size: 14px; color: var(--text);
}
.ed-body:empty::before { content: attr(data-ph); color: var(--muted); }
.ed-body h2 { font-size: 18px; margin: 12px 0 8px; }
.ed-body h3 { font-size: 16px; margin: 12px 0 8px; }
.ed-body p, .ed-body ul, .ed-body ol { margin: 0 0 10px; }
.ed-body ul, .ed-body ol { padding-left: 24px; }
.ed-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.editor.ed-busy{opacity:.6;pointer-events:none}
.editor.ed-busy::after{content:'загрузка картинки…';position:absolute;right:12px;top:8px;font-size:12px;color:var(--muted)}
.editor{position:relative}
.ed-body a { color: var(--accent); }

/* Описание в карточке товара: ширина как у блока описания на витрине — ровно 1200px
   (<main> = min(1280, окно) с px-6/lg:px-10). Уже окна админки — растягивается
   на всю карточку, поэтому не фиксированная ширина, а max-width. */
.desc-field .editor { width: 100%; max-width: 1200px; box-sizing: border-box; }

/* ---------- мастер-товар: варианты «все цвета / размеры раздела» ---------- */
.mk-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 12px; margin-top: 6px;
}
.mk-grid label {
  display: flex; align-items: center; gap: 6px;
  color: var(--text); font-size: 13px; margin: 0; min-width: 0;
}
.mk-grid label input { width: auto; margin: 0; }
.mk-grid .sw { width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(0,0,0,.2); flex: none;
  background-size: cover; background-position: center; }
.mk-grid label { padding: 2px 0; }
.mk-grid .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-preview { margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm); font-size: 13px; color: var(--muted); }
.mk-preview b { color: var(--text); }
/* превью цветов серии: крупные образцы, у отмеченных — рамка */
.mk-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mk-thumbs .mk-thumb {
  width: 40px; height: 40px; border-radius: 8px; border: 1px solid rgba(0,0,0,.18);
  background-size: cover; background-position: center; opacity: .45; transition: opacity .15s, box-shadow .15s;
}
.mk-thumbs .mk-thumb.on { opacity: 1; box-shadow: 0 0 0 2px var(--accent); }

/* ---------- прочее ---------- */
.muted { color: var(--muted); font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.pager { display: flex; gap: 6px; }
.pager a, .pager span {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.pager .cur { background: var(--accent); border-color: var(--accent); color: #26343A; font-weight: 600; }
.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(47, 58, 64, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  max-width: 640px;
  width: 92%;
  max-height: 88vh;
  overflow: auto;
  box-shadow: var(--shadow);
}

/* ---------- мобильные ---------- */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: auto;
    flex: none;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px;
  }
  .sidebar .logo { padding: 0 12px 0 4px; font-size: 15px; white-space: nowrap; }
  .sidebar .logo small { display: none; }
  .sidebar a { padding: 8px 12px; white-space: nowrap; }
  .sidebar .logout { margin-top: 0; }
  .main { padding: 16px; }
  .hide-sm { display: none; }
}

@media print {
  .sidebar, .topbar .btn, .no-print { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; padding: 0; }
}
