/* ============================================================
   components.css — 按钮 / 徽章 / 表单 / 标签 / 吐司 / 抽屉 / 列表
   ============================================================ */

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
  transition: filter .15s, background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: var(--bad-weak); }
.btn.danger:hover { background: var(--bad-weak); filter: brightness(.98); }
.btn.block { width: 100%; justify-content: center; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.icon-btn {
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  width: 36px; height: 36px; border-radius: 10px; font-size: 17px; display: inline-grid; place-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { border: none; background: transparent; color: var(--text-2); padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* ---------- 徽章 / 状态点 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
}
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.bad { background: var(--bad-weak); color: var(--bad); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.accent { background: var(--accent-weak); color: var(--accent); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 25%, transparent); }
.dot.off { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a99a8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 160px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); user-select: none; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- 标签页 ---------- */
.tabs { display: inline-flex; background: var(--surface-3); border-radius: 999px; padding: 4px; gap: 2px; margin-bottom: 16px; }
.tab { border: none; background: transparent; color: var(--text-2); padding: 8px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600; transition: background .15s, color .15s; }
.tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ---------- 拖拽上传 ---------- */
.dropzone {
  display: block; width: 100%; box-sizing: border-box;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 26px; text-align: center; color: var(--text-2);
  transition: border-color .15s, background .15s; cursor: pointer; background: var(--surface-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); }
.dropzone strong { color: var(--text); }
.dropzone .meta { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }

/* ---------- 列表（任务 / 打印机） ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.item .main { min-width: 0; flex: 1; }
.item .title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 26px 0; }

/* ---------- 打印机大卡 ---------- */
.printer-card { display: flex; gap: 14px; align-items: flex-start; }
.printer-card .pic {
  width: 46px; height: 46px; border-radius: 12px; background: var(--accent-weak); display: grid; place-items: center; font-size: 22px; flex: none;
}
.printer-card .name { font-weight: 650; font-size: 15px; }
.printer-card .state { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

/* ---------- 吐司 ---------- */
.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  box-shadow: var(--shadow); border-radius: 10px; padding: 12px 16px; font-size: 13.5px; min-width: 220px; max-width: 360px;
  animation: toast-in .2s ease; color: var(--text);
}
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast .t-title { font-weight: 650; }
.toast .t-msg { color: var(--text-2); margin-top: 2px; word-break: break-word; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 登录门禁 ---------- */
.login-gate {
  position: fixed; inset: 0; z-index: 300; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.login-card {
  width: min(380px, 94vw); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 26px 22px;
}
.login-card .brand-row { display: flex; align-items: center; gap: 10px; font-size: 17px; margin-bottom: 6px; }
.login-card .brand-logo { font-size: 22px; }
.login-card .sub { color: var(--text-3); font-size: 12.5px; margin: 0 0 18px; }
.login-card .field { margin-bottom: 14px; }
.login-card .err { color: var(--bad); font-size: 12.5px; min-height: 16px; margin: -6px 0 10px; }
.login-card .hint { color: var(--text-3); font-size: 11.5px; margin: 12px 0 0; line-height: 1.5; }

/* ---------- 日志抽屉 ---------- */
.scrim { position: fixed; inset: 0; background: rgba(8, 12, 18, .45); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
.scrim.show { opacity: 1; pointer-events: auto; }
.logdrawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); z-index: 60;
  background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(105%); transition: transform .22s ease; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.logdrawer.open { transform: translateX(0); }
.logdrawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.logdrawer-head > div { display: flex; align-items: center; gap: 4px; }
.logbody { flex: 1; overflow: auto; margin: 0; padding: 14px 16px; font-family: var(--mono); font-size: 12px; line-height: 1.55; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }

/* ---------- 杂项 ---------- */
.spinner { width: 16px; height: 16px; border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--text-3); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: none; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- 小屏适配（≤560px） ---------- */
@media (max-width: 560px) {
  .login-card { padding: 22px 18px 18px; }
  .login-card .brand-row { font-size: 16px; }
  .login-card .sub { font-size: 12px; margin-bottom: 14px; }
  .logdrawer { width: 100%; }
  .toast { min-width: 0; max-width: 92vw; font-size: 12.5px; padding: 11px 14px; }
  .kv { grid-template-columns: 92px 1fr; font-size: 12.5px; }
  .printer-card { flex-wrap: wrap; }
  .printer-card .pic { width: 40px; height: 40px; font-size: 20px; }
  .tabs { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .item { gap: 10px; }
  .item .sub { font-size: 11.5px; }
  .item .btn { padding: 7px 12px; font-size: 12.5px; }
  .dropzone { padding: 20px 16px; }
  .actions { gap: 8px; }
  .btn { padding: 9px 13px; font-size: 13px; }
}
