/* SA247 certificate — Phôi overlay (name / date / code / QR) */
:root {
  --cert-navy: #0b1f3a;
  --cert-ink: #12233a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #e8ecf1;
  color: var(--cert-ink);
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
}

.cert-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: #0b1f3a;
  color: #fff;
}

.cert-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cert-toolbar .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.45rem 1rem;
  border-radius: 0.45rem;
  border: 1px solid transparent;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.cert-toolbar .btn--amber { background: #f0b429; color: #12233a; }
.cert-toolbar .btn--line {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

.cert-status {
  margin: 1rem auto;
  max-width: 52rem;
  padding: 0 1rem;
  text-align: center;
  color: #334155;
}
.cert-disclaimer {
  margin: 0 auto 1rem;
  max-width: 40rem;
  padding: 0 1rem;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.4;
  opacity: 0.85;
  color: #475569;
}

.cert-stage {
  padding: 1.25rem 1rem 2.5rem;
  display: flex;
  justify-content: center;
}

/* Display Form mẫu (showcase) */
.cert-showcase {
  width: min(100%, 1100px);
}
.cert-showcase img {
  width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 18px 50px rgba(6, 20, 40, 0.18);
}

/* Printable Phôi sheet */
.cert-sheet {
  --cw: 1491;
  --ch: 1055;
  position: relative;
  width: min(100%, 1100px);
  aspect-ratio: 1491 / 1055;
  background: #fff;
  box-shadow: 0 18px 50px rgba(6, 20, 40, 0.18);
  overflow: hidden;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.cert-sheet__phoi {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
  user-select: none;
}

.cert-field {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--cert-navy);
  line-height: 1.1;
  overflow: hidden;
}

.cert-field--name {
  left: calc(100% * 430 / 1491);
  top: calc(100% * 438 / 1055);
  width: calc(100% * 630 / 1491);
  height: calc(100% * 110 / 1055);
  /* Great Vibes thiếu glyph tiếng Việt → chữ chồng. Dùng Be Vietnam Pro (có dấu). */
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
  font-size: clamp(1.15rem, 2.8vw, 2.15rem);
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1.25;
  white-space: normal;
  overflow: hidden;
  word-break: keep-all;
  hyphens: none;
  color: #0a2744;
}

.cert-field--code-cover {
  left: calc(100% * 248 / 1491);
  top: calc(100% * 848 / 1055);
  width: calc(100% * 340 / 1491);
  height: calc(100% * 34 / 1055);
  background: #f7f8f9;
}

.cert-field--code {
  left: calc(100% * 248 / 1491);
  top: calc(100% * 848 / 1055);
  width: calc(100% * 340 / 1491);
  height: calc(100% * 34 / 1055);
  justify-content: flex-start;
  padding-left: 0.15em;
  font-size: clamp(0.5rem, 0.95vw, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
}

.cert-field--date {
  left: calc(100% * 640 / 1491);
  top: calc(100% * 908 / 1055);
  width: calc(100% * 200 / 1491);
  height: calc(100% * 36 / 1055);
  font-size: clamp(0.7rem, 1.25vw, 0.95rem);
  font-weight: 700;
}

.cert-field--qr {
  /* Căn giữa khung QR trên phôi 1491×1055 (vùng trong viền navy ≈ 106,812,123×128) */
  left: calc(100% * 114 / 1491);
  top: calc(100% * 822 / 1055);
  width: calc(100% * 108 / 1491);
  height: calc(100% * 108 / 1055);
  background: transparent;
  padding: 0;
  margin: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-field--qr > canvas,
.cert-field--qr > img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  display: block !important;
  margin: 0 auto !important;
  object-fit: contain;
  object-position: center;
  border: 0;
  padding: 0;
}

/* qrcodejs đôi khi chèn canvas ẩn + table — ẩn hết phần thừa */
.cert-field--qr canvas[style*="display: none"],
.cert-field--qr canvas[style*="display:none"] {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
}

.cert-field--qr table {
  display: none !important;
}

@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { background: #fff; }
  .cert-toolbar, .cert-status, .no-print { display: none !important; }
  .cert-stage { padding: 0; }
  .cert-sheet, .cert-showcase {
    width: 297mm;
    height: 210mm;
    aspect-ratio: auto;
    box-shadow: none;
  }
  .cert-showcase img { width: 100%; height: 100%; object-fit: fill; }
}
