/* ==========================================================================
   GB/T 9704-2012 党政机关公文格式 标准样式规范表
   严格对标国家标准：A4纸张、版心、边距、字体、行距与排版规则
   ========================================================================== */

:root {
  /* 标准公文字体族定义（首选嵌入方正小标宋，兼顾各操作系统字库命名） */
  --gw-font-xiaobiaosong: "FZXiaoBiaoSong-B05S", "方正小标宋简体", "方正小标宋_GBK", "FZXSSK--GBK1-0", "XiaoBiaoSong", "SimSun", serif;
  --gw-font-fangsong: "FangSong", "仿宋", "FangSong_GB2312", "STFangsong", "SimSun", serif;
  --gw-font-hei: "SimHei", "黑体", "STHeiti", "PingFang SC", "Microsoft YaHei", sans-serif;
  --gw-font-kai: "KaiTi", "楷体", "KaiTi_GB2312", "STKaiti", "Kaiti SC", serif;
  --gw-font-song: "SimSun", "宋体", "STSong", "Songti SC", serif;

  /* 标准字号（点数对应） */
  --gw-size-1: 26pt;      /* 1号: 26pt */
  --gw-size-2: 22pt;      /* 2号: 22pt (公文主标题) */
  --gw-size-3: 16pt;      /* 3号: 16pt (正文、一至四级标题) */
  --gw-size-4: 14pt;      /* 4号: 14pt (页码、大表格) */
  --gw-size-xiao4: 12pt;  /* 小4号: 12pt (紧凑表格、附注) */
  --gw-size-5: 10.5pt;    /* 5号: 10.5pt */

  /* 标准公文版面行距：225mm版心排22行，每行约 10.227mm ≈ 28.98pt */
  --gw-line-height: 28.98pt;
  --gw-line-height-table: 19pt; /* 国标公文表格4号/小4号字单倍/紧凑行距(约1.36倍)，舒展不拥挤 */

  /* 公文红色标准色 */
  --gw-red-color: #e50012;
}

/* 纸张容器（屏幕显示 A4 效果） */
.a4-page-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 24px 10px 60px;
}

.a4-page {
  width: 210mm;
  min-height: 297mm;
  height: auto;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
  position: relative;
  box-sizing: border-box;

  /* 严格遵循国标 GB/T 9704-2012 版面边距：
     天头（上白边）：37mm ± 1mm
     地脚（下白边）：35mm ± 1mm
     订口（左白边）：28mm ± 1mm
     切口（右白边）：26mm ± 1mm
     版心尺寸：156mm × 225mm
  */
  padding-top: 37mm;
  padding-right: 26mm;
  padding-bottom: 35mm;
  padding-left: 28mm;

  /* 文字排版基础属性 */
  font-family: var(--gw-font-fangsong);
  font-size: var(--gw-size-3);
  color: #000000;
  line-height: var(--gw-line-height);
  text-align: justify;
  text-justify: inter-ideograph;
  word-break: break-word;
  line-break: strict;
  overflow: visible;
}

/* 一页纸紧凑压缩模式（适用于希望单页打印完所有议程的场景） */
.gw-compact-fit {
  --gw-line-height: 22pt !important;
  --gw-line-height-table: 16pt !important;
  font-size: 14pt !important;
}

.gw-compact-fit .gw-title {
  margin-bottom: 8pt !important;
  line-height: 26pt !important;
  font-size: 18pt !important;
  white-space: pre-line;
}

.gw-compact-fit .gw-subtitle {
  margin-top: -4pt !important;
  margin-bottom: 8pt !important;
}

.gw-compact-fit .gw-red-header {
  margin-bottom: 4mm !important;
}

.gw-compact-fit .gw-red-line {
  margin: 0 0 4mm 0 !important;
}

.gw-compact-fit .gw-meta-section {
  margin-bottom: 4pt !important;
}

