/* ============================================================
 * 导入图纸 - 多步向导（对齐 → 裁剪 → 解析 → 微调）
 * ============================================================ */

.ip-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #f5f7fa;
}

.ip-header {
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-shrink: 0;
}

.ip-header h2 {
  margin: 0;
  font-size: 18px;
  color: #1a1a1a;
}

.ip-hint {
  font-size: 12px;
  color: #999;
}

.ip-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ─── 中间画布区 ──────────────────────────────────────────── */
.ip-canvas-wrap {
  flex: 1;
  background: #e8e8e8;
  border-right: 1px solid #e0e0e0;
  overflow: hidden;
  position: relative;
  min-height: 0;
  min-width: 0;
}

/* 微调步骤：主区纵向排布（顶部通栏标签 + 下方切片网格） */
.ip-canvas-wrap.has-tabs {
  display: flex;
  flex-direction: column;
}

.ip-canvas-wrap canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  cursor: crosshair;
}

/* 顶部通栏标签栏 */
.ip-tabs-top {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 0;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  z-index: 5;
}

.ip-tabs-scroll {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 10px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ip-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.ip-tab-nav {
  flex-shrink: 0;
  width: 28px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #fff;
  color: #666;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.ip-tab-nav:hover {
  color: #1660AB;
  background: #f0f7ff;
}

.ip-tab-nav:active {
  background: #e6f1fb;
}

/* 微调步骤：切片网格（替代 canvas 主视图） */
.ip-canvas-wrap.has-tabs .ip-slice-grid {
  position: relative;
  flex: 1;
  inset: auto;
}

.ip-slice-grid {
  position: absolute;
  inset: 0;
  display: none;
  background: #fff;
  overflow: auto;
  padding: 16px;
  align-content: flex-start;
  grid-template-columns: repeat(auto-fill, 46px);
  gap: 8px;
  user-select: none;
}

.ip-slice-grid.active {
  display: grid;
}

.ip-slice {
  position: relative;
  width: 46px;
  height: 46px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: #f8f8f8;
  transition: border-color 0.12s, transform 0.1s;
  flex-shrink: 0;
}

.ip-slice:hover {
  border-color: #1660AB;
}

.ip-slice.selected {
  border-color: #1660AB;
  box-shadow: 0 0 0 2px rgba(22,96,171,0.25);
}

.ip-slice canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.ip-slice-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  padding: 0 3px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
  font-family: monospace;
  color: #333;
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(0,0,0,0.08);
  pointer-events: none;
  max-width: calc(100% - 4px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ip-slice-grid-drag {
  position: absolute;
  border: 1px solid #1660AB;
  background: rgba(22,96,171,0.12);
  border-radius: 2px;
  pointer-events: none;
  display: none;
  z-index: 10;
}

.ip-empty-slice {
  border-style: dashed;
  border-color: #ccc;
}

.ip-slice-tab-title {
  grid-column: 1 / -1;
  padding: 8px 4px 4px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.ip-slice-tab-title span {
  font-size: 12px;
  color: #888;
  font-weight: 400;
}

/* 分页标签 */
.ip-tab-pager {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 16px;
  background: #fff;
  font-size: 12px;
  color: #333;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.ip-tab-pager:hover { border-color: #1660AB; color: #1660AB; }
.ip-tab-pager:disabled { opacity: 0.4; cursor: not-allowed; border-color: #e0e0e0; color: #999; }

.ip-drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f7fa;
  z-index: 5;
}

.ip-drop-inner {
  width: 100%;
  max-width: 480px;
  padding: 60px 40px;
  border: 2px dashed #d9d9d9;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
}

.ip-drop-inner:hover,
.ip-drop-zone.dragover .ip-drop-inner {
  border-color: #1660AB;
  background: #f0f7ff;
}

.ip-drop-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.ip-drop-text {
  font-size: 16px;
  color: #333;
  margin-bottom: 8px;
}

.ip-drop-hint {
  font-size: 12px;
  color: #999;
}

/* ─── 右侧步骤面板 ────────────────────────────────────────── */
.ip-step-panel {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
}

.ip-step-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.ip-step-hint {
  font-size: 12px;
  color: #666;
  line-height: 1.5;
  margin-bottom: 6px;
}

.ip-step-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ip-step-btns .btn {
  flex: 1;
  min-width: 80px;
}

/* ─── 通用卡片 ────────────────────────────────────────────── */
.ip-section {
  background: #fafafa;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid #f0f0f0;
}

.ip-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

/* ─── 准星 / 裁剪 控制 ────────────────────────────────────── */
.ip-crosshair-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #e74c3c;
  font-weight: 600;
  margin-bottom: 8px;
}

.ip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.ip-dot.red { background: #e74c3c; }
.ip-dot.blue { background: #1660AB; }

.ip-dir-btns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  width: 120px;
  margin: 0 auto;
}

.ip-dir-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  font-size: 16px;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  user-select: none;
}

.ip-dir-btn:hover { background: #f0f7ff; border-color: #1660AB; color: #1660AB; }
.ip-dir-btn:active { background: #1660AB; color: #fff; }

.ip-dir-btn[data-dir="up"]    { grid-column: 2; grid-row: 1; }
.ip-dir-btn[data-dir="left"]  { grid-column: 1; grid-row: 2; }
.ip-dir-btn[data-dir="down"]  { grid-column: 2; grid-row: 2; }
.ip-dir-btn[data-dir="right"] { grid-column: 3; grid-row: 2; }

.ip-crosshair-val {
  text-align: center;
  font-size: 12px;
  color: #666;
  margin-top: 8px;
  font-family: monospace;
}

.ip-size-ctrl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
}

.ip-size-btn {
  width: 40px;
  height: 40px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  background: #fff;
  font-size: 20px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  user-select: none;
}

.ip-size-btn:hover { background: #f0f7ff; border-color: #1660AB; color: #1660AB; }
.ip-size-btn:active { background: #1660AB; color: #fff; }

.ip-size-val {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}

.ip-size-val span:first-child {
  font-size: 24px;
  font-weight: 700;
  color: #1660AB;
  line-height: 1;
}

.ip-size-unit {
  font-size: 10px;
  color: #999;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.ip-dim {
  font-size: 13px;
  color: #1660AB;
  font-weight: 600;
  text-align: center;
  padding: 10px;
  background: #f0f7ff;
  border-radius: 6px;
}

/* ─── 色包按钮 ────────────────────────────────────────────── */
.ip-set-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ip-set-btn {
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s;
}

.ip-set-btn:hover { border-color: #1660AB; color: #1660AB; }

.ip-set-btn.active {
  background: #1660AB;
  color: #fff;
  border-color: #1660AB;
}

/* ─── 进度条 ──────────────────────────────────────────────── */
.ip-progress-wrap {
  margin-top: 12px;
}

.ip-progress-bar {
  width: 100%;
  height: 10px;
  background: #f0f0f0;
  border-radius: 5px;
  overflow: hidden;
}

.ip-progress-fill {
  height: 100%;
  width: 0%;
  background: #1660AB;
  transition: width 0.1s linear;
}

.ip-progress-text {
  text-align: center;
  font-size: 13px;
  color: #666;
  margin-top: 8px;
  font-weight: 600;
}

/* ─── 选区操作 ────────────────────────────────────────────── */
.ip-op-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ip-op-btns .btn-sm {
  flex: 1;
  min-width: 60px;
  font-size: 11px;
  padding: 4px 8px;
}

/* ─── 色卡 ────────────────────────────────────────────────── */
.ip-palette-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  align-content: start;
}

.ip-color-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.ip-color-chip:hover { background: #f5f5f5; }

.ip-color-chip.active {
  border-color: #1660AB;
  background: #f0f7ff;
}

.ip-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
}

.ip-color-code {
  font-size: 10px;
  color: #666;
  font-family: monospace;
}

/* ─── 微调标签页 ──────────────────────────────────────────── */
.ip-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 8px 0 4px;
  scrollbar-width: thin;
}

.ip-tabs::-webkit-scrollbar {
  height: 5px;
}

.ip-tabs::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 3px;
}

.ip-tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 16px;
  background: #fff;
  font-size: 12px;
  color: #333;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.ip-tab:hover {
  border-color: #1660AB;
  color: #1660AB;
}

.ip-tab.active {
  background: #1660AB;
  color: #fff;
  border-color: #1660AB;
}

.ip-tab-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
}

.ip-tab.active .ip-tab-swatch {
  border-color: rgba(255,255,255,0.5);
}

.ip-tab-count {
  font-size: 10px;
  padding: 1px 4px;
  background: rgba(0,0,0,0.06);
  border-radius: 8px;
  color: #666;
}

.ip-tab.active .ip-tab-count {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.ip-tab.checked {
  border-color: #52c41a;
  background: #f6ffed;
}

.ip-tab.active.checked {
  background: #1660AB;
}

.ip-tab-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #52c41a;
  color: #fff;
  font-size: 10px;
  line-height: 1;
}

.ip-tab-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  background: #f0f7ff;
  border-radius: 6px;
  margin-bottom: 4px;
}

.ip-tab-title {
  font-weight: 600;
  color: #1660AB;
  font-size: 14px;
}

.ip-tab-sub {
  font-size: 12px;
  color: #666;
}

/* ─── 颜色选择弹窗 ────────────────────────────────────────── */
.ip-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.ip-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  overflow: hidden;
}

