/* ═══════════════════════════════════════════════════════
   WF 卡密管理器 - 列表 + 弹窗 UI
   Apple-inspired Design System
   ═══════════════════════════════════════════════════════ */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text2: #86868b;
  --text3: #aeaeb2;
  --border: #e5e5ea;
  --border-light: #f0f0f5;
  --input-bg: #f5f5f7;
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --primary-light: rgba(0,113,227,0.12);
  --success: #34c759;
  --success-bg: #e8f8ee;
  --success-text: #146c2e;
  --warning: #ff9f0a;
  --error: #ff3b30;
  --error-bg: #fceceb;
  --error-text: #c93400;
  --info-bg: #eef3fc;
  --info-text: #0050a3;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-modal: 0 24px 80px rgba(0,0,0,0.2);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
}

/* ─── Navbar ────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-icon { font-size: 22px; }

.navbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0f0f5;
  padding: 6px 14px;
  border-radius: var(--radius-md);
}

.server-time-label {
  font-size: 11px;
  color: var(--text2);
  font-weight: 500;
}

.server-time-value {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 70px;
}

.server-time-refresh {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.server-time-refresh:hover {
  background: #e0e0e5;
  color: var(--primary);
}

.server-time-refresh.spinning {
  animation: spin 0.7s linear infinite;
}

.navbar-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  border: none;
  background: var(--primary);
  color: #fff;
}

.nav-btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.nav-btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.nav-btn-outline:hover {
  background: var(--input-bg);
  border-color: #d1d1d6;
  color: var(--text);
}

.nav-btn-icon { font-size: 14px; }

/* ─── Stats Bar ─────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 12px;
  padding: 14px 24px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text2);
}

.stat-value { font-weight: 700; color: var(--text); font-family: var(--mono); font-size: 14px; }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; }
.stat-dot.dot-total { background: var(--text); }
.stat-dot.dot-h { background: #5856d6; }
.stat-dot.dot-t { background: #ff9500; }
.stat-dot.dot-d { background: #007aff; }
.stat-dot.dot-p { background: #34c759; }

/* ─── Toolbar ───────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }

.filter-group {
  display: flex;
  background: #e8e8ed;
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.filter-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #636366;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover { color: var(--text); }
.filter-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.search-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  width: 200px;
  outline: none;
  transition: all 0.2s var(--ease);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-input::placeholder { color: var(--text3); }

.toolbar-btn {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar-btn:hover { background: var(--error-bg); color: var(--error); border-color: var(--error); }

/* ─── Table ─────────────────────────────────────────── */
.table-container {
  padding: 0 24px 24px;
  overflow-x: auto;
}

