/**
 * MyVideoStudio — Image Generator (v1.62.3)
 *
 * Shared 3-column studio template:
 *   - Left: config (prompt + options)
 *   - Center: player + info bar
 *   - Right: gallery rail (thumbnails)
 */

.mvs-imggen {
  display: grid;
  grid-template-columns: 370px 1fr 280px;
  gap: 16px;
  min-height: calc(100vh - 120px);
  align-items: start;
}
.mvs-imggen svg { display: inline-block; flex-shrink: 0; }
.mvs-imggen [hidden] { display: none !important; }

/* =====================================================================
   LEFT: CONFIG COLUMN
   ===================================================================== */
.mvs-imggen__config {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.mvs-imggen__config::-webkit-scrollbar { width: 0; height: 0; display: none; }
.mvs-imggen__field { display: flex; flex-direction: column; gap: 6px; }
.mvs-imggen__field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mvs-imggen__label {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mvs-imggen__select {
  appearance: none; -webkit-appearance: none;
  width: 100%;
  padding: 10px 30px 10px 12px;
  border-radius: 10px;
  border: 1px solid #E2E8F0;
  background: #fff;
  color: #1C2434;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.mvs-imggen__select:focus { outline: none; border-color: #3C50E0; }
.mvs-imggen__prompt {
  width: 100%;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  color: #1C2434;
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}
.mvs-imggen__prompt:focus { outline: none; border-color: #3C50E0; }
.mvs-imggen__prompt::placeholder { color: #94A3B8; }
.mvs-imggen__attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px dashed #CBD5E1;
  border-radius: 10px;
  background: #F8FAFC;
  color: #3C50E0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 130ms ease, background 130ms ease;
}
.mvs-imggen__attach-btn:hover { border-color: #3C50E0; background: #EEF2FF; }
.mvs-imggen__run-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid #F1F5F9;
}
.mvs-imggen__cost-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #94A3B8;
}
.mvs-imggen__cost-line strong { color: #475569; font-weight: 700; }
.mvs-imggen__cost { display: inline-flex; align-items: center; gap: 4px; }
.mvs-imggen__run {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #3C50E0, #6D5BE0);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(60, 80, 224, 0.32);
  transition: transform 130ms ease, box-shadow 130ms ease, opacity 130ms ease;
}
.mvs-imggen__run:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(60, 80, 224, 0.42); }
.mvs-imggen__run:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.mvs-imggen__run-icon { width: 14px; height: 14px; }

/* Reference thumbnails row */
.mvs-imggen__refs-row { display: block; }
.mvs-imggen__refs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

/* =====================================================================
   CENTER: PLAYER + INFO BAR
   ===================================================================== */
.mvs-imggen__main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  width: 100%;
}
.mvs-imggen__player-wrap {
  background: #0F172A;
  border-radius: 16px;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.mvs-imggen__player-wrap img { display: block; }
.mvs-imggen__player-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #64748B;
  text-align: center;
  padding: 40px;
}
.mvs-imggen__player-empty svg { width: 56px; height: 56px; opacity: 0.5; }
.mvs-imggen__player-empty p { margin: 0; max-width: 260px; font-size: 13px; }

.mvs-imggen__info {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mvs-imggen__info-empty {
  color: #94A3B8;
  text-align: center;
  font-size: 13px;
  padding: 18px 12px;
}
.mvs-imggen__info-prompt {
  font-size: 13.5px;
  color: #1C2434;
  line-height: 1.55;
  background: #F7F9FC;
  border-radius: 10px;
  padding: 12px 14px;
  border-left: 3px solid #3C50E0;
}
.mvs-imggen__info-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.mvs-imggen__info-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.mvs-imggen__info-date { font-size: 11.5px; color: #94A3B8; }
.mvs-imggen__info-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #F1F5F9;
}
.mvs-imggen__info-btn {
  width: 38px;
  height: 38px;
  background: #F7F9FC;
  border: 1px solid #E2E8F0;
  border-radius: 9px;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
}
.mvs-imggen__info-btn:hover { background: #EFF4FB; border-color: #3C50E0; color: #3C50E0; }
.mvs-imggen__info-btn svg { width: 15px !important; height: 15px !important; }

/* =====================================================================
   RIGHT: GALLERY RAIL
   ===================================================================== */
.mvs-imggen__rail {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 12px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.mvs-imggen__rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 4px;
}
.mvs-imggen__gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  padding-right: 2px;
  min-height: 100px;
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 transparent;
}
.mvs-imggen__gallery::-webkit-scrollbar { width: 6px; }
.mvs-imggen__gallery::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }

.mvs-imggen__card {
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  position: relative;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.mvs-imggen__card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(28, 36, 52, 0.08);
}
.mvs-imggen__card.is-active { outline: 2px solid #3C50E0; outline-offset: 2px; }
.mvs-imggen__card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

/* =====================================================================
   HORIZONTAL HOVER TOOLBAR (bottom of each rail card)
   ===================================================================== */

.mvs-imggen__card-tools {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  transform: translateY(6px);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  padding: 4px;
  background: rgba(28, 36, 52, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 9px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
  z-index: 3;
}
.mvs-imggen__card:hover .mvs-imggen__card-tools {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.mvs-imggen__card-tool {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0;
  transition: background 130ms ease, color 130ms ease, transform 130ms ease;
}
.mvs-imggen__card-tool svg {
  width: 13px !important;
  height: 13px !important;
  display: inline-block;
  flex-shrink: 0;
}
.mvs-imggen__card-tool:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
}
.mvs-imggen__card-tool:active { transform: scale(0.94); }
.mvs-imggen__card-tool.is-danger:hover { background: rgba(220, 38, 38, 0.7); }
.mvs-imggen__card-tool.is-active {
  color: #F87171;
  background: rgba(255, 255, 255, 0.12);
}
.mvs-imggen__card-tool.is-active svg { fill: currentColor; }

/* Loading / status overlay on cards still processing */
.mvs-imggen__card--queued {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F1F5F9;
  position: relative;
}
.mvs-imggen__card--queued::before {
  content: '';
  width: 28px;
  height: 28px;
  border: 3px solid #CBD5E1;
  border-top-color: #3C50E0;
  border-radius: 50%;
  animation: mvs-imggen-spin 0.8s linear infinite;
}
.mvs-imggen__card--failed {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FEF2F2, #FEE2E2);
  border: 1px solid #FCA5A5;
  color: #991B1B;
  font-size: 12.5px;
  padding: 16px;
  text-align: center;
  position: relative;
}
.mvs-imggen__card-failed-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 220px;
  line-height: 1.45;
}
.mvs-imggen__card-failed-msg {
  font-weight: 500;
  letter-spacing: -0.005em;
}
@keyframes mvs-imggen-spin { to { transform: rotate(360deg); } }

/* v1.44.5 — Erase × on failed / queued cards */
.mvs-imggen__card-erase {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: #991B1B;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 4;
  transition: background 130ms ease, transform 130ms ease, color 130ms ease;
}
.mvs-imggen__card-erase:hover {
  background: #DC2626;
  color: #FFFFFF;
  border-color: #DC2626;
  transform: scale(1.05);
}
.mvs-imggen__card-erase--on-dark {
  background: rgba(28, 36, 52, 0.85);
  border-color: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}
.mvs-imggen__card-erase--on-dark:hover {
  background: #DC2626;
  border-color: #DC2626;
}

/* v1.44.5 — Bulk clear bar above the masonry grid */
.mvs-imggen__failed-bar {
  /* Span all columns in masonry layout */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 10px;
  margin: 0 0 12px;
  break-inside: avoid;
  grid-column: 1 / -1;
}
.mvs-imggen__failed-bar-text {
  font-size: 12.5px;
  color: #991B1B;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.mvs-imggen__failed-bar-btn {
  background: #DC2626;
  color: #FFFFFF;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 130ms ease;
}
.mvs-imggen__failed-bar-btn:hover { background: #991B1B; }
.mvs-imggen__failed-bar-btn:disabled { background: #94A3B8; cursor: not-allowed; }

/* Empty state */
.mvs-imggen__empty {
  text-align: center;
  padding: 80px 24px 40px;
  color: #64748B;
  font-size: 14px;
  break-inside: avoid;
  grid-column: 1 / -1;
}
.mvs-imggen__empty-icon {
  font-size: 42px;
  margin-bottom: 10px;
  opacity: 0.5;
}
.mvs-imggen__empty-title {
  font-size: 17px;
  font-weight: 600;
  color: #1C2434;
  margin: 0 0 6px;
}

/* Initial loading */
.mvs-imggen__gallery-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 24px;
  color: #64748B;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.mvs-imggen__spinner-large {
  width: 36px;
  height: 36px;
  border: 3px solid #E2E8F0;
  border-top-color: #3C50E0;
  border-radius: 50%;
  animation: mvs-imggen-spin 0.8s linear infinite;
}


/* =====================================================================
   LIGHTBOX MODAL
   ===================================================================== */

.mvs-imggen__lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
  animation: mvs-lb-fade 200ms ease;
}
.mvs-imggen__lightbox.is-open { display: flex; }
@keyframes mvs-lb-fade { from { opacity: 0; } to { opacity: 1; } }

/* Close button */
.mvs-imggen__lb-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 130ms ease;
  z-index: 4;
}
.mvs-imggen__lb-close:hover { background: rgba(255, 255, 255, 0.22); }
.mvs-imggen__lb-close svg { width: 18px; height: 18px; }

/* Nav arrows */
.mvs-imggen__lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 130ms ease, transform 130ms ease;
  z-index: 4;
}
.mvs-imggen__lb-nav:hover { background: rgba(255, 255, 255, 0.22); }
.mvs-imggen__lb-nav:active { transform: translateY(-50%) scale(0.94); }
.mvs-imggen__lb-nav svg { width: 22px; height: 22px; }
.mvs-imggen__lb-nav--prev { left: 18px; }
.mvs-imggen__lb-nav--next { right: 18px; }

/* Panel: image + sidebar */
.mvs-imggen__lb-panel {
  background: #FFFFFF;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 320px;
  max-width: 1100px;
  width: 100%;
  max-height: calc(100vh - 64px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  animation: mvs-lb-pop 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes mvs-lb-pop {
  from { transform: translateY(10px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* Image area */
.mvs-imggen__lb-imgwrap {
  background: #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}
.mvs-imggen__lb-imgwrap img {
  max-width: 100%;
  max-height: calc(100vh - 96px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

/* Sidebar */
.mvs-imggen__lb-sidebar {
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  border-left: 1px solid #E2E8F0;
  overflow-y: auto;
}
.mvs-imggen__lb-meta {
  flex: 1;
  padding: 22px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mvs-imggen__lb-model {
  font-size: 16px;
  font-weight: 700;
  color: #1C2434;
  letter-spacing: -0.01em;
}

.mvs-imggen__lb-refs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mvs-imggen__lb-refs img {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #E2E8F0;
}

.mvs-imggen__lb-prompt {
  font-size: 13.5px;
  color: #1C2434;
  line-height: 1.55;
  letter-spacing: -0.005em;
  max-height: 160px;
  overflow-y: auto;
}

.mvs-imggen__lb-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mvs-imggen__lb-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.mvs-imggen__lb-date {
  font-size: 12px;
  color: #64748B;
  margin-top: auto;
}

.mvs-imggen__lb-actions {
  display: flex;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid #F1F5F9;
}
.mvs-imggen__lb-iconbtn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #F7F9FC;
  border: 1px solid #E2E8F0;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
}
.mvs-imggen__lb-iconbtn:hover {
  background: #EFF4FB;
  border-color: #3C50E0;
  color: #3C50E0;
}
.mvs-imggen__lb-iconbtn.is-danger:hover {
  background: #FEE2E2;
  border-color: #DC2626;
  color: #DC2626;
}
.mvs-imggen__lb-iconbtn.is-active {
  color: #DC2626;
  background: #FEE2E2;
  border-color: #FCA5A5;
}
.mvs-imggen__lb-iconbtn.is-active svg { fill: currentColor; }
.mvs-imggen__lb-iconbtn svg {
  width: 14px !important;
  height: 14px !important;
  display: inline-block;
  flex-shrink: 0;
}
.mvs-imggen__lb-primary svg {
  width: 16px !important;
  height: 16px !important;
  display: inline-block;
}

/* CTA buttons */
.mvs-imggen__lb-cta {
  padding: 14px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid #F1F5F9;
}
.mvs-imggen__lb-primary {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  background: #1C2434;
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 130ms ease, transform 80ms ease;
}
.mvs-imggen__lb-primary svg { width: 16px; height: 16px; }
.mvs-imggen__lb-primary:hover { background: #000000; }
.mvs-imggen__lb-primary:active { transform: translateY(0.5px); }
.mvs-imggen__lb-primary--ghost {
  background: #FFFFFF;
  color: #1C2434;
  border: 1px solid #1C2434;
}
.mvs-imggen__lb-primary--ghost:hover {
  background: #1C2434;
  color: #FFFFFF;
}

/* Responsive */
@media (max-width: 860px) {
  .mvs-imggen__lightbox { padding: 0; }
  .mvs-imggen__lb-panel {
    grid-template-columns: 1fr;
    max-height: 100vh;
    border-radius: 0;
  }
  .mvs-imggen__lb-sidebar {
    border-left: none;
    border-top: 1px solid #E2E8F0;
    max-height: 38vh;
  }
  .mvs-imggen__lb-imgwrap { padding: 8px; }
  .mvs-imggen__lb-nav { width: 40px; height: 40px; }
  .mvs-imggen__lb-nav--prev { left: 8px; }
  .mvs-imggen__lb-nav--next { right: 8px; }
}

/* =====================================================================
   RESPONSIVE — 3-column studio layout (v1.62.3)
   ===================================================================== */
@media (max-width: 1180px) {
  .mvs-imggen { grid-template-columns: 360px 1fr; }
  .mvs-imggen__rail { grid-column: 1 / -1; position: static; max-height: none; }
  .mvs-imggen__gallery { flex-direction: row; flex-wrap: wrap; }
  .mvs-imggen__gallery > * { flex: 0 0 150px; }
}
@media (max-width: 860px) {
  .mvs-imggen { grid-template-columns: 1fr; }
  .mvs-imggen__config { position: static; max-height: none; }
}
