/* ============================================================
   E8 — Video Generation Workspace UI
   ============================================================ */

/* -- Video Studio Container -- */
.video-studio {
  max-width: var(--max-content-w);
  margin: 0 auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.video-studio-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.video-studio-header h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: 0;
}
.video-studio-header .model-card-mini {
  margin-left: auto;
}

/* -- Mode Selector -- */
.video-mode-tabs {
  display: flex;
  gap: var(--space-1);
  padding: 3px;
  background: var(--bg-inset);
  border-radius: var(--radius-md);
  width: fit-content;
}
.video-mode-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: var(--control-height-md);
}
.video-mode-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-panel);
}
.video-mode-tab.active {
  background: var(--bg-panel-solid);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.video-mode-tab svg {
  width: 16px;
  height: 16px;
}

/* -- Image Upload for i2v -- */
.video-image-upload {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 2px dashed var(--border-soft);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  cursor: pointer;
  min-height: 80px;
}
.video-image-upload:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.video-image-upload.has-image {
  border-style: solid;
  border-color: var(--accent-soft);
  cursor: default;
}
.video-image-thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}
.video-image-info {
  flex: 1;
  min-width: 0;
}
.video-image-info .filename {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-image-info .filemeta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}
.video-image-actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}
.video-image-actions button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--bg-inset);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}
.video-image-actions button:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.video-image-actions button svg { width: 14px; height: 14px; }

.video-upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.video-upload-placeholder svg {
  width: 28px;
  height: 28px;
  opacity: 0.5;
}

/* -- Prompt Area -- */
.video-prompt-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.video-prompt-area label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}
.video-prompt-input {
  width: 100%;
  min-height: 100px;
  max-height: 200px;
  padding: var(--space-3);
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: inherit;
  line-height: var(--leading-normal);
  resize: vertical;
  outline: none;
  transition: var(--transition-fast);
}
.video-prompt-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}

/* -- Parameters Grid -- */
.video-params {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
}
.video-param {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.video-param label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.video-param select,
.video-param input {
  height: var(--control-height-md);
  padding: 0 var(--space-3);
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
  transition: var(--transition-fast);
}
.video-param select:focus,
.video-param input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}

/* Duration slider */
.video-duration-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.video-duration-wrap input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: var(--border-soft);
  border-radius: 2px;
  outline: none;
  border: none;
  padding: 0;
}
.video-duration-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.video-duration-val {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--accent);
  min-width: 28px;
  text-align: right;
}

/* -- Advanced Params (collapsible) -- */
.video-advanced-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}
.video-advanced-toggle:hover { color: var(--text-secondary); }
.video-advanced-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform var(--duration-fast) var(--ease-standard);
}
.video-advanced-toggle.open svg {
  transform: rotate(90deg);
}
.video-advanced-params {
  display: none;
  padding-top: var(--space-2);
}
.video-advanced-params.show {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
}

/* -- Generate Button -- */
.video-generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  height: var(--control-height-lg);
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--text-inverse, #fff);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: var(--transition-fast);
}
.video-generate-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.video-generate-btn:active {
  transform: scale(0.98);
}
.video-generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.video-generate-btn svg { width: 18px; height: 18px; }

/* -- Model Card -- */
.video-model-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
}
.video-model-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.video-model-icon svg { width: 20px; height: 20px; }
.video-model-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.video-model-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}
.video-model-tags {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-1);
  flex-wrap: wrap;
}
.video-model-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: var(--weight-medium);
}

/* -- Generation Progress -- */
.video-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  text-align: center;
}
.video-progress-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
.video-progress-stage {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}
.video-progress-detail {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.video-progress-bar {
  height: 4px;
  background: var(--bg-inset);
  border-radius: 2px;
  overflow: hidden;
}
.video-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 2px;
  animation: videoProgressFlow 2s ease-in-out infinite;
}
@keyframes videoProgressFlow {
  0% { width: 10%; opacity: 0.8; }
  50% { width: 70%; opacity: 1; }
  100% { width: 10%; opacity: 0.8; }
}

/* -- Result Card -- */
.video-result {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
}
.video-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.video-result-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.video-result-title svg { width: 16px; height: 16px; color: var(--success); }

.video-player-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
}
.video-player-wrap video {
  width: 100%;
  display: block;
  max-height: 480px;
  object-fit: contain;
}
.video-player-wrap video::-webkit-media-controls {
  /* Keep native controls for simplicity */
}

.video-result-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.video-action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: var(--transition-fast);
}
.video-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.video-action-btn svg { width: 14px; height: 14px; }

.video-result-meta {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
}
.video-result-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* -- Video Details (collapsible) -- */
.video-details-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
}
.video-details-toggle:hover { color: var(--text-secondary); }
.video-details-content {
  display: none;
  padding: var(--space-2) 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.6;
}
.video-details-content.show { display: block; }

/* -- Error Card -- */
.video-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--danger-soft);
  border: 1px solid rgba(213, 85, 98, 0.2);
  border-radius: var(--radius-md);
}
.video-error-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--danger-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  flex-shrink: 0;
}
.video-error-icon svg { width: 18px; height: 18px; }
.video-error-msg {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--danger);
}
.video-error-detail {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}
.video-error-retry {
  margin-top: var(--space-2);
}

/* -- History list -- */
.video-history {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.video-history-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}
.video-history-item:hover {
  background: var(--bg-inset);
}
.video-history-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xs);
  background: var(--bg-inset);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  overflow: hidden;
}
.video-history-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-history-info {
  flex: 1;
  min-width: 0;
}
.video-history-prompt {
  font-size: var(--text-xs);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-history-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* -- Responsive -- */
@media (max-width: 640px) {
  .video-params { grid-template-columns: 1fr 1fr; }
  .video-advanced-params.show { grid-template-columns: 1fr 1fr; }
  .video-result-actions { flex-direction: column; }
  .video-result-actions .video-action-btn { width: 100%; justify-content: center; }
}
