/* ================================================================
   共享侧栏样式 — 所有含设置面板的工具通用
   引用方式：<link rel="stylesheet" href="../_shared/sidebar.css">
   ================================================================ */

/* ---------- CSS 工具预设演示色 ---------- */
:root {
  --demo-purple: hsl(280 72% 62%);
}

/* ---------- 侧栏容器 ---------- */
aside {
  position: sticky;
  top: var(--space-4);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

aside.is-inactive {
  opacity: 0.4;
  pointer-events: none;
  user-select: none;
}

/* ---------- 设置面板 ---------- */
aside .panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

/* ---------- 面板标题 ---------- */
aside .panel-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-base);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

/* ---------- 数量输入组 (.qty-group) ---------- */
/* 标准结构: label + input + .opt-row 快捷按钮                 */
/* <div class="qty-group">                                     */
/*   <label class="field-label">数量</label>                   */
/*   <input class="input" ...>                                 */
/*   <div class="opt-row"> <button>N</button> ... </div>       */
/* </div>                                                      */
.qty-group {
  display: flex;
  flex-direction: column;
}
.qty-group .field-label {
  margin-bottom: 6px;
}
.qty-group .input,
.qty-group .select {
  margin-bottom: 8px;
}
.qty-group .opt-row {
  margin-top: 0;       /* 由 input/select 的 margin-bottom 控制间距 */
  grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
}

/* ---------- 选项按钮组 (.opt-row / .preset-row) ---------- */
.opt-row,
.preset-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 6px;
  margin-top: var(--space-3);
}
.opt-row:first-child,
.preset-row:first-child,
.panel-title + .opt-row,
.panel-title + .preset-row {
  margin-top: 0;
}
.opt-row .btn,
.preset-row .btn {
  padding: 8px 10px;
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
  border: 1px solid transparent;
  color: var(--fg-base);
  transition: all .15s;
  cursor: pointer;
}
.opt-row .btn:hover,
.preset-row .btn:hover {
  background: var(--bg-surface-2);
  border-color: var(--border-base);
}
.opt-row .btn.active,
.opt-row .btn.is-active,
.preset-row .btn.active,
.preset-row .btn.is-active {
  background: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
  box-shadow: 0 2px 8px rgba(var(--color-brand-rgb, 99,102,241), .25);
}

/* ---------- 滑块行 (range + value) ---------- */
aside .range-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
}
aside .range-row input[type="range"] {
  flex: 1;
}
aside .range-row .val {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-muted);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* range-row 内的 field-label 不需要下方间距，固定宽度对齐 */
aside .range-row .field-label,
aside .u-row .field-label { margin-bottom: 0; }
aside .range-row .field-label { min-width: 52px; flex-shrink: 0; }

/* ---------- 颜色输入 ---------- */
aside input[type="color"] {
  width: 34px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

/* ---------- 输出信息网格 ---------- */
.output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  color: var(--fg-muted);
  font-size: var(--text-xs);
}
.output-grid strong {
  display: block;
  color: var(--fg-strong);
  font-size: var(--text-sm);
}

/* ---------- 单选/复选选项卡 ---------- */
aside .opt-card {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 12px;
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: all .15s;
  background: var(--bg-surface);
}
aside .opt-card:hover {
  border-color: var(--color-brand);
  background: rgba(var(--color-brand-rgb, 99,102,241), .04);
}
aside .opt-card.active,
aside .opt-card:has(input:checked) {
  border-color: var(--color-brand);
  background: rgba(var(--color-brand-rgb, 99,102,241), .06);
  color: var(--color-brand);
  font-weight: 600;
}
aside .opt-card input[type="radio"],
aside .opt-card input[type="checkbox"] {
  accent-color: var(--color-brand);
}

/* ---------- 复选开关列表 ---------- */
aside .switch-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
aside .switch-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background .12s;
}
aside .switch-item:hover {
  background: var(--bg-surface-2);
}
aside .switch-item input[type="checkbox"] {
  accent-color: var(--color-brand);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ---------- 下拉框 ---------- */
aside .input,
aside select.input {
  width: 100%;
  padding: 8px 12px;
  font-size: var(--text-sm);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--fg-base);
  transition: border-color .15s;
}
aside .input:focus,
aside select.input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(var(--color-brand-rgb, 99,102,241), .12);
}

/* ---------- 字段标签 ---------- */
aside .field-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

/* ---------- 操作按钮区 ---------- */
aside .act-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
aside .act-group .btn {
  width: 100%;
  justify-content: center;
}
aside .act-group .u-row {
  flex-wrap: nowrap;
}
aside .act-group .u-row .btn {
  width: auto;
  flex: 1;
  min-width: 0;
}
aside .act-group .btn.is-primary {
  padding: 10px;
  font-weight: 700;
  font-size: var(--text-sm);
}

/* ---------- 分隔线 ---------- */
aside .sep {
  height: 1px;
  background: var(--border-base);
  margin: var(--space-3) 0;
  border: none;
}

/* ---------- 提示文字 ---------- */
aside .hint {
  font-size: 11px;
  color: var(--fg-muted);
  line-height: 1.4;
  margin-top: 4px;
}

/* ---------- 位置网格 (水印等) ---------- */
aside .pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  max-width: 156px;
  margin: 0 auto;
}
aside .pos-grid .pos-cell {
  aspect-ratio: 1;
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  transition: all .12s;
  background: var(--bg-surface);
}
aside .pos-grid .pos-cell:hover {
  border-color: var(--color-brand);
}
aside .pos-grid .pos-cell.active {
  background: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
}

/* ---------- 预览画布容器（多工具共用） ---------- */
.preview-wrap {
  position: relative;
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--preview-min-h, 300px);
}
.preview-wrap canvas {
  max-width: 100%;
  max-height: var(--canvas-max-h, 500px);
  display: block;
}

/* ---------- 悬浮删除按钮（共享视觉基础） ---------- */
.remove-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, opacity .15s;
  line-height: 1;
}
.remove-btn:hover { background: rgba(0,0,0,.7); }
.remove-btn [data-lucide] { width: 14px; height: 14px; }

/* ---------- 预设卡片列表（images_border / images_merge 等） ---------- */
.preset-list { display: grid; gap: var(--space-2); }
.preset-card {
  display: grid;
  grid-template-columns: var(--preset-thumb, 56px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--fg-base);
  text-align: left;
  cursor: pointer;
}
.preset-card:hover { border-color: var(--border-strong); background: var(--bg-surface-2); }
.preset-card.active { border-color: var(--color-brand); box-shadow: inset 0 0 0 1px var(--color-brand); }
.preset-card-copy { display: grid; gap: 2px; min-width: 0; }
.preset-card-copy strong { color: var(--fg-strong); font-size: var(--text-xs); }
.preset-card-copy span { color: var(--fg-muted); font-size: 11px; line-height: 1.25; }

/* ---------- 折叠示例区（CSS 工具共用） ---------- */
.tool-details summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg-base);
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  aside {
    position: static;
  }
  aside .panel {
    padding: var(--space-3) var(--space-4);
  }
  .preset-list { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}
