/* ===== AccountListPanel 样式 =====
 *
 * 通用「账户列表管理面板」组件，用于分身详情页（已挂载账户管理）与
 * 授权管理页（已授权账户管理）。
 *
 * 视觉与 account-picker.css 对齐，所有颜色 / 圆角 / 阴影读取项目 CSS 变量
 * （variables.css / dark-mode.css），暗色模式自动适配。
 *
 * 四段式布局：
 *   .alp-toolbar    顶部工具栏（标题 + 搜索；搜索支持粘贴多个 ID 批量筛选+选中）
 *   .alp-controls   控制栏：左 .alp-controls-left（已选数 + 全选所有匹配 / 清空选择）
 *                   + 右 .alp-controls-right（批量撤销/操作，对齐操作区）；选中时整条高亮
 *   .alp-body       列表区（table）
 *   .alp-footer     分页页脚（左:总数/页码 · 右:每页 N 条 + 翻页）
 */

/* ───────── Root ───────── */
.alp-root {
  display: flex;
  flex-direction: column;
  background: var(--md-surface);
  color: var(--md-on-surface);
  border: 1px solid var(--md-surface-3);
  border-radius: var(--radius-sm, 12px);
  overflow: hidden;
  min-height: 0;
}

/* ───────── Toolbar（标题 + 搜索 + pageSize） ───────── */
.alp-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--md-surface-3);
  background: var(--md-surface-1);
  flex-wrap: wrap;
}
.alp-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--md-on-surface);
  margin-right: auto;
}
.alp-title .alp-title-sub {
  margin-left: 8px;
  font-weight: 400;
  font-size: 11px;
  color: var(--md-outline);
}
.alp-search {
  position: relative;
  flex: 0 1 260px;
  min-width: 160px;
}
.alp-search input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  background: var(--md-surface);
  color: var(--md-on-surface);
  border: 1px solid var(--md-surface-3);
  border-radius: var(--radius-xs, 8px);
  outline: none;
  font-size: 12px;
  font-family: inherit;
  box-sizing: border-box;
}
.alp-search input::placeholder { color: var(--md-outline) }
.alp-search input:focus {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 2px rgba(61, 128, 255, .12);
}
.alp-search .alp-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--md-outline);
  pointer-events: none;
}

/* ───────── 控制栏：左 = 选中状态 + 选择助手；右 = 批量执行（对齐操作区） ─────────
 * 单行布局：左组占据剩余空间靠左、右组靠右；放不下时右组整体 flex-wrap 到下一行，
 * 仍由 margin-left:auto 维持右对齐。容器无关（不依赖 viewport 媒体查询）。
 * 选中态时整条轻微高亮（alp-has-selection）。 */
.alp-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-bottom: 1px solid var(--md-surface-3);
  background: var(--md-surface-1);
  transition: background .15s ease;
}
.alp-controls.alp-has-selection {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}
.alp-controls-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--md-on-surface-variant);
}
.alp-controls.alp-has-selection .alp-controls-left {
  color: var(--md-on-primary-container);
}
.alp-controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}

.alp-actions-info { white-space: nowrap; }
.alp-actions-info strong {
  color: var(--md-primary);
  font-weight: 700;
}
.alp-controls.alp-has-selection .alp-actions-info strong {
  color: var(--md-on-primary-container);
}

/* 选择助手按钮（全选所有匹配 / 清空选择）：比执行按钮更轻量 */
.alp-btn-sm {
  padding: 3px 8px;
  font-size: 11px;
}
.alp-btn-sm .material-symbols-outlined { font-size: 13px }
.alp-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 6px;
  border: 1px solid var(--md-surface-3);
  background: var(--md-surface);
  color: var(--md-on-surface);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.alp-btn:hover:not(:disabled) { background: var(--md-surface-2) }
.alp-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.alp-btn-primary {
  background: var(--md-primary);
  color: #fff;
  border-color: transparent;
}
.alp-btn-primary:hover:not(:disabled) { filter: brightness(1.08) }
.alp-btn-danger {
  background: transparent;
  color: var(--md-error);
  border-color: var(--md-error-container);
}
.alp-btn-danger:hover:not(:disabled) {
  background: var(--md-error-container);
}
.alp-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--md-primary);
}
.alp-btn-ghost:hover:not(:disabled) {
  background: var(--md-surface-2);
}
.alp-btn .material-symbols-outlined { font-size: 14px }

