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

:root {
  --primary: #1890ff;
  --primary-dark: #0066cc;
  --success: #52c41a;
  --danger: #ff4d4f;
  --warning: #faad14;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --bg: #f5f7fa;
  --bg-white: #ffffff;
  --border: #e5e7eb;
  --shadow-sm: 0 2rpx 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-lg: 20px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== 头部 ===== */
.header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.logo-icon { font-size: 28px; }

.nav {
  display: flex;
  gap: 32px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  transition: color 0.2s;
}

.nav-link:hover { color: var(--primary); }

/* ===== 主容器 ===== */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 32px;
}

/* ===== 步骤指示器 ===== */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px 40px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  transition: all 0.3s;
}

.step.active {
  color: var(--primary);
}

.step.active .step-num {
  background: var(--primary);
  color: #fff;
}

.step.completed .step-num {
  background: var(--success);
  color: #fff;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e5e7eb;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s;
}

.step-label {
  font-size: 15px;
  font-weight: 500;
}

.step-line {
  flex: 1;
  height: 2px;
  background: #e5e7eb;
  margin: 0 16px;
  min-width: 40px;
  max-width: 120px;
  transition: background 0.3s;
}

/* ===== 通用按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(24,144,255,0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(24,144,255,0.4);
}

.btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-secondary:hover {
  background: #e6f7ff;
}

.btn-text {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
}

.btn-text:hover {
  background: #f5f5f5;
  color: var(--primary);
}

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

.btn-large {
  padding: 14px 32px;
  font-size: 16px;
}

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

/* ===== 上传区域 ===== */
.upload-area {
  background: #fff;
  border: 3px dashed #d9d9d9;
  border-radius: var(--radius-lg);
  padding: 80px 40px;
  text-align: center;
  transition: all 0.3s;
  cursor: pointer;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--primary);
  background: #f0f7ff;
}

.upload-icon {
  font-size: 80px;
  margin-bottom: 24px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.upload-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.upload-desc {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.upload-tips {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.tip-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

.tip-item span:first-child { font-size: 18px; }

/* ===== 文件列表 ===== */
.file-list-section {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-top: 24px;
  box-shadow: var(--shadow-sm);
}

.file-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.file-list-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: #fafafa;
  border-radius: var(--radius);
  transition: all 0.2s;
  cursor: grab;
}

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

.file-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.file-item-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #1890ff, #0066cc);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.file-item-index {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

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

.file-item-name {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

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

.file-item-actions {
  display: flex;
  gap: 8px;
}

.file-item-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}

.file-item-btn:hover {
  background: #fff;
  color: var(--primary);
}

.file-item-btn.delete:hover {
  color: var(--danger);
}

.file-list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.file-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
}

.file-summary strong {
  color: var(--primary);
  font-size: 18px;
}

.text-success {
  color: var(--success) !important;
}

/* ===== 排版选择器 ===== */
.layout-selector {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.layout-selector h4 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text);
}

.layout-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.layout-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: #fafafa;
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.layout-option:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}

.layout-option input[type="radio"] {
  position: absolute;
  opacity: 0;
}

.layout-option input[type="radio"]:checked + .layout-preview {
  border-color: var(--primary);
}

.layout-option:has(input:checked) {
  border-color: var(--primary);
  background: #e6f7ff;
  box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
}

.layout-preview {
  width: 80px;
  height: 100px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  display: grid;
  gap: 2px;
  transition: border-color 0.2s;
}

