/* ============================================
   文档扫描合并PDF - 样式表
   参考 2.047.me 紫蓝渐变风格
   ============================================ */

/* ---- 全局 ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1b1b1b;
  background: linear-gradient(135deg, #f6f7fb 0%, #f0f4f9 100%);
  min-height: 100vh;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

a { text-decoration: none; color: inherit; }

/* ---- 顶部导航 ---- */
.topbar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px 0;
}

.topbar .content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.brand {
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: white;
}

/* ---- 主容器 ---- */
#app {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 120px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- 上传区域 ---- */
.upload-section {
  width: 100%;
  max-width: 768px;
  margin: 32px 16px 16px 16px;
}

.file-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 12px;
  margin: 0 auto;
  width: 100%;
  max-width: 768px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-align: center;
  transition: all 0.3s ease;
  border: 2px solid rgba(102, 126, 234, 0.3);
  position: relative;
  cursor: pointer;
  overflow: hidden;
  min-height: 140px;
}

.file-selector:hover {
  background: linear-gradient(135deg, #f6f7fb 0%, #ffffff 100%);
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.file-selector.highlight,
.file-selector.dragover {
  background: linear-gradient(135deg, #f6f7fb 0%, #ffffff 100%);
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.file-selector-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #1b1b1b;
}

.file-selector-subtitle {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 16px;
}

.file-selector-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}

.file-selector-button:hover {
  background: linear-gradient(135deg, #764ba2 0%, #5a6bb8 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.file-selector-button:active {
  transform: translateY(1px);
}

.file-selector-button svg {
  width: 20px;
  height: 20px;
}

/* ---- 图片计数器 ---- */
.files-counter {
  padding: 8px 16px;
  margin: 0 auto 16px;
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-align: center;
  max-width: 500px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 1;
}

.counter-text {
  font-size: 15px;
  color: #1b1b1b;
}

.counter-number {
  color: #667eea;
  font-weight: bold;
}

.btn-clear-all {
  background: none;
  border: none;
  color: #999;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-clear-all:hover {
  color: #EF4444;
  background: #FEE2E2;
}

/* ---- 文件列表 ---- */
.file-list {
  max-width: 500px;
  width: 100%;
  padding: 0 16px;
  padding-bottom: 100px;
}

/* ---- 文件卡片（横向布局：缩略图 + 信息 + 操作） ---- */
.file-card {
  display: flex;
  background: #ffffff;
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  height: 120px;
  min-height: 120px;
  width: 100%;
  border: 2px solid transparent;
  cursor: grab;
}

.file-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.07);
  border-color: rgba(102, 126, 234, 0.3);
}

.file-card.dragging {
  opacity: 0.5;
  transform: scale(1.05);
  cursor: grabbing;
}

.file-card.processing {
  border-color: #667eea;
}

.file-card.done {
  border-color: #10B981;
}

.file-card.error {
  border-color: #EF4444;
}

/* 序号角标 */
.file-card-number {
  width: 28px;
  height: 28px;
  background-color: #667eea;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  position: absolute;
  border-radius: 6px;
  top: 8px;
  left: 8px;
  z-index: 10;
}

.file-card.done .file-card-number {
  background-color: #10B981;
}

.file-card.error .file-card-number {
  background-color: #EF4444;
}

.file-card.processing .file-card-number {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* 删除按钮（右上角圆形） */
.file-card-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: rgba(255, 71, 87, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  padding: 0;
}

.file-card-delete:hover {
  background: rgba(255, 71, 87, 1);
  transform: scale(1.1);
}

.file-card-delete svg {
  width: 14px;
  height: 14px;
}

/* 状态角标 */
.file-card-status {
  position: absolute;
  top: 8px;
  right: 44px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  z-index: 10;
  display: none;
}

.file-card-status.processing {
  display: inline-flex;
  background: #667eea;
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

.file-card-status.success {
  display: inline-flex;
  background: #10B981;
  color: white;
}

.file-card-status.fail {
  display: inline-flex;
  background: #EF4444;
  color: white;
}

/* 缩略图区域 */
.file-card-preview {
  width: 100px;
  min-width: 100px;
  height: 100px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  margin: 10px;
  align-self: center;
  border-radius: 6px;
  cursor: pointer;
}

.file-card-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

/* 信息区域 */
.file-card-info {
  flex: 1;
  padding: 12px 6px 12px 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
  max-height: 100%;
  overflow: hidden;
}

.file-card-name {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: #1b1b1b;
  padding-bottom: 8px;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: break-word;
  max-height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.file-card-size {
  font-size: 0.75rem;
  color: #717171;
  margin-bottom: 8px;
  flex-shrink: 0;
}

/* 操作按钮区域（上移/下移） */
.file-card-actions {
  display: flex;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 2px;
  margin-top: auto;
  width: 100%;
  max-width: 100%;
  padding-bottom: 4px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.card-action-btn {
  padding: 3px 4px;
  border: none;
  background-color: rgba(0,0,0,0.04);
  border-radius: 6px;
  font-size: 0.85rem;
  color: #4f4f4f;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 1px;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  justify-content: center;
  text-align: center;
  margin: 0 2px;
}

.card-action-btn:hover:not(:disabled) {
  background-color: rgba(0,0,0,0.08);
  color: #1b1b1b;
}

.card-action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.card-action-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Sortable 拖拽 */
.sortable-ghost {
  opacity: 0.3;
}

.sortable-chosen {
  box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
}

.sortable-drag {
  opacity: 0.9;
}

/* ---- 进度条 ---- */
.progress-section {
  margin: 16px auto;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 500px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
}

#progressText { color: #1b1b1b; }
#progressPercent { color: #667eea; font-weight: 600; }

.progress-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 3px;
  width: 0;
  transition: width 0.4s ease;
}

/* ---- 底部固定操作栏 ---- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border-top: 1px solid rgba(0,0,0,0.06);
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  backdrop-filter: blur(10px);
  z-index: 10;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-bar.show {
  transform: translateY(0);
}

.bottom-bar .buttons {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 16px;
}

.bottom-bar .button {
  flex: 1;
  padding: 16px 0;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: white;
}

.bottom-bar .btn-scan {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bottom-bar .btn-add {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bottom-bar .button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.07);
}

.bottom-bar .button:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.bottom-bar .button svg {
  width: 20px;
  height: 20px;
}

/* ---- 结果区 ---- */
.result-section {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  margin: 16px auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 500px;
}

.result-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #1b1b1b;
}

.result-merged {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
  border: 2px solid rgba(102, 126, 234, 0.2);
  border-radius: 12px;
}

.result-merged-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  flex-shrink: 0;
}

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

.result-merged-title {
  font-size: 15px;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 4px;
}

.result-merged-meta {
  font-size: 13px;
  color: #717171;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.07);
  color: white;
}

/* ---- 使用说明 ---- */
.howto-section {
  margin-top: 24px;
  padding: 20px 0;
  width: 100%;
  max-width: 500px;
}

.howto-section h2 {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 16px;
  position: relative;
  padding-top: 12px;
}

.howto-section h2::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 1px;
}

.howto-list {
  list-style: none;
  counter-reset: step-counter;
  padding: 0;
}

.howto-list li {
  counter-increment: step-counter;
  position: relative;
  padding: 14px 14px 14px 52px;
  margin-bottom: 10px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  font-size: 14px;
  color: #4f4f4f;
  line-height: 1.5;
}

.howto-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.howto-list li strong {
  color: #1b1b1b;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(27, 27, 27, 0.9);
  color: #fff;
  padding: 12px 28px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: fadeInUp 0.3s ease;
  backdrop-filter: blur(10px);
}

.toast-error {
  background: rgba(239, 68, 68, 0.9);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- 其它工具导航链接 ---- */
.navigation-links {
  max-width: 800px;
  width: 100%;
  margin: 0 auto 16px auto;
  padding: 0 16px;
  box-sizing: border-box;
}

.navigation-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 16px;
  text-align: center;
  padding-top: 24px;
  position: relative;
}

.navigation-section-title::before {
  content: '';
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 1px;
}

.navigation-links-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 0;
  width: 100%;
  box-sizing: border-box;
}

