/* CSS Variables */
:root {
  --bg-dark: #0a0a0f;
  --bg-card: #12121a;
  --bg-elevated: #1a1a24;
  --bg-hover: #22222e;
  --border-color: #2a2a3a;
  --border-light: #3a3a4a;
  
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #5a5a70;
  
  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-success: #10b981;
  --accent-success-hover: #34d399;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  
  --column-upload-width: 280px;
  --column-tasks-width: 320px;
  --toolbar-height: 56px;
  
  --font-sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Three Column Layout */
.app-container.three-column {
  display: flex;
  height: 100vh;
  background: 
    radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(16, 185, 129, 0.06) 0%, transparent 50%),
    var(--bg-dark);
}

/* Column Base */
.column {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
}

.column-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.column-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Column 1: Upload */
.column-upload {
  width: var(--column-upload-width);
  flex-shrink: 0;
}

.column-upload .column-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo svg {
  width: 24px;
  height: 24px;
  color: var(--accent-primary);
}

.logo span {
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Section Title */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.section-title svg {
  width: 14px;
  height: 14px;
}

/* Upload Zone */
.upload-section {
  flex-shrink: 0;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 30px 16px;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--bg-elevated);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.05);
}

.upload-zone.dragover {
  transform: scale(1.02);
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.upload-zone:hover .upload-icon {
  color: var(--accent-primary);
}

.upload-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

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

/* URL Section */
.url-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.url-input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.url-input-group textarea {
  flex: 1;
  min-height: 100px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  resize: none;
  transition: border-color var(--transition-fast);
}

.url-input-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.url-input-group textarea::placeholder {
  color: var(--text-muted);
}

/* Column 2: Tasks */
.column-tasks {
  width: var(--column-tasks-width);
  flex-shrink: 0;
}

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

.tasks-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tasks-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.tasks-title svg {
  width: 16px;
  height: 16px;
  color: var(--accent-primary);
}

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

.column-tasks .column-content {
  padding: 12px;
}

/* Tasks List */
.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.task-card:hover {
  border-color: var(--accent-primary);
  transform: translateX(2px);
}

.task-card.selected {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.task-card-filename {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.task-card-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 8px;
}

.task-card-status.pending {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-warning);
}

.task-card-status.processing {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-primary);
}

.task-card-status.completed {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-success);
}

.task-card-status.failed {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-danger);
}

.task-card-status.processing::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border: 1.5px solid var(--accent-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.task-card-preview {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.task-card-preview img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-dark);
}

.task-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.task-card-time {
  font-size: 10px;
  color: var(--text-muted);
}

.task-card-error {
  font-size: 10px;
  color: var(--accent-danger);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 增强任务标识 */
.task-enhanced-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  font-size: 10px;
}

/* 增强任务卡片样式 */
.task-card.enhanced {
  border-color: var(--accent-warning);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
}

.task-card.enhanced:hover {
  border-color: var(--accent-warning);
}

.task-card.enhanced .task-card-filename {
  color: var(--accent-warning);
}

.task-card-actions {
  display: flex;
  gap: 4px;
}

.task-card-actions .btn {
  flex: 1;
  padding: 4px 8px;
  font-size: 10px;
}

.task-card-actions .btn svg {
  width: 12px;
  height: 12px;
}

/* Empty tasks state */
.tasks-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  color: var(--text-muted);
  text-align: center;
}

