/* ============================================================
 * 灵音托管引擎自动化工作台 - 每日任务待办工作台 (comp-todo-workbench.css)
 * 阶段三：任务管理组件
 * 挂载点：#mount-todo-workbench
 * 功能：任务增删勾选、进度统计、AI指令生成、跨天归档
 * ============================================================ */

/* ===== 工作台主容器 ===== */
.todo-workbench-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  flex: 1; min-height: 0;
  overflow-y: auto; /* 20260808: 内容超高时自身滚动，避免 flex 压缩子元素导致重叠 */
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  animation: todoSlideIn 0.4s ease-out;
}
/* 20260808: 所有直接子元素禁止被 flex 压缩，避免矮视口下模板面板/输入框重叠 */
.todo-workbench-container > * { flex-shrink: 0; }

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

/* ===== 顶部统计卡片行 ===== */
.todo-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.todo-stat-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  transition: var(--transition);
}

.todo-stat-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

/* 霓虹发光边框 - 统计卡片 */
.todo-stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  padding: 1px;
  background: linear-gradient(135deg, rgba(59,130,246,0.3), rgba(6,182,212,0.1));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.todo-stat-card .stat-number {
  font-size: 28px;
  font-weight: 700;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  line-height: 1.2;
}

.todo-stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 统计数字颜色 */
.todo-stat-card.total .stat-number { color: var(--accent-blue); }
.todo-stat-card.done .stat-number { color: var(--accent-green); }
.todo-stat-card.done .stat-number.text-green { color: #22c55e; }
.todo-stat-card.pending .stat-number { color: var(--accent-orange); }
.todo-stat-card.pending .stat-number.text-orange { color: #f97316; }

/* ===== 进度条 ===== */
.todo-progress-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

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

.todo-progress-label {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.todo-progress-label i {
  color: var(--accent-cyan);
  font-size: 12px;
}

.todo-progress-percent {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-cyan);
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

.todo-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.todo-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

.todo-progress-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 20px;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--text-muted));
  border-radius: 0 4px 4px 0;
}

/* ===== 任务输入区域 ===== */
.todo-input-area {
  display: flex;
  gap: 10px;
  align-items: center;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.todo-input-wrap {
  flex: 1;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.todo-input-wrap .el-input__wrapper {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
  transition: all 0.3s ease;
}

.todo-input-wrap .el-input__wrapper:hover {
  border-color: rgba(59, 130, 246, 0.4) !important;
}

.todo-input-wrap .el-input__wrapper.is-focus {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.2) !important;
}

.todo-input-wrap .el-input__inner {
  color: var(--text-primary) !important;
  font-size: 14px;
}

.todo-input-wrap .el-input__inner::placeholder {
  color: var(--text-muted) !important;
}

/* 赛博朋克添加按钮 */
.todo-add-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.3);
  position: relative;
  z-index: 3;
  pointer-events: auto;
}

.todo-add-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(6, 182, 212, 0.5);
}

.todo-add-btn:active {
  transform: translateY(0);
}

.todo-add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== 任务区段通用 ===== */
.todo-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.todo-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.todo-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.todo-section-title i {
  font-size: 12px;
}

.todo-section-title .count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

/* 待办区标题颜色 */
.todo-section.pending-section .todo-section-title { color: var(--accent-orange); }
.todo-section.pending-section .todo-section-title .count-badge {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-orange);
}

/* 已完成区标题颜色 */
.todo-section.done-section .todo-section-title { color: var(--accent-green); }
.todo-section.done-section .todo-section-title .count-badge {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
}

/* 折叠按钮 */
.todo-toggle-section-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.todo-toggle-section-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.todo-toggle-section-btn i {
  font-size: 10px;
  transition: transform 0.3s;
}

.todo-toggle-section-btn.collapsed i {
  transform: rotate(-90deg);
}

/* ===== 任务列表 ===== */
.todo-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 360px;
  overflow-y: auto;
}

.todo-list-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.todo-list-empty i {
  display: block;
  font-size: 24px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ===== 单条任务 ===== */
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
  animation: todoItemIn 0.3s ease-out;
}

@keyframes todoItemIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.todo-item:last-child {
  border-bottom: none;
}

.todo-item:hover {
  background: var(--bg-hover);
}

/* 已完成任务置灰 */
.todo-item.completed .todo-item-title {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: rgba(90, 122, 158, 0.4);
}

.todo-item.completed .todo-item-note {
  color: rgba(90, 122, 158, 0.5);
}

/* 自定义勾选框 */
.todo-checkbox {
  position: relative;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.todo-checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
  margin: 0;
}

.todo-checkbox .checkmark {
  position: absolute;
  inset: 0;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: transparent;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.todo-checkbox .checkmark::after {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 10px;
  color: var(--text-primary);
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
}

.todo-checkbox input:checked + .checkmark {
  background: var(--accent-green);
  border-color: var(--accent-green);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

.todo-checkbox input:checked + .checkmark::after {
  opacity: 1;
  transform: scale(1);
}

.todo-checkbox input:indeterminate + .checkmark {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
}

/* 任务内容区 */
.todo-item-body {
  flex: 1;
  min-width: 0;
}

.todo-item-title {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
  transition: var(--transition);
}

.todo-item-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 8px;
  width: 100%;
  transition: var(--transition);
}

.todo-item-note:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.15);
}

/* 删除按钮 */
.todo-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0;
}

.todo-item:hover .todo-delete-btn {
  opacity: 1;
}

.todo-delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

