/* ================================================================
   5. VERIFIED CERTIFICATE OF COMPLETION (CHỨNG CHỈ HSK)
   ================================================================ */
.certificate-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  animation: certFadeIn 0.2s ease-out;
}
.certificate-modal-overlay[hidden],
.certificate-modal-overlay.hidden {
  display: none !important;
}

.certificate-dialog-card {
  width: min(840px, 100%);
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: certZoomIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.certificate-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.certificate-dialog-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: #1e1b4b;
}

/* Outer Border of the Certificate */
.certificate-paper-wrap {
  padding: 24px;
  background: #f1f5f9;
  display: flex;
  justify-content: center;
}
.certificate-paper {
  position: relative;
  width: 100%;
  max-width: 760px;
  background: #fffdfa;
  border: 4px solid #b45309;
  border-radius: 12px;
  padding: 36px 40px;
  box-shadow: 0 10px 30px rgba(180, 83, 9, 0.12), inset 0 0 0 3px #fef3c7;
  text-align: center;
  overflow: hidden;
  box-sizing: border-box;
}

/* Background Watermark */
.certificate-paper::before {
  content: 'HSK';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-15deg);
  font-size: 160px;
  font-weight: 900;
  color: rgba(180, 83, 9, 0.03);
  pointer-events: none;
  font-family: serif;
}

/* Inner decorative line */
.certificate-inner-border {
  position: absolute;
  inset: 12px;
  border: 1.5px solid #d97706;
  border-radius: 8px;
  pointer-events: none;
}

.cert-header-crest {
  font-size: 32px;
  margin-bottom: 4px;
}
.cert-main-chinese-title {
  font-family: STKaiti, KaiTi, 'KaiTi SC', serif;
  font-size: 34px;
  font-weight: 900;
  color: #92400e;
  letter-spacing: 6px;
  margin: 0 0 2px;
}
.cert-english-subtitle {
  font-size: 12px;
  font-weight: 800;
  color: #b45309;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.cert-recipient-intro {
  font-size: 13.5px;
  color: #64748b;
  margin-bottom: 6px;
}
.cert-student-name {
  font-size: 32px;
  font-weight: 900;
  color: #1e1b4b;
  font-family: inherit;
  border-bottom: 2px solid #b45309;
  display: inline-block;
  padding: 0 24px 6px;
  margin-bottom: 16px;
}

.cert-statement {
  font-size: 14.5px;
  line-height: 1.6;
  color: #334155;
  max-width: 580px;
  margin: 0 auto 24px;
}

.cert-level-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  font-size: 14px;
  font-weight: 800;
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 24px;
}

/* Footer with Seal & Signatures */
.cert-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px dashed #e2e8f0;
}
.cert-footer-meta {
  text-align: left;
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
}
.cert-code {
  font-family: monospace;
  font-weight: 700;
  color: #1e1b4b;
}

/* Red Imperial Seal */
.cert-seal {
  width: 74px;
  height: 74px;
  border: 3px solid #dc2626;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #dc2626;
  font-family: STKaiti, KaiTi, 'KaiTi SC', serif;
  transform: rotate(-10deg);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
  user-select: none;
}
.cert-seal-text-top {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
}
.cert-seal-text-main {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
}

/* Controls Toolbar */
.certificate-toolbar {
  padding: 16px 24px;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cert-name-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}
.cert-name-input {
  flex: 1;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: #1e1b4b;
}

@keyframes certFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes certZoomIn {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@media print {
  body * {
    visibility: hidden;
  }
  #certificateModal,
  #certificateModal .certificate-paper,
  #certificateModal .certificate-paper * {
    visibility: visible;
  }
  #certificateModal {
    position: absolute;
    inset: 0;
    background: transparent;
    padding: 0;
  }
  .certificate-dialog-header,
  .certificate-toolbar,
  .certificate-paper-wrap {
    padding: 0;
    background: transparent;
  }
  .certificate-dialog-card {
    box-shadow: none;
    border-radius: 0;
  }
}

