/* ============================================
   组件样式 - 按钮、表单、卡片、对话框等
   ============================================ */

/* ========== 按钮 ========== */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

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

.btn-success:hover {
  background: #218838;
}

/* 已缓存按钮样式 - 无背景色，只显示图标文字 */
.btn-cached {
  background: transparent !important;
  color: var(--success-color, #28a745);
  border: 1px solid var(--success-color, #28a745);
  cursor: pointer;
  position: relative;
}

.btn-cached:hover {
  background: var(--success-color, #28a745) !important;
  color: white;
}

.btn-cached::after {
  content: ' ↻';
  font-size: 10px;
  opacity: 0.6;
  margin-left: 2px;
}

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

.btn-danger:hover {
  background: #c82333;
}

.btn-warning {
  background: var(--warning-color);
  color: #333;
}

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

.btn-outline:hover {
  background: var(--primary-color);
  color: white;
}

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

/* ========== 表单元素 ========== */
.input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  width: 100%;
}

.input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1);
}

.input-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ========== 文件列表 ========== */
.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 5px;
  position: relative;
}

.file-item:hover {
  background: #f0f0f0;
}

.file-item.selected {
  background: #e3f2fd;
  border-left: 3px solid var(--primary-color);
}

.file-item.checked {
  background: #f0fff0;
  border-left: 3px solid var(--success-color);
}

.file-checkbox {
  margin-right: 10px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary-color, #4CAF50);
  flex-shrink: 0;
}

.file-icon {
  width: 32px;
  height: 32px;
  margin-right: 10px;
  font-size: 24px;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  word-break: break-all;
}

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

.file-status-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
}

.file-status-badge.processed {
  background: var(--success-color);
  color: white;
}

.file-status-badge.pending {
  background: var(--warning-color);
  color: #333;
}

/* ========== 徽章和标签 ========== */
.badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success { background: var(--success-color); color: white; }
.badge-warning { background: var(--warning-color); color: #333; }
.badge-info { background: var(--info-color); color: white; }
.badge-secondary { background: var(--secondary-color); color: white; }

.folder-tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #e9ecef;
  transition: all 0.2s;
  font-size: 13px;
}

.folder-tab.active {
  background: var(--primary-color);
  color: white;
}

.folder-tab:hover:not(.active) {
  background: #dee2e6;
}

/* ========== 模态框/对话框 ========== */
.modal, .browse-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content, .browse-dialog-content {
  background: white;
  padding: 24px;
  border-radius: var(--radius-lg);
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  cursor: pointer;
  font-size: 24px;
  color: var(--text-muted);
  line-height: 1;
}

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

/* ========== 进度条 ========== */
.progress-bar {
  height: 20px;
  background: #e9ecef;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
  transition: width 0.3s ease;
  border-radius: 10px;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ========== 批量处理进度 ========== */
.batch-progress-modal .modal-content {
  max-width: 900px;
}

.batch-stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 12px 16px;
  background: #f8f9fa;
}

.batch-stat-item {
  text-align: center;
  padding: 8px;
  background: white;
  border-radius: 6px;
  border: 1px solid #eee;
}

.batch-stat-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}

.batch-stat-value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.batch-details-container {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
  background: white;
}

.batch-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.batch-details-table th {
  background: #f8f9fa;
  padding: 8px 12px;
  text-align: left;
  font-weight: 500;
  color: #666;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 1;
}

.batch-details-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
}

.batch-details-table tr:hover {
  background: #f8f9fa;
}

.batch-file-index {
  color: #999;
  font-size: 12px;
}

