:root {
  --theme: #4153ff;
  --radius-1: 4px;
  --radius-2: 6px;
  --bg-color: #f6f6f6;
  --text-color: #222222;
  --text-light: #707070;
  --border-color: #e9e9e9;
  --success-color: #11d55c;
  --error-color: #fc4d4d;
  --warning-color: #ff9800;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

button {
  border-radius: var(--radius-1);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

body {
  position: relative;
  background-color: var(--bg-color);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  padding: 20px;
}

/* Container */
.container {
  max-width: 940px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Header */
.header {
  margin-top: 50px;
  text-align: center;
  padding: 40px 0;
  background: linear-gradient(135deg, var(--theme) 0%, #5a6bff 100%);
  color: white;
  border-radius: var(--radius-2);
  margin-bottom: 30px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  width: 100%;
}

.header h1 {
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.header p {
  font-size: 14px;
  opacity: 0.9;
}

/* Query Section */
.query-section {
  background: white;
  padding: 40px;
  border-radius: var(--radius-2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  margin-bottom: 30px;
  width: 100%;
}

.query-form {
  max-width: 600px;
  margin: 0 auto;
}

.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  min-width: 200px;
  margin-bottom: 20px;
}

.form-group label {
  display: inline-block;
  margin-bottom: 8px;
  margin-right: 0;
  font-weight: 600;
  color: var(--text-color);
  font-size: 14px;
  min-width: 55px;
}

.form-group input {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-1);
  font-size: 14px;
  transition: all 0.3s ease;
  background-color: white;
}

.form-group input:focus {
  outline: none;
  border-color: var(--theme);
  box-shadow: 0 0 0 2px rgba(65, 83, 255, 0.2);
}

/* Captcha Section */
.captcha-group {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.captcha-group input {
  flex: 1;
}

.captcha-img {
  width: 120px;
  height: 40px;
  border-radius: var(--radius-1);
  cursor: pointer;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  color: var(--theme);
  letter-spacing: 4px;
  user-select: none;
  border: 1px solid var(--border-color);
}

/* Button */
.btn {
  width: 100%;
  padding: 10px;
  background-color: var(--theme);
  color: white;
  border: none;
  border-radius: var(--radius-1);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(65, 83, 255, 0.3);
}

.btn:hover {
  background-color: #3a47e0;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(65, 83, 255, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Secondary button (reset) */
.btn-secondary {
  background-color: #6c757d;
  border-color: #6c757d;
}

.btn-secondary:hover {
  background-color: #5a6268;
}

/* Query form actions button group */
.query-form-actions {
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  gap: 50px;
  margin-top: 30px;
  width: 70%;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.query-form-actions .btn {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  -moz-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
}

/* Status Messages */
.status {
  text-align: center;
  padding: 16px;
  margin-bottom: 30px;
  border-radius: var(--radius-1);
  font-size: 14px;
  display: none;
  width: 100%;
}

.status.show {
  display: block;
}

.loading {
  background-color: #e3f2fd;
  color: #1976d2;
  border: 1px solid #bbdefb;
}

.error {
  background-color: #ffebee;
  color: var(--error-color);
  border: 1px solid #ffcdd2;
}

.loading::after {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 10px;
  border: 2px solid #1976d2;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Certificate Result Section */
.certificate-container {
  display: none;
  margin-bottom: 30px;
  width: 100%;
}

.certificate-container.show {
  display: block;
}

.certificate-title {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  padding: 20px;
}

.certificate-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 16px;
}

.img-generating {
  display: none;
  margin: 16px auto 0;
  text-align: center;
  font-size: 14px;
  color: #1976d2;
}

.btn-print,
.btn-preview {
  padding: 7px 20px;
  border-radius: var(--radius-1);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid var(--theme);
}

.btn-print {
  background-color: var(--theme);
  color: white;
}

.btn-print:hover {
  background-color: #3a47e0;
}

.btn-preview {
  background-color: white;
  color: var(--theme);
}

.btn-preview:hover {
  background-color: #f6f9ff;
}

.certificate-title h2 {
  color: var(--theme);
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 10px;
}

/* Certificate Card */
.certificate-card {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  -webkit-background-size: 100% 100%;
  -moz-background-size: 100% 100%;
  background-size: 100% 100%;
  background-position: center center;
  background-repeat: no-repeat;
  overflow: hidden;
  aspect-ratio: 800 / 1200;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

/* aspect-ratio fallback for older browsers */
@supports not (aspect-ratio: 800 / 1200) {
  .certificate-card {
    aspect-ratio: auto;
    height: 1200px;
  }
}

/* aspect-ratio fallback - mobile responsive */
@media (max-width: 768px) {
  @supports not (aspect-ratio: 800 / 1200) {
    .certificate-card {
      height: 0;
      padding-top: 150%;
      /* 1200/800 = 1.5 = 150% */
    }
  }
}

/* Certificate Logo - 右上角，上半卡片 */
.certificate-logo {
  position: absolute;
  top: 3%;
  right: 5%;
  left: auto;
  z-index: 10;
  display: none;
}

.certificate-logo .logo-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
}

/* Certificate Logo 2 - 下半卡片右上角 */
.certificate-logo-bottom {
  position: absolute;
  top: 58%;
  right: 10%;
  left: auto;
  z-index: 10;
  display: none;
}

.certificate-logo-bottom .logo-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
}

/* Certificate Seal - 上下两张卡片之间，覆盖交界处 */
.certificate-seal {
  position: absolute;
  top: 27%;
  right: 8%;
  bottom: auto;
  z-index: 12;
  display: none;
}

.certificate-seal .seal-img {
  width: 180px;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Certificate Content */
.certificate-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  z-index: 5;
}

.certificate-info {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}

.info-item {
  position: absolute;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: baseline;
  -webkit-align-items: baseline;
  -moz-box-align: baseline;
  -ms-flex-align: baseline;
  align-items: baseline;
  padding: 0;
  margin: 0;
  white-space: nowrap;
}

.info-label {
  color: #333;
  margin-right: 0.5%;
  line-height: 1.4;
  white-space: nowrap;
  min-width: 110px;
  text-align: left;
  -webkit-flex-shrink: 0;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  font-size: 18px;
  font-weight: bold;
}

.info-value {
  color: #000;
  font-weight: bold;
  line-height: 1.4;
  white-space: nowrap;
  text-align: left;
  font-size: 18px;
}

.info-item img {
  max-height: 60px;
  -o-object-fit: contain;
  object-fit: contain;
}

/* Certificate Photo */
.certificate-photo {
  display: block;
  width: 15%;
}

.certificate-photo .photo-value {
  width: 100%;
}

.certificate-photo img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}

/* Certificate Footer */
.certificate-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 30px;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.9);
  padding: 20px;
  border-radius: var(--radius-1);
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.certificate-date {
  font-size: 13px;
  color: var(--text-light);
}

.certificate-qr {
  width: 100px;
  height: 100px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-1);
  padding: 10px;
}

.certificate-qr img {
  width: 100%;
  height: 100%;
}

/* Footer */
footer {
  font-size: 12px;
  margin-bottom: 20px;
  margin-top: 20px;
  color: var(--text-light);
  font-weight: 400;
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px 8px;
  }

  .container {
    width: 100%;
  }

  .header h1 {
    font-size: 20px;
    letter-spacing: 0;
    margin-bottom: 6px;
  }

  .header p {
    font-size: 12px;
  }

  .header {
    margin-top: 16px;
    padding: 20px 12px;
    margin-bottom: 20px;
    border-radius: 8px;
  }

  .query-section {
    padding: 18px 14px;
    margin-bottom: 20px;
    border-radius: 8px;
  }

  .query-form {
    max-width: 100%;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
    margin-bottom: 0;
  }

  .form-group {
    margin-bottom: 16px;
    min-width: 0;
  }

  .form-group label {
    text-align: left;
    margin-right: 0;
    margin-bottom: 6px;
    min-width: 0;
    font-size: 13px;
  }

  .form-group input {
    height: 42px;
    font-size: 15px;
    padding: 0 14px;
  }

  /* Captcha 移动端适配 */
  .captcha-group {
    flex-direction: row;
    gap: 8px;
    align-items: flex-end;
  }

  .captcha-img {
    width: 100px;
    height: 42px;
    font-size: 14px;
    letter-spacing: 2px;
  }

  /* 查询按钮组 移动端适配 - 保持同一行 */
  .query-form-actions {
    flex-direction: row;
    gap: 16px;
    width: 100%;
    margin-top: 20px;
  }

  .query-form-actions .btn {
    padding: 12px;
    font-size: 16px;
    flex: 1;
  }

  /* Status 提示 */
  .status {
    margin-bottom: 20px;
    padding: 12px;
    font-size: 13px;
  }

  .certificate-container {
    padding: 0;
    margin-bottom: 0;
  }

  .certificate-card {
    max-width: 100%;
    border-radius: 10px;
  }

  /* 移动端证书字体适配 */
  .certificate-card .info-label {
    font-size: 12px;
    min-width: 80px;
    line-height: 1.3;
  }

  .certificate-card .info-value {
    font-size: 12px;
    line-height: 1.3;
  }

  /* 移动端logo尺寸适配 */
  .certificate-logo .logo-img {
    width: 50px;
    height: 50px;
  }

  .certificate-logo-bottom .logo-img {
    width: 50px;
    height: 50px;
  }

  /* 移动端公章尺寸适配 */
  .certificate-seal .seal-img {
    width: 100px;
  }

  /* 移动端照片尺寸适配 */
  .certificate-photo img {
    border-radius: 2px;
  }

  .certificate-footer {
    flex-direction: column;
    gap: 20px;
    text-align: center;
  }

  .certificate-actions {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .btn-print,
  .btn-preview {
    width: 100%;
    max-width: 200px;
    text-align: center;
  }

  /* 移动端按钮区域间距 */
  .certificate-title {
    padding: 15px 10px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  body {
    padding: 6px 4px;
  }

  .header h1 {
    font-size: 18px;
  }

  .header {
    margin-top: 10px;
    padding: 16px 10px;
    margin-bottom: 14px;
  }

  .query-section {
    padding: 14px 12px;
    margin-bottom: 14px;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .form-group label {
    font-size: 12px;
  }

  .form-group input {
    height: 40px;
    font-size: 14px;
    padding: 0 12px;
  }

  .captcha-img {
    width: 88px;
    height: 40px;
    font-size: 13px;
  }

  .query-form-actions {
    gap: 12px;
    margin-top: 16px;
  }

  .query-form-actions .btn {
    padding: 11px 8px;
    font-size: 15px;
    flex: 1;
  }

  .certificate-card {
    max-width: 100%;
  }

  /* 小屏幕进一步缩小字体 */
  .certificate-card .info-label {
    font-size: 11px;
    min-width: 70px;
  }

  .certificate-card .info-value {
    font-size: 11px;
  }

  /* 小屏幕logo尺寸 */
  .certificate-logo .logo-img {
    width: 40px;
    height: 40px;
  }

  .certificate-logo-bottom .logo-img {
    width: 40px;
    height: 40px;
  }

  /* 小屏幕公章尺寸 */
  .certificate-seal .seal-img {
    width: 80px;
  }
}

/* Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header,
.query-section,
.certificate-container {
  animation: fadeIn 0.5s ease-out;
}