/* ===== 认证证书查询系统 —— 前台样式 ===== */
:root {
  --red: #c8102e;
  --red-deep: #9c0d24;
  --ink: #1f2430;
  --gray: #667085;
  --line: #e6e8ee;
  --bg: #f5f6f8;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

/* 页头 */
.site-head { text-align: center; padding: 24px 0 8px; }
.site-brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
}
.brand-name { font-size: 26px; font-weight: 700; letter-spacing: 1px; }
.site-sub { color: var(--gray); margin: 8px 0 0; }

/* 查询框 */
.search-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-top: 24px;
  box-shadow: 0 4px 16px rgba(21, 30, 55, .05);
}
.search-row { display: flex; gap: 10px; }
.search-input {
  flex: 1;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #cfd4e0;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(200, 16, 46, .12); }
.search-btn {
  height: 46px;
  min-width: 108px;
  padding: 0 22px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background .2s;
}
.search-btn:hover { background: var(--red-deep); }
.search-btn:disabled { background: #d7a1ab; cursor: not-allowed; }
.search-tip { margin: 12px 0 0; color: var(--gray); font-size: 13px; }

/* 结果区 */
.result-area { margin-top: 22px; }
/* 查询结果以图片形式展示（由 assets/main.js 生成） */
.cert-image { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.empty-hint {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 32px 22px;
  text-align: center;
  color: var(--gray);
}

.alert { padding: 14px 18px; border-radius: 8px; font-size: 15px; }
.alert.error { background: #fff1f2; border: 1px solid #ffd7dc; color: #a11226; }
.alert.success { background: #eefaf1; border: 1px solid #cdeeda; color: #1a7a41; }

/* 查询结果：证书版式卡片 */
.cert-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(21, 30, 55, .06);
}
/* 满幅装饰边框：外花纹带（linear-gradient 平铺，html2canvas 可渲染）+ 内层细线 + 四角角花 */
.cert-doc {
  position: relative;
  width: 100%;
  max-width: 560px;               /* 竖版 A4 基准版面，并按需求向下拉长：下方预留空间让二维码与公章完整显示 */
  margin: 0 auto;
  display: flex;                  /* 内框可撑满卡片；卡片高度可随内容增长 */
  flex-direction: column;
  height: auto;                   /* 高度由内容决定：内容更长时卡片自动向下生长，底部不会被裁掉 */
  min-height: 830px;              /* 基准版面高度 = 560 × 310/210，内容更长时在此之上继续向下加长 */
  padding: 12px;
  border: 2px solid #a9884e;
  border-radius: 4px;
  overflow: hidden;
  background-image: linear-gradient(45deg, #ddcda6 0 25%, #fbf6e9 0 50%, #ddcda6 0 75%, #fbf6e9 0);
  background-size: 12px 12px;
  background-repeat: repeat;
}
.cert-doc-line1 { position: absolute; left: 12px; top: 12px; right: 12px; bottom: 12px; border: 1px solid #cdb684; pointer-events: none; }
.cert-doc-line2 { position: absolute; left: 4px; top: 4px; right: 4px; bottom: 4px; border: 1px solid #efe6cd; pointer-events: none; }
.cert-doc-corner { position: absolute; width: 30px; height: 30px; border: 2px solid #a9884e; pointer-events: none; }
.cert-doc-corner.tl { left: 6px; top: 6px; border-right: 0; border-bottom: 0; }
.cert-doc-corner.tr { right: 6px; top: 6px; border-left: 0; border-bottom: 0; }
.cert-doc-corner.bl { left: 6px; bottom: 6px; border-right: 0; border-top: 0; }
.cert-doc-corner.br { right: 6px; bottom: 6px; border-left: 0; border-top: 0; }

.cert-doc-frame {
  position: relative;
  flex: 1 1 auto;                 /* 撑满卡片高度（不再依赖父级 height:100%） */
  height: auto;
  display: flex;
  flex-direction: column;
  border: 1px solid #c9b489;
  background: #fffdf7;
  padding: 14px 26px 44px;        /* 底部留白加大，二维码与公章不再贴边或被压 */
  text-align: center;
}
.cert-doc-content {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;                 /* 占满版面高度，纵向均匀分布各区块 */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* 重复水印底纹（企业名称浅色斜排平铺） */
.cert-doc-wm { position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.cert-doc-wm .wm { position: absolute; white-space: nowrap; font-size: 15px; font-weight: 600; letter-spacing: 4px; color: rgba(163, 136, 84, .16); transform: rotate(-22deg); }
.cert-doc-wm .wm:nth-child(1) { left: -4%; top: 5%; }
.cert-doc-wm .wm:nth-child(2) { left: 33%; top: 1%; }
.cert-doc-wm .wm:nth-child(3) { left: 68%; top: 8%; }
.cert-doc-wm .wm:nth-child(4) { left: -6%; top: 28%; }
.cert-doc-wm .wm:nth-child(5) { left: 31%; top: 24%; }
.cert-doc-wm .wm:nth-child(6) { left: 66%; top: 31%; }
.cert-doc-wm .wm:nth-child(7) { left: -2%; top: 52%; }
.cert-doc-wm .wm:nth-child(8) { left: 35%; top: 58%; }
.cert-doc-wm .wm:nth-child(9) { left: 70%; top: 52%; }
.cert-doc-wm .wm:nth-child(10) { left: 6%; top: 76%; }
.cert-doc-wm .wm:nth-child(11) { left: 42%; top: 82%; }
.cert-doc-wm .wm:nth-child(12) { left: 72%; top: 74%; }

.cert-status {
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.cert-status.valid { background: #e8f7ee; color: #1a7a41; border: 1px solid #bde5cd; }
.cert-status.expired { background: #f4f5f7; color: #667085; border: 1px solid #dfe2e8; }
.cert-status.paused { background: #fff7e6; color: #a2711a; border: 1px solid #ffe1a8; }
.cert-status.revoked { background: #fff1f2; color: #a11226; border: 1px solid #ffd7dc; }
.cert-doc .cert-status { position: absolute; right: 16px; top: 14px; }

/* 顶部机构圆形标识（canvas 绘制） */
.cert-logo-top { display: block; width: 56px; height: 56px; margin: 0 auto 4px; }
.cert-doc-title {
  margin: 2px 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 7px;
  color: #1a1a1a;
  line-height: 1.35;
}

.cert-doc-starline { position: relative; min-height: 26px; }
.cert-doc-stars { font-size: 20px; letter-spacing: 5px; }
.cert-doc-no {
  position: absolute;
  right: 0;
  bottom: 1px;
  font-size: 12px;
  color: var(--ink);
}

.stars { color: var(--red); letter-spacing: 2px; }

.cert-doc-body { position: relative; margin-top: 6px; }
.cert-doc-certify { margin: 6px 0 4px; font-size: 18px; letter-spacing: 7px; color: var(--ink); }
.cert-doc-company { margin: 0 0 6px; font-size: 20px; font-weight: 700; letter-spacing: 2px; color: var(--ink); }
.cert-doc-line { margin: 2px 0; font-size: 14px; color: var(--ink); }
.cert-doc-require {
  margin: 6px 0 4px;
  color: #8f1226;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
}
.cert-doc-scope { margin: 3px 0 0; font-size: 15px; color: var(--ink); }
.cert-doc-dates { margin-top: 8px; text-align: right; font-size: 13px; color: var(--ink); }
.cert-doc-dates p { margin: 2px 0; }

.cert-doc-foot {
  position: relative;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #e8dfc8;
  color: #3f4550;
  font-size: 11px;
  line-height: 1.45;
  text-align: left;
}
.cert-doc-note { margin: 1px 0; }

/* 卡片底部：左下机构标识 + 二维码 + 右下印章区 */
.cert-doc-sign {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-top: 6px;
}
.cert-sign-left { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.cert-logo-bottom { display: block; width: 52px; height: 52px; }
.cert-sign-short { font-size: 12px; color: #3f4550; letter-spacing: 1px; }
.cert-sign-qr { display: flex; flex-direction: column; align-items: center; gap: 3px; }
/* 右下印章区：印刷文字在下，红色印章叠压其上 */
.cert-sign-seal { position: relative; min-width: 210px; padding: 2px 6px 6px; text-align: center; }
.cert-sign-print { position: relative; z-index: 1; }
.cert-sign-org { display: block; font-size: 13px; font-weight: 700; color: #1a1a1a; }
.cert-sign-role { display: block; margin-top: 2px; font-size: 12px; color: #1a1a1a; letter-spacing: 2px; }
.cert-sign-no { display: block; margin-top: 3px; font-size: 12px; color: #3f4550; letter-spacing: 2px; }
.cert-qr {
  display: block;
  width: 92px;
  height: 92px;
  background: #fff;
  border: 1px solid #e6dfce;
  border-radius: 6px;
}
.cert-qr-cap { font-size: 11px; color: var(--gray); letter-spacing: 1px; }
.cert-seal { position: absolute; right: 0; bottom: 0; width: 112px; height: 112px; z-index: 2; transform: rotate(-8deg); }

/* 页脚 */
.site-foot { margin-top: 34px; color: var(--gray); text-align: center; font-size: 13px; }
.site-foot p { margin: 4px 0; }
.foot-links a { color: var(--gray); }
.foot-support a { color: var(--gray); }
.foot-support a:hover { color: var(--ink); }

@media (max-width: 560px) {
  .brand-name { font-size: 21px; }
  .search-row { flex-direction: column; }
  .search-btn { width: 100%; }
  /* 手机端：卡片同竖版 A4 基准版面（宽度撑满，底座高度按宽度推导），字号适度放大以填满版面；
     高度由内容决定，内容更长时卡片向下生长，底部二维码与公章不会被裁掉 */
  .cert-doc {
    padding: 6px;
    background-size: 8px 8px;
    min-height: calc((100vw - 32px) * 310 / 210);   /* 卡片宽度（.page 左右各 16px）× 310/210，内容更长时自动加高 */
  }
  .cert-doc-line1 { left: 5px; top: 5px; right: 5px; bottom: 5px; }
  .cert-doc-corner { width: 14px; height: 14px; }
  .cert-doc-frame { padding: 8px 10px 32px; }       /* 底部留白加大，二维码与公章不再贴边或被压 */
  .cert-logo-top { width: 24px; height: 24px; margin: 0 auto 2px; }
  .cert-doc-title { margin: 0 0 4px; font-size: 15px; line-height: 1.25; letter-spacing: 3px; }
  .cert-doc-starline { min-height: 30px; }
  .cert-doc-stars { display: block; position: relative; top: -4px; font-size: 13px; line-height: 1.35; letter-spacing: 2px; }
  .cert-doc-body { margin-top: 3px; }
  .cert-doc-certify { margin: 5px 0 2px; font-size: 13px; line-height: 1.3; letter-spacing: 4px; }
  .cert-doc-company { margin: 0 0 4px; font-size: 14px; line-height: 1.3; letter-spacing: 1px; }
  .cert-doc-line { margin: 2px 0; font-size: 10.5px; line-height: 1.35; }
  .cert-doc-require { margin: 5px 0 2px; font-size: 12px; line-height: 1.35; }
  .cert-doc-scope { margin: 2px 0 0; font-size: 11px; line-height: 1.35; }
  .cert-doc-dates { margin-top: 6px; font-size: 10.5px; line-height: 1.3; }
  .cert-doc-dates p { margin: 1px 0; }
  .cert-doc-wm .wm { font-size: 9px; letter-spacing: 2px; }
  .cert-doc-no { bottom: 0; font-size: 9.5px; line-height: 1.1; }
  .cert-doc-foot { margin-top: 8px; padding-top: 4px; font-size: 9.5px; line-height: 1.45; }
  .cert-doc-note { margin: 0; }
  .cert-doc-sign { gap: 8px; margin-top: 5px; }
  .cert-logo-bottom { width: 28px; height: 28px; }
  .cert-sign-short { font-size: 9px; }
  .cert-qr { width: 62px; height: 62px; }
  .cert-qr-cap { font-size: 9px; }
  .cert-sign-seal { min-width: 0; padding-bottom: 3px; }
  .cert-sign-org { font-size: 11px; }
  .cert-sign-role { font-size: 10px; letter-spacing: 0; }
  .cert-seal { width: 64px; height: 64px; }
}

/* 分页（与后台共用 pagination() 输出，保证前台也能正确显示） */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pager-info { color: var(--gray); font-size: 13px; margin-right: 8px; }
.pager-link {
  min-width: 32px; height: 32px; padding: 0 9px; border: 1px solid var(--line);
  border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--ink); background: #fff;
}
.pager-link:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.pager-link.active { background: var(--red); border-color: var(--red); color: #fff; }

@media print {
  .search-box, .site-foot, .foot-links, .search-tip { display: none; }
  body { background: #fff; }
  .cert-card { box-shadow: none; }
}