/* ==========================================================================
   v7-desktop.css —— 桌面端（≥1024px）组件
   --------------------------------------------------------------------------
   新增/改造组件：
     · .v7-scrim / .dialog           L3（480px）/ L4（560px）标准与破坏性确认
     · .context-menu                 右键上下文菜单（低频操作收口）
     · .table--v7                    行 hover / 选中态 / 行操作聚合成「更多」
     · .table-toolbar / .batch-bar   工具栏与批量操作栏
     · .page-head                    页头层级（标题/描述/操作）
   颜色全部取自既有令牌。
   ========================================================================== */

/* --------------------------------------------------------------------------
   遮罩 + Dialog
   -------------------------------------------------------------------------- */
.v7-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--overlay-scrim);
  animation: v7-scrim-in var(--m-scrim) var(--ease-standard) both;
  backdrop-filter: blur(2px);
}
.v7-scrim.is-leaving { animation: v7-scrim-out var(--m-scrim) var(--ease-standard) both; }
.v7-scrim--strong { background: var(--overlay-scrim-strong); }

@keyframes v7-scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes v7-scrim-out { from { opacity: 1; } to { opacity: 0; } }

.dialog {
  position: relative;
  width: 100%;
  max-width: 480px;                 /* L3 标准确认 */
  max-height: calc(100% - var(--space-12));
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  /* 打开：opacity + scale(.98→1) 200ms */
  animation: v7-dialog-in var(--m-panel-in) var(--ease-standard) both;
}
.dialog--lg { max-width: 560px; }    /* L4 破坏性 / 宽 Dialog */
.dialog--xl { max-width: 760px; }    /* 复杂表单（桌面宽 Dialog） */
/* 关闭：反向 150ms */
.dialog.is-leaving { animation: v7-dialog-out var(--m-panel-out) var(--ease-standard) both; }

@keyframes v7-dialog-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes v7-dialog-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(0.98); }
}

.dialog__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6) var(--space-4);
}
.dialog__icon {
  display: grid; place-items: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--bg-active);
  color: var(--brand-500);
}
.dialog__icon--danger { background: var(--danger-soft); color: var(--danger); }
.dialog__icon--warning { background: var(--warning-soft); color: var(--warning); }
.dialog__icon--success { background: var(--success-soft); color: var(--success); }

.dialog__titles { flex: 1 1 auto; min-width: 0; }
.dialog__title { font-size: 19px; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; }
.dialog__subtitle { margin-top: 2px; font-size: var(--text-sm); color: var(--text-tertiary); }

.dialog__body {
  padding: 0 var(--space-6) var(--space-6);
  overflow-y: auto;
  font-size: var(--text-base);      /* 正文 14px */
  line-height: 1.65;
  color: var(--text-secondary);
}
.dialog__body strong, .dialog__body b { color: var(--text-primary); font-weight: 640; }

.dialog__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;        /* 按钮右对齐 */
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-muted);
}
.dialog__foot--split { justify-content: space-between; }

/* L4 危险区块：用现有 danger 令牌 + 图标 + 文案表达风险，不新增颜色 */
.dialog__danger {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
}
.dialog__danger-icon { display: grid; place-items: center; color: var(--danger); flex-shrink: 0; }
.dialog__danger-text { font-size: var(--text-sm); color: var(--text-primary); line-height: 1.55; }
.dialog__danger-text b { color: var(--danger); font-weight: 650; }

/* 要求输入名称确认 */
.dialog__typing { margin-top: var(--space-4); }
.dialog__typing code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: var(--bg-muted);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

/* --------------------------------------------------------------------------
   Context Menu（右键 / 「更多」）
   -------------------------------------------------------------------------- */
.context-menu {
  position: fixed;
  z-index: var(--z-tooltip);
  min-width: 208px;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  animation: v7-pop-in var(--dur-pop) var(--ease-standard) both;
}
.context-menu.is-leaving { animation: v7-pop-out var(--dur-fast) var(--ease-standard) both; }

.context-menu__header {
  padding: var(--space-2) var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-tertiary);
}
.context-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--tap-min-desktop);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--text-secondary);
  text-align: left;
  transition: background var(--dur-press) var(--ease-standard), color var(--dur-press) var(--ease-standard);
}
.context-menu__item:hover,
.context-menu__item.is-active { background: var(--bg-hover); color: var(--text-primary); }
.context-menu__item:active { background: var(--bg-active); }
.context-menu__item--danger { color: var(--danger); }
.context-menu__item--danger:hover, .context-menu__item--danger.is-active { background: var(--danger-soft); color: var(--danger); }
.context-menu__item[disabled] { opacity: 0.42; cursor: not-allowed; }
.context-menu__item[disabled]:hover { background: transparent; color: var(--text-tertiary); }
.context-menu__shortcut { margin-left: auto; font-size: var(--text-xs); color: var(--text-tertiary); font-family: var(--font-mono); }
.context-menu__divider { height: 1px; margin: var(--space-2) var(--space-1); background: var(--border-subtle); }

/* --------------------------------------------------------------------------
   Drawer（桌面侧滑面板，translateX 250ms；遮罩同步 fade 150ms）
   -------------------------------------------------------------------------- */
.v7-drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  background: var(--overlay-scrim);
  animation: v7-scrim-in var(--m-scrim) var(--ease-standard) both;
}
.v7-drawer-scrim.is-leaving { animation: v7-scrim-out var(--m-scrim) var(--ease-standard) both; }

.v7-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--z-drawer) + 1);
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-raised);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xl);
  animation: v7-drawer-in var(--m-drawer) var(--ease-standard) both;
}
.v7-drawer--left {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--border-subtle);
  animation-name: v7-drawer-in-left;
}
.v7-drawer.is-leaving { animation: v7-drawer-out var(--m-drawer) var(--ease-standard) both; }
.v7-drawer--left.is-leaving { animation-name: v7-drawer-out-left; }