/* ===== 操作按钮栏 ===== */
.todo-actions-bar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.todo-action-btn {
  padding: 8px 14px;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.todo-action-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.08);
}

.todo-action-btn.danger:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.08);
}

.todo-action-btn.success:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
  background: rgba(34, 197, 94, 0.08);
}

.todo-action-btn i {
  font-size: 11px;
}

/* ===== AI 提示弹窗 ===== */
.todo-ai-prompt-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: todoFadeIn 0.2s ease-out;
}

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

.todo-ai-prompt-dialog {
  background: var(--bg-secondary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 420px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(6, 182, 212, 0.1);
  animation: todoDialogIn 0.3s ease-out;
}

@keyframes todoDialogIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.todo-ai-prompt-dialog .dialog-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.todo-ai-prompt-dialog .dialog-title i {
  color: var(--accent-cyan);
  font-size: 16px;
}

.todo-ai-prompt-dialog .dialog-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  border: 1px solid var(--border-color);
}

.todo-ai-prompt-dialog .dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.todo-ai-prompt-dialog .dialog-btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 6px;
}

.todo-ai-prompt-dialog .dialog-btn.cancel {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.todo-ai-prompt-dialog .dialog-btn.cancel:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.todo-ai-prompt-dialog .dialog-btn.confirm {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  border: none;
  color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.todo-ai-prompt-dialog .dialog-btn.confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

/* ===== 模板管理面板 ===== */
.todo-template-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.todo-template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

.todo-template-header:hover {
  background: rgba(59, 130, 246, 0.05);
}

.todo-template-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 8px;
}

.todo-template-title i {
  font-size: 12px;
}

.todo-template-body {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.todo-template-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 16px 0;
}

.todo-template-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.todo-template-item:last-of-type {
  border-bottom: none;
}

.todo-template-item:hover {
  background: var(--bg-hover);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

.todo-template-drag {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.todo-template-move-btn {
  width: 22px;
  height: 18px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  padding: 0;
}

.todo-template-move-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

.todo-template-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 13px;
  transition: var(--transition);
  min-width: 0;
}

.todo-template-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.15);
}

/* 自定义开关 */
.todo-template-switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  cursor: pointer;
}

.todo-template-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.todo-template-switch-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--border-color);
  border-radius: 10px;
  transition: var(--transition);
}

.todo-template-switch-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: var(--transition);
}

.todo-template-switch input:checked + .todo-template-switch-slider {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
}

.todo-template-switch input:checked + .todo-template-switch-slider::after {
  transform: translateX(16px);
}

.todo-template-switch-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 28px;
  text-align: center;
}

.todo-template-delete-btn {
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  opacity: 0;
}

.todo-template-item:hover .todo-template-delete-btn {
  opacity: 1;
}

.todo-template-delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

.todo-template-add-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 0 8px;
}

.todo-template-add-row .todo-input-wrap {
  flex: 1;
}

.todo-template-footer {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
  border-top: 1px solid var(--border-color);
}

/* ===== 循环任务标签 ===== */
.todo-cycle-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  margin-right: 6px;
  border-radius: 3px;
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  font-weight: 600;
  letter-spacing: 0.5px;
  vertical-align: middle;
  white-space: nowrap;
}

/* 循环任务左侧竖条 */
.todo-item.recurring {
  border-left: 3px solid #3b82f6;
  padding-left: 12px;
}

/* 被跳过的循环任务 */
.todo-item.skipped {
  opacity: 0.5;
}

.todo-item.skipped .todo-item-title {
  text-decoration: line-through;
  text-decoration-color: rgba(90, 122, 158, 0.4);
}

/* ===== 完成率预警 ===== */
.todo-progress-percent.progress-warning {
  color: #f97316 !important;
}

/* ===== 跳过按钮 ===== */
.todo-skip-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  opacity: 0;
}

.todo-item:hover .todo-skip-btn {
  opacity: 1;
}

.todo-skip-btn:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--accent-orange);
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .todo-workbench-container {
    padding: 12px;
    gap: 12px;
  }

  .todo-stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .todo-stat-card {
    padding: 12px 8px;
  }

  .todo-stat-card .stat-number {
    font-size: 22px;
  }

  .todo-stat-card .stat-label {
    font-size: 11px;
  }

  .todo-input-area {
    gap: 8px;
  }

  .todo-add-btn {
    width: 40px;
    height: 40px;
  }

  .todo-actions-bar {
    gap: 6px;
  }

  .todo-action-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .todo-item {
    padding: 10px 12px;
    gap: 8px;
  }

  .todo-item-title {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .todo-workbench-container {
    padding: 10px;
    gap: 10px;
  }

  .todo-stats-row {
    gap: 6px;
  }

  .todo-stat-card {
    padding: 10px 6px;
  }

  .todo-stat-card .stat-number {
    font-size: 20px;
  }

  .todo-progress-wrap {
    padding: 10px 12px;
  }

  .todo-ai-prompt-dialog {
    width: calc(100vw - 24px);
    padding: 18px;
  }
}

/* ===== 滚动条 ===== */
.todo-list::-webkit-scrollbar {
  width: 4px;
}

.todo-list::-webkit-scrollbar-track {
  background: transparent;
}

.todo-list::-webkit-scrollbar-thumb {
  background: rgba(6, 182, 212, 0.15);
  border-radius: 4px;
}

.todo-list::-webkit-scrollbar-thumb:hover {
  background: rgba(6, 182, 212, 0.3);
}
