/* ===== PSD/PPT 生成工作区 ===== */
.psdppt-container {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(135deg, #0b1220 0%, #111827 100%);
}
[data-theme="light"] .psdppt-container {
  background: linear-gradient(135deg, #e8ecf4 0%, #dfe6f3 100%);
}

/* ===== 主面板：左右分栏 ===== */
.psdppt-panel {
  flex: 1;
  display: flex;
  gap: 1px;
  overflow: hidden;
  min-height: 0;
}

/* --- 左侧表单区 --- */
.psdppt-left {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 0;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.06);
  background: rgba(15,23,42,0.4);
}
[data-theme="light"] .psdppt-left {
  background: rgba(255,255,255,0.4);
  border-right-color: rgba(0,0,0,0.06);
}

/* --- 右侧任务列表区 --- */
.psdppt-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  min-width: 0;
}

/* ===== 表单样式 ===== */
.psdppt-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.psdppt-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: -8px;
}

.psdppt-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.psdppt-required {
  color: var(--red, #f38ba8);
  font-weight: 500;
  font-size: 11px;
}

.psdppt-optional {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
}

.psdppt-experimental {
  font-size: 10px;
  color: var(--warn, #d29922);
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 8px;
  background: rgba(210,153,34,0.15);
}

/* --- 提示词输入框 --- */
.psdppt-prompt {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.psdppt-prompt:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.psdppt-prompt::placeholder {
  color: var(--text-dim);
}
[data-theme="light"] .psdppt-prompt {
  background: rgba(0,0,0,0.02);
  border-color: rgba(0,0,0,0.1);
}

/* ===== 上传区 ===== */
.psdppt-upload-stage {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  min-height: 72px;
}

.psdppt-upload-box {
  width: 72px;
  height: 72px;
  border: 2px dashed rgba(255,255,255,0.12);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all .25s;
  background: rgba(255,255,255,0.02);
  flex-shrink: 0;
}
.psdppt-upload-box:hover {
  border-color: #3b82f6;
  background: rgba(59,130,246,0.04);
  transform: translateY(-1px);
}
.psdppt-upload-box.dragover {
  border-color: #3b82f6;
  background: rgba(59,130,246,0.08);
  border-style: solid;
  transform: scale(1.08);
}

.psdppt-upload-icon {
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
}

.psdppt-upload-text {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
}

.psdppt-upload-hint {
  display: none;
}

[data-theme="light"] .psdppt-upload-box {
  border-color: rgba(0,0,0,0.12);
  background: rgba(0,0,0,0.02);
}

/* ===== 参考图列表 ===== */
.psdppt-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.psdppt-ref-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--bg-deep);
  flex-shrink: 0;
  transition: border-color .15s;
}
.psdppt-ref-item:hover {
  border-color: #3b82f6;
}

.psdppt-ref-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.psdppt-ref-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.psdppt-ref-item:hover .psdppt-ref-del {
  opacity: 1;
}
.psdppt-ref-del:hover {
  background: var(--red, #f85149);
}

/* --- 参考图计数提示 --- */
.psdppt-ref-count {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 0;
}

/* ===== 提交按钮 ===== */
.psdppt-submit-btn {
  width: 100%;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
  margin-top: 4px;
}
.psdppt-submit-btn:hover {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  box-shadow: 0 4px 14px rgba(59,130,246,0.4);
  transform: translateY(-1px);
}
.psdppt-submit-btn:active {
  transform: translateY(0);
}
.psdppt-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

/* ===== 右侧任务列表 ===== */
.psdppt-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.psdppt-active-tasks {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
}

.psdppt-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
[data-theme="light"] .psdppt-history {
  border-top-color: rgba(0,0,0,0.08);
}

.psdppt-task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.psdppt-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 0 4px;
}

/* 当前任务卡片带蓝色左边框 */
.psdppt-active-tasks .psdppt-task-card {
  border-left: 3px solid #3b82f6;
}

/* 历史记录卡片更低调 */
.psdppt-history .psdppt-task-card {
  opacity: 0.85;
}

/* ===== 空状态 ===== */
.psdppt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}

.psdppt-empty-icon {
  font-size: 40px;
  opacity: 0.3;
  line-height: 1;
}

.psdppt-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.psdppt-empty-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 280px;
}