.gw-compact-fit .gw-meta-item {
  font-size: 13pt !important;
  line-height: 20pt !important;
}

.gw-compact-fit .gw-h1 {
  font-size: 14pt !important;
  margin-top: 6pt !important;
  margin-bottom: 4pt !important;
}

.gw-compact-fit .gw-h2 {
  font-size: 13.5pt !important;
  line-height: 20pt !important;
}

.gw-compact-fit .gw-agenda-content {
  font-size: 12.5pt !important;
  line-height: 18pt !important;
  margin-bottom: 4pt !important;
}

.gw-compact-fit .gw-table th,
.gw-compact-fit .gw-table td {
  padding: 3pt 3pt !important;
  font-size: 11pt !important;
  line-height: 15pt !important;
}

.gw-compact-fit .gw-signoff {
  padding-top: 6pt !important;
  font-size: 13pt !important;
}

/* 版心区域指示线（辅助视图开关） */
.show-rulers .a4-page::before {
  content: "";
  position: absolute;
  top: 37mm;
  left: 28mm;
  right: 26mm;
  bottom: 35mm;
  border: 1px dashed rgba(229, 0, 18, 0.35);
  pointer-events: none;
  z-index: 10;
}

.show-rulers .a4-page::after {
  content: "版心尺寸 156mm × 225mm (上37 下35 左28 右26)";
  position: absolute;
  top: 10mm;
  left: 28mm;
  font-size: 11px;
  color: #e50012;
  font-family: var(--gw-font-song);
  pointer-events: none;
}

/* 公文主体内容区 */
.gw-content {
  width: 156mm;
  min-height: 225mm;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* ------------------ 公文标题 ------------------ */
/* 2号小标宋体，不加粗，居中排布，词意相对完整 */
.gw-title {
  font-family: var(--gw-font-xiaobiaosong);
  font-size: var(--gw-size-2);
  line-height: 30pt;
  text-align: center;
  margin-top: 0;
  margin-bottom: 12pt;
  font-weight: normal;
  letter-spacing: 0;
  white-space: pre-line;
  word-break: break-word;
}

.gw-subtitle {
  font-family: var(--gw-font-kai);
  font-size: var(--gw-size-3);
  text-align: center;
  margin-top: -8pt;
  margin-bottom: 10pt;
}

/* ------------------ 红头文书样式 ------------------ */
.gw-red-header {
  margin-bottom: 2mm;
  text-align: center;
}

.gw-red-org {
  font-family: var(--gw-font-xiaobiaosong);
  font-size: 26pt;
  font-weight: bold;
  color: var(--gw-red-color);
  letter-spacing: 1px;
  line-height: 1.15;
  margin-bottom: 2mm;
}

.gw-doc-code-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--gw-font-fangsong);
  font-size: var(--gw-size-3); /* GB/T 9704-2012 7.2.5/7.2.6: 发文字号用3号仿宋体字，签发人用3号仿宋体字 */
  line-height: var(--gw-line-height);
  margin-bottom: 3.5mm;
}

.gw-doc-code {
  flex: 1;
  text-align: center; /* GB/T 9704-2012 7.2.5: 无签发人时发文字号居中排布 */
  letter-spacing: 0.5px;
}

/* GB/T 9704-2012 7.2.6: 上行文有签发人时，发文字号居左空一字，签发人姓名居右空一字 */
.gw-has-signer .gw-doc-code {
  text-align: left;
  padding-left: 1em; /* 居左空一字 */
}

.gw-signer {
  flex: 0 0 auto;
  font-family: var(--gw-font-fangsong);
  font-size: var(--gw-size-3); /* “签发人”三字用3号仿宋体字 */
  padding-right: 1em; /* 居右空一字 */
}

.gw-signer-name {
  font-family: var(--gw-font-kai); /* 签发人姓名用3号楷体字 */
}

