/* ==========================================================================
   MEDIA LIGHTBOX — просмотр результата (картинка/видео).
   Визуал 1:1 повторяет модалку галереи (.modal-*), но на своих классах .mlb__*,
   чтобы не конфликтовать с gallery.css. Используется на главной (клик по
   результату / карточке истории). Движок зума переиспользуется в галерее.
   ========================================================================== */

.mlb {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .22s ease;
}
.mlb[aria-hidden="false"] { display: flex; }
.mlb.is-open { opacity: 1; }

body.mlb-lock { overflow: hidden; }

/* --- Контейнер-карточка --- */
.mlb__container {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(11, 18, 32, 0.98));
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 20px;
  max-width: 1200px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* --- Шапка --- */
.mlb__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}
.mlb__title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.mlb__badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  color: #ddd6fe;
  background: linear-gradient(135deg, rgba(139, 92, 246, .3), rgba(99, 102, 241, .2));
  border: 1px solid rgba(139, 92, 246, .4);
}
.mlb__title {
  font-size: 18px;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mlb__close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.mlb__close:hover { background: rgba(239, 68, 68, 0.2); }
.mlb__close svg { width: 20px; height: 20px; }

/* --- Тело: две колонки (как .modal-body) --- */
.mlb__body {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 2rem;
  padding: 2rem;
  max-height: calc(90vh - 90px);
  overflow-y: auto;
}
/* Если справа нет секций — медиа на всю ширину */
.mlb__container--no-details .mlb__body { grid-template-columns: 1fr; }

/* --- Левая колонка: медиа + действия --- */
.mlb__media-column { min-width: 0; }
.mlb__media-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #1a1f2e;
  margin-bottom: 1rem;
  max-height: 70vh;
  display: grid;
  place-items: center;
  touch-action: none;   /* свой зум/пан для картинок */
}
.mlb__media {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}
/* Картинка — зум/пан */
.mlb__media--img {
  transform-origin: 0 0;
  will-change: transform;
  cursor: zoom-in;
}
.mlb__media--img.is-zoomed { cursor: grab; }
.mlb__media--img.is-panning { cursor: grabbing; }
/* Видео */
.mlb__media--video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 12px;
}

/* --- Кнопки действий --- */
.mlb__actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.mlb__action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.mlb__action svg { width: 18px; height: 18px; }
.mlb__action--primary {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: #fff;
  border: none;
}
.mlb__action--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
}
/* Вторичная (Повторить) */
.mlb__action--secondary {
  background: rgba(139, 92, 246, 0.12);
  color: #ddd6fe;
  border: 1px solid rgba(139, 92, 246, 0.35);
}
.mlb__action--secondary:hover {
  background: rgba(139, 92, 246, 0.22);
  border-color: rgba(139, 92, 246, 0.5);
}
/* Призрачная (В избранное) */
.mlb__action--ghost {
  background: rgba(148, 163, 184, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.mlb__action--ghost:hover {
  background: rgba(148, 163, 184, 0.16);
  border-color: rgba(148, 163, 184, 0.35);
}
.mlb__action--ghost.is-active {
  background: rgba(251, 191, 36, 0.14);
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.45);
}
/* Опасная (Удалить) */
.mlb__action--danger {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.mlb__action--danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

/* --- Навигация в шапке (←/→) --- */
.mlb__nav {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.mlb__nav:hover:not(:disabled) { background: rgba(139, 92, 246, 0.2); }
.mlb__nav:disabled { opacity: 0.35; cursor: default; }
.mlb__nav svg { width: 20px; height: 20px; }

/* --- Теги --- */
.mlb__tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.mlb__tag {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.25);
}

/* --- Правая колонка: инфо-секции --- */
.mlb__details-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  min-width: 0;
}
.mlb__section {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 12px;
  padding: 1rem;
}
.mlb__section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: #a78bfa;
  margin: 0 0 0.75rem;
}
.mlb__section-title svg { width: 16px; height: 16px; }
.mlb__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.mlb__row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 13px;
}
.mlb__row-label { color: #94a3b8; flex-shrink: 0; }
.mlb__row-value { color: #e2e8f0; font-weight: 600; text-align: right; word-break: break-word; }
.mlb__prompt {
  font-size: 14px;
  color: #e2e8f0;
  line-height: 1.6;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- Адаптив (одна колонка, как в галерее) --- */
@media (max-width: 768px) {
  .mlb { padding: 0.5rem; }
  .mlb__container {
    max-height: 95vh;
    border-radius: 16px;
  }
  .mlb__header { padding: 1rem; }
  .mlb__title { font-size: 16px; line-height: 1.3; }
  .mlb__body {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
    max-height: calc(95vh - 76px);
  }
  .mlb__details-column { max-height: none; }
}

/* Доступность: уважать prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .mlb { transition: none; }
  .mlb__media--img { will-change: auto; }
  .mlb__action--primary:hover { transform: none; }
}