/* ===== 任务卡片 ===== */
.psdppt-task-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow .2s, border-color .2s;
}
.psdppt-task-card:hover {
  border-color: rgba(59,130,246,0.3);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

/* --- 卡片头部 --- */
.psdppt-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.psdppt-card-kind {
  font-weight: 600;
  color: var(--blue, #58a6ff);
  padding: 2px 8px;
  background: rgba(59,130,246,0.12);
  border-radius: 6px;
  font-size: 11px;
}

.psdppt-card-elapsed {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.psdppt-card-del {
  margin-left: 8px;
  padding: 0 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.psdppt-card-del:hover {
  color: #ff6b6b;
  background: rgba(255,107,107,0.12);
}

/* --- 状态徽章 --- */
.psdppt-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
  line-height: 1.4;
}
.psdppt-badge.queued {
  color: var(--text-muted);
  background: rgba(139,148,158,0.12);
}
.psdppt-badge.running {
  color: var(--blue, #58a6ff);
  background: rgba(88,166,255,0.12);
}
.psdppt-badge.success {
  color: var(--green, #a6e3a1);
  background: rgba(35,134,54,0.12);
}
.psdppt-badge.error {
  color: var(--red, #f38ba8);
  background: rgba(248,81,73,0.1);
}
.psdppt-badge.timeout {
  color: var(--warn, #d29922);
  background: rgba(210,153,34,0.12);
}

/* --- 旋转动画（running 用） --- */
.psdppt-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: psdppt-spin .8s linear infinite;
}
@keyframes psdppt-spin {
  to { transform: rotate(360deg); }
}

/* --- 提示词预览 --- */
.psdppt-card-prompt {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  padding: 8px 10px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="light"] .psdppt-card-prompt {
  background: rgba(0,0,0,0.03);
}

/* --- 进度条 --- */
.psdppt-progress {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.psdppt-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 2px;
  animation: psdppt-progress-pulse 1.5s ease-in-out infinite;
  transition: width .3s ease;
}
@keyframes psdppt-progress-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* --- 错误信息 --- */
.psdppt-card-error {
  font-size: 12px;
  color: var(--red, #f38ba8);
  line-height: 1.5;
  padding: 8px 10px;
  background: rgba(248,81,73,0.08);
  border-radius: 6px;
}

/* --- 下载按钮区 --- */
.psdppt-card-downloads {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.psdppt-dl-btn {
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue, #58a6ff);
  background: transparent;
  border: 1px solid var(--blue, #58a6ff);
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.psdppt-dl-btn:hover {
  color: #fff;
  background: var(--blue, #58a6ff);
}
.psdppt-dl-btn.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border-color: transparent;
}
.psdppt-dl-btn.primary:hover {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

/* ===== 历史记录加载状态 ===== */
.psdppt-history-loading,
.psdppt-history-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ===== 调试日志面板 ===== */
.psdppt-log-box {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
  flex-shrink: 0;
  max-height: 240px;
  transition: max-height .25s ease;
}
.psdppt-log-box.collapsed {
  max-height: 38px;
}
.psdppt-log-box.collapsed .psdppt-log-list,
.psdppt-log-box.collapsed .psdppt-log-tip {
  display: none;
}

.psdppt-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
[data-theme="light"] .psdppt-log-header {
  background: rgba(0,0,0,0.04);
}

.psdppt-log-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.psdppt-log-actions {
  display: flex;
  gap: 6px;
}

.psdppt-log-btn {
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s;
}
.psdppt-log-btn:hover {
  color: var(--text);
  border-color: var(--blue, #58a6ff);
  background: rgba(59,130,246,0.08);
}

.psdppt-log-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.6;
  background: rgba(0,0,0,0.4);
  min-height: 80px;
}
[data-theme="light"] .psdppt-log-list {
  background: rgba(0,0,0,0.03);
}
.psdppt-log-list::-webkit-scrollbar {
  width: 6px;
}
.psdppt-log-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}

.psdppt-log-line {
  display: flex;
  gap: 8px;
  padding: 1px 0;
  word-break: break-all;
}
.psdppt-log-ts {
  color: var(--text-dim);
  flex-shrink: 0;
  font-size: 10px;
  padding-top: 1px;
}
.psdppt-log-msg {
  flex: 1;
  color: var(--text);
  white-space: pre-wrap;
}

/* 日志类型颜色 */
.psdppt-log-line.info .psdppt-log-msg { color: var(--text); }
.psdppt-log-line.req .psdppt-log-msg { color: var(--blue, #58a6ff); }
.psdppt-log-line.success .psdppt-log-msg { color: var(--green, #a6e3a1); }
.psdppt-log-line.error .psdppt-log-msg { color: var(--red, #f38ba8); }
.psdppt-log-line.warn .psdppt-log-msg { color: var(--warn, #d29922); }

.psdppt-log-tip {
  padding: 6px 12px;
  font-size: 10px;
  color: var(--warn, #d29922);
  background: rgba(210,153,34,0.08);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===== 响应式：移动端上下布局 ===== */
@media (max-width: 768px) {
  .psdppt-panel {
    flex-direction: column;
  }

  .psdppt-left {
    width: 100%;
    flex-shrink: 1;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 16px;
    max-height: 50%;
  }
  [data-theme="light"] .psdppt-left {
    border-bottom-color: rgba(0,0,0,0.06);
  }

  .psdppt-right {
    padding: 16px;
  }

  .psdppt-upload-stage {
    min-height: 140px;
  }

  .psdppt-log-box {
    max-height: 200px;
  }
}