@keyframes v7-drawer-in {
  from { opacity: 0.6; transform: translate3d(100%, 0, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes v7-drawer-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0.6; transform: translate3d(100%, 0, 0); }
}
@keyframes v7-drawer-in-left {
  from { opacity: 0.6; transform: translate3d(-100%, 0, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes v7-drawer-out-left {
  from { opacity: 1; transform: none; }
  to { opacity: 0.6; transform: translate3d(-100%, 0, 0); }
}

.v7-drawer__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}
.v7-drawer__title { font-size: var(--text-lg); font-weight: 650; }
.v7-drawer__subtitle { margin-top: 2px; font-size: var(--text-sm); color: var(--text-tertiary); }
.v7-drawer__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--space-6); }
.v7-drawer__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-muted);
}

/* --------------------------------------------------------------------------
   页头层级
   -------------------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}
.page-head__title {
  display: flex; align-items: center; gap: var(--space-3);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text-primary);
}
.page-head__icon {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--tint-brand);
  color: var(--brand-600);
}
.page-head__desc {
  margin-top: var(--space-2);
  font-size: var(--text-base);
  color: var(--text-tertiary);
  max-width: 72ch;
  line-height: 1.6;
}
.page-head__actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

/* --------------------------------------------------------------------------
   表格工具栏
   -------------------------------------------------------------------------- */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-wrap: wrap;
}
.table-toolbar__search {
  position: relative;
  flex: 1 1 240px;
  max-width: 340px;
}
.table-toolbar__search .input { padding-left: 34px; }
.table-toolbar__search-icon {
  position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary); pointer-events: none;
}
.table-toolbar__spacer { flex: 1 1 auto; }
.table-toolbar__meta { font-size: var(--text-sm); color: var(--text-tertiary); white-space: nowrap; }

/* --------------------------------------------------------------------------
   表格 v7：hover 行高亮 / 选中态 / 行操作收口
   -------------------------------------------------------------------------- */
.table--v7 { table-layout: auto; }
.table--v7 tbody tr {
  cursor: default;
  transition: background var(--dur-press) var(--ease-standard), box-shadow var(--dur-press) var(--ease-standard);
}
.table--v7 tbody tr:hover { background: var(--bg-hover); }              /* 复用现有背景 token */
.table--v7 tbody tr.is-selected { background: var(--bg-active); }
.table--v7 tbody tr.is-selected:hover { background: var(--bg-active); }
.table--v7 tbody tr.is-selected td { border-bottom-color: var(--border-default); }
.table--v7 tbody tr:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: -2px;
}
.table--v7 tbody tr.is-flash { animation: v7-row-flash 900ms var(--ease-standard) both; }
@keyframes v7-row-flash {
  0% { background: var(--bg-active); }
  100% { background: transparent; }
}

.table--v7 td.table__cell-main { font-weight: 560; color: var(--text-primary); }
.table--v7 td.table__cell-muted { color: var(--text-tertiary); font-size: var(--text-sm); }
.table--v7 td.table__cell-num { font-variant-numeric: tabular-nums; }

.table--v7 th[data-col='select'], .table--v7 td[data-col='select'] { width: 48px; padding-right: 0; }
.table--v7 th[data-col='actions'], .table--v7 td[data-col='actions'] { width: 1%; white-space: nowrap; text-align: right; }

/* 行内「更多」按钮：hover 才显形，键盘 focus 也显形 */
.row-more {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity var(--dur-press) var(--ease-standard),
    background var(--dur-press) var(--ease-standard),
    color var(--dur-press) var(--ease-standard);
}
.table--v7 tbody tr:hover .row-more,
.table--v7 tbody tr.is-selected .row-more,
.row-more:focus-visible { opacity: 1; }
.row-more:hover { background: var(--bg-hover); color: var(--text-primary); }
.row-more:active { background: var(--bg-active); }
@media (hover: none) { .row-more { opacity: 1; } }

/* --------------------------------------------------------------------------
   批量操作栏（选中 ≥1 项时出现在底部）
   -------------------------------------------------------------------------- */
.batch-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-6) + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  animation: v7-batch-in var(--dur-sheet) var(--ease-emphasized) both;
}
.batch-bar.is-leaving { animation: v7-batch-out var(--dur-fast) var(--ease-standard) both; }
.batch-bar__count { font-size: var(--text-sm); font-weight: 650; white-space: nowrap; }
.batch-bar__count b { color: var(--brand-600); font-variant-numeric: tabular-nums; }
.batch-bar__divider { width: 1px; height: 20px; background: var(--border-default); }
.batch-bar__actions { display: flex; align-items: center; gap: var(--space-2); }

@keyframes v7-batch-in {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes v7-batch-out {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, 12px); }
}

/* 批量栏出现时，把底部 Snackbar 抬高，避免相互遮挡 */
.has-batch-bar .snackbar-host {
  bottom: calc(var(--space-6) + var(--safe-bottom) + 64px);
}

/* --------------------------------------------------------------------------
   桌面端按钮/输入最小尺寸补齐（≥32px）
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  .btn { min-height: var(--tap-min-desktop); }
  .btn--sm { min-height: var(--tap-min-desktop); }
  .icon-button { width: 38px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .dialog,
  .v7-scrim,
  .v7-drawer,
  .v7-drawer-scrim,
  .context-menu,
  .batch-bar {
    animation: none !important;
    transform: none !important;
  }
  /* 行 hover / 选中只切颜色，不做任何位移或过渡位移 */
  .table--v7 tbody tr {
    transition-property: background-color !important;
    transition-duration: 1ms !important;
  }
}
