/* ============================================================
   admin.css — оформление панели управления.
   Спокойное и плотное: это рабочий инструмент, а не витрина.
   ============================================================ */

:root {
  --a-bg:       #f4f7fa;
  --a-panel:    #ffffff;
  --a-side:     #12305f;
  --a-side-hi:  #1c4a8f;
  --a-brand:    #1f8fd6;
  --a-ink:      #16324c;
  --a-muted:    #6c8199;
  --a-line:     #dde5ee;
  --a-ok:       #17794d;
  --a-warn:     #b06a00;
  --a-err:      #c0392b;
  --a-radius:   8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--a-bg);
  color: var(--a-ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--a-brand); }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ---------- Боковое меню ---------- */

.side {
  display: flex;
  flex-direction: column;
  background: var(--a-side);
  color: #fff;
}

.side__brand {
  padding: 20px 18px;
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.side__nav { flex: 1; padding: 10px 0; }

.side__link {
  display: block;
  padding: 10px 18px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.side__link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }

.side__link.is-active {
  background: var(--a-side-hi);
  border-left-color: #6fc4f5;
  color: #fff;
  font-weight: 600;
}

.side__user {
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
}

.side__name { color: rgba(255, 255, 255, 0.85); }
.side__logout { color: #8fd0f5; text-decoration: none; }

/* ---------- Основная область ---------- */

.main { min-width: 0; padding: 0 28px 40px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--a-line);
  margin-bottom: 20px;
}

.topbar__title { margin: 0; font-size: 22px; }

.h2 { margin: 28px 0 12px; font-size: 17px; }

.muted { color: var(--a-muted); }
.is-warn { color: var(--a-warn); font-weight: 600; }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-block;
  padding: 8px 18px;
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  background: #fff;
  color: var(--a-ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { border-color: var(--a-brand); }

.btn--primary,
.btn--publish {
  background: var(--a-brand);
  border-color: var(--a-brand);
  color: #fff;
  font-weight: 600;
}

.btn--primary:hover,
.btn--publish:hover { background: #1877b5; }

.btn--wide { width: 100%; padding: 11px; }

/* ---------- Сообщения ---------- */

.flash {
  margin: 0 0 16px;
  padding: 11px 15px;
  border-radius: var(--a-radius);
  border-left: 4px solid;
}

.flash--ok   { background: #e8f6ee; border-color: var(--a-ok);   color: var(--a-ok); }
.flash--warn { background: #fdf3e3; border-color: var(--a-warn); color: var(--a-warn); }
.flash--err  { background: #fdeceb; border-color: var(--a-err);  color: var(--a-err); }

/* ---------- Карточки обзора ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.card {
  padding: 18px;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
}

.card--warn { border-color: var(--a-warn); background: #fffaf2; }

.card__value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.card__label { margin-top: 6px; font-size: 13px; color: var(--a-muted); }

/* ---------- Таблица ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  overflow: hidden;
}

.table th,
.table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--a-line);
}

.table th {
  background: #eef3f8;
  font-size: 13px;
  font-weight: 600;
  color: var(--a-muted);
}

.table tr:last-child td { border-bottom: 0; }

/* ---------- Поля ---------- */

.field { display: block; margin-bottom: 14px; }

.field__label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--a-muted);
}

.field__input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  font: inherit;
  background: #fff;
}

.field__input:focus {
  outline: none;
  border-color: var(--a-brand);
  box-shadow: 0 0 0 3px rgba(31, 143, 214, 0.15);
}

/* ---------- Вход ---------- */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #1f8fd6, #12305f);
}

.login {
  width: 340px;
  padding: 30px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(6, 30, 60, 0.28);
}

.login__title { margin: 0; font-size: 20px; }
.login__sub { margin: 4px 0 22px; font-size: 13px; color: var(--a-muted); }

.stub-page { padding: 30px 0; }

/* ---------- Панель действий над списком ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.right { text-align: right; }
.small { font-size: 12px; }
.inline { display: inline; }
.req { color: var(--a-err); font-weight: 600; font-size: 11px; }

.btn--sm { padding: 5px 12px; font-size: 13px; }
.btn--danger { color: var(--a-err); border-color: #f0c7c2; }
.btn--danger:hover { background: var(--a-err); border-color: var(--a-err); color: #fff; }

.pill {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  background: #e7f1fa;
  color: #1a6ba8;
  font-size: 11px;
}

.pill--off { background: #f0f2f5; color: var(--a-muted); }
.pill--err { background: #fdeceb; color: var(--a-err); }

/* Панель публикации */
.publish-box {
  max-width: 560px;
  padding: 20px;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
}

.h3 { margin: 18px 0 6px; font-size: 14px; }

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}

.two-col .publish-box { max-width: none; }

.tune {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.tune__item { display: block; }
.tune__item .field__input { padding: 6px 8px; }

.settings-group {
  margin-bottom: 22px;
  padding: 20px;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  max-width: 720px;
}

.field--narrow { max-width: 200px; }

.steps { margin: 0; padding-left: 20px; line-height: 1.8; }

.token {
  display: inline-block;
  margin: 6px 0;
  padding: 6px 12px;
  background: #fff;
  border: 1px dashed var(--a-ok);
  border-radius: 5px;
  font-family: Consolas, monospace;
  font-size: 14px;
  user-select: all;
}

.is-muted td { opacity: 0.55; }

.thumb {
  display: block;
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 5px;
  background: #eef2f6;
}

.thumb--empty {
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--a-muted);
}

/* ---------- Перетаскивание строк ---------- */

.drag {
  cursor: grab;
  color: var(--a-muted);
  font-size: 18px;
  user-select: none;
  text-align: center;
}

.table--sortable tr.is-dragging {
  opacity: 0.45;
  background: #eef6fd;
}

/* ---------- Форма ---------- */

.form__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  gap: 34px;
  align-items: start;
}

