/* ========== 全局重置与变量 ========== */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #6b7280;
  --success: #10b981;
  --danger: #ef4444;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

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

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

/* ========== 应用容器 ========== */
.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ========== 顶部标题 ========== */
.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}


/* ========== 步骤指示器 ========== */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.3s;
  cursor: pointer;
  user-select: none;
}

.step:hover {
  background: #f1f5f9;
}

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

.step.completed:hover {
  background: #059669;
}

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

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

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-weight: 700;
}

.step-arrow {
  color: var(--border);
  font-size: 16px;
  font-weight: 700;
}

/* ========== 面板通用 ========== */
.panel {
  display: none;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.3s ease;
}

.panel.active-panel {
  display: block;
}

.panel h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

.panel h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

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

/* ========== 上传区域 ========== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: #f9fafb;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: #eef2ff;
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upload-zone p {
  color: var(--text-secondary);
  font-size: 14px;
}

.upload-hint {
  font-size: 12px !important;
  color: var(--secondary) !important;
  margin-top: 4px;
}

/* ========== 预览区域 ========== */
.preview-area {
  margin-top: 20px;
  text-align: center;
}

.preview-area canvas {
  max-width: 100%;
  max-height: 300px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ========== 对比区域 ========== */
.compare-area {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  margin-bottom: 20px;
}

.compare-item {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.canvas-wrapper {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}

.canvas-wrapper canvas {
  max-width: 100%;
  max-height: 320px;
  display: block;
}

/* 棋盘格背景表示透明 */
.checkerboard {
  background-image:
    linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
    linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* ========== 控件组 ========== */
.bg-removal-controls {
  background: #f9fafb;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.control-group {
  margin-bottom: 12px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.radio-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 0;
}

input[type="range"] {
  width: 100%;
  max-width: 300px;
  height: 6px;
  border-radius: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

/* ========== 编辑器布局（左右分栏） ========== */
.editor-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.editor-main {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.editor-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: #f9fafb;
  border-radius: 8px;
  padding: 14px;
}

.sidebar-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section:last-of-type {
  border-bottom: none;
}

.sidebar-section h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.sidebar-section .control-group {
  margin-bottom: 0;
}

.sidebar-section input[type="range"] {
  max-width: 100%;
}

.sidebar-btn {
  width: 100%;
  justify-content: center;
  margin-bottom: 8px;
}

.sidebar-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ========== 页码导航（侧边栏竖排） ========== */
.page-nav-vertical {
  font-size: 13px;
}

.page-nav-row {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

#page-number-input {
  width: 40px;
  text-align: center;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

/* ========== PDF 画布容器 ========== */
.pdf-canvas-container {
  position: relative;
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
  margin: 0 auto;
  max-width: 100%;
}

.pdf-canvas-container canvas {
  display: block;
}

#stamp-overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  cursor: grab;
}

#stamp-overlay-canvas:active {
  cursor: grabbing;
}

.hint {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 12px;
}

/* ========== 最终预览 ========== */
.preview-final {
  text-align: center;
  margin-bottom: 20px;
}

.preview-final canvas {
  max-width: 100%;
  max-height: 600px;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

/* ========== 按钮 ========== */
.btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

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

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

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: #f1f5f9;
}

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

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

/* ========== 响应式 ========== */
@media (max-width: 640px) {
  .app-container {
    padding: 16px 12px 40px;
  }

  .panel {
    padding: 20px 16px;
  }

  .compare-area {
    flex-direction: column;
  }

  .editor-layout {
    flex-direction: column;
  }

  .editor-sidebar {
    width: 100%;
  }

  .step-indicator {
    gap: 4px;
  }

  .step {
    padding: 6px 10px;
    font-size: 11px;
  }

  .step-arrow {
    font-size: 12px;
  }

  .radio-group {
    flex-direction: column;
    gap: 8px;
  }
}
