/* ============================================
   components.css — 按钮 / 表格 / 校验状态 / 组件
   ============================================ */

/* 确保 hidden 属性始终生效（覆盖 .btn 等 display 声明） */
[hidden] { display: none !important; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px;
  border-radius: 8px;
  font-size: 14px; font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--grad-accent); color: #fff; box-shadow: 0 4px 12px var(--primary-glow); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 6px 16px var(--primary-glow); }

.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text-1); border-color: var(--border-strong); }

.btn-danger { background: var(--err-soft); color: var(--err); }
.btn-danger:hover:not(:disabled) { background: var(--err-soft); filter: brightness(1.05); }

.btn-danger-solid { background: var(--err); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { filter: brightness(1.08); }

.btn-primary-solid { background: #2563eb; color: #fff; }
.btn-primary-solid:hover:not(:disabled) { filter: brightness(1.08); }

.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 26px; padding: 0; }

/* ---------- 表格 ---------- */
.table-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}
.data-table th {
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
  user-select: none;
  font-size: 13px;
}
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: top;
  word-break: break-word;
  white-space: pre-wrap;
  min-height: 30px;
  position: relative;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table td:last-child { border-right: none; }

/* 单元格选中态 */
.data-table td.cell-selected {
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
  color: var(--text-1);
}
.data-table td.cell-anchor { box-shadow: inset 0 0 0 2px var(--primary); }

/* 可编辑单元格 */
.data-table td.editable { cursor: text; }
.data-table td.editable:hover { background: var(--surface-2); }
.data-table td.cell-editing {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 2px var(--primary);
}

.cell-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-1);
  font-size: 13px;
  resize: none;
  line-height: 1.5;
  padding: 2px;
  overflow: hidden;
  min-height: 1.5em;
  display: block;
}
.cell-input:focus { outline: none; }

/* 行操作列 */
.row-op-cell {
  width: 72px;
  text-align: center !important;
  vertical-align: middle !important;
  white-space: nowrap;
}
.row-op-cell .icon-btn { display: inline-grid; margin: 0 2px; vertical-align: middle; }
.icon-btn.danger:hover { color: var(--err); background: var(--err-soft); }

/* 弱提示 "缺失" */
.weak-tag {
  display: inline-block;
  font-size: 10px; color: var(--warn);
  background: var(--warn-soft);
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ---------- 校验状态标记 ---------- */
.qa-mark {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  font-size: 13px; font-weight: 700;
  user-select: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.qa-mark:hover { transform: scale(1.15); }
.qa-mark.pass { color: var(--ok); background: var(--ok-soft); }
.qa-mark.warn { color: var(--warn); background: var(--warn-soft); }
.qa-mark.fail { color: var(--err); background: var(--err-soft); }

.qa-cell { display: inline-flex; align-items: flex-start; gap: 6px; margin-top: 4px; }
.qa-reason-text { font-size: 12px; color: var(--text-3); line-height: 1.4; margin-top: 1px; word-break: break-word; white-space: pre-wrap; }

/* ---------- 术语资产抽屉 ---------- */
/* 折叠态：右侧边缘竖条按钮 */
.term-drawer-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1001;
  writing-mode: vertical-rl;
  letter-spacing: 4px;
  padding: 16px 8px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 12px 0 0 12px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 0.2s, background 0.2s, opacity 0.2s;
}
.term-drawer-toggle:hover { color: var(--primary-strong); background: var(--surface-2); }
.term-drawer-toggle-text { display: inline-block; }
.term-drawer.open .term-drawer-toggle { opacity: 0; pointer-events: none; }

/* 抽屉面板 */
.term-drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 50vw;
  max-width: 720px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s ease;
  z-index: 1000;
}
.term-drawer.open .term-drawer-panel { transform: translateX(0); }

.term-drawer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.term-drawer-title { font-size: 14px; font-weight: 600; color: var(--text-1); }
.term-drawer-header .term-count { font-size: 11px; color: var(--text-3); font-weight: 400; }
.term-drawer-header .term-save-state { font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: 10px; }
.term-drawer-header .term-save-state.saved { color: var(--ok); background: var(--ok-soft); }
.term-drawer-header .term-save-state.dirty { color: var(--warn); background: var(--warn-soft); }
.term-drawer-close {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.2s;
}
.term-drawer-close:hover { color: var(--text-1); }

/* 遮罩 */
.term-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  z-index: 999;
}
.term-drawer.open ~ .term-drawer-backdrop { opacity: 1; pointer-events: auto; }