.gw-red-line {
  border: none;
  height: 1.2mm;
  background-color: var(--gw-red-color);
  margin: 0 0 3.5mm 0;
}

/* ------------------ 会议元信息（时间、地点、主持人、参会人） ------------------ */
.gw-meta-section {
  margin-bottom: 4pt;
}

.gw-meta-item {
  display: flex;
  align-items: baseline;
  line-height: var(--gw-line-height); /* GB/T 9704-2012: 公文正文与要素统一采用标准行距 */
  margin-bottom: 0;
  font-size: var(--gw-size-3);
  font-family: var(--gw-font-fangsong);
}

.gw-meta-label {
  flex: 0 0 4.2em;
  text-align: justify;
  text-align-last: justify;
  font-family: var(--gw-font-hei);
  font-weight: bold;
  color: #000000;
  letter-spacing: 0;
  white-space: nowrap;
}

.gw-meta-colon {
  flex: 0 0 auto;
  font-family: var(--gw-font-hei);
  font-weight: bold;
  margin-right: 0.25em;
  color: #000000;
}

.gw-meta-value {
  flex: 1;
  text-align: justify;
  text-justify: inter-ideograph;
  color: #000000;
  word-break: break-all;
}

/* ------------------ 各级公文标题规范 ------------------ */
.gw-h1 {
  font-family: var(--gw-font-hei);
  font-size: var(--gw-size-3);
  font-weight: bold;
  text-indent: 0;
  margin-top: 8pt;
  margin-bottom: 4pt;
  line-height: var(--gw-line-height);
}

.gw-h2 {
  font-family: var(--gw-font-kai);
  font-size: var(--gw-size-3);
  font-weight: normal;
  text-indent: 2em;
  margin: 0;
  line-height: var(--gw-line-height);
}

.gw-h3 {
  font-family: var(--gw-font-fangsong);
  font-size: var(--gw-size-3);
  font-weight: bold;
  text-indent: 2em;
  margin: 0;
  line-height: var(--gw-line-height);
}

.gw-p,
.gw-body,
.gw-agenda-content {
  font-family: var(--gw-font-fangsong);
  font-size: var(--gw-size-3);
  text-indent: 2em;
  margin: 0;
  line-height: var(--gw-line-height);
  text-align: justify;
  text-justify: inter-ideograph;
  word-break: break-all;
}

.gw-agenda-item {
  margin-bottom: 4pt;
  line-height: var(--gw-line-height);
}

/* 微紧凑行距适配（27.5pt - 28.0pt）：优雅微调间距，确保4项议程舒适落入单页 */
.a4-page[style*="27.5pt"] .gw-agenda-item,
.a4-page[style*="28.0pt"] .gw-agenda-item {
  margin-bottom: 3pt;
}

.a4-page[style*="27.5pt"] .gw-meta-section,
.a4-page[style*="28.0pt"] .gw-meta-section {
  margin-bottom: 3pt;
}

.a4-page[style*="27.5pt"] .gw-meta-item,
.a4-page[style*="28.0pt"] .gw-meta-item {
  margin-bottom: 1pt;
}

.a4-page[style*="27.5pt"] .gw-title,
.a4-page[style*="28.0pt"] .gw-title {
  margin-bottom: 10pt;
  line-height: 28pt;
}

.a4-page[style*="27.5pt"] .gw-h1,
.a4-page[style*="28.0pt"] .gw-h1 {
  margin-top: 6pt;
  margin-bottom: 3pt;
}

.a4-page[style*="27.5pt"] .gw-table th,
.a4-page[style*="27.5pt"] .gw-table td {
  padding: 3pt 4pt;
}

/* ------------------ 公文表格标准样式（三线表） ------------------ */
.gw-table-wrap {
  margin: 4pt 0 6pt;
  width: 100%;
}

.gw-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1.5pt solid #000000;
  border-bottom: 1.5pt solid #000000;
  font-family: var(--gw-font-fangsong);
  font-size: var(--gw-size-4);
  line-height: var(--gw-line-height-table);
}

.gw-table th {
  font-family: var(--gw-font-hei);
  font-weight: bold;
  border-bottom: 1pt solid #000000;
  padding: 4pt 4pt;
  text-align: center;
  background-color: #fafafa;
}

.gw-table td {
  border-bottom: 0.5pt solid #888888;
  padding: 3.5pt 4pt;
  text-align: left;
  vertical-align: middle;
}

.gw-table td.center,
.gw-table th.center {
  text-align: center;
}

.gw-notes-section {
  margin-top: 8pt;
}

.gw-signoff {
  margin-top: 10pt;
  margin-bottom: 0;
  padding-top: 0;
  text-align: right;
  padding-right: 4em; /* GB/T 9704-2012 7.3.5.1: 成文日期一般右空四字编排 */
  font-family: var(--gw-font-fangsong);
  font-size: var(--gw-size-3);
  line-height: 24pt;
}

.gw-signoff-org {
  margin-bottom: 2pt;
}

.gw-signoff-date {
  letter-spacing: 0.5px;
}

.gw-page-number {
  position: absolute !important;
  bottom: 14mm !important;
  left: 0 !important;
  right: 0 !important;
  height: 16pt !important;
  line-height: 16pt !important;
  text-align: center !important;
  font-family: var(--gw-font-song) !important;
  font-size: var(--gw-size-4) !important;
  color: #000000 !important;
  letter-spacing: 1px;
  pointer-events: none !important;
  z-index: 15 !important;
}

/* ------------------ 打印输出媒体查询 ------------------ */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html, body {
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #app, .app, .workspace, .preview-viewport, .zoom-stage, .a4-page-wrapper {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    position: static !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .no-print,
  .sidebar,
  .preview-toolbar,
  .name-card-footer,
  .tool-legal-dialog,
  .toast-msg,
  .preview-footer-status,
  .mobile-view-tabs {
    display: none !important;
  }

  .a4-page {
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    position: relative !important;
    margin: 0 auto !important;
    padding: 37mm 26mm 20mm 28mm !important;
    box-shadow: none !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    overflow: hidden !important;
  }

  .a4-page:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  .gw-page-number {
    position: absolute !important;
    bottom: 14mm !important;
    left: 0 !important;
    right: 0 !important;
    height: 16pt !important;
    line-height: 16pt !important;
    text-align: center !important;
    font-family: var(--gw-font-song) !important;
    font-size: var(--gw-size-4) !important;
    color: #000000 !important;
  }

  .gw-agenda-item,
  .gw-meta-section,
  .gw-table tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .gw-signoff {
    page-break-inside: avoid;
    break-inside: avoid;
    padding-right: 4em !important;
  }

  .show-rulers .a4-page::before,
  .show-rulers .a4-page::after,
  .a4-page::before,
  .a4-page::after,
  .a4-tolerance-zone,
  .a4-banxin-limit-line,
  .a4-page-number-limit-line,
  .a4-page-limit-line,
  .a4-page-header-bar,
  .gw-page-ruler {
    display: none !important;
    content: none !important;
    visibility: hidden !important;
  }
}

/* 导出专用纯净文档样式（彻底剥离辅助线） */
.exporting-clean-doc .a4-page::before,
.exporting-clean-doc .a4-page::after,
.exporting-clean-doc .show-rulers .a4-page::before,
.exporting-clean-doc .show-rulers .a4-page::after,
.exporting-clean-doc .a4-tolerance-zone,
.exporting-clean-doc .a4-banxin-limit-line,
.exporting-clean-doc .a4-page-number-limit-line,
.exporting-clean-doc .a4-page-limit-line,
.exporting-clean-doc .a4-page-header-bar,
.exporting-clean-doc .gw-page-ruler {
  display: none !important;
  content: none !important;
  visibility: hidden !important;
}