.tasks-empty svg {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.tasks-empty p {
  font-size: 12px;
}

/* Column 3: Workspace */
.column-workspace {
  flex: 1;
  min-width: 0;
  border-right: none;
}

/* Toolbar */
.toolbar {
  height: var(--toolbar-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  flex-shrink: 0;
}

.toolbar-left h2 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-right {
  display: flex;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

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

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.btn-success {
  background: var(--accent-success);
  border-color: var(--accent-success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: var(--accent-success-hover);
  border-color: var(--accent-success-hover);
}

.btn-small {
  padding: 5px 10px;
  font-size: 11px;
}

.btn-small svg {
  width: 14px;
  height: 14px;
}

.btn-icon {
  padding: 6px;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

.btn-block {
  width: 100%;
}

/* 增强按钮 - 渐变色突出显示 */
.btn-enhance {
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  border: none;
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.btn-enhance:hover:not(:disabled) {
  background: linear-gradient(135deg, #fbbf24 0%, #f87171 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-enhance svg {
  width: 16px;
  height: 16px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Workspace */
.workspace {
  flex: 1;
  display: flex;
  background: var(--bg-dark);
  overflow: hidden;
  position: relative;
}

/* Empty State in Workspace */
.workspace > .empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Grid Display - 四宫格 */
/* Grid Display - 2x3 六宫格 */
.grid-display {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.grid-item {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

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

.grid-label {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(10, 10, 15, 0.8);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  z-index: 1;
  backdrop-filter: blur(4px);
}

.grid-item img {
  flex: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.grid-item img:hover {
  transform: scale(1.02);
}

/* 四宫格下载按钮 */
.grid-download-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.9);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
  z-index: 2;
}

.grid-download-btn svg {
  width: 18px;
  height: 18px;
}

.grid-item:hover .grid-download-btn {
  opacity: 1;
}

.grid-download-btn:hover {
  background: var(--accent-success);
  transform: scale(1.1);
}

/* 空白格子样式 */
.grid-item-empty {
  background: var(--bg-dark);
  border: 1px dashed var(--border-color);
  opacity: 0.5;
}

/* Result Display - 保留用于单图模式 */
.result-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  background: 
    linear-gradient(45deg, var(--bg-elevated) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg-elevated) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg-elevated) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg-elevated) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: var(--bg-dark);
}

.result-display img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

/* Compare Display */
.compare-display {
  flex: 1;
  display: flex;
  gap: 20px;
  padding: 20px;
  overflow: auto;
  background: var(--bg-dark);
}

.compare-display.horizontal {
  flex-direction: row;
}

.compare-display.vertical {
  flex-direction: column;
}

.compare-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  background: 
    linear-gradient(45deg, var(--bg-elevated) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg-elevated) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg-elevated) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg-elevated) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: var(--bg-dark);
  border-radius: var(--radius-md);
  padding: 15px;
}

.compare-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  padding: 4px 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

.compare-item img {
  max-width: 100%;
  max-height: calc(100% - 40px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
}

.empty-state .hint {
  font-size: 12px;
  margin-top: 4px;
  opacity: 0.7;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.loading-overlay.visible {
  display: flex;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

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

.loading-text {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
}

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

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

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

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

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

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

.toast.warning {
  border-left: 3px solid var(--accent-warning);
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.toast.error .toast-icon {
  color: var(--accent-danger);
}

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

.toast-message {
  font-size: 13px;
  color: var(--text-primary);
}

/* Image Modal - 图片预览弹窗 */
.image-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.image-modal.visible {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-image-container {
  overflow: auto;
  max-width: 90vw;
  max-height: calc(90vh - 70px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-image-container.zoomed {
  cursor: grab;
}

.modal-image-container.zoomed:active {
  cursor: grabbing;
}

.modal-content img {
  max-width: 100%;
  max-height: calc(90vh - 70px);
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  transition: none;
}

.modal-content img.zoomed {
  max-width: none;
  max-height: none;
}

.modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--accent-danger);
  border-color: var(--accent-danger);
}

.modal-close svg {
  width: 18px;
  height: 18px;
  }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* Modal Toolbar */
.modal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.modal-tool-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.modal-tool-btn:active {
  transform: scale(0.95);
}

.modal-tool-btn svg {
  width: 20px;
  height: 20px;
}

.modal-zoom-level {
  min-width: 50px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.modal-toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 4px;
}

/* Responsive */
@media (max-width: 1000px) {
  .column-upload {
    width: 240px;
  }
  
  .column-tasks {
    width: 280px;
  }
  }
  
@media (max-width: 800px) {
  .app-container.three-column {
    flex-direction: column;
  }
  
  .column-upload,
  .column-tasks {
    width: 100%;
    max-height: 200px;
  }
  
  .column-workspace {
    flex: 1;
  }
}