/* ───────── Body 表格 ───────── */
.alp-body {
  flex: 1;
  min-height: 200px;
  max-height: 60vh;
  overflow: auto;
}
.alp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.alp-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--md-surface-2);
  color: var(--md-on-surface-variant);
  font-weight: 600;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--md-surface-3);
}
.alp-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--md-surface-3);
  vertical-align: middle;
  color: var(--md-on-surface);
}
.alp-table tbody tr:hover td {
  background: rgba(61, 128, 255, .05);
}
.alp-table input[type="checkbox"],
.alp-table input[type="radio"] {
  accent-color: var(--md-primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.alp-col-cb {
  width: 44px;
  text-align: center;
}
.alp-col-state {
  width: 96px;
  color: var(--md-on-surface-variant);
}
.alp-col-primary {
  width: 64px;
  text-align: center;
}
.alp-state-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.alp-state-active   { background: var(--md-success-container); color: var(--md-success) }
.alp-state-expired  { background: var(--md-error-container); color: var(--md-error) }
.alp-state-source_removed,
.alp-state-suppressed { background: var(--md-surface-2); color: var(--md-outline) }

.alp-name-line {
  font-weight: 600;
  font-size: 13px;
  color: var(--md-on-surface);
}
.alp-id-line {
  font-size: 11px;
  color: var(--md-outline);
  font-family: var(--font-family-mono, monospace);
  margin-top: 2px;
}
.alp-scope { color: var(--md-on-surface-variant) }

.alp-loading,
.alp-empty {
  padding: 40px 12px !important;
  text-align: center;
  color: var(--md-outline);
}

/* ───────── Footer / Pager ───────── */
.alp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-top: 1px solid var(--md-surface-3);
  background: var(--md-surface);
  font-size: 11px;
  color: var(--md-outline);
}
.alp-info strong {
  color: var(--md-primary);
  font-weight: 700;
}
/* footer 右侧：每页 N 条（下沉于此）+ 翻页 */
.alp-footer-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.alp-footer .alp-page-size {
  font-size: 11px;
  color: var(--md-outline);
  display: flex;
  align-items: center;
  gap: 6px;
}
.alp-footer .alp-page-size select {
  padding: 4px 6px;
  font-size: 11px;
  border: 1px solid var(--md-surface-3);
  border-radius: 6px;
  background: var(--md-surface);
  color: var(--md-on-surface);
  font-family: inherit;
  cursor: pointer;
}
.alp-pager {
  display: flex;
  gap: 6px;
  align-items: center;
}
.alp-pager-btn {
  font-size: 11px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--md-surface-3);
  color: var(--md-on-surface);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.alp-pager-btn:hover:not(:disabled) { background: var(--md-surface-2) }
.alp-pager-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.alp-pager-page {
  color: var(--md-on-surface);
}

/* ───────── 进度条（拉取中） ───────── */
.alp-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--md-surface-3);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-size: 11px;
}
.alp-progress-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(0, 82, 217, .12);
  overflow: hidden;
}
.alp-progress-bar-fill {
  height: 100%;
  background: var(--md-primary);
  border-radius: 2px;
  transition: width .3s ease-out;
}
.alp-progress-text {
  white-space: nowrap;
  font-feature-settings: 'tnum';
}

/* ───────── 暗色模式兜底 ───────── */
[data-theme="dark"] .alp-table input[type="checkbox"],
[data-theme="dark"] .alp-table input[type="radio"] {
  accent-color: var(--md-primary);
}
[data-theme="dark"] .alp-controls.alp-has-selection {
  background: rgba(61, 128, 255, .14);
  color: var(--md-on-surface);
}
[data-theme="dark"] .alp-controls.alp-has-selection .alp-controls-left {
  color: var(--md-on-surface);
}
[data-theme="dark"] .alp-controls.alp-has-selection .alp-actions-info strong {
  color: var(--md-primary);
}
[data-theme="dark"] .alp-progress {
  background: rgba(61, 128, 255, .14);
  color: var(--md-on-surface);
}

/* 异步拉取进度条 spinner（方案 1A · mkt-status.js token_group 卡片内嵌） */
.acl-cred-pull-progress-spinner {
  animation: spin 1.4s linear infinite;
  transform-origin: 50% 50%;
}
