/* =====================================================
   多模态随心生成 · 千面 Dark OLED 设计系统
   ===================================================== */

/* ---------- 字体加载 ---------- */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ---------- 设计 Token ---------- */
:root {
  /* 背景层级 */
  --bg-primary: #0A0A0F;
  --bg-card: #13131A;
  --bg-elevated: #1C1C26;
  --bg-hover: #23232F;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  /* 边框 */
  --border: #2A2A38;
  --border-strong: #3A3A4A;
  --border-focus: #6366F1;

  /* 文字 */
  --text-primary: #F4F4F5;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;
  --text-disabled: #52525B;

  /* 品牌色 - 靛蓝 + 琥珀 */
  --accent: #6366F1;
  --accent-hover: #818CF8;
  --accent-active: #4F46E5;
  --accent-soft: rgba(99, 102, 241, 0.12);

  --amber: #F59E0B;
  --amber-hover: #FBBF24;

  /* 状态色 */
  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --info: #3B82F6;
  --info-soft: rgba(59, 130, 246, 0.12);
  --neutral: #71717A;
  --neutral-soft: rgba(113, 113, 122, 0.12);

  /* 字体 */
  --font-sans: 'IBM Plex Sans', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', 'Consolas', 'Courier New', monospace;

  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* 间距 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 48px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 16px rgba(99, 102, 241, 0.25);

  /* 动效 */
  --t-fast: 150ms ease-out;
  --t-base: 200ms ease-in-out;
  --t-slow: 300ms ease-in-out;
}

/* ---------- Reset ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  overflow-x: hidden;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ---------- 布局 ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.app-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--amber) 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-glow);
}

.app-logo-text {
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-stats {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.stat-pill-value {
  color: var(--text-primary);
  font-weight: 600;
}

.stat-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

.stat-pill-dot.running { background: var(--info); }
.stat-pill-dot.failed { background: var(--danger); }

/* ---------- 主内容 ---------- */
.app-main {
  flex: 1;
  padding: var(--space-5) var(--space-6);
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
}

.tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast);
  position: relative;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.tab.active .tab-count {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex: 1;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  transition: all var(--t-fast);
}

.filter-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.filter-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 0 0 1px var(--accent-active);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

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

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid transparent;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ---------- 任务列表 ---------- */
.task-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.task-table-empty {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--text-muted);
}

.task-table-empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-3);
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-disabled);
}

.task-table-empty-title {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.task-table-empty-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.task-table table {
  width: 100%;
  border-collapse: collapse;
}

.task-table thead th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.task-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}

.task-table tbody tr:hover {
  background: var(--bg-elevated);
}

.task-table tbody tr:last-child {
  border-bottom: none;
}

.task-table tbody td {
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: middle;
}

.col-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-name {
  font-weight: 500;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-model {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.col-time {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.col-actions .btn {
  margin-left: 4px;
}

/* ---------- 状态徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-pending {
  background: var(--neutral-soft);
  color: var(--text-secondary);
}
.badge-pending .badge-dot { background: var(--neutral); }

.badge-running {
  background: var(--info-soft);
  color: var(--info);
}
.badge-running .badge-dot {
  background: var(--info);
  animation: pulse 1.2s ease-in-out infinite;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}
.badge-success .badge-dot { background: var(--success); }

.badge-failed {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-failed .badge-dot { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

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

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------- 抽屉 ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 201;
  transform: translateX(100%);
  transition: transform var(--t-slow);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.drawer-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--t-fast);
}

.drawer-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

.drawer-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  background: var(--bg-card);
}

/* ---------- 表单 ---------- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-label-required::after {
  content: ' *';
  color: var(--danger);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--t-fast);
  font-family: var(--font-sans);
}

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

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-disabled);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.form-hint {
  margin-top: var(--space-1);
  font-size: 11px;
  color: var(--text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}
.checkbox-row:hover {
  border-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.04);
}
.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
  margin: 0;
}
.checkbox-row span {
  line-height: 1;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.radio-group {
  display: flex;
  gap: var(--space-2);
}

.radio-card {
  flex: 1;
  padding: var(--space-3);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.radio-card:hover {
  border-color: var(--border-strong);
}

.radio-card input {
  display: none;
}

.radio-card.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.radio-card-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.radio-card.selected .radio-card-icon {
  background: var(--accent);
  color: white;
}

.radio-card-text {
  flex: 1;
}

.radio-card-title {
  font-size: 13px;
  font-weight: 500;
}

.radio-card-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- 模态框（任务详情/结果预览） ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

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

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

.modal-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

.detail-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--space-3) var(--space-4);
  font-size: 13px;
}

.detail-label {
  color: var(--text-muted);
  font-weight: 500;
}

.detail-value {
  color: var(--text-primary);
  font-family: var(--font-mono);
  word-break: break-all;
}

.detail-prompt {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
}

.result-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  min-height: 200px;
}

.result-preview img,
.result-preview video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius-sm);
}

/* ---------- 预览多图网格 ---------- */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  max-width: 90vw;
  max-height: 75vh;
  overflow-y: auto;
  padding: var(--space-2);
}
.preview-grid-item {
  position: relative;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.preview-grid-item:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
}
.preview-grid-item img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  max-height: none;
}
.preview-grid-label {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  min-width: 240px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  animation: slideInRight var(--t-base);
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--info); }

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

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .app-header {
    padding: var(--space-3) var(--space-4);
  }
  .app-main {
    padding: var(--space-4);
  }
  .header-stats {
    display: none;
  }
  .drawer {
    width: 100%;
  }
  .task-table {
    overflow-x: auto;
  }
  .task-table table {
    min-width: 720px;
  }
  .col-id, .col-model, .col-time {
    font-size: 10px;
  }
}