.form__col { min-width: 0; }

.form__actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--a-line);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
}

.counter {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--a-muted);
}

.counter.is-warn { color: var(--a-warn); }
.counter.is-err  { color: var(--a-err); font-weight: 600; }

/* ---------- Вкладки языков ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--a-line);
}

.tabs__btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 0;
  background: none;
  font: inherit;
  color: var(--a-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs__btn.is-active {
  color: var(--a-ink);
  font-weight: 600;
  border-bottom-color: var(--a-brand);
}

/* Точка у незаполненного языка: видно сразу, где дыра */
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--a-warn);
}

.tabs__panel { display: none; }
.tabs__panel.is-active { display: block; }

/* ---------- Точка фокуса ---------- */

.focal {
  position: relative;
  margin-bottom: 8px;
  border-radius: var(--a-radius);
  overflow: hidden;
  cursor: crosshair;
  border: 1px solid var(--a-line);
}

.focal img { display: block; width: 100%; }

.focal--empty {
  display: grid;
  place-items: center;
  height: 180px;
  background: #eef2f6;
  color: var(--a-muted);
  cursor: default;
}

.focal__dot {
  position: absolute;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: rgba(31, 143, 214, 0.85);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* ---------- Медиатека ---------- */

.grid-media {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.mediacard {
  margin: 0;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  overflow: hidden;
}

.mediacard img { width: 100%; height: 130px; object-fit: cover; display: block; }
.mediacard figcaption { padding: 8px 10px; }

/* ---------- Всплывающее сообщение ---------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 11px 18px;
  border-radius: var(--a-radius);
  background: var(--a-ok);
  color: #fff;
  box-shadow: 0 8px 24px rgba(6, 30, 60, 0.25);
  animation: toast-in 160ms ease-out;
}

.toast--err { background: var(--a-err); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Общий переключатель языка формы ---------- */

.is-hidden { display: none !important; }

.langbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: #eaf2fa;
  border-radius: var(--a-radius);
}

.langbar__label { margin-right: 6px; font-size: 13px; color: var(--a-muted); }

.langbar__btn {
  padding: 6px 16px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: none;
  font: inherit;
  color: var(--a-ink);
  cursor: pointer;
}

.langbar__btn.is-active {
  background: #fff;
  border-color: var(--a-brand);
  font-weight: 600;
}

/* ---------- Фильтры списка ---------- */

.filters { display: flex; gap: 8px; align-items: center; }
.field__input--inline { width: auto; padding: 7px 10px; }
.field__input--area { resize: vertical; font: inherit; line-height: 1.5; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spacer { flex: 1; }

/* ---------- Блоки описания ---------- */

.block {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
}

.block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.block__type {
  font-size: 12px;
  font-weight: 600;
  color: var(--a-muted);
}

.block__tools { display: flex; gap: 4px; }
.block__tools .btn { padding: 3px 9px; line-height: 1.2; }

.blocks__add {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ---------- Галерея ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.gallery__item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  border: 1px solid var(--a-line);
}

.gallery__item.is-dragging { opacity: 0.4; }
.gallery__item img { display: block; width: 100%; height: 70px; object-fit: cover; }

.gallery__del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.gallery__del:hover { background: var(--a-err); }
