/* ============================================================
   components.css — 按钮、表单、卡片、面板、标签、提示、弹窗、抽屉
   ============================================================ */

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
  color: var(--danger);
}
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); }

.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover:not(:disabled) { filter: brightness(1.08); }

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

.btn.mini { padding: 3px 8px; font-size: 11.5px; gap: 4px; }
.btn.mini svg { width: 12px; height: 12px; }
.btn.icon { padding: 6px; }
.btn.block { width: 100%; justify-content: center; }

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

.input, textarea, select {
  padding: 8px 11px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  width: 100%;
}
.input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
select { cursor: pointer; }

.input[type="search"] { padding-left: 30px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}
.field > small {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.5;
}

.field.checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface-2);
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 14px;
}
.field.checkbox:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.field.checkbox input {
  margin: 2px 0 0;
  flex: 0 0 auto;
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}
.field.checkbox > div { flex: 1; min-width: 0; }
.field.checkbox > div > span { font-size: 13px; color: var(--text); display: block; }
.field.checkbox small {
  display: block;
  color: var(--text-faint);
  font-size: 11.5px;
  margin-top: 3px;
  line-height: 1.5;
}

.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 780px) { .form-grid { grid-template-columns: 1fr; } }

/* 搜索框带图标 */
.search-wrap { position: relative; flex: 1; min-width: 160px; }
.search-wrap svg {
  position: absolute;
  left: 9px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-faint);
  pointer-events: none;
}

/* ---------------- 面板与卡片 ---------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.panel.flush { padding: 0; overflow: hidden; }
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.panel.flush .panel-head { padding: 14px 18px 0; margin-bottom: 12px; }
.panel-head h2 { flex-shrink: 0; }
.panel-head .desc { font-size: 12px; color: var(--text-faint); }
.panel-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.panel-sub {
  font-size: 12px;
  color: var(--text-faint);
  margin: -8px 0 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.stat-card .label {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.stat-card .label svg { width: 13px; height: 13px; opacity: .7; }
.stat-card .value {
  font-size: 27px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: -.5px;
  line-height: 1.1;
}
.stat-card .value.sm { font-size: 15px; letter-spacing: 0; word-break: break-all; }
.stat-card .sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 7px;
  line-height: 1.5;
}
.stat-card .accent-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: .8;
}
.stat-card.ok .accent-bar { background: var(--ok); }
.stat-card.warn .accent-bar { background: var(--warn); }
.stat-card.info .accent-bar { background: var(--info); }

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-family: var(--mono);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
  line-height: 1.6;
}
.tag.ai { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }
.tag.manual { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.tag.import { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, transparent); background: var(--info-soft); }
.tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.tag.err { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }

/* ---------------- 登录门 ---------------- */

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(900px 500px at 50% -10%, #1d2439, var(--bg));
  z-index: 100;
  padding: 20px;
}
[data-theme="light"] .gate {
  background: radial-gradient(900px 500px at 50% -10%, #dde5f5, var(--bg));
}
.gate-card {
  width: 370px;
  max-width: 100%;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-lg);
}
.gate-card .brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.gate-card .brand-row .logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--info));
  display: grid;
  place-items: center;
}
.gate-card .brand-row .logo svg { width: 17px; height: 17px; }
.gate-card input {
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.gate-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gate-card button { padding: 10px; justify-content: center; }
.gate-error { color: var(--danger); font-size: 12px; margin: 0; min-height: 16px; }

/* ---------------- 输出块 ---------------- */

.output {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 440px;
  overflow: auto;
  margin: 12px 0 0;
  color: var(--code-text);
}
.output.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.output.err { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.output.tall { max-height: 620px; }
.output.center-empty {
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-faint);
  min-height: 120px;
}

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

.notice {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid var(--border);
  background: var(--surface-2);
  align-items: flex-start;
}
.notice svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.notice.info { border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: var(--accent-soft); }
.notice.ok { border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.notice.danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.notice strong { font-weight: 600; }

/* ---------------- 弹窗 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, .72);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-card {
  width: 580px;
  max-width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
}
.modal-card.wide { width: 860px; }
.modal-head {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
  gap: 10px;
}
.modal-head h3 { flex: 1; }
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

/* ---------------- 抽屉 ---------------- */

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 560px;
  max-width: 94vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 75;
  display: flex;
  flex-direction: column;
  animation: slide-in .2s ease;
}
@keyframes slide-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-head h3 { flex: 1; }
.drawer-body { padding: 18px 20px 30px; overflow-y: auto; flex: 1; }
.drawer-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--text-dim); font-size: 12px; padding-top: 1px; }
.kv dd { margin: 0; word-break: break-word; }
.kv dd.pre {
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  background: var(--surface-2);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

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

.toast-stack {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  align-items: center;
}
.toast {
  padding: 10px 18px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease;
  max-width: 90vw;
}
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }
.toast.warn { border-color: var(--warn); }

/* ---------------- 校验清单 / 步骤条 ---------------- */

.steps { display: flex; gap: 0; margin-bottom: 20px; }
.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 4px;
  font-size: 12.5px;
  color: var(--text-faint);
  border-bottom: 2px solid var(--border);
  transition: var(--transition);
}
.step .num {
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-family: var(--mono);
  flex-shrink: 0;
}
.step.active { color: var(--accent); border-bottom-color: var(--accent); }
.step.active .num { background: var(--accent); color: #fff; }
.step.done { color: var(--ok); border-bottom-color: var(--ok); }
.step.done .num { background: var(--ok); color: #fff; }

.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.checklist li {
  display: flex;
  gap: 10px;
  font-size: 13px;
  line-height: 1.6;
  align-items: flex-start;
}
.checklist .mark {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  margin-top: 1px;
  display: grid;
  place-items: center;
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.checklist .mark.done {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

/* 复制行 */
.copy-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.copy-row .input, .copy-row .output {
  flex: 1;
  margin: 0;
}