.license-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.license-table thead {
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

.license-table th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.license-table td {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.license-table tbody tr { transition: background 0.15s ease; }
.license-table tbody tr:hover { background: #f8f8fa; }
.license-table tbody tr:last-child td { border-bottom: none; }

.th-index { width: 40px; }
.th-type { width: 70px; }
.th-license { min-width: 240px; }
.th-actions { width: 220px; }

/* 操作按钮组 - 固定常用 + 下拉更多 */
.action-group {
  display: flex;
  gap: 4px;
  align-items: center;
  position: relative;
}

.action-btn {
  padding: 4px 10px;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.4;
}

/* 复制按钮 - 蓝色 */
.action-btn-copy {
  color: var(--primary);
}
.action-btn-copy:hover { background: var(--primary-light); }

/* 详情按钮 - 灰色 */
.action-btn-detail {
  color: var(--text2);
}
.action-btn-detail:hover { background: var(--input-bg); color: var(--text); }

/* 验证按钮 - 紫色 */
.action-btn-verify {
  color: #5856d6;
}
.action-btn-verify:hover { background: #f0eeff; }

/* 检测按钮 - 蓝色 */
.action-btn-check {
  color: #007aff;
}
.action-btn-check:hover { background: #e8f0fe; }

/* 更多按钮触发器 */
.action-dropdown-trigger {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text3);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  position: relative;
}

.action-dropdown-trigger:hover {
  background: var(--input-bg);
  color: var(--text2);
  border-color: #c7c7cc;
}

/* 下拉菜单 - 使用 fixed 定位避免被表格裁剪 */
.action-dropdown {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 120px;
  z-index: 999;
  display: none;
}

.action-dropdown.open {
  display: block;
}

.action-dropdown-item {
  display: block;
  width: 100%;
  padding: 7px 12px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background 0.12s ease;
  white-space: nowrap;
}

.action-dropdown-item:hover { background: var(--input-bg); }

/* 下拉菜单项颜色 */
.action-dropdown-item-verify { color: #5856d6; }
.action-dropdown-item-verify:hover { background: #f0eeff; }

.action-dropdown-item-check { color: #007aff; }
.action-dropdown-item-check:hover { background: #e8f0fe; }

.action-dropdown-item-unbind { color: #ff9500; }
.action-dropdown-item-unbind:hover { background: #fff4e6; }

.action-dropdown-item-delete { color: var(--error); }
.action-dropdown-item-delete:hover { background: var(--error-bg); }

.action-dropdown-sep {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

/* 类型标签 */
.type-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.type-tag-H { background: #f0eeff; color: #5856d6; }
.type-tag-T { background: #fff4e6; color: #e68600; }
.type-tag-D { background: #e8f0fe; color: #007aff; }
.type-tag-P { background: #e8f8ee; color: #28a745; }


/* ─── Empty State ───────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state .empty-text { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state .empty-hint { font-size: 13px; color: var(--text3); }

/* ─── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s var(--ease);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--input-bg);
  border-radius: 50%;
  font-size: 18px;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}

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

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

/* ─── Form Elements (Modal) ─────────────────────────── */
.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
  margin-top: 14px;
}

.modal-body label:first-child { margin-top: 0; }

.modal-body input,
.modal-body select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: all 0.2s var(--ease);
}

.modal-body input:focus,
.modal-body select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.mono-input { font-family: var(--mono) !important; }

.input-row {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}

.input-col { flex: 1; }

/* Type Group */
.type-group {
  display: flex;
  background: #e8e8ed;
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  margin-top: 2px;
}

.type-btn {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  color: #636366;
}

.type-btn:hover { color: var(--text); }
.type-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.type-btn .badge {
  font-size: 10px;
  display: block;
  margin-top: 1px;
  opacity: 0.55;
  font-weight: 400;
}

/* ─── Buttons ───────────────────────────────────────── */
.btn-primary {
  padding: 9px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 9px 20px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover { background: #e8e8ed; }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn-primary.loading .spinner { display: inline-block; }
.btn-primary.loading .btn-label { opacity: 0.7; }

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

/* ─── Test Result ───────────────────────────────────── */
.test-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: none;
  line-height: 1.5;
}

.test-result.ok { background: var(--success-bg); border: 1px solid var(--success); color: var(--success-text); display: block; }
.test-result.fail { background: var(--error-bg); border: 1px solid var(--error); color: var(--error-text); display: block; }
.test-result.loading { background: var(--info-bg); border: 1px solid var(--primary); color: var(--info-text); display: block; }

.test-result pre {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 11px;
  margin-top: 8px;
  font-family: var(--mono);
  opacity: 0.9;
}

.test-result b { display: block; margin-bottom: 6px; font-size: 13px; }

/* ─── Misc ──────────────────────────────────────────── */
.hint { font-size: 12px; color: var(--text2); line-height: 1.5; }
.warn { font-size: 11px; color: var(--warning); margin-top: 6px; font-weight: 500; }
.err { font-size: 12px; color: var(--error); margin-top: 8px; font-weight: 500; }

#duration-section { transition: opacity 0.3s ease; }

/* ─── Detail Meta ───────────────────────────────────── */
.detail-meta { margin-top: 8px; }
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--text2); flex-shrink: 0; }
.detail-val { color: var(--text); font-family: var(--mono); font-weight: 500; text-align: right; word-break: break-all; margin-left: 16px; font-size: 12px; }

/* ─── Toast ─────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(29,29,31,0.92);
  backdrop-filter: blur(16px);
  color: #fff;
  padding: 10px 22px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  .navbar { flex-direction: column; gap: 10px; padding: 12px 16px; }
  .navbar-right { width: 100%; justify-content: center; }
  .toolbar { flex-direction: column; padding: 12px 16px; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .search-input { width: 100%; }
  .table-container { padding: 0 8px 16px; }
  .license-table th, .license-table td { padding: 8px 10px; font-size: 12px; }
  .th-duration, .th-deadline, .th-machine, .th-checksum { display: none; }
  .td-duration, .td-deadline, .td-machine, .td-checksum { display: none; }
  .modal { width: 95%; max-width: none; }
}
/* ─── 卡密单元格（打码+复制图标）─── */
.license-cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.license-text-masked {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
  line-height: 1.4;
}

.license-copy-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text3);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  opacity: 0.3;
}

.license-cell:hover .license-copy-btn,
.license-copy-btn:focus {
  opacity: 1;
  color: var(--primary);
}

.license-copy-btn:hover {
  background: var(--primary-light);
  opacity: 1;
}