/* video.css — Video Studio (Lipsync Focus)
   Consistent with Image Studio: generate strip + framed thumbs + action buttons + empty state
*/

/* -------------------------
   Layout
------------------------- */

.video-panel {
  display: flex;
  flex-direction: column;
  min-height: 480px;
  gap: 20px;
}

/*
  Layout update: match I2V consistency
  - Top row: Reference image + Audio/Prompt side-by-side
  - Bottom row: Gallery full width
*/
.video-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

/* Top row grid (Reference + Settings) */
.video-column-left {
  width: 100%;
  max-width: none;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(360px, 1fr);
  gap: 20px;
  align-items: start;
}

/* Gallery row */
.video-column-right {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* -------------------------
   Cards (match Mojoe dark theme)
------------------------- */

.video-source-card,
.video-settings-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* -------------------------
   Image Source Preview
------------------------- */

.video-source-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f1424;
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.1);

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}

.video-source-preview:hover,
.video-source-preview.drag-over {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(15, 20, 36, 1);
}

.video-source-preview.has-file,
.video-source-preview.has-image {
  border-style: solid;
  border-color: rgba(56, 189, 248, 0.3);
}

.video-source-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-source-placeholder {
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.5;
}

.video-source-actions {
  display: flex;
  gap: 10px;
}

/* -------------------------
   Audio Drop Zone
------------------------- */

.audio-upload-zone {
  width: 100%;
  height: 80px;
  background: #0f1424;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.audio-upload-zone:hover,
.audio-upload-zone.drag-over {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.05);
}

.audio-upload-zone.has-file {
  border-style: solid;
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(15, 23, 42, 0.8);
}

#audioPlaceholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 12px;
}

#audioPlaceholder .icon {
  font-size: 20px;
}

#audioFileInfo {
  display: flex; /* Hidden by default via JS */
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0 30px; /* Space for close btn */
}

.audio-name {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.audio-meta {
  color: #38bdf8;
  font-size: 11px;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
}

.btn-icon-close {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);

  background: none;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
}

.btn-icon-close:hover {
  color: #fff;
}

/* -------------------------
   Prompt / Inputs
------------------------- */

.textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 10px;
  border-radius: 8px;
  resize: vertical;
  font-family: inherit;
  font-size: 13px;
}

.textarea:focus {
  outline: none;
  border-color: #38bdf8;
}

/* -------------------------
   Generate strip (match Image Studio pill strip)
------------------------- */

.video-generate-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 999px;
  background: radial-gradient(
    circle at 0 0,
    rgba(248, 113, 113, 0.22),
    rgba(15, 23, 42, 0.96)
  );
  border: 1px solid rgba(55, 65, 81, 0.9);
}

/* Use the same shared button system: .btn primary / .btn ghost */
.video-generate-btn {
  flex: 1 1 auto;
  min-width: 140px;
  justify-content: center;
}

.video-stop-btn {
  flex: 0 0 auto;
}

.video-credit-est {
  margin-left: auto;
}

.video-price-pill {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(2, 6, 23, 0.35);
  color: rgba(226, 232, 240, 0.92);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  min-width: 86px;
  box-shadow: inset 0 0 0 1px rgba(2, 6, 23, 0.25);
}


/* Status pill/text (same semantics as image session state) */
.video-status {
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
  min-height: 20px;
}

.video-status.active {
  color: #38bdf8;
}
.video-status.error {
  color: #f87171;
}
.video-status.success {
  color: #4ade80;
}

/* -------------------------
   Gallery – framed thumbs (same as Image Studio)
------------------------- */

.video-gallery-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  padding: 8px 2px 0;
  overflow-y: auto;
}

/* Empty-state text */
.image-gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 0.75rem 0;
  font-size: 12px;
  color: var(--sub, #94a3b8);
}

/* If your video.js reuses Image Studio wrappers, keep them here too */
.image-thumb {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Video thumb uses same frame feel but 16:9 aspect */
.video-thumb-inner {
  position: relative;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 16 / 9;
  margin-inline: auto;

  border-radius: 0.9rem;
  overflow: hidden;

  background: radial-gradient(circle at top, #1e293b 0, #020617 60%, #000 100%);
  padding: 2px;
  box-shadow:
    0 0 0 1px rgba(148, 163, 184, 0.4),
    0 0 20px rgba(59, 130, 246, 0.2);
}

.video-thumb-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(148, 163, 184, 0.35);
  pointer-events: none;
}

.video-thumb-inner video {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 0.75rem;
  object-fit: cover;
}

/* Actions bar (same style as Image Studio) */
.image-thumb-actions {
  position: absolute;
  inset-inline: 6px;
  bottom: 6px;
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 2;
}

.image-thumb-action-btn {
  border: none;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.86);
  color: #e5e7eb;
  border: 1px solid rgba(148, 163, 184, 0.5);
  backdrop-filter: blur(6px);
}

.image-thumb-action-btn:hover {
  border-color: rgba(248, 113, 113, 0.9);
}

/* -------------------------
   Backwards compatibility (older markup)
   Keep these so existing HTML doesn’t break
------------------------- */

.video-result-card {
  background: #0f1424;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  overflow: hidden;
}

.video-result-player {
  width: 100%;
  aspect-ratio: 9 / 16; /* keep your current portrait default */
  background: #000;
  display: block;
}

.video-result-meta {
  padding: 10px;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.download-link {
  color: #38bdf8;
  text-decoration: none;
}

.download-link:hover {
  text-decoration: underline;
}

/* -------------------------
   Gallery picker modal (kept)
------------------------- */

.gallery-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
}

.gallery-picker-item {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
}

.gallery-picker-item:hover {
  border-color: #38bdf8;
}

.gallery-picker-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* -------------------------
   Dark scrollbars for video panel
------------------------- */

.video-panel ::-webkit-scrollbar {
  width: 8px;
}

.video-panel ::-webkit-scrollbar-track {
  background: transparent;
}

.video-panel ::-webkit-scrollbar-thumb {
  background: rgba(30, 41, 59, 0.9);
  border-radius: 999px;
}

/* -------------------------
   Mobile
------------------------- */

@media (max-width: 900px) {
  .video-column-left {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------
   Mobile (match Image Studio): stack Generate/Stop/Credits
--------------------------------------------------- */
@media (max-width: 680px) {
  .video-generate-strip {
    flex-wrap: wrap;
    border-radius: 18px;
  }

  .video-generate-btn,
  .video-stop-btn {
    width: 100%;
    min-width: 0;
  }

  .video-credit-est {
    width: 100%;
    margin-left: 0;
    text-align: left;
  }
}