.ip-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #f0f0f0;
  font-weight: 600;
  font-size: 15px;
}

.ip-modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: #f5f5f5;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #666;
}

.ip-modal-close:hover { background: #e8e8e8; color: #333; }

.ip-modal-search {
  padding: 12px 18px;
  border-bottom: 1px solid #f0f0f0;
}

.ip-modal-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.ip-modal-search input:focus { border-color: #1660AB; }

.ip-modal-actions {
  padding: 10px 18px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: flex-start;
}

.ip-modal-unassign {
  padding: 6px 14px;
  border: 1px solid #1660AB;
  background: #fff;
  color: #1660AB;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}

.ip-modal-unassign:hover {
  border-color: #1660AB;
  background: #f0f7ff;
}

.ip-modal-colors {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 10px;
  align-content: flex-start;
}

.ip-modal-color {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  background: #fafafa;
  transition: all 0.12s;
}

.ip-modal-color:hover { border-color: #1660AB; background: #f0f7ff; }

.ip-modal-color .swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.08);
}

.ip-modal-color .code {
  font-size: 11px;
  color: #333;
  font-family: monospace;
  white-space: nowrap;
}

.ip-modal-color .name {
  font-size: 10px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ip-modal-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #999;
  font-size: 13px;
  padding: 30px 0;
}

/* ─── 空色点选 ────────────────────────────────────────────── */
.ip-empty-pick-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.ip-empty-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid #ccc;
  flex-shrink: 0;
}
.ip-empty-val {
  font-size: 12px;
  color: #666;
  font-family: monospace;
}
.ip-empty-tol {
  margin-top: 10px;
}
.ip-empty-tol label {
  font-size: 12px;
  color: #666;
  display: block;
  margin-bottom: 4px;
}
.ip-empty-tol input[type="range"] {
  accent-color: #1660AB;
}
.btn-sm.active {
  background: #1660AB;
  color: #fff;
  border-color: #1660AB;
}

/* ─── 响应式 ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .ip-body {
    flex-direction: column;
  }
  .ip-step-panel {
    width: 100%;
    max-height: 45vh;
    border-top: 1px solid #e0e0e0;
  }
}
