/* components.css — 通用组件 */

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .13s, border-color .13s, color .13s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-danger { color: var(--danger); border-color: #fecaca; background: var(--danger-soft); }
.btn-danger:hover { background: #fee2e2; border-color: #fca5a5; }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14.5px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 15px;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 18px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { font-size: 14.5px; }
.card-head .spacer { flex: 1; }

.section { margin-bottom: 22px; }
.section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 12px;
}
.section-head h2 { font-size: 15px; }
.section-head .muted { font-size: 12.5px; }

/* ---------------- 统计数字 ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; line-height: 1.2; }
.stat .sub { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.stat.accent .value { color: var(--brand); }
.stat.ok .value { color: var(--ok); }
.stat.warn .value { color: var(--warn); }
.stat.danger .value { color: var(--danger); }

/* ---------------- 标签 / 徽标 ---------------- */

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.tag.brand { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-dark); }
.tag.ok { background: var(--ok-soft); border-color: #a7f3d0; color: var(--ok); }
.tag.warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.tag.danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.tag.info { background: var(--info-soft); border-color: #bfdbfe; color: #1d4ed8; }

.type-tag { font-weight: 600; }
.type-tag.single { background: var(--info-soft); border-color: #bfdbfe; color: #1d4ed8; }
.type-tag.multiple { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }
.type-tag.judge { background: var(--ok-soft); border-color: #a7f3d0; color: var(--ok); }
.type-tag.fill { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.type-tag.short { background: #fdf2f8; border-color: #fbcfe8; color: #be185d; }

/* ---------------- 表单 ---------------- */

.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.input[type="search"] { -webkit-appearance: none; }

.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

.checkbox { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; user-select: none; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .13s, background .13s;
}
.radio-item:hover { border-color: var(--brand-line); background: var(--surface-2); }
.radio-item.checked { border-color: var(--brand); background: var(--brand-soft); }
.radio-item input { margin-top: 3px; accent-color: var(--brand); }
.radio-item .rt { font-weight: 600; font-size: 13px; }
.radio-item .rd { font-size: 12px; color: var(--muted); }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow-x: auto; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.tbl th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky; top: 0;
}
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 列表行 ---------------- */

.row-list { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--surface-2); }
.row .row-main { flex: 1; min-width: 0; }
.row .row-title {
  font-weight: 600;
  font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row .row-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.row .row-actions { display: flex; gap: 6px; flex: none; }

/* ---------------- 进度条 ---------------- */

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 20px;
  overflow: hidden;
}
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 20px; transition: width .3s; }
.progress.ok > i { background: var(--ok); }
.progress.warn > i { background: var(--warn); }
.progress.danger > i { background: var(--danger); }

/* ---------------- 空状态 ---------------- */

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}
.empty .empty-ico {
  font-size: 34px;
  opacity: .35;
  margin-bottom: 12px;
}
.empty h3 { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }
.empty p { font-size: 13px; max-width: 420px; margin: 0 auto 16px; }

/* ---------------- 提示条 ---------------- */

.notice {
  display: flex;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.55;
  border: 1px solid;
}
.notice.info { background: var(--info-soft); border-color: #bfdbfe; color: #1e40af; }
.notice.warn { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.notice.danger { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.notice.ok { background: var(--ok-soft); border-color: #a7f3d0; color: #065f46; }
.notice .n-ico { flex: none; font-weight: 700; }

/* ---------------- 模态框 ---------------- */

.modal-host {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: rgba(17, 24, 39, .42);
  padding: 20px;
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(680px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  animation: pop .16s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } }

.modal.wide { width: min(980px, 100%); }
.modal.narrow { width: min(460px, 100%); }

.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.modal-head h2 { font-size: 15px; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex: none;
}
.modal-foot .spacer { flex: 1; }

/* ---------------- Toast ---------------- */

.toast-host {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: #1f2937;
  color: #f9fafb;
  padding: 10px 16px;
  border-radius: 22px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
  max-width: 80vw;
  display: flex; align-items: center; gap: 8px;
}
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
.toast.ok { background: #065f46; }
.toast.warn { background: #92400e; }
.toast.danger { background: #991b1b; }
.toast.out { animation: toast-out .22s ease forwards; }
@keyframes toast-out { to { transform: translateY(10px); opacity: 0; } }

/* ---------------- 遮罩 loading ---------------- */

.overlay {
  position: fixed; inset: 0; z-index: 150;
  display: grid; place-items: center;
  background: rgba(249, 250, 251, .72);
  backdrop-filter: blur(2px);
}
.overlay-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 26px 34px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  min-width: 240px;
}
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--brand-line);
  border-top-color: var(--brand);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-text { font-size: 13.5px; font-weight: 600; }
.overlay-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------------- 通用小工具类 ---------------- */

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.grow { flex: 1; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 标签页 ---------------- */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--muted);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .13s, border-color .13s;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ---------------- 分段控件 ---------------- */

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.segmented button {
  padding: 5px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--muted);
  transition: background .13s, color .13s;
}
.segmented button:hover { color: var(--text-2); }
.segmented button.active {
  background: var(--surface);
  color: var(--brand);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ---------------- 上传拖放区 ---------------- */

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  background: var(--surface-2);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.dropzone .dz-ico { font-size: 30px; opacity: .5; margin-bottom: 8px; }
.dropzone .dz-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.dropzone .dz-sub { font-size: 12px; color: var(--muted); }