.term-body { padding: 12px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.term-table-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.term-drawer .data-table { font-size: 11px; }
.term-drawer .data-table td { padding: 5px 6px; }
.term-actions { display: flex; gap: 6px; margin-top: 10px; }
.term-actions .btn { flex: 1; }

/* ---------- 小标签 / 提示 ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: var(--surface-3); color: var(--text-2); }

.empty-hint {
  padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 14px;
}

/* ---------- 遮罩 & 状态条 ---------- */
.status-bar { display: flex; align-items: center; gap: 8px; font-size: 13px; min-height: 20px; }
.status-bar.ok { color: var(--ok); }
.status-bar.err { color: var(--err); }
.status-bar.info { color: var(--text-2); }
.status-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 12px; font-weight: 700; line-height: 1;
  flex: 0 0 auto;
}
.status-bar.ok .status-icon { color: #fff; background: var(--ok); }
.status-bar.err .status-icon { color: #fff; background: var(--err); }

/* 表格容器滚动 */
.table-scroll { max-height: 56vh; overflow: auto; }

/* 复制选区辅助文本 */
.copy-hint { font-size: 11px; color: var(--text-3); }

/* ============================================
   常用链接模块
   ============================================ */
.links-module { display: flex; flex-direction: column; gap: 16px; }

.links-searchbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.links-searchbar .search-input {
  flex: 1;
  height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 13px; color: var(--text-1);
}
.links-searchbar .search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.links-searchbar .link-count { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.link-group { margin-bottom: 8px; }
.link-group-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin: 4px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.link-group-title .count { font-size: 11px; color: var(--text-3); font-weight: 400; }
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.link-card {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: all 0.2s;
}
.link-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.link-card-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-1); font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-card-main:hover { color: var(--primary); text-decoration: none; }
.link-card-main .link-url-sub { color: var(--text-3); font-weight: 400; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.link-card-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.2s; }
.link-card:hover .link-card-actions { opacity: 1; }
.link-card:hover .link-card-actions .icon-btn { color: var(--text-3); }

/* 分类管理面板 */
.cat-manage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.cat-manage-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cat-manage-head .section-title { margin: 0; flex: 1; }
.cat-manage-add { display: flex; gap: 8px; margin-bottom: 12px; }
.cat-manage-add input {
  flex: 1; height: 32px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 13px; color: var(--text-1);
}
.cat-manage-add input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
.cat-row:last-child { border-bottom: none; }
.cat-row-name { flex: 1; font-size: 13px; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row-name.uncat { color: var(--text-3); font-style: italic; }
.cat-row-actions { display: flex; gap: 2px; }

/* 链接编辑表单（弹窗内） */
.link-form { display: flex; flex-direction: column; gap: 12px; }
.link-form-field { display: flex; flex-direction: column; gap: 4px; }
.link-form-field label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.link-form-field input, .link-form-field select {
  height: 34px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 13px; color: var(--text-1);
}
.link-form-field input:focus, .link-form-field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* ============================================
   兑换码生成模块
   ============================================ */
.code-module { display: flex; flex-direction: column; gap: 16px; }

.code-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
.code-form-left, .code-form-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.code-form-field { display: flex; flex-direction: column; gap: 4px; }
.code-form-field label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.code-form-field input[type="text"], .code-form-field input[type="number"], .code-form-field select, .code-form-field textarea {
  width: 100%;
  height: 34px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 13px; color: var(--text-1);
}
.code-form-field textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }
.code-form-field input:focus, .code-form-field select:focus, .code-form-field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.code-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 位置选择 */
.code-position-row { display: flex; flex-wrap: wrap; gap: 6px; }
.code-position-pill {
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px; color: var(--text-2);
  transition: all 0.2s; cursor: pointer;
}
.code-position-pill:hover { border-color: var(--primary); color: var(--primary-strong); }
.code-position-pill.selected { background: var(--primary-soft); color: var(--primary-strong); border-color: var(--primary); font-weight: 500; }

.code-options { display: flex; flex-direction: column; gap: 10px; }
.code-check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.code-check-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.code-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code-actions .btn { min-width: 96px; }

.code-result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.code-result-head .count { font-size: 12px; color: var(--text-3); }

.code-history { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.code-history summary {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; list-style: none; user-select: none;
  color: var(--text-2); transition: color 0.2s;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.code-history summary::-webkit-details-marker { display: none; }
.code-history summary:hover { color: var(--primary-strong); }
.code-history summary .term-count { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: auto; }
.code-history-body { padding: 10px 16px; max-height: 260px; overflow-y: auto; }
.code-history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--border);
  font-size: 12px; color: var(--text-2);
}
.code-history-item:last-child { border-bottom: none; }
.code-history-item .meta { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-history-item .btn-sm { flex-shrink: 0; }

/* ============================================
   Emoji 参考模块
   ============================================ */
.emoji-module { display: flex; flex-direction: column; gap: 16px; }

.emoji-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.7fr auto;
  align-items: end;
  gap: 12px;
}
.emoji-form .code-form-field { min-width: 0; }
.emoji-form .btn { height: 34px; white-space: nowrap; }

.emoji-result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.emoji-result-head .count { font-size: 12px; color: var(--text-3); }
.emoji-result-actions { display: flex; gap: 6px; }
.emoji-char-cell { font-size: 22px; text-align: center; }
.emoji-raw { margin-top: 10px; }
.emoji-raw textarea {
  width: 100%; min-height: 140px;
  padding: 10px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 12px; color: var(--text-1);
  font-family: ui-monospace, Consolas, monospace;
  resize: vertical;
}
.emoji-raw textarea:focus { outline: none; border-color: var(--primary); }
