/* 拼豆图纸生成器 - 自定义样式 */

/* 隐藏默认数字输入箭头 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

/* ========== 主题背景 ========== */
.app-bg {
  transition: background 0.6s ease;
}
body.theme-sakura .app-bg {
  background:
    radial-gradient(1200px 500px at 10% -10%, #ffd9e6 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 10%, #dbeafe 0%, transparent 60%),
    linear-gradient(180deg, #fff5f7 0%, #f5f8ff 100%);
}
body.theme-ocean .app-bg {
  background:
    radial-gradient(1200px 500px at 10% -10%, #bae6fd 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 10%, #e0e7ff 0%, transparent 60%),
    linear-gradient(180deg, #f0f9ff 0%, #f5f3ff 100%);
}
body.theme-mint .app-bg {
  background:
    radial-gradient(1200px 500px at 10% -10%, #d1fae5 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 10%, #ecfccb 0%, transparent 60%),
    linear-gradient(180deg, #f0fdf4 0%, #fefce8 100%);
}
body.theme-dark {
  color: #e2e8f0;
}
body.theme-dark .app-bg {
  background:
    radial-gradient(1200px 500px at 10% -10%, #1e293b 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 10%, #312e81 0%, transparent 60%),
    linear-gradient(180deg, #0f172a 0%, #111827 100%);
}
body.theme-dark aside,
body.theme-dark .bg-white {
  background-color: rgba(30, 41, 59, 0.85) !important;
  color: #e2e8f0;
  border-color: rgba(71, 85, 105, 0.3) !important;
}
body.theme-dark select,
body.theme-dark input[type="number"] {
  background-color: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}
body.theme-dark .text-slate-500,
body.theme-dark .text-slate-600,
body.theme-dark .text-slate-700,
body.theme-dark .text-slate-800 {
  color: #cbd5e1 !important;
}
body.theme-dark .bg-slate-50 { background-color: #1e293b !important; }
body.theme-dark .border-slate-100,
body.theme-dark .border-slate-200 { border-color: #334155 !important; }

/* ========== 侧边导航按钮 ========== */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  width: 100%;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-align: left;
  transition: all .2s ease;
  background: transparent;
  border: 1px solid transparent;
}
.nav-item i { font-size: 16px; }
.nav-item:hover {
  background: rgba(255, 71, 115, 0.06);
  color: #ff4773;
}
.nav-item.active {
  background: linear-gradient(135deg, #ff4773, #ff80a8);
  color: white;
  box-shadow: 0 6px 16px -4px rgba(255, 71, 115, .5);
}
body.theme-dark .nav-item { color: #94a3b8; }
body.theme-dark .nav-item:hover { background: rgba(255,255,255,.08); color:#fff; }

/* ========== 皮肤按钮 ========== */
.theme-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s, border-color .2s;
}
.theme-btn:hover { transform: scale(1.08); }
.theme-btn.active { border-color: #0f172a; box-shadow: 0 0 0 2px white, 0 0 0 4px #ff4773; }

/* ========== 尺寸按钮 ========== */
.size-btn {
  padding: 10px 0;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  background: white;
  transition: all .2s;
  cursor: pointer;
}
.size-btn:hover { border-color: #ff80a8; transform: translateY(-1px); }
.size-btn.active {
  border-color: #ff4773 !important;
  background: linear-gradient(135deg, #fff5f7, #ffe4ec) !important;
  color: #b91545 !important;
}

/* ========== 快捷按钮 ========== */
.preset-btn {
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  transition: all .15s ease;
}
.preset-btn:hover {
  color: #b91545;
  border-color: #ffc6d6;
  background: #fff5f7;
}

/* ========== 数字输入框组（宽度 / 高度 / 颜色数量） ========== */
.num-input-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: border-color .15s, box-shadow .15s;
}
.num-input-group:focus-within {
  border-color: #ff80a8;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 71, 115, 0.12);
}
.num-step-btn {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  color: #64748b;
  background: transparent;
  border: none;
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
}
.num-step-btn:hover { background: #fff; color: #ff4773; }
.num-step-btn:active { transform: scale(0.92); }
.num-input {
  width: 44px;
  height: 22px;
  padding: 0 2px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  background: transparent;
  border: none;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.num-input { -moz-appearance: textfield; }
.num-unit {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  padding: 0 6px 0 2px;
}
.num-auto-tag {
  font-size: 10px;
  font-weight: 700;
  color: #b91545;
  background: linear-gradient(135deg, #ffe4ec, #fff5f7);
  padding: 2px 8px;
  margin-right: 2px;
  border-radius: 999px;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.num-auto-tag.show {
  opacity: 1;
  transform: scale(1);
}
body.theme-dark .num-input-group {
  background: #1e293b;
  border-color: #334155;
}
body.theme-dark .num-input-group:focus-within {
  background: #0f172a;
  border-color: #ff80a8;
}
body.theme-dark .num-input { color: #f1f5f9; }
body.theme-dark .num-step-btn { color: #cbd5e1; }
body.theme-dark .num-step-btn:hover { background: #334155; color: #fff; }
body.theme-dark .num-unit { color: #64748b; }

/* 高度区块解锁状态 */
#heightBlock.enabled {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* ========== 预览 Tab ========== */
.preview-tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #f1f5f9;
  gap: 2px;
}
.preview-tab {
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all .2s;
  border: none;
  background: transparent;
}
.preview-tab:hover { color: #ff4773; }
.preview-tab.active {
  background: white;
  color: #ff4773;
  box-shadow: 0 2px 6px -1px rgba(0,0,0,.08);
}

/* ========== 统计卡片 ========== */
.stat-card {
  position: relative;
  background: white;
  border-radius: 20px;
  padding: 14px 16px;
  border: 1px solid #f1f5f9;
  box-shadow: 0 4px 16px -4px rgba(0,0,0,0.04);
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -8px rgba(0,0,0,0.1);
}
.stat-card-accent {
  background: linear-gradient(135deg, #ff4773, #ff80a8);
  color: white;
  border-color: transparent;
  box-shadow: 0 10px 24px -6px rgba(255, 71, 115, .5);
}
.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  font-size: 16px;
  margin-bottom: 8px;
}
.stat-label { font-size: 12px; color: #64748b; }
.stat-value { font-size: 20px; font-weight: 800; color: #1e293b; line-height: 1.2; margin-top: 2px; }
.stat-card-accent .stat-value { color: white; }
body.theme-dark .stat-card .stat-value { color: #f1f5f9; }

/* ========== 范围滑杆美化 ========== */
input[type="range"] {
  -webkit-appearance: none;
  height: 6px;
  border-radius: 999px;
  /* --pct 由 JS 动态更新，决定粉色填充到的位置 */
  background: linear-gradient(to right,
    #ff4773 0%,
    #ff80a8 var(--pct, 50%),
    #e2e8f0 var(--pct, 50%),
    #e2e8f0 100%);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid #ff4773;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(255, 71, 115, .4);
  transition: transform .1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid #ff4773;
  cursor: pointer;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ========== 拖拽状态 ========== */
.drag-over {
  background-color: rgba(255, 71, 115, 0.06) !important;
}

/* ========== 打印 ========== */
@media print {
  body * { visibility: hidden; }
  #patternCanvas, #patternCanvas * { visibility: visible; }
  #patternCanvas {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
  }
  aside, header, footer, .no-print { display: none !important; }
}

/* ========== Toast ========== */
#toast.show {
  opacity: 1 !important;
  transform: translate(-50%, -10px);
}

/* ========== 动画 ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fadeInUp { animation: fadeInUp .25s ease both; }

/* 响应式：小屏侧栏收缩 */
@media (max-width: 900px) {
  aside.w-\[200px\] {
    width: 64px;
    padding: 12px 8px;
  }
  aside .nav-item span,
  aside .text-\[11px\],
  aside .text-\[10px\],
  aside .font-black,
  aside .text-slate-400,
  aside .theme-btn,
  aside [class*="扫码"] {
    display: none;
  }
  aside .nav-item { justify-content: center; padding: 10px 0; }
  aside .nav-item i { font-size: 18px; }
}

/* ========== 图纸编辑器 ========== */
.edit-tool {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid transparent;
  transition: all .15s ease;
  cursor: pointer;
}
.edit-tool:hover:not(:disabled) {
  background: #fff5f7;
  color: #ff4773;
  border-color: #ffc6d6;
}
.edit-tool.active {
  background: linear-gradient(135deg, #ff4773, #ff80a8);
  color: #fff;
  box-shadow: 0 4px 10px -2px rgba(255, 71, 115, .5);
  border-color: transparent;
}
.edit-tool:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
body.theme-dark .edit-tool { background: #334155; color: #cbd5e1; }
body.theme-dark .edit-tool:hover:not(:disabled) { background: #475569; color: #fff; }

/* ========== 编辑模式下的缩放容器 ========== */
/* 默认模式：两个 wrap 以 inline-block 方式让 canvas 自适应容器 */
/* 编辑模式：previewStage 下任意一个 wrap 进入"可滚动+缩放"状态 */
#previewStage.zooming [data-view-pane] {
  overflow: auto;
  /* 内容小于容器时居中；超出时可滚动查看 */
  align-items: center;
  justify-content: center;
  padding: 8px;
}
#previewStage.zooming #pixelWrap,
#previewStage.zooming #patternWrap {
  display: inline-block;
  /* 编辑模式不使用 transform，直接通过 canvas 的显式 width/height 控制缩放。
     这样 wrap 的布局盒子尺寸 === 显示尺寸，flex 容器能正确居中。 */
  transform: none;
  max-width: none;
  max-height: none;
  position: relative;
  flex: 0 0 auto;
}
#previewStage.zooming #pixelWrap canvas,
#previewStage.zooming #patternWrap canvas {
  /* canvas 的 CSS 显示尺寸由 JS 动态设置为 cssW*zoom × cssH*zoom */
  max-width: none;
  max-height: none;
}

/* 缩放控制条（编辑时才显示） */
#zoomBar {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 30;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  box-shadow: 0 6px 16px -4px rgba(0,0,0,0.12);
  font-size: 12px;
  color: #475569;
}
#zoomBar.show { display: inline-flex; }
#zoomBar button {
  width: 26px; height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  background: transparent;
  transition: background .15s, color .15s;
  cursor: pointer;
}
#zoomBar button:hover { background: #fff5f7; color: #ff4773; }
#zoomBar .zoom-val {
  min-width: 42px;
  text-align: center;
  font-weight: 700;
  color: #1e293b;
}
body.theme-dark #zoomBar {
  background: rgba(30,41,59,0.9);
  border-color: #334155;
  color: #cbd5e1;
}
body.theme-dark #zoomBar .zoom-val { color: #f1f5f9; }
body.theme-dark #zoomBar button { color: #cbd5e1; }
body.theme-dark #zoomBar button:hover { background: #475569; color: #fff; }

/* 颜色选择弹窗 */
.color-tab {
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 600;
  transition: all .15s;
  border: none;
  cursor: pointer;
}
.color-tab:hover { color: #ff4773; }
.color-tab.active {
  background: linear-gradient(135deg, #ff4773, #ff80a8);
  color: #fff;
  box-shadow: 0 2px 6px -1px rgba(255, 71, 115, .4);
}

.color-cell {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, border-color .15s;
  overflow: hidden;
}
.color-cell .code {
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.color-cell .name {
  font-size: 9px;
  opacity: 0.85;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.color-cell:hover {
  transform: translateY(-1px) scale(1.04);
  border-color: #ff4773;
  box-shadow: 0 6px 16px -4px rgba(255,71,115,0.4);
}

/* overlay canvas：覆盖在 pixelCanvas 之上，尺寸由父容器尺寸自适应控制 */
#pixelWrap, #patternWrap { line-height: 0; }
#pixelWrap canvas, #patternWrap canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; }
#pixelOverlay, #patternOverlay {
  position: absolute !important;
  left: 0; top: 0;
  /* 宽高必须与主 canvas 的显示尺寸完全一致 */
  width: 100% !important;
  height: 100% !important;
  image-rendering: auto;
}