﻿﻿/**
 * 常用标签模块 - 样式
 * 实验室智能台账系统
 */

.container { max-width: 1440px; margin: 0 auto; padding: 24px; }

.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}

.header-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.back-btn {
  padding: 8px 16px; background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: 8px; color: var(--text-primary); text-decoration: none; font-size: .9rem;
}
.back-btn:hover { border-color: var(--accent-primary); }

.page-title { font-size: 1.8rem; font-weight: 600; color: var(--text-primary); }

/* ── 分类标签 ── */
.category-tabs {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px;
}

.cat-tab {
  padding: 8px 18px; border: 1px solid var(--border-color); background: var(--bg-secondary);
  border-radius: 999px; color: var(--text-secondary); cursor: pointer; font-size: .88rem;
  transition: all .2s; font-family: inherit;
}
.cat-tab:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.cat-tab.active {
  background: var(--accent-primary); color: #fff; border-color: var(--accent-primary);
}

/* ── 主布局 ── */
.main-layout {
  display: grid; grid-template-columns: 360px 1fr; gap: 24px; align-items: start;
}

/* 模板库列表 */
.template-library {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 16px; max-height: calc(100vh - 160px);
  overflow-y: auto; position: sticky; top: 24px;
}

.template-library h3 {
  font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
}

/* 增加标签按钮 */
.add-tpl-btn {
  padding: 4px 12px; font-size: .78rem; font-weight: 500;
  background: var(--accent-primary); color: #fff;
  border: none; border-radius: 6px; cursor: pointer; font-family: inherit;
  transition: all .18s; white-space: nowrap;
}
.add-tpl-btn:hover { opacity: .9; transform: translateY(-1px); }
.add-tpl-btn:active { transform: translateY(0); opacity: .85; }

.tpl-card {
  display: flex; gap: 12px; padding: 12px; border-radius: 8px;
  border: 2px solid transparent; background: var(--bg-secondary);
  cursor: pointer; margin-bottom: 8px; transition: all .18s;
}
.tpl-card:hover { border-color: var(--accent-primary); background: var(--bg-tertiary); }
.tpl-card.active { border-color: var(--accent-primary); background: rgba(59,130,246,.12); }
[data-theme="dark"] .tpl-card.active { background: rgba(59,130,246,.18); }

.tpl-thumb {
  width: 48px; height: 48px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border-color); overflow: hidden;
}
.tpl-thumb svg { width: 100%; height: 100%; }

.tpl-info { flex: 1; min-width: 0; }
.tpl-name { font-size: .88rem; font-weight: 600; color: var(--text-primary); }
.tpl-desc { font-size: .74rem; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }

/* 右侧：表单 + 预览 */
.right-panel { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 22px;
}

