@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Noto+Sans+SC:wght@400;500;700&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  font-family: 'PingFang SC', 'Noto Sans SC', system-ui, sans-serif;
  line-height: 1.5;
  font-weight: 400;
  
  color-scheme: light;
  background-color: #f0f0f0;
}

body {
  margin: 0;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  background-color: #e5e5e5;
}

/* Ensure print styles are clean */
@media print {
  body {
    background-color: white;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .no-print {
    display: none !important;
  }
  
  /* Reset fluid padding for print */
  .pl-\[380px\] {
    padding-left: 0 !important;
  }

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

  /* 强制每个页面组件占满一页，并且后面强制分页 */
  .print-page {
    width: 210mm !important;
    min-height: 297mm !important; /* 改为 min-height，允许微量溢出而不被切断 */
    page-break-after: always !important;
    break-after: page !important;
    overflow: hidden !important;
    position: relative !important;
    box-sizing: border-box !important;
    background-color: white !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* 最后一页不需要分页 */
  .print-page:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }
}

/* 打印模式（模拟打印环境，如 Puppeteer 注入 print-mode 时） */
.print-mode .print-page {
  width: 210mm !important;
  min-height: 297mm !important;
  page-break-after: always !important;
  break-after: page !important;
  margin: 0 auto !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

.print-mode {
  overflow: visible !important;
}

.print-mode body {
  overflow: visible !important;
  background-color: white !important;
}

.print-mode .print-page:last-child {
  page-break-after: avoid !important;
  break-after: avoid !important;
}

/* 非打印预览模式下，为了开发查看方便，也可以给个间距 */
.print-page {
  margin: 0 auto 20px auto;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  width: 210mm;
  height: 297mm;
  background-color: white;
  position: relative;
  overflow: hidden;
}

.is-exporting .print-page {
  margin: 0 !important;
  box-shadow: none !important;
}

/* Export State: Force A4 width during PDF generation */
.is-exporting {
  width: 794px !important; /* Standard A4 width at 96 DPI */
  min-height: 1123px !important; /* Standard A4 height at 96 DPI */
  margin: 0 auto !important;
  transform: none !important;
  box-shadow: none !important;
  background: white !important;
  overflow: visible !important; /* 确保不被截断 */
}

/* Fix for html2canvas flex and alignment issues */
.is-exporting * {
  box-sizing: border-box !important;
}

/* Ensure images don't overflow */
.is-exporting img {
  max-width: none !important;
}

/* Force page break after specific elements */
.pdf-page-break {
  page-break-after: always;
}

/* Stable Header Pattern for html2canvas */
.title-container {
  display: flex !important;
  align-items: center !important;
  height: 32px !important;
  line-height: 32px !important;
  margin-bottom: 12px !important;
}

.subtitle-container {
  display: flex !important;
  align-items: center !important;
  height: 24px !important;
  line-height: 24px !important;
  margin-bottom: 8px !important;
}

.blue-bar-title {
  display: inline-block !important;
  width: 4px !important;
  height: 18px !important;
  background-color: #2386EE !important;
  margin-right: 10px !important;
  border-radius: 2px !important;
  flex-shrink: 0 !important;
}

.blue-bar-subtitle {
  display: inline-block !important;
  width: 3px !important;
  height: 14px !important;
  background-color: #2386EE !important;
  margin-right: 8px !important;
  border-radius: 1.5px !important;
  flex-shrink: 0 !important;
}

/* Force block and line-height for export stability */
.is-exporting {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif !important;
}

.is-exporting .title-container,
.is-exporting .subtitle-container {
  display: flex !important;
}

/* ECharts Export Toggle */
.is-exporting .echarts-inner {
  display: none !important;
}

.is-exporting .echarts-export-image {
  display: block !important;
}