.layout-preview:has(.half) { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.layout-preview:has(.quad) { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.layout-preview:has(.sixth) { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; }
.layout-preview:has(.ninth) { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; }
.layout-preview:has(.single) { grid-template-columns: 1fr; grid-template-rows: 1fr; }

.layout-cell {
  background: linear-gradient(135deg, #e6f7ff, #bae7ff);
  border-radius: 2px;
}

.layout-label {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.layout-label span {
  font-size: 12px;
  color: var(--text-muted);
}

.layout-tip {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #ad6800;
  line-height: 1.6;
}

.layout-tip strong { color: #874d00; }

/* ===== 预览网格 ===== */
.preview-toolbar {
  background: #fff;
  padding: 16px 24px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.toolbar-info {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  text-align: center;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.preview-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  cursor: grab;
}

.preview-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.preview-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

.preview-card-index {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.preview-card-title {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-card-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
}

.preview-card-delete:hover { color: var(--danger); }

.preview-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.preview-page {
  aspect-ratio: 0.707; /* A4 ratio */
  background: #fafafa;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.preview-page:hover {
  border-color: var(--primary);
}

.preview-page.selected {
  border-color: var(--primary);
  background: #e6f7ff;
}

.preview-page canvas {
  max-width: 100%;
  max-height: 100%;
}

.preview-page-num {
  position: absolute;
  bottom: 2px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
}

.preview-page-checkbox {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.preview-page.selected .preview-page-checkbox {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ===== 合并区域 ===== */
.merge-area {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 80px 40px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.merge-icon {
  font-size: 80px;
  margin-bottom: 24px;
  animation: rotate 2s linear infinite;
}

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

.merge-area h2 {
  font-size: 24px;
  margin-bottom: 24px;
}

.progress-bar {
  width: 100%;
  max-width: 400px;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  margin: 0 auto 16px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #69c0ff);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

.merge-detail {
  color: var(--text-secondary);
}

.merge-result {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  box-shadow: var(--shadow-sm);
  min-height: 400px;
  border: 2px solid var(--success);
}

.result-success {
  text-align: center;
  margin-bottom: 32px;
}

.success-icon {
  font-size: 80px;
  margin-bottom: 16px;
}

.result-success h2 {
  font-size: 28px;
  color: var(--success);
}

.result-info {
  max-width: 480px;
  margin: 0 auto 32px;
  background: #fafafa;
  border-radius: var(--radius);
  padding: 20px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: none; }

.info-label {
  color: var(--text-secondary);
}

.info-value {
  font-weight: 500;
}

.result-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== 打印区域 ===== */
.print-area {
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.print-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}

.print-preview-toolbar h3 {
  font-size: 18px;
}

.print-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.form-select, .form-input {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
}

.form-input {
  cursor: text;
}

.print-preview-container {
  height: 70vh;
  min-height: 600px;
}

.pdf-preview {
  width: 100%;
  height: 100%;
  border: none;
}

/* ===== 页脚 ===== */
.footer {
  text-align: center;
  padding: 40px 32px;
  color: var(--text-muted);
  font-size: 14px;
}

.footer-sub {
  margin-top: 8px;
  font-size: 12px;
}

/* ===== 模态框 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 40px 60px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #f0f0f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .header-inner { padding: 16px 20px; }
  .nav { display: none; }
  .main { padding: 20px 16px; }
  .stepper { padding: 16px; }
  .step-label { display: none; }
  .step-line { margin: 0 8px; min-width: 20px; }
  .upload-area { padding: 60px 20px; }
  .upload-title { font-size: 22px; }
  .upload-tips { flex-direction: column; gap: 12px; }
  .file-list-footer { flex-direction: column; gap: 16px; align-items: stretch; }
  .preview-grid { grid-template-columns: 1fr; }
  .preview-toolbar { flex-direction: column; }
  .result-actions { flex-direction: column; }
  .result-actions button { width: 100%; }
  .print-preview-toolbar { flex-direction: column; align-items: stretch; }
  .print-toolbar-actions { justify-content: center; }
}

/* ===== 拖拽占位 ===== */
.drag-placeholder {
  border: 2px dashed #1890ff;
  background: #f0f7ff;
  border-radius: 12px;
  height: 80px;
  margin: 8px 0;
}
/* ===== SEO 正文内容区 ===== */
.seo-content {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
}
.seo-block {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.seo-block h1 {
  font-size: 26px;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--primary);
}
.seo-block h2 {
  font-size: 21px;
  color: var(--primary-dark);
  margin-bottom: 16px;
}
.seo-block p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.9;
  margin-bottom: 14px;
}
.seo-block strong { color: var(--text); }
.seo-steps {
  list-style: none;
  counter-reset: seo-step;
}
.seo-steps li {
  position: relative;
  padding-left: 42px;
  margin-bottom: 18px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.8;
}
.seo-steps li::before {
  counter-increment: seo-step;
  content: counter(seo-step);
  position: absolute;
  left: 0;
  top: 2px;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}
.seo-faq h3 {
  font-size: 16px;
  color: var(--text);
  margin: 20px 0 8px;
  padding-left: 14px;
  border-left: 3px solid var(--primary);
}
.seo-faq p { margin-bottom: 12px; }

@media (max-width: 768px) {
  .seo-block { padding: 20px; }
  .seo-block h1 { font-size: 21px; }
  .seo-block h2 { font-size: 18px; }
}