.batch-file-name {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-file-type {
  text-align: center;
  color: #666;
}

.batch-file-status {
  text-align: center;
}

.batch-file-detail {
  color: #666;
  font-size: 12px;
}

.batch-file-chars {
  text-align: right;
  font-weight: 500;
  color: #1976d2;
}

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-pending {
  background: #f0f0f0;
  color: #666;
}

.status-processing {
  background: #e3f2fd;
  color: #1976d2;
}

.status-success {
  background: #e8f5e9;
  color: #388e3c;
}

.status-error {
  background: #ffebee;
  color: #d32f2f;
}

.status-skipped {
  background: #f5f5f5;
  color: #757575;
}

.batch-dialog-actions {
  display: flex;
  justify-content: space-between;
  padding: 16px;
  border-top: 1px solid #eee;
  background: #fafafa;
}

/* ========== 统计卡片 ========== */
.stat-card {
  background: white;
  padding: 15px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  min-width: 120px;
}

.stat-value {
  font-size: 32px;
  font-weight: bold;
  color: var(--primary-color);
}

.stat-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* ========== Toast提示 ========== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #333;
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

.toast.success { background: var(--success-color); }
.toast.error { background: var(--danger-color); }
.toast.warning { background: var(--warning-color); color: #333; }

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

/* ========== 右键菜单 ========== */
.context-menu {
  position: fixed;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  z-index: 1500;
  min-width: 150px;
}

.context-menu-item {
  padding: 10px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.context-menu-item:hover {
  background: var(--bg-lighter);
}

.context-menu-item.danger {
  color: var(--danger-color);
}

.context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 5px 0;
}
/* 查重确认对话框 */
.dup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: #fff8e1;
}

.dup-row-info {
  flex: 1;
  min-width: 0;
}

.dup-row-title {
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.dup-row-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  word-break: break-all;
}

.dup-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* 文件搜索框与删除按钮（文档管理） */
.file-search-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.file-delete-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: var(--radius-sm);
  opacity: 0.35;
  flex-shrink: 0;
}

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

.file-delete-btn:hover {
  background: rgba(220, 53, 69, 0.12);
}

/* office/markdown 预览容器 */
.office-preview {
  padding: 16px;
  background: #fff;
  height: 100%;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  box-sizing: border-box;
}

.office-preview table {
  border-collapse: collapse;
  margin-bottom: 12px;
}

.office-preview td,
.office-preview th {
  border: 1px solid #ddd;
  padding: 4px 8px;
  text-align: left;
}

.md-preview h2,
.md-preview h3,
.md-preview h4,
.md-preview h5 {
  margin: 12px 0 6px;
}

.md-preview ul {
  padding-left: 20px;
}

.md-preview code {
  background: var(--bg-color);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
}

.md-table td {
  border: 1px solid #ddd;
  padding: 4px 8px;
}

/* 分类摘要表单 */
.summary-category-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  grid-column: 1 / -1;
}

.summary-category-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  border-radius: 12px;
  padding: 2px 10px;
}

.summary-actions-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

/* 分类摘要操作行与阶段状态 */
.summary-actions-row-bar {
  margin-top: -6px;
}

.summary-stage-status {
  font-size: 12px;
  color: var(--text-secondary);
  align-self: center;
}

/* ============================================
   按钮/操作条统一体系
   - .action-bar：操作条容器（flex + 8px 间距 + 可换行 + 垂直居中）
   - 主流程按钮（一键处理/批量一键处理）: btn-primary
   - 确认/完成类（摘要结果确认/保存）: btn-success
   - 次级操作: btn-secondary；危险操作: btn-danger
   ============================================ */
.action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.action-bar + .action-bar {
  margin-top: 8px;
}

.action-bar-block {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.summary-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* 摘要区紧凑条（默认两行内，点击展开完整表单） */
.summary-compact-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.summary-compact-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 查重对比弹窗 */
.dup-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dup-compare-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  word-break: break-all;
}

.dup-compare-body {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  min-height: 200px;
  max-height: 65vh;
  overflow-y: auto;
  text-align: center;
}

.dup-compare-body img {
  max-width: 100%;
  display: block;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .dup-compare-grid {
    grid-template-columns: 1fr;
  }
}

/* 阶段筛选条与阶段徽标 */
.stage-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--stage-color, var(--border-color));
  border-radius: 12px;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  color: var(--stage-color, var(--text-secondary));
}

.stage-chip.active {
  background: var(--stage-color);
  color: #fff;
}

.stage-chip-count {
  font-size: 10px;
  opacity: 0.75;
}

.file-status-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
  color: #fff;
}

.file-status-badge.stage-0 { background: #9e9e9e; }
.file-status-badge.stage-1 { background: #1976d2; }
.file-status-badge.stage-2 { background: #00838f; }
.file-status-badge.stage-3 { background: #ef6c00; }
.file-status-badge.stage-4 { background: #2e7d32; }
