﻿/* ============ Reset & Base ============ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0b0d17;
  --bg-secondary: #11131f;
  --bg-card: #16182a;
  --bg-hover: #1e2040;
  --border-color: #2a2d4a;
  --border-active: #6c5ce7;
  --text-primary: #e8e9f3;
  --text-secondary: #8e90a6;
  --text-muted: #5c5e76;
  --accent: #6c5ce7;
  --accent-hover: #7f70f5;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --success: #00cec9;
  --warning: #fdcb6e;
  --error: #e74c3c;
  --gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ============ App Container ============ */
.app-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============ Header ============ */
.header {
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 32px;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 32px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo-text h1 {
  font-size: 22px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.model-badge {
  display: inline-block;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ============ Workspace Layout ============ */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: 70vh;
}

.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
}

.panel:hover {
  border-color: rgba(108, 92, 231, 0.3);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

/* ============ Upload Area ============ */
.upload-area {
  position: relative;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  cursor: pointer;
  transition: var(--transition);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.upload-area:hover {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.05);
}

.upload-area.drag-over {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.1);
  box-shadow: 0 0 30px var(--accent-glow);
}

.upload-placeholder {
  text-align: center;
  color: var(--text-muted);
}

.upload-icon {
  margin-bottom: 12px;
  opacity: 0.5;
}

.upload-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.upload-preview {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-preview img {
  max-width: 100%;
  max-height: 280px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.remove-btn:hover {
  background: var(--error);
}

/* ============ Form Elements ============ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: var(--transition);
  line-height: 1.5;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea::placeholder {
  color: var(--text-muted);
}

.slider-container {
  padding: 4px 0;
}

.form-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  outline: none;
  transition: var(--transition);
}

.form-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--gradient);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: var(--transition);
}

.form-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============ Buttons ============ */
.btn-primary {
  width: 100%;
  padding: 14px 24px;
  background: var(--gradient);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spinner-ring {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
}

.btn-icon:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

/* ============ Empty State ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon {
  margin-bottom: 20px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  max-width: 300px;
  margin: 0 auto;
}

/* ============ Task Progress ============ */
.task-progress {
  margin-bottom: 20px;
}

.progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.progress-title {
  font-size: 14px;
  font-weight: 600;
}

.progress-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.progress-badge.running {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent);
  animation: pulse-badge 2s infinite;
}

.progress-badge.succeeded {
  background: rgba(0, 206, 201, 0.15);
  color: var(--success);
}

.progress-badge.failed {
  background: rgba(231, 76, 60, 0.15);
  color: var(--error);
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-percent {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: right;
}

.progress-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

/* ============ Video Result ============ */
.result-video {
  margin-bottom: 20px;
}

.video-container {
  background: black;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-actions {
  display: flex;
  gap: 12px;
}

/* ============ History Section ============ */
.history-section {
  margin-top: 24px;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.history-header {
  margin-bottom: 12px;
}

.history-header h3 {
  font-size: 14px;
  color: var(--text-secondary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.history-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.history-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-primary);
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-prompt {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ============ Toast ============ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 280px;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--error);
}

.toast.warning {
  border-color: var(--warning);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============ Scrollbar ============ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}


/* ============ Grid Layout Adjustments ============ */
.task-card-header {
  padding: 6px 10px;
}
.task-thumb {
  width: 32px;
  height: 32px;
}
.task-prompt {
  font-size: 11px;
}
.task-meta {
  font-size: 9px;
}
.task-status-badge {
  font-size: 10px;
  padding: 2px 8px;
}
.task-card-body {
  padding: 6px 10px;
}
.task-card-actions {
  padding: 4px 10px;
}
.task-card-actions .btn-ghost {
  font-size: 11px;
  padding: 3px 8px;
}

@media (max-width: 1100px) {
  .task-list {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 600px) {
  .task-list {
    grid-template-columns: 1fr !important;
  }
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .model-badge {
    font-size: 10px;
    padding: 4px 10px;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding: 0 12px;
  }

  .panel {
    padding: 16px;
  }

  .video-actions {
    flex-direction: column;
  }
}

/* ============ Option Chips ============ */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.options-grid .form-group {
  margin-bottom: 0;
}

.option-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
  flex: 1;
  min-width: 0;
  text-align: center;
}

.chip:hover {
  border-color: var(--text-muted);
  color: var(--text-secondary);
}

.chip.active,
.chip:has(input:checked) {
  background: rgba(108, 92, 231, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 600px) {
  .options-grid {
    grid-template-columns: 1fr;
  }
}

/* ============ Multi-image Upload ============ */
.upload-preview-grid {
  width: 100%;
}

.thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.thumb-item {
  position: relative;
  width: calc(33.33% - 6px);
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  min-width: 80px;
}

.thumb-item:hover {
  border-color: var(--accent);
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-item .thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.6);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
}

.thumb-item:hover .thumb-remove {
  opacity: 1;
}

.add-more-btn {
  width: 100%;
  justify-content: center;
  padding: 8px;
  font-size: 13px;
}

/* ============ Task List ============ */
.task-list {
  display: grid;
  flex-direction:
  gap: 12px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
  grid-template-columns: repeat(3, 1fr);}

.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.task-card:hover {
  border-color: rgba(108, 92, 231, 0.3);
}

.task-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

.task-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.task-info {
  flex: 1;
  min-width: 0;
}

.task-prompt {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.task-status-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.task-status-badge.pending {
  background: rgba(108, 92, 231, 0.1);
  color: var(--accent);
}

.task-status-badge.running {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent);
  animation: pulse-badge 1.5s infinite;
}

.task-status-badge.succeeded {
  background: rgba(0, 206, 201, 0.15);
  color: var(--success);
}

.task-status-badge.failed {
  background: rgba(231, 76, 60, 0.15);
  color: var(--error);
}

.task-card-body {
  padding: 10px 14px;
}

.task-progress-bar {
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}

.task-progress-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

.task-progress-fill.succeeded {
  background: var(--success);
}

.task-progress-fill.failed {
  background: var(--error);
}

.task-card-video {
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  cursor: pointer;
  border-top: 1px solid var(--border-color);
}

.task-card-video video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.task-card-actions {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border-color);
}

.task-card-actions .btn-ghost {
  font-size: 12px;
  padding: 4px 10px;
}

/* ============ Video Modal ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90vw;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
}

.modal-body {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 300px;
}

.modal-body video {
  max-width: 100%;
  max-height: 65vh;
  border-radius: 4px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

/* ============ Submit Button Badge ============ */
.btn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}


/* ============ Grid Layout Adjustments ============ */
.task-card-header {
  padding: 6px 10px;
}
.task-thumb {
  width: 32px;
  height: 32px;
}
.task-prompt {
  font-size: 11px;
}
.task-meta {
  font-size: 9px;
}
.task-status-badge {
  font-size: 10px;
  padding: 2px 8px;
}
.task-card-body {
  padding: 6px 10px;
}
.task-card-actions {
  padding: 4px 10px;
}
.task-card-actions .btn-ghost {
  font-size: 11px;
  padding: 3px 8px;
}

@media (max-width: 1100px) {
  .task-list {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 600px) {
  .task-list {
    grid-template-columns: 1fr !important;
  }
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .model-badge {
    font-size: 10px;
    padding: 4px 10px;
  }
  .options-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding: 0 12px;
  }
  .panel {
    padding: 16px;
  }
  .modal-content {
    width: 98vw;
    border-radius: 8px;
  }
}






/* ============ Video Tooltip ============ */
.task-card-video {
  position: relative;
  cursor: pointer;
}
.task-card-video::after {
  content: attr(data-prompt);
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 11px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(4px);
  z-index: 2;
  line-height: 1.4;
}
.task-card-video:hover::after {
  opacity: 1;
}

