/* ============ 通用 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: #f5f7fa; color: #2c3e50; font-size: 14px; }

/* 顶部导航 */
.navbar {
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 24px;
  background: #fff; border-bottom: 1px solid #e8ecf0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.navbar .brand { font-weight: 600; font-size: 16px; color: #1a1a1a; }
.navbar .nav-links { display: flex; gap: 4px; }
.navbar .nav-links a { padding: 6px 12px; border-radius: 6px; text-decoration: none; color: #4a5568; font-size: 13px; }
.navbar .nav-links a:hover { background: #f0f2f5; }
.navbar .nav-links a.active { background: #e6f0ff; color: #1976d2; font-weight: 500; }
.navbar .spacer { flex: 1; }
.navbar .user-info { display: flex; align-items: center; gap: 12px; color: #4a5568; font-size: 13px; }
.navbar .btn-logout { padding: 4px 10px; background: #ff4d4f; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; }
.navbar .btn-logout:hover { background: #d9363e; }

/* 表单 */
.form-card { max-width: 380px; margin: 80px auto; padding: 32px; background: #fff; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.form-card h2 { text-align: center; margin-bottom: 24px; color: #1a1a1a; }
.form-card .field { margin-bottom: 16px; }
.form-card label { display: block; margin-bottom: 6px; font-size: 13px; color: #4a5568; }
.form-card input, .form-card select, .form-card textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 14px;
}
.form-card input:focus, .form-card select:focus, .form-card textarea:focus { outline: none; border-color: #1976d2; box-shadow: 0 0 0 2px rgba(25,118,210,0.12); }
.form-card button { width: 100%; padding: 10px; background: #1976d2; color: #fff; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; margin-top: 8px; }
.form-card button:hover { background: #1565c0; }
.form-card .err { color: #d32f2f; font-size: 12px; margin-top: 8px; text-align: center; min-height: 16px; }

/* 表格 */
.table-card { max-width: 900px; margin: 24px auto; padding: 24px; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.table-card h2 { margin-bottom: 16px; }
.table-card .toolbar { margin-bottom: 16px; display: flex; gap: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef0f3; }
table th { background: #fafbfc; color: #4a5568; font-weight: 500; }
.btn-sm { padding: 4px 10px; border: 1px solid #d9d9d9; background: #fff; border-radius: 4px; cursor: pointer; font-size: 12px; }
.btn-sm:hover { background: #f0f2f5; }
.btn-sm.danger { color: #d32f2f; border-color: #d32f2f; }
.btn-sm.danger:hover { background: #fff5f5; }
.btn-sm.primary { background: #1976d2; color: #fff; border-color: #1976d2; }
.btn-sm.primary:hover { background: #1565c0; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.tag-admin { background: #fff7e6; color: #ad6800; }
.tag-user { background: #e6f7ff; color: #096dd9; }
.tag-active { background: #f6ffed; color: #389e0d; }
.tag-disabled { background: #ffccc7; color: #cf1322; }

/* ============ 工作台 ============ */
.workspace-container { padding: 16px 24px 80px; }
.task-list { display: flex; flex-direction: column; gap: 16px; }
.task-row {
  display: flex; gap: 12px; align-items: stretch;
  background: #fff; border: 1px solid #e8ecf0; border-radius: 8px;
  padding: 12px; box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  min-width: max-content; overflow-x: auto;
}
.task-row .task-seq {
  flex: 0 0 auto; min-width: 40px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 600; color: #b0b8c1;
  border-right: 1px dashed #e8ecf0; padding-right: 8px;
}
/* 模板功能列 */
.tpl-col {
  flex: 0 0 220px; display: flex; flex-direction: column; gap: 8px;
  border-right: 1px dashed #e8ecf0; padding-right: 12px;
}
.tpl-col .tpl-title { font-size: 12px; color: #4a5568; font-weight: 500; margin-bottom: 4px; }
.tpl-col select { width: 100%; padding: 6px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 12px; }
.tpl-col select:disabled { background: #f5f5f5; cursor: not-allowed; }
.tpl-col .tpl-opts { font-size: 12px; color: #4a5568; padding: 4px 0; }
.tpl-col .tpl-opts label { display: flex; align-items: center; gap: 4px; padding: 2px 0; }
.tpl-col .tpl-opts input[type=checkbox] { margin: 0; }
.tpl-col input[type=text].filename { width: 100%; padding: 6px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 12px; }
.tpl-col .btn-generate { width: 100%; padding: 8px; background: #1976d2; color: #fff; border: none; border-radius: 4px; font-size: 13px; cursor: pointer; font-weight: 500; }
.tpl-col .btn-generate:hover { background: #1565c0; }
.tpl-col .btn-generate:disabled { background: #ccc; cursor: not-allowed; }
.tpl-col .btn-row { display: flex; gap: 4px; }
.tpl-col .btn-row button { flex: 1; padding: 6px; font-size: 12px; border: 1px solid #d9d9d9; background: #fff; border-radius: 4px; cursor: pointer; }
.tpl-col .btn-row button:hover { background: #f0f2f5; }
.tpl-col .progress-bar { height: 6px; background: #eef0f3; border-radius: 3px; overflow: hidden; }
.tpl-col .progress-bar .fill { height: 100%; background: #1976d2; width: 0%; transition: width 0.3s; }
.tpl-col .progress-text { font-size: 11px; color: #8a94a6; }

/* 通用模块 */
.module {
  flex: 0 0 220px; display: flex; flex-direction: column; gap: 6px;
  border-right: 1px dashed #e8ecf0; padding-right: 12px;
}
.module:last-child { border-right: none; padding-right: 0; }
.module .m-title { font-size: 12px; color: #4a5568; font-weight: 500; margin-bottom: 4px; }
.module .m-hint { font-size: 11px; color: #8a94a6; }

/* 图片模块（板块1/2/3） - 紧凑横条版 */
.img-module .drop-zone {
  flex: 0 0 auto; min-height: 56px; border: 1px dashed #c0c6cf; border-radius: 6px;
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; background: #fafbfc; font-size: 12px; color: #8a94a6; padding: 6px 10px;
  transition: all 0.2s;
}
.img-module .drop-zone:hover { border-color: #1976d2; background: #f0f7ff; }
.img-module .drop-zone .icon { font-size: 18px; color: #b0b8c1; }
.img-module .drop-zone .hint-text { white-space: nowrap; }
.img-module .batch-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border: 1px solid #d9d9d9; background: #fff; border-radius: 12px;
  font-size: 11px; cursor: pointer; color: #8a94a6; user-select: none;
  margin-left: 8px; transition: all 0.2s;
}
.img-module .batch-toggle:hover { border-color: #1976d2; color: #1976d2; }
.img-module .batch-toggle.on { background: #1976d2; color: #fff; border-color: #1976d2; }
.img-module .batch-toggle .dot { width: 6px; height: 6px; border-radius: 50%; background: #c0c6cf; }
.img-module .batch-toggle.on .dot { background: #fff; }
.img-module .img-list {
  display: flex; gap: 6px; margin-top: 6px; overflow-x: auto; padding-bottom: 4px;
  min-height: 86px;
}
.img-module .img-list .img-item {
  position: relative; flex: 0 0 80px; width: 80px; height: 80px;
  border-radius: 4px; overflow: hidden; border: 1px solid #e8ecf0; cursor: pointer;
}
.img-module .img-list .img-item:hover { border-color: #1976d2; }
.img-module .img-list .img-item img { width: 100%; height: 100%; object-fit: cover; }
.img-module .img-list .img-item .del {
  position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.6); color: #fff;
  font-size: 11px; width: 16px; height: 16px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; cursor: pointer; line-height: 1;
}
.img-module .img-list .img-item .del:hover { background: rgba(220,53,69,0.85); }

/* Lightbox 图片放大查看 */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 9999;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
  animation: fadein 0.2s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 4px; }
.lightbox .close-btn {
  position: absolute; top: 16px; right: 24px; color: #fff; font-size: 32px; cursor: pointer;
  line-height: 1; user-select: none;
}
.lightbox .nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%); color: #fff;
  font-size: 48px; cursor: pointer; padding: 16px; user-select: none;
}
.lightbox .nav-btn.prev { left: 16px; }
.lightbox .nav-btn.next { right: 16px; }
.lightbox .nav-btn:hover { color: #1976d2; }
.lightbox .caption { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; }

/* 提示词模块 */
.prompt-module textarea { width: 100%; flex: 1; min-height: 140px; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 12px; resize: vertical; font-family: inherit; }
.prompt-module textarea:focus { outline: none; border-color: #1976d2; }
.prompt-module .word-count { text-align: right; font-size: 11px; color: #8a94a6; }

/* 参数模块 */
.params-module label { display: block; font-size: 12px; color: #4a5568; margin-bottom: 2px; }
.params-module select, .params-module input { width: 100%; padding: 4px 6px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 12px; }
.params-module .field { margin-bottom: 8px; }

/* 结果模块 */
.result-module { flex: 0 0 260px; }
.result-module .result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; min-height: 140px; }
.result-module .result-grid .result-item { position: relative; aspect-ratio: 1; border-radius: 4px; overflow: hidden; border: 1px solid #e8ecf0; background: #fafbfc; }
.result-module .result-grid .result-item img { width: 100%; height: 100%; object-fit: cover; }
.result-module .result-grid .result-item .result-badge {
  position: absolute; top: 2px; left: 2px; background: #1976d2; color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 3px; z-index: 2;
  font-weight: 500; letter-spacing: 0.5px;
}
.result-module .result-grid .result-item .actions { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.6); display: flex; justify-content: space-around; padding: 2px 0; opacity: 0; transition: opacity 0.2s; }
.result-module .result-grid .result-item:hover .actions { opacity: 1; }
.result-module .result-grid .result-item .actions a { color: #fff; font-size: 11px; text-decoration: none; }
.result-module .result-grid .result-item .del {
  position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.6); color: #fff;
  font-size: 11px; width: 16px; height: 16px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; cursor: pointer; line-height: 1;
  z-index: 3; opacity: 0; transition: opacity 0.2s;
}
.result-module .result-grid .result-item:hover .del { opacity: 1; }
.result-module .result-grid .result-item .del:hover { background: rgba(220,53,69,0.85); }
.result-module .result-grid .empty { grid-column: span 2; display: flex; align-items: center; justify-content: center; color: #b0b8c1; font-size: 12px; }

/* 新增任务按钮 */
.add-task-bar { margin-top: 16px; text-align: center; }
.add-task-bar button {
  padding: 10px 24px; background: #fff; border: 1px dashed #1976d2; color: #1976d2;
  border-radius: 6px; font-size: 14px; cursor: pointer; font-weight: 500;
}
.add-task-bar button:hover { background: #f0f7ff; }

/* Toast */
.toast { position: fixed; top: 20px; right: 20px; padding: 12px 20px; border-radius: 6px; color: #fff; font-size: 13px; z-index: 9999; opacity: 0; transition: opacity 0.3s; }
.toast.success { background: #52c41a; }
.toast.error { background: #ff4d4f; }
.toast.show { opacity: 1; }

/* ============ 图片编辑器（画笔遮蔽）============ */
.ie-overlay { position: fixed; inset: 0; z-index: 10000; background: #eceef1; display: none; flex-direction: column; animation: fadein 0.15s; }
.ie-topbar { height: 52px; background: #fff; border-bottom: 1px solid #e4e7ec; display: flex; align-items: center; padding: 0 16px; gap: 6px; flex: 0 0 auto; }
.ie-topbar .ie-title { font-size: 15px; font-weight: 600; color: #1a1a1a; margin-right: 4px; white-space: nowrap; }
.ie-topbar .ie-hint { font-size: 12px; color: #8a94a6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ie-spacer { flex: 1; }
.ie-btn { width: 34px; height: 34px; border: none; background: transparent; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: #4a5568; padding: 0; }
.ie-btn:hover { background: #f0f2f5; }
.ie-btn:disabled { color: #c8cdd5; cursor: not-allowed; background: transparent; }
.ie-btn svg { width: 20px; height: 20px; }
.ie-zoom-pct { min-width: 46px; text-align: center; font-size: 12px; color: #4a5568; user-select: none; }
.ie-sep { width: 1px; height: 20px; background: #e4e7ec; margin: 0 4px; flex: 0 0 auto; }
.ie-btn-save { height: 34px; padding: 0 16px; background: #1976d2; color: #fff; border: none; border-radius: 8px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ie-btn-save:hover { background: #1565c0; }
.ie-btn-save:disabled { background: #9ec4e8; cursor: not-allowed; }
.ie-btn-save svg { width: 16px; height: 16px; }

.ie-body { flex: 1; display: flex; min-height: 0; position: relative; }
.ie-sidebar { width: 52px; background: #fff; border-right: 1px solid #e4e7ec; display: flex; flex-direction: column; align-items: center; padding-top: 12px; gap: 8px; flex: 0 0 auto; z-index: 2; }
.ie-tool { width: 40px; height: 40px; border: none; border-radius: 10px; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #4a5568; padding: 0; }
.ie-tool:hover { background: #f0f2f5; }
.ie-tool.active { background: #1976d2; color: #fff; }
.ie-tool svg { width: 20px; height: 20px; }

.ie-canvas-wrap { flex: 1; position: relative; min-width: 0; overflow: hidden; }
.ie-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* 画笔设置面板 */
.ie-brush-panel { position: absolute; top: 14px; left: 66px; width: 236px; background: #fff; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,0.12); padding: 12px 14px; z-index: 3; user-select: none; }
.ie-brush-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; color: #1a1a1a; margin-bottom: 10px; }
.ie-brush-head .x { cursor: pointer; color: #8a94a6; font-size: 16px; line-height: 1; }
.ie-brush-head .x:hover { color: #4a5568; }
.ie-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ie-row label { flex: 0 0 54px; font-size: 12px; color: #4a5568; }
.ie-row input[type=range] { flex: 1; min-width: 0; accent-color: #1976d2; cursor: pointer; }
.ie-row .val { flex: 0 0 42px; text-align: right; font-size: 12px; color: #4a5568; }
.ie-color-row { display: flex; align-items: center; gap: 8px; }
.ie-color-row input[type=color] { width: 32px; height: 32px; border: 1px solid #e4e7ec; border-radius: 6px; padding: 2px; cursor: pointer; background: #fff; }
.ie-color-row input[type=text] { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid #e4e7ec; border-radius: 6px; font-size: 12px; }
.ie-color-row input[type=text]:focus { outline: none; border-color: #1976d2; }
.ie-swatches { display: flex; gap: 8px; margin-top: 10px; }
.ie-swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid #fff; box-shadow: 0 0 0 1px #d9dde3; }
.ie-swatch.active { box-shadow: 0 0 0 2px #1976d2; }

/* 图片右键菜单 */
#img-edit-menu { position: fixed; z-index: 10001; background: #fff; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.14); padding: 4px; display: none; min-width: 138px; }
#img-edit-menu .item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: #2c3e50; border-radius: 6px; cursor: pointer; }
#img-edit-menu .item svg { width: 15px; height: 15px; }
#img-edit-menu .item:hover { background: #e6f0ff; color: #1976d2; }
