/* ============================================================
   公共样式：重置 / 变量 / 通用组件
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --info: #0891b2;
  --info-bg: #ecfeff;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --gray: #6b7280;
  --gray-light: #9ca3af;
  --border: #e5e7eb;
  --bg: #f6f7f9;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

img {
  max-width: 100%;
}

/* ---------- 布局 ---------- */
.container {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
}

.page-main {
  flex: 1;
  padding: 24px 0 48px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
}

.page-header .sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-danger-outline {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: #15803d;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--primary-light);
}

.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-lg {
  min-height: 50px;
  padding: 0 24px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- 表单 ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* 手机端防止 iOS 聚焦自动放大 */
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.form-card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 6px;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  cursor: pointer;
}

.radio-group input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
}

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
}

.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red   { background: var(--danger-bg);  color: var(--danger); }
.badge-blue  { background: var(--primary-light); color: var(--primary); }
.badge-gray  { background: #f3f4f6; color: var(--gray); }
.badge-orange{ background: var(--warning-bg); color: var(--warning); }
.badge-purple{ background: var(--purple-bg); color: var(--purple); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--gray);
}

.empty-state .icon {
  font-size: 42px;
  margin-bottom: 12px;
}

/* ---------- 加载中 ---------- */
.loading {
  text-align: center;
  padding: 40px 16px;
  color: var(--gray);
}

.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -5px;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Toast ---------- */
#toast-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(420px, calc(100% - 32px));
  pointer-events: none;
}

.toast {
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  color: #fff;
  width: 100%;
  text-align: center;
  animation: toast-in 0.25s ease;
  pointer-events: auto;
}

.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: #374151; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  animation: fade-in 0.18s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  width: 640px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.modal-head h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--gray);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal-close:hover {
  background: #f3f4f6;
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: #fff;
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.table th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.table tbody tr:hover {
  background: #f9fafb;
}

/* ---------- 报名详情展示（用户端查询页 / 管理端查看弹窗共用） ---------- */
.result-user-line {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.result-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.result-username {
  font-size: 17px;
  font-weight: 700;
}

.answer-list {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 6px;
}

.answer-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 14px;
  border-bottom: 1px dashed var(--border);
}

.answer-item .k {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.answer-item .v {
  text-align: right;
  word-break: break-all;
  white-space: pre-wrap;
}

/* ---------- 工具 ---------- */
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.hidden { display: none !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 1023px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 767px) {
  .container {
    width: calc(100% - 24px);
  }

  .page-main {
    padding: 16px 0 32px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-card {
    padding: 16px;
  }

  .modal-box {
    width: calc(100% - 24px);
  }

  .btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 34px;
  }
}
