/* ==================== 基础重置 ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Helvetica Neue", sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
}

/* ==================== 顶部标题栏 ==================== */
.top-bar {
  background: linear-gradient(135deg, #003478, #0052a2);
  color: #fff;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.top-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo { font-size: 20px; font-weight: bold; }
.subtitle { font-size: 13px; opacity: 0.85; }

/* ==================== 布局容器 ==================== */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 24px;
  padding: 24px;
}

/* ==================== 左侧导航 ==================== */
.side-nav {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  align-self: flex-start;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  overflow: hidden;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.side-nav ul { list-style: none; }
.side-nav li { border-bottom: 1px solid #f0f0f0; }
.side-nav li:last-child { border-bottom: none; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  text-decoration: none;
  color: #555;
  font-size: 14px;
  transition: all 0.2s;
}
.side-nav a:hover { background: #f5f8ff; color: #0052a2; }
.side-nav a.active { background: #0052a2; color: #fff; font-weight: bold; }
.nav-num {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  background: #e8ecf1;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
}
.side-nav a.active .nav-num { background: rgba(255,255,255,0.3); }
.side-nav a.completed { color: #27ae60; }
.side-nav a.completed::after {
  content: '✓';
  margin-left: auto;
  font-weight: bold;
  color: #27ae60;
}

/* ==================== 表单主区域 ==================== */
.form-main {
  flex: 1;
  min-width: 0;
}

/* ==================== 章节卡片 ==================== */
.form-section {
  background: #fff;
  border-radius: 8px;
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  scroll-margin-top: 80px;
}
.section-title {
  font-size: 20px;
  color: #003478;
  border-bottom: 2px solid #0052a2;
  padding-bottom: 12px;
  margin-bottom: 24px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.section-num {
  background: #0052a2;
  color: #fff;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 16px;
}
.section-title small { font-size: 13px; color: #999; font-weight: normal; }

.sub-section-title {
  font-size: 15px;
  color: #444;
  margin: 16px 0 12px;
  padding-left: 12px;
  border-left: 3px solid #0052a2;
}

/* ==================== 表单网格 ==================== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field-group { display: flex; flex-direction: column; }
.field-group.full-width { grid-column: 1 / -1; }
.field-group label {
  font-size: 13px;
  font-weight: 600;
  color: #444;
  margin-bottom: 4px;
}
.required { color: #e74c3c; }

.field-group input[type="text"],
.field-group input[type="tel"],
.field-group input[type="email"],
.field-group input[type="number"],
.field-group input[type="date"],
.field-group select,
.field-group textarea {
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fafbfc;
}
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: #0052a2;
  box-shadow: 0 0 0 3px rgba(0,82,162,0.1);
  background: #fff;
}
.field-group input.field-error,
.field-group select.field-error,
.field-group textarea.field-error {
  border-color: #e74c3c;
  background: #fff5f5;
}
.field-hint {
  font-size: 11px;
  color: #e67e22;
  margin-top: 2px;
}
.error-msg {
  font-size: 12px;
  color: #e74c3c;
  margin-top: 2px;
}

/* ==================== 单选按钮组 ==================== */
.radio-group { display: flex; gap: 16px; }
.radio-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: normal;
  cursor: pointer;
}
.radio-group input[type="radio"] { accent-color: #0052a2; }

/* ==================== 条件显示/隐藏 ==================== */
.conditional-block { margin: 12px 0; }
.conditional-hidden { display: none; }
.conditional-visible { display: block; }

/* ==================== 动态行（子女/随行家属） ==================== */
.dynamic-row {
  background: #f8f9fb;
  border: 1px solid #e0e3e8;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}
.dynamic-row .form-grid { margin-bottom: 0; }
.btn-add-row {
  margin-top: 8px;
  padding: 8px 20px;
  background: #0052a2;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-add-row:hover { background: #003478; }
.btn-remove-row {
  position: absolute;
  top: 8px;
  right: 12px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
}
.btn-remove-row:hover { background: #c0392b; }

/* ==================== 照片区域 ==================== */
.photo-upload-area {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  padding: 16px;
  background: #f8f9fb;
  border-radius: 8px;
  border: 1px dashed #ccc;
}
.photo-box {
  width: 90px;
  height: 120px;
  border: 2px dashed #bbb;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  color: #999;
  background: #fff;
}
.photo-note { font-size: 12px; color: #888; }

/* ==================== 护照上传识别区域 ==================== */
.passport-upload-area {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #f0f7ff, #e8f0fe);
  border-radius: 8px;
  border: 2px dashed #0052a2;
  align-items: center;
}
.passport-upload-box {
  width: 160px;
  min-height: 110px;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d0d5dd;
  transition: border-color 0.2s;
}
.passport-upload-box:hover { border-color: #0052a2; }
.passport-upload-box.scan-success { border-color: #27ae60; box-shadow: 0 0 0 3px rgba(39,174,96,0.15); }
.upload-prompt {
  text-align: center;
  color: #666;
  font-size: 13px;
}
.upload-icon { font-size: 32px; display: block; margin-bottom: 4px; }
.passport-upload-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.btn-rescan {
  position: absolute;
  bottom: 6px;
  right: 6px;
  padding: 3px 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
#passportPreview { position: relative; width: 100%; height: 100%; }
.passport-upload-info { font-size: 12px; color: #555; line-height: 1.6; }
.passport-upload-info p { margin-bottom: 2px; }

/* 扫描进度 */
.scan-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin-bottom: 16px;
  background: #fffdf5;
  border: 1px solid #e5d98a;
  border-radius: 6px;
  font-size: 13px;
  color: #8c6e00;
}
.scan-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #ddd;
  border-top-color: #0052a2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== OCR 调试面板 ==================== */
.ocr-debug {
  margin-bottom: 16px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  overflow: hidden;
  font-size: 12px;
}
.ocr-debug-header {
  background: #f0f2f5;
  padding: 8px 14px;
  cursor: pointer;
  color: #555;
  font-weight: 600;
  user-select: none;
}
.ocr-debug-header:hover { background: #e0e3e8; }
.ocr-debug-content {
  padding: 12px;
  margin: 0;
  background: #fafbfc;
  max-height: 200px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.4;
  color: #333;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: "Courier New", monospace;
}
.ocr-debug-content.hidden { display: none; }

/* ==================== 声明框 ==================== */
.declaration-box {
  background: #fffdf5;
  border: 1px solid #e5d98a;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
.declaration-box h4 { color: #8c6e00; margin-bottom: 8px; }
.declaration-box p { font-size: 13px; color: #666; margin-bottom: 6px; }

.signature-area {
  background: #f8f9fb;
  border-radius: 6px;
  padding: 16px;
  margin-top: 16px;
  text-align: center;
}
.signature-note { font-size: 13px; color: #e67e22; }

/* ==================== 提交按钮 ==================== */
.submit-area {
  text-align: center;
  padding: 24px;
}
.btn-submit {
  padding: 14px 48px;
  background: linear-gradient(135deg, #003478, #0052a2);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(0,52,120,0.3);
}
.btn-submit:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,52,120,0.4); }
.btn-submit:active { transform: translateY(0); }
.btn-submit:disabled { background: #999; cursor: not-allowed; box-shadow: none; }

/* ==================== 成功弹窗 ==================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #27ae60;
  color: #fff;
  font-size: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.modal-box h2 { color: #27ae60; margin-bottom: 12px; }
.modal-box p { color: #666; margin-bottom: 8px; }
.modal-id { font-size: 18px; color: #003478; }
.btn-close-modal {
  margin-top: 20px;
  padding: 10px 40px;
  background: #0052a2;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}
.btn-close-modal:hover { background: #003478; }

/* ==================== 响应式（手机端适配） ==================== */
@media (max-width: 768px) {
  .app-container { flex-direction: column; padding: 8px; }

  /* 移动端导航改为横向滚动 */
  .side-nav {
    width: 100%;
    position: sticky;
    top: 52px;
    z-index: 99;
    max-height: none;
    border-radius: 0;
    margin: -8px -8px 8px -8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  }
  .side-nav ul { display: flex; padding: 4px 4px; }
  .side-nav li { border-bottom: none; flex-shrink: 0; }
  .side-nav a { padding: 8px 10px; font-size: 11px; white-space: nowrap; gap: 4px; }
  .nav-num { width: 18px; height: 18px; font-size: 10px; }
  .side-nav a.completed::after { display: none; }

  /* 单列布局 */
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-section { padding: 14px; margin-bottom: 12px; border-radius: 6px; scroll-margin-top: 100px; }
  .section-title { font-size: 17px; padding-bottom: 8px; margin-bottom: 14px; }
  .section-num { width: 26px; height: 26px; font-size: 13px; }

  /* 表单控件触摸优化 */
  .field-group input[type="text"],
  .field-group input[type="tel"],
  .field-group input[type="email"],
  .field-group input[type="number"],
  .field-group input[type="date"],
  .field-group select,
  .field-group textarea {
    padding: 12px 14px;
    font-size: 16px; /* 防止 iOS 缩放 */
    border-radius: 8px;
  }
  .field-group label { font-size: 14px; }

  /* 护照上传区域移动端优化 */
  .passport-upload-area {
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }
  .passport-upload-box {
    width: 100%;
    min-height: 180px;
    max-height: 240px;
  }
  .passport-upload-info p { font-size: 11px; }

  /* 照片区域移动端 */
  .photo-upload-area { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* 单选按钮触摸优化 */
  .radio-group { flex-wrap: wrap; gap: 12px; }
  .radio-group label { padding: 6px 0; }

  /* 动态行移动端 */
  .dynamic-row { padding: 12px; }
  .btn-remove-row { top: 4px; right: 8px; padding: 6px 14px; }
  .btn-add-row { width: 100%; padding: 12px; font-size: 14px; }

  /* 提交按钮移动端 */
  .btn-submit {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    border-radius: 10px;
  }
  .submit-area { padding: 16px 4px; }

  /* 顶部栏移动端 */
  .top-bar { padding: 10px 14px; }
  .top-bar-inner { flex-direction: column; gap: 2px; text-align: center; }
  .logo { font-size: 16px; }
  .subtitle { font-size: 11px; }

  /* 弹窗移动端 */
  .modal-box { padding: 28px 20px; width: 95%; }

  /* 条件块间距 */
  .conditional-block { margin: 8px 0; }
}

/* 小屏手机进一步优化 */
@media (max-width: 400px) {
  .side-nav a { padding: 6px 7px; font-size: 10px; }
  .section-title { font-size: 15px; }
  .field-group input[type="text"],
  .field-group input[type="tel"],
  .field-group input[type="email"],
  .field-group input[type="number"],
  .field-group input[type="date"],
  .field-group select { padding: 10px 10px; }
}
