/* ============================================
   工具类样式 - 特定功能区域的样式
   ============================================ */

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  margin: 0 0 8px 0;
  color: var(--text-secondary);
}

.empty-state p {
  margin: 0;
  font-size: 13px;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* ========== 加载状态 ========== */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

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

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

/* ========== 图片预览 ========== */
.image-preview {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #1a1a1a;
  overflow: auto;
}

.image-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.image-wrapper img#previewImg {
  /* 单张图片使用absolute定位，让 JavaScript 的 transform scale 完全控制 */
  position: absolute;
}

/* PDF多页预览的图片不使用absolute定位 */
.pdf-pages-container img {
  position: static !important;
  max-width: 100%;
  height: auto;
}

.image-controls {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-lighter);
  border-bottom: 1px solid #eee;
}

.ctrl-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ctrl-btn {
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  font-size: 12px;
}

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

.ctrl-btn:hover:not(.active) {
  background: var(--bg-light);
}

.zoom-info {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 50px;
  text-align: center;
}

/* ========== OCR文本区域 ========== */
.ocr-text {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 200px;
  overflow-y: auto;
}

/* OCR文本滚动条样式 */
.ocr-text::-webkit-scrollbar {
  width: 8px;
}

.ocr-text::-webkit-scrollbar-track {
  background: #2d2d2d;
  border-radius: 4px;
}

.ocr-text::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

.ocr-text::-webkit-scrollbar-thumb:hover {
  background: #666;
}

/* ========== Tab切换 ========== */
.tab-buttons {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.tab-btn {
  padding: 4px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
}

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

.tab-btn:hover:not(.active) {
  background: var(--bg-light);
}

.ocr-tab {
  padding: 4px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

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

.ocr-tab:hover:not(.active) {
  background: var(--bg-light);
}

/* ========== 浏览文件夹对话框 ========== */
.browse-path-input {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.browse-path-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.browse-current-path {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 8px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
}

.browse-folder-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.browse-folder-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
}

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

.browse-folder-item:hover {
  background: var(--bg-light);
}

.browse-folder-item.selected {
  background: #e3f2fd;
}

.browse-folder-icon {
  font-size: 20px;
  margin-right: 10px;
}

.browse-folder-name {
  flex: 1;
}

.browse-folder-count {
  font-size: 12px;
  color: var(--text-muted);
}

.browse-folder-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
}

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

/* 多选区域的跳过选项 */
.skip-existing-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 12px;
}

.skip-existing-label input[type="checkbox"] {
  margin-right: 6px;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.skip-existing-label:hover {
  color: var(--text-primary);
}

.batch-options {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
}

.batch-options .checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
}

.batch-options .checkbox-label input[type="checkbox"] {
  margin-right: 8px;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.batch-stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.batch-stat-item {
  text-align: center;
  padding: 10px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
}

.batch-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.batch-stat-value {
  font-size: 18px;
  font-weight: bold;
}

.batch-details-container {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.batch-details-table {
  width: 100%;
  border-collapse: collapse;
}

.batch-details-table th {
  background: var(--bg-lighter);
  padding: 8px;
  font-size: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.batch-details-table td {
  padding: 8px;
  font-size: 13px;
}

.batch-dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

/* ========== 多选模式 ========== */
.multi-select-actions {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  flex-direction: column;
  gap: 8px;
}

.multi-select-actions.active {
  display: flex;
}

.selected-count {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ========== JSON展示 ========== */
.json-container {
  font-family: 'Fira Code', monospace;
  font-size: 13px;
}

.json-header {
  cursor: pointer;
  padding: 4px 0;
}

.json-arrow {
  color: var(--text-muted);
  margin-right: 4px;
}

.json-key {
  color: #9333ea;
}

.json-string {
  color: #059669;
}

.json-number {
  color: #d97706;
}

.json-boolean {
  color: #dc2626;
}

.json-content {
  padding-left: 16px;
}

/* ========== 摘要编辑表单 ========== */
.summary-grid.editable {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px;
}

.summary-grid.editable .summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-grid.editable label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.summary-grid.editable input,
.summary-grid.editable select {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: white;
}

.summary-grid.editable input:focus,
.summary-grid.editable select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.summary-grid.editable input[type="date"] {
  cursor: pointer;
}

.summary-grid.editable input[type="number"] {
  width: 100%;
}

/* 日期输入框包装器 */
.date-input-wrapper {
  display: flex;
  gap: 4px;
  align-items: center;
}

.date-input-wrapper input[type="text"] {
  flex: 1;
}

.date-input-wrapper input[type="date"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.date-picker-btn {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  font-size: 14px;
}

.date-picker-btn:hover {
  background: var(--bg-light);
}

/* 组合输入框（可输入+下拉选择） */
.combo-input {
  position: relative;
}

.combo-input input {
  width: 100%;
}

.combo-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 100;
}

.combo-dropdown.show {
  display: block;
}

.combo-option {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
}

.combo-option:hover {
  background: var(--bg-light);
}

.combo-option:empty {
  display: none;
}

/* 下拉选择 + 输入框组合 */
.input-with-select {
  display: flex;
  gap: 4px;
}

.input-with-select select {
  flex: 0 0 80px;
  min-width: 60px;
}

.input-with-select input {
  flex: 1;
  min-width: 0;
}

/* 性别单选框 */
.radio-group {
  display: flex;
  gap: 16px;
  padding: 6px 0;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 13px;
}

.radio-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

/* 摘要操作按钮区域 */
.summary-actions {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-light);
}

.summary-actions .btn {
  padding: 8px 16px;
  font-size: 13px;
}

/* ========== 文件信息栏 ========== */
.file-info-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-lighter);
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.file-info-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.file-info-item.file-name {
  flex: 1;
  min-width: 200px;
}

.file-info-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.file-info-value {
  color: var(--text-primary);
}

/* ========== 隐藏元素 ========== */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