.card-title {
  font-size: 1.08rem; font-weight: 600; margin-bottom: 16px;
  color: var(--text-primary); padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* 表单 */
.form-section { margin-bottom: 16px; }
.form-section h4 {
  font-size: .88rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 10px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.form-row-full { margin-bottom: 12px; }

.form-label {
  display: block; font-size: .82rem; color: var(--text-secondary);
  margin-bottom: 5px; font-weight: 500;
}
.form-input, .form-select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-color);
  border-radius: 6px; background: var(--bg-secondary); color: var(--text-primary);
  font-size: .88rem; box-sizing: border-box; font-family: inherit;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

/* 打印数量选择 */
.size-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

/* 操作按钮 */
.action-row {
  display: flex; gap: 12px; flex-wrap: wrap;
}

.btn {
  padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer;
  font-size: .88rem; font-weight: 500; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; transition: all .18s; font-family: inherit;
}
.btn-primary { background: var(--accent-primary); color: #fff; }
.btn-primary:hover { opacity: .92; }
.btn-secondary {
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover { border-color: var(--accent-primary); }
.btn-success { background: var(--accent-secondary); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 预览区 */
.preview-card {}

.sheet-stage {
  background: #e5e7eb; border-radius: 8px; padding: 20px;
  max-height: 560px; overflow: auto;
  display: flex; justify-content: center; align-items: flex-start;
}
[data-theme="dark"] .sheet-stage { background: #1f2937; }

/* A4 纸张容器 */
.a4-sheet {
  width: 210mm; min-height: 297mm; background: #fff;
  box-shadow: 0 4px 18px rgba(0,0,0,.15);
  font-family: "Microsoft YaHei", "SimHei", "PingFang SC", sans-serif;
  box-sizing: border-box;
}

/* ── 标签模板 A：字段填写型（试剂/培养基/生物材料 通用） ── */
.label-grid {
  padding: 1.5mm; display: grid;
  grid-template-columns: repeat(3, 67mm);
  grid-template-rows: repeat(7, 39.43mm);
  column-gap: 3mm; row-gap: 3mm;
  justify-content: center; align-content: center;
}
.label-grid.bleed {
  padding: 0; grid-template-columns: repeat(3, 67.967mm);
  grid-template-rows: repeat(7, 39.857mm);
  column-gap: 3mm; row-gap: 3mm;
}

.label-cell {
  border: 1px solid #333; border-radius: 2mm;
  padding: 3mm 3.5mm;
  display: flex; flex-direction: column;
  justify-content: space-between;
  overflow: hidden; page-break-inside: avoid;
  font-size: 9.5pt; line-height: 1.25; color: #000;
}

.label-cell .title {
  font-size: 11pt; font-weight: 700;
  display: flex; align-items: flex-end;
  padding-bottom: 1.2mm;
}
.label-cell .title .val {
  flex: 1; margin-left: 1mm; border-bottom: 1px solid #555;
  min-height: 11pt; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.label-cell .row {
  display: flex; align-items: flex-end; gap: 0;
}
.label-cell .row .field { white-space: nowrap; }
.label-cell .row .fill {
  display: inline-block; border-bottom: 1px solid #555;
  min-height: 9.5pt; margin-left: 1mm;
}
.label-cell .row .fill.s  { min-width: 15.7mm; }
.label-cell .row .fill.m  { min-width: 26mm; }
.label-cell .row .fill.l  { min-width: 34mm; }

.label-cell .row .field.prep {
  display: flex; align-items: flex-end; flex: 1;
  margin-left: 3.4mm;
}
.label-cell .row .field.prep .fill {
  flex: 1; min-width: 0; margin-left: 1mm;
  border-bottom: 1px solid #555;
}

.label-cell .row .field.storage-r {
  display: flex; align-items: flex-end; flex: 1; margin-left: 0;
}
.label-cell .row .field.storage-r .fill {
  flex: 1; margin-left: 1mm; border-bottom: 1px solid #555;
}

.label-cell .row .field.prep-r {
  display: flex; align-items: flex-end; margin-left: 3mm; white-space: nowrap;
}
.label-cell .row .field.prep-r .fill {
  display: inline-block; min-width: 16mm; margin-left: 1mm;
  border-bottom: 1px solid #555;
}

.label-cell .line {
  display: flex; align-items: flex-end;
}
.label-cell .line .fill {
  flex: 1; margin-left: 1mm; border-bottom: 1px solid #555;
  min-height: 9.5pt;
}
.label-cell .line .date {
  display: flex; align-items: flex-end; flex: 1;
  margin-left: 1mm; border-bottom: 1px solid #555; min-height: 9.5pt;
}
.label-cell .line .date .d { display: inline-block; }
.label-cell .line .date .w3 { flex: 3; min-width: 10mm; }
.label-cell .line .date .w1 { flex: 1; min-width: 3.5mm; }
.label-cell .line .date .w2 { flex: 2; min-width: 7mm; }

.label-cell .storage {
  display: flex; align-items: flex-end;
}
.label-cell .storage .fill {
  flex: 1; margin-left: 1mm; border-bottom: 1px solid #555;
  min-height: 9.5pt;
}

/* ── 警示标签模板 B：GB 2894 SVG 图标 + 大字 + 小字 ──
   按用户 PDF 参考稿提供两种版式：
   · .warn-grid-l   横版 A4（297×210mm）2×2 = 4 枚 / 格 148.5×105mm
   · .warn-grid-p   竖版 A4（210×297mm）上下 2 = 2 枚 / 格 210×148.5mm
*/

/* A4 横版 sheet 容器（仅用于浏览器预览 + 打印时 @page size: A4 landscape） */
.a4-sheet.sheet-landscape { width: 297mm; min-height: 210mm; }

/* 横版 2×2 grid */
.warn-grid-l {
  padding: 3mm;
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  column-gap: 3mm; row-gap: 3mm;
  height: 210mm;
}

/* 竖版 上下 2 grid */
.warn-grid-p {
  padding: 3mm;
  display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr 1fr;
  row-gap: 3mm;
  height: 297mm;
}

/* 单卡通用 */
.warn-card {
  background: #fff;
  border: 1px solid #888;
  border-radius: 4mm;
  padding: 7mm 10mm;
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  text-align: center; overflow: hidden;
  page-break-inside: avoid; color: #000;
  box-sizing: border-box;
}

.warn-card .wc-icon {
  width: 45mm; height: 45mm;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.warn-card .wc-icon svg { width: 100%; height: 100%; display: block; }

.warn-card .wc-title {
  font-size: 26pt; font-weight: 900; line-height: 1.15;
  letter-spacing: 1pt; color: #000;
  font-family: "SimHei", "Microsoft YaHei", sans-serif;
  word-break: break-all;
}

.warn-card .wc-subs {
  font-size: 10pt; color: #444; font-weight: 500;
  line-height: 1.4;
  max-width: 100%;
}

/* 横版单卡：上下三段均分 */
.warn-card.warn-card-l {
  padding-top: 9mm; padding-bottom: 5mm;
}
.warn-card.warn-card-l .wc-icon { width: 40mm; height: 40mm; }
.warn-card.warn-card-l .wc-title { font-size: 18pt; }
.warn-card.warn-card-l .wc-subs { font-size: 9pt; }

/* 竖版单卡：图标更大，标题更粗 */
.warn-card.warn-card-p {
  padding-top: 16mm; padding-bottom: 10mm;
}
.warn-card.warn-card-p .wc-icon { width: 70mm; height: 70mm; }
.warn-card.warn-card-p .wc-title { font-size: 32pt; }
.warn-card.warn-card-p .wc-subs {
  font-size: 13pt; color: #333; font-weight: 600;
  line-height: 1.6;
}

/* GB 图标类 */
.gb-icon { width: 100%; height: 100%; display: block; }
.gb-warning polygon, .gb-prohibition circle, .gb-prohibition line { vector-effect: non-scaling-stroke; }

/* ── 区域标识（A4 整页红底白字版） ── */
.zone-red-a4 {
  width: 210mm; height: 297mm;
  background: #DA251C;
  box-sizing: border-box;
  padding: 12mm;
  page-break-inside: avoid;
}
.zone-red-inner {
  width: 100%; height: 100%;
  border: 5mm solid #fff;
  border-radius: 12mm;
  box-sizing: border-box;
  padding: 14mm 18mm 18mm;
  color: #fff;
  display: flex; flex-direction: column;
}
.zone-red-title {
  font-size: 72pt; font-weight: 900; text-align: center;
  line-height: 1.05; letter-spacing: 3pt;
  font-family: "SimHei", "Microsoft YaHei", sans-serif;
  padding-top: 2mm;
}
.zone-red-divider {
  width: 60%; height: 3mm;
  background: #fff; margin: 5mm auto 8mm;
  border-radius: 2mm;
}
.zone-red-icon {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 90mm;
}
.zone-red-icon .zone-svg {
  width: 90mm; height: 90mm; display: block;
}
.zone-red-subs {
  text-align: center;
  font-size: 28pt; font-weight: 700; line-height: 1.45;
  font-family: "SimHei", "Microsoft YaHei", sans-serif;
  padding-bottom: 2mm;
}

/* 旧版（已废弃但保留 fallback） */
.full-sheet-label {
  width: 210mm; height: 297mm; padding: 10mm;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  box-sizing: border-box;
}

/* ── 打印模式隐藏控制区 ── */
@media print {
  .app-header, .app-footer, .category-tabs,
  .template-library, .right-panel .card:not(.preview-card),
  .page-header, .no-print { display: none !important; }

  .main-layout { display: block; }
  .container { max-width: none; padding: 0; margin: 0; }
  .sheet-stage { background: #fff; padding: 0; max-height: none; overflow: visible; }
  .a4-sheet { box-shadow: none; margin: 0; }

  @page { size: A4; margin: 0; }
}

/* ── 响应式 ── */
@media (max-width: 1024px) {
  .main-layout { grid-template-columns: 1fr; }
  .template-library {
    position: static; max-height: none;
  }
}

@media (max-width: 768px) {
  .container { padding: 14px; }
  .page-title { font-size: 1.4rem; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .a4-sheet { transform-origin: top left; transform: scale(.4); }
  .sheet-stage { padding: 10px; }
}

@media (max-width: 400px) {
  .a4-sheet { transform: scale(.33); }
}

/* ═══════════════════════════════════════════════════════════
   新增标签模板 Modal 表单
═══════════════════════════════════════════════════════════ */

.add-form .form-group { margin-bottom: 14px; }
.add-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }

/* 预设选项（卡片式单选） */
.preset-row {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.preset-opt {
  flex: 1; min-width: 160px; cursor: pointer;
}
.preset-opt input { display: none; }
.preset-opt span {
  display: block; padding: 12px 14px; border-radius: 8px;
  border: 2px solid var(--border-color); background: var(--bg-secondary);
  font-size: .85rem; font-weight: 500;
  transition: all .18s; line-height: 1.5;
}
.preset-opt span small { display: block; font-weight: 400; color: var(--text-muted); font-size: .72rem; margin-top: 2px; }
.preset-opt:hover span { border-color: var(--accent-primary); }
.preset-opt input:checked + span {
  border-color: var(--accent-primary);
  background: rgba(59,130,246,.12);
  color: var(--accent-primary);
}
[data-theme="dark"] .preset-opt input:checked + span {
  background: rgba(59,130,246,.2);
}

/* 图标选择 */
.icon-row {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.icon-opt {
  cursor: pointer;
}
.icon-opt input { display: none; }
.icon-opt span {
  display: block; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border-color); background: var(--bg-secondary);
  font-size: .82rem; font-weight: 500; transition: all .15s;
}
.icon-opt:hover span { border-color: var(--accent-primary); }
.icon-opt input:checked + span {
  border-color: var(--accent-primary);
  background: rgba(59,130,246,.12);
  color: var(--accent-primary);
}

/* 字段编辑器 */
.field-editor {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 12px; margin-top: 6px;
}
.field-editor-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.field-editor-header label {
  font-size: .85rem; font-weight: 600; color: var(--text-secondary);
}
.field-list { display: flex; flex-direction: column; gap: 8px; }
.field-row {
  display: flex; gap: 8px; align-items: center;
}
.field-row .form-input {
  flex: 1; min-width: 0;
}
.field-row .btn-danger {
  padding: 7px 10px; font-size: 1rem;
  background: transparent; color: var(--accent-danger);
  border: 1px solid var(--accent-danger);
  width: 32px; height: 32px; border-radius: 6px;
}
.field-row .btn-danger:hover {
  background: var(--accent-danger); color: #fff;
}

/* 自定义模板标记 */
.custom-tpl { position: relative; }
.custom-tag {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  font-size: .62rem; font-weight: 600; margin-left: 6px;
  background: rgba(16,185,129,.18); color: #059669;
  vertical-align: middle;
}
[data-theme="dark"] .custom-tag {
  background: rgba(16,185,129,.25); color: #34d399;
}

/* Toast 容器位置 */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 18px; border-radius: 8px;
  font-size: .88rem; font-weight: 500; color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  animation: toastIn .28s ease-out;
}
.toast-out { animation: toastOut .28s ease-in forwards; }
.toast-success { background: #047857; }
.toast-error   { background: #b91c1c; }
.toast-info    { background: #1d4ed8; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }
