/* ==========================================================================
   A4 标准纸张画布与简历版式布局 (支持无缝跨页防截断与全端自适应)
   ========================================================================== */

/* 屏幕预览画布居中包裹容器 */
.paper-canvas-wrap {
  width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
}

/* 屏幕预览下的 A4 画布 - 无论窗口怎么缩放，严格锁定 A4 210mm 黄金比例，决不压缩变形 */
.resume-paper {
  width: 210mm;
  min-width: 210mm;
  max-width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: var(--bg-page);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  padding: var(--page-padding);
  position: relative;
  transition: padding 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  flex-shrink: 0;
}

/* 简历头部个人信息 (支持收缩自适应与弹性换行) */
.resume-header {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
  margin-bottom: 14px;
  position: relative;
}

.header-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 8px;
}

.candidate-name {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.5px;
  outline: none;
}

.candidate-role {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  outline: none;
}

.header-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.contact-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  outline: none;
}

/* 板块容器 (Section) */
.resume-section {
  margin-bottom: 14px;
  position: relative;
}

/* 隐藏板块 */
.resume-section.is-hidden {
  display: none !important;
}

/* 板块大标题与控制坞 */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid var(--primary-border);
  padding-bottom: 4px;
  margin-bottom: 10px;
}

.section-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  outline: none;
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--primary);
  border-radius: 2px;
}

/* 整个板块的控制按钮 (板块上移、下移、删除整个板块) */
.section-actions {
  display: none;
  align-items: center;
  gap: 4px;
}
.resume-section:hover .section-actions {
  display: flex;
}

/* 条目卡片 (Experience / Project / Skill / Edu) */
.item-card {
  position: relative;
  margin-bottom: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.item-card:hover {
  background: rgba(241, 245, 249, 0.45);
}

/* 条目内部标题行 (公司/岗位/时间) */
.item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}

.item-head-title {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.item-main-title {
  font-weight: 700;
  color: #111827;
  outline: none;
}

.item-sub-title {
  font-weight: 600;
  color: var(--accent);
  outline: none;
}

.item-date-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  outline: none;
}

/* 项目与经验要点列表 */
.bullet-list {
  list-style-type: disc;
  padding-left: 18px;
  color: var(--text-main);
  font-size: 12.8px;
}
.bullet-list li {
  margin-bottom: 5px;
  line-height: var(--line-height);
  outline: none;
}

/* 个人总结/优势文本 */
.summary-content {
  font-size: 12.8px;
  line-height: var(--line-height);
  color: var(--text-main);
  outline: none;
  min-height: 1.5em;
}

/* 内容为空时显示提示语（提示语属于界面占位，不会被导出进 PDF） */
.summary-content:empty::before {
  content: attr(data-placeholder);
  color: #9aa7b8;
}

/* 技能矩阵网格 */
.skill-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skill-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: var(--line-height);
  font-size: 12.8px;
  flex-wrap: wrap;
}

.skill-cat-title {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  outline: none;
}

.skill-cat-body {
  flex: 1;
  min-width: 200px;
  color: var(--text-main);
  outline: none;
}

/* 空状态占位引导 */
.empty-section-placeholder {
  padding: 16px;
  text-align: center;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 12.5px;
}
.empty-section-placeholder button {
  margin-left: 8px;
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 4px;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  cursor: pointer;
}

/* contenteditable 聚焦交互反馈 */
[contenteditable="true"] {
  transition: background 0.15s, outline 0.15s;
}
[contenteditable="true"]:hover {
  outline: 1px dashed rgba(59, 130, 246, 0.45);
  outline-offset: 2px;
  border-radius: 2px;
}
[contenteditable="true"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
  background: rgba(239, 246, 255, 0.45);
}

/* ==========================================================================
   PDF 导出专用页面舞台
   只在导出瞬间挂载到 body 上：固定 A4 尺寸逐页真实排版，导出结束即移除，
   不参与常规页面布局，也不影响预览。
   ========================================================================== */
.pdf-stage {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 99990;
  background: #ffffff;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  line-height: var(--line-height);
  font-size: var(--font-base);
  -webkit-font-smoothing: antialiased;
}

.pdf-page {
  width: 210mm;
  height: 297mm;
  box-sizing: border-box;
  background: #ffffff;
  overflow: hidden;
}

/* BFC 容器：保证子元素外边距被计入 scrollHeight，从而精确判断版心是否溢出 */
.pdf-body {
  height: 100%;
  overflow: hidden;
}

.pdf-stage .no-print,
.pdf-stage .item-action-bar,
.pdf-stage .section-actions,
.pdf-stage .tag-remove-btn,
.pdf-stage .add-tag-chip,
.pdf-stage #floating-toolbar {
  display: none !important;
}

.pdf-stage .item-card,
.pdf-stage .item-card:hover {
  background: transparent !important;
}

/* 空标签行（只有"加标签"按钮）导出时已被移除，这里再兜一层，避免多出空行 */
.pdf-stage .tag-container:empty {
  display: none !important;
}

.pdf-stage [contenteditable="true"],
.pdf-stage [contenteditable="true"]:hover,
.pdf-stage [contenteditable="true"]:focus {
  outline: none !important;
  background: transparent !important;
}

/* ==========================================================================
   CSS 打印防腰斩控制与多页留白边距控制 (@media print)
   ========================================================================== */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  @page {
    size: A4 portrait;
    /* 核心：设置统一的每页物理边距，确保第 1 页、第 2 页及后续每一页顶部与底部都有完美的 14mm 留白 */
    margin: 14mm 16mm !important;
  }

  html, body {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 12.5px;
    width: 100% !important;
  }

  .top-dock,
  .no-print,
  .item-action-bar,
  .section-actions,
  #floating-toolbar,
  .modal-overlay,
  .pdf-stage,
  .pdf-mask,
  .tag-remove-btn,
  .add-tag-chip,
  .toast-notice {
    display: none !important;
  }

  .paper-canvas-wrap {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    width: 100% !important;
  }

  .resume-paper {
    width: 100% !important;
    max-width: none !important;
    min-height: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    /* 关键：打印时边距由 @page margin 统一接管，将元素内 padding 置 0，彻底解决第二页离顶部太近的问题 */
    padding: 0 !important;
    box-sizing: border-box !important;
  }

  /* 允许大板块跨页流动，避免因整个板块不可截断导致第一页大面积留白 */
  .resume-section {
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  /* 标题绝不单独留在页末 */
  .section-header {
    break-after: avoid !important;
    page-break-after: avoid !important;
  }

  /* 核心防腰斩：每一个具体的经历卡片、项目卡片、技能行自身绝不被截断 */
  .item-card,
  .skill-row {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    margin-bottom: 8px !important;
  }

  [contenteditable="true"] {
    outline: none !important;
    background: transparent !important;
  }
}
