/* Админка каталога. Всё, что здесь, видно только вошедшему администратору,
   кроме самих карточек товаров. Оформление минималистичное, скругления как у карточек. */

/* ------------------------------------------------------------------ плашка HUD */
.admin-hud {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #f0c9c9;
  border-left: 3px solid #d32f2f;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
  font-size: 13.5px;
}

.admin-hud__text { color: #d32f2f; font-weight: 700; white-space: nowrap; }

/* сайт открыт не через serve.py: сохранять некуда */
.admin-hud--warn { flex-wrap: wrap; max-width: 420px; border-left-color: #b26a00; }
.admin-hud__warn {
  flex-basis: 100%;
  color: #8a5200;
  background: #fff5e0;
  border-radius: 8px;
  padding: 8px 10px;
  line-height: 1.45;
}

.admin-hud__link {
  flex: none;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  font: inherit;
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
}
.admin-hud__link:hover { border-color: var(--blue); background: #f2f7fa; }

.admin-hud__out {
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  color: #fff;
  background: #d32f2f;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .2s ease;
}
.admin-hud__out:hover { background: #b32525; }

@media (max-width: 560px) {
  .admin-hud { right: 10px; bottom: 10px; left: 10px; justify-content: space-between; }
  .admin-hud__text { white-space: normal; }
}

/* --------------------------------------------------------- карточка «добавить» */
.card--add { justify-content: flex-start; }

.card__add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  aspect-ratio: 1 / 1;
  width: 100%;
  border: 2px dashed #c8ccd0;
  border-radius: 10px;
  background: #fafafa;
  color: #6b7075;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}
.card__add:hover { border-color: var(--blue); background: #f2f7fa; color: var(--blue); }

/* плюс рисуем значком: у текстового «+» своя метрика,
   из-за неё он вставал выше середины кружка */
.card__add-plus {
  display: grid;
  place-items: center;
  width: 62px; height: 62px;
  border-radius: 50%;
  border: 2px solid currentColor;
}

/* ------------------------------------------------- меню на карточке товара */
.card { position: relative; }

.card__tools {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 3;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .18s ease;
}
.card:hover .card__tools, .card__tools:focus-within { opacity: 1; }

.card__tool {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 8px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .14);
  cursor: pointer;
  color: #3c4145;
  transition: background-color .18s ease, color .18s ease;
}
.card__tool:hover { background: #fff; color: var(--blue); }
.card__tool--del:hover { color: #d32f2f; }

/* ручка перетаскивания: touch-action нужен, иначе на телефоне
   палец будет прокручивать страницу вместо переноса карточки */
.card__tool--move { cursor: grab; touch-action: none; }
.card__tool--move:active { cursor: grabbing; }

.card.is-dragging {
  opacity: .45;
  outline: 2px dashed var(--blue);
  outline-offset: 3px;
  border-radius: 10px;
}

/* пока тащим, ничего не выделяем и карточки не «оживают» под курсором */
body.is-reordering { user-select: none; }
body.is-reordering .card__media img { transform: none !important; }
body.is-reordering .card__tools { opacity: 1; }

/* -------------------------------------------------------- всплывающее сообщение */
.admin-toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 12px);
  z-index: 9200;
  padding: 10px 18px;
  font-size: 13.5px;
  color: #fff;
  background: #2b2b2b;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.admin-toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.admin-toast.is-bad { background: #d32f2f; }

/* только на телефоне кнопки видны всегда: наведения там нет */
@media (hover: none) {
  .card__tools { opacity: 1; }
}

/* -------------------------------------------------------------------- окно */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 22, 24, .55);
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }

.modal__box {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .3);
}
.modal__box--narrow { max-width: 420px; }

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal__head h2 { margin: 0; font-size: 17px; font-weight: 700; }

.modal__close {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--muted);
}
.modal__close:hover { background: #f2f2f2; color: var(--ink); }

.modal__body { padding: 20px 22px; overflow-y: auto; }
.modal__body p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.6; }

.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
}

/* Подсказка про незаполненные поля: занимает свободное место слева
   от кнопок, на узком экране уходит на свою строку. */
.modal__hint {
  margin-right: auto;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
  text-align: left;
}
.modal__hint:empty { display: none; }

@media (max-width: 480px) {
  .modal__foot { flex-wrap: wrap; }
  .modal__hint { margin-right: 0; flex-basis: 100%; }
}

/* ------------------------------------------------------------------- поля

   Только внутри окна правки. Без этой привязки правила доставали до полей
   на других страницах: у формы заказа и у проверки заказа те же классы,
   и правило .field input[type="text"] перебивало их собственный шрифт,
   а шрифт мельче 16px заставляет телефон приближать страницу. */
.modal .field { margin-bottom: 16px; }
.modal .field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.modal .field input[type="text"],
.modal .field input[type="number"],
.modal .field select,
.modal .field textarea {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  padding: 10px 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #dcdfe2;
  border-radius: 8px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.modal .field input:focus, .modal .field select:focus, .modal .field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 108, 147, .12);
}
.modal .field textarea { resize: vertical; min-height: 62px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ файлы */
.upload {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 13.5px;
  padding: 9px 16px;
  color: var(--blue);
  background: #fff;
  border: 1px dashed var(--blue);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .18s ease;
}
.upload:hover { background: #f2f7fa; }
.upload input { display: none; }

.media {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.media__item {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f2f2f2;
  cursor: grab;
}
.media__item.is-dragging { opacity: .4; }
.media__item.is-over { outline: 2px solid var(--blue); outline-offset: -2px; }
.media__item img, .media__item video { width: 100%; height: 100%; object-fit: cover; }
.media__item video { pointer-events: none; }   /* чтобы не мешал перетаскиванию */

.media__grip {
  position: absolute;
  left: 5px; bottom: 5px;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: 2px;
  color: #fff;
  background: rgba(0, 0, 0, .45);
  border-radius: 6px;
  pointer-events: none;
}

.media__del {
  position: absolute;
  top: 5px; right: 5px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 15px; line-height: 1;
  cursor: pointer;
}
.media__del:hover { background: #d32f2f; }

.media__tag {
  position: absolute;
  top: 5px; left: 5px;
  padding: 2px 7px;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, .55);
  border-radius: 6px;
}

.hint { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- кнопки */
.btn-flat {
  font: inherit;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease;
}
.btn-flat:hover { background: #f4f4f4; }

.btn-main {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 8px;
  border: 0;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  transition: background-color .18s ease;
}
.btn-main:hover:not(:disabled) { background: var(--blue-dark); }
.btn-main:disabled { background: #c3ccd2; cursor: not-allowed; }

.btn-danger { background: #d32f2f; }
.btn-danger:hover:not(:disabled) { background: #b32525; }

.modal__error { margin: 0 0 12px; font-size: 13.5px; color: #d32f2f; }
.modal__error:empty { display: none; }