.navigation-link-item {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 2px solid rgba(102, 126, 234, 0.25);
  border-radius: 10px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.navigation-link-item:hover {
  border-color: #667eea;
  background: linear-gradient(135deg, #f6f7fb 0%, #ffffff 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.navigation-link-item:active {
  transform: translateY(0);
}

.navigation-link-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navigation-link-icon svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.navigation-link-item:hover .navigation-link-icon svg {
  transform: scale(1.1);
}

.navigation-link-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 4px;
  line-height: 1.2;
}

.navigation-link-subtitle {
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 0;
  line-height: 1.2;
  display: inline-block;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ---- 响应式 ---- */
@media (max-width: 767px) {
  .file-selector {
    width: calc(100% - 32px);
    margin: 0 16px 16px 16px;
    padding: 16px;
  }

  .file-selector-title {
    font-size: 1.1rem;
  }

  .file-selector-subtitle {
    font-size: 0.85rem;
    margin-bottom: 20px;
  }

  .file-selector-button {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .file-card {
    height: 100px;
    min-height: 100px;
    margin-bottom: 12px;
  }

  .file-card-preview {
    width: 80px;
    min-width: 80px;
    height: 80px;
    margin: 10px 8px;
  }

  .file-card-info {
    padding: 10px 4px 10px 0;
  }

  .file-card-name {
    font-size: 0.85rem;
    padding-bottom: 6px;
    max-height: 2.4em;
    line-height: 1.2;
  }

  .file-card-size {
    font-size: 0.7rem;
    margin-bottom: 6px;
  }

  .file-card-actions {
    padding: 2px 3px;
    font-size: 0.8rem;
    margin: 0 1px;
  }

  .card-action-btn {
    padding: 2px 3px;
    font-size: 0.8rem;
    margin: 0 1px;
  }

  .card-action-btn svg {
    width: 14px;
    height: 14px;
  }

  .file-card-number {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    top: 6px;
    left: 6px;
  }

  .file-card-delete {
    width: 28px;
    height: 28px;
    top: 6px;
    right: 6px;
    font-size: 0.9rem;
  }

  .file-card-delete svg {
    width: 12px;
    height: 12px;
  }

  .file-card-status {
    top: 6px;
    right: 40px;
    font-size: 10px;
    padding: 1px 6px;
  }

  .bottom-bar .button {
    padding: 12px 0;
    font-size: 0.95rem;
  }

  /* 移动端导航链接 */
  .navigation-links {
    padding: 0 16px;
  }

  .navigation-section-title {
    font-size: 0.9rem;
    padding-top: 16px;
    margin-bottom: 12px;
  }

  .navigation-section-title::before {
    width: 40px;
    top: 8px;
  }

  .navigation-links-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .navigation-link-item {
    padding: 8px 4px;
    min-height: 50px;
  }

  .navigation-link-icon {
    width: 20px;
    height: 20px;
    margin-bottom: 4px;
  }

  .navigation-link-icon svg {
    width: 16px;
    height: 16px;
  }

  .navigation-link-title {
    font-size: 0.7rem;
    margin-bottom: 2px;
  }

  .navigation-link-subtitle {
    font-size: 0.65rem;
    padding: 3px 6px;
    margin-bottom: 0;
  }
}

/* 平板端适配 */
@media (min-width: 481px) and (max-width: 768px) {
  .file-selector {
    width: calc(100% - 32px);
    margin: 0 16px 16px 16px;
    padding: 16px;
  }

  .file-selector-title {
    font-size: 1.15rem;
  }

  .navigation-links {
    padding: 0 16px;
  }

  .navigation-section-title {
    font-size: 0.95rem;
    padding-top: 20px;
    margin-bottom: 14px;
  }

  .navigation-section-title::before {
    width: 50px;
    top: 10px;
  }

  .navigation-links-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .navigation-link-item {
    padding: 10px 6px;
    min-height: 55px;
  }

  .navigation-link-icon svg {
    width: 18px;
    height: 18px;
  }

  .navigation-link-title {
    font-size: 0.72rem;
    margin-bottom: 3px;
  }

  .navigation-link-subtitle {
    font-size: 0.68rem;
    padding: 3px 7px;
    margin-bottom: 0;
  }
}

/* 桌面端适配 */
@media (min-width: 769px) {
  .navigation-links {
    padding: 0 16px;
  }

  .navigation-links-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .navigation-link-item {
    padding: 16px 12px;
    min-height: 70px;
  }

  .navigation-link-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 8px;
  }

  .navigation-link-icon svg {
    width: 24px;
    height: 24px;
  }

  .navigation-link-title {
    font-size: 0.8rem;
    margin-bottom: 4px;
  }

  .navigation-link-subtitle {
    font-size: 0.75rem;
    padding: 4px 8px;
    margin-bottom: 0;
  }
}
