/* ===== Batch 5: 全面界面优化（三轮建议落地） ===== */

/* ===== 1. 表格视觉：斑马纹 + 行悬停竖线 ===== */
.data-table tbody tr:nth-child(even) {
  background: var(--bg-hover);
}
.data-table tbody tr {
  position: relative;
  transition: background 0.15s ease;
}
.data-table tbody tr:hover {
  background: var(--primary-bg);
}

/* ===== 2. 金额千分位 + 颜色高亮 ===== */
.money-positive {
  color: var(--success, #10b981);
  font-weight: 600;
}
.money-negative {
  color: var(--danger, #ef4444);
  font-weight: 600;
}
.money-neutral {
  color: var(--text-secondary);
}
.money-zero {
  color: var(--text-tertiary);
}
td.money-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
td.money-cell .money-symbol {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-right: 2px;
}

/* ===== 3. 表头排序 ===== */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}
th.sortable:hover {
  color: var(--primary);
}
th.sortable .sort-indicator {
  display: inline-block;
  width: 14px;
  margin-left: 4px;
  font-size: 10px;
  color: var(--text-tertiary);
  vertical-align: middle;
  line-height: 1;
}
th.sortable.sort-asc .sort-indicator::after {
  content: '▲';
  color: var(--primary);
}
th.sortable.sort-desc .sort-indicator::after {
  content: '▼';
  color: var(--primary);
}
th.sortable:not(.sort-asc):not(.sort-desc) .sort-indicator::after {
  content: '⇅';
  opacity: 0.35;
}
/* 表头排版优化 */
.data-table thead th {
  letter-spacing: 0.5px;
  font-weight: 600;
  font-size: 12px;
}
.data-table td {
  padding-top: 6px;
  padding-bottom: 6px;
}

/* ===== 4. 快捷筛选标签 ===== */
.quick-filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.quick-filter-chip {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}
.quick-filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.quick-filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

/* ===== 5. 右键菜单 ===== */
.context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  padding: 6px;
  animation: scaleIn 0.12s ease-out;
  transform-origin: top left;
}
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease;
}
.context-menu-item:hover {
  background: var(--primary-bg);
  color: var(--primary);
}
.context-menu-item.danger {
  color: var(--danger);
}
.context-menu-item.danger:hover {
  background: var(--danger-bg, rgba(239, 68, 68, 0.1));
}
.context-menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 5px 0;
}
.context-menu-item .ctx-ico {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}

/* ===== 6. 回款进度条 ===== */
.pay-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}
.pay-progress {
  flex: 1;
  height: 7px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.pay-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.pay-progress-fill.pay-ok {
  background: linear-gradient(90deg, #10b981, #34d399);
}
.pay-progress-fill.pay-mid {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.pay-progress-fill.pay-low {
  background: linear-gradient(90deg, #ef4444, #f87171);
}
.pay-progress-text {
  font-size: 12px;
  font-weight: 600;
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pay-progress-text.t-ok { color: var(--success, #10b981); }
.pay-progress-text.t-mid { color: #f59e0b; }
.pay-progress-text.t-low { color: var(--danger, #ef4444); }

/* 回款健康度图标 */
.pay-health {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  margin-right: 6px;
  vertical-align: middle;
}
.pay-health.h-ok { background: rgba(16, 185, 129, 0.12); }
.pay-health.h-mid { background: rgba(245, 158, 11, 0.12); }
.pay-health.h-low { background: rgba(239, 68, 68, 0.12); }

/* 逾期徽章 */
.badge-overdue {
  background: var(--danger-bg, rgba(239, 68, 68, 0.12));
  color: var(--danger, #ef4444);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
  white-space: nowrap;
}

/* ===== 7. 操作列图标按钮 ===== */
.row-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.row-actions .btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.row-actions .btn-ghost {
  padding: 5px 9px;
  font-size: 12px;
}
.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* ===== 8. 卡片 hover 抬升 + 行入场动画 ===== */
.card-list-item {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card-list-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.data-table tbody tr {
  animation: rowIn 0.25s ease-out both;
}
@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 9. 按钮涟漪颜色跟随（使用当前按钮主色） ===== */
.ripple-btn {
  position: relative;
  overflow: hidden;
}
.ripple-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.25;
  transition: width 0.45s ease, height 0.45s ease, opacity 0.45s ease;
  pointer-events: none;
}
.ripple-btn:active::after {
  width: 220%;
  height: 220%;
  opacity: 0;
}

/* ===== 10. 输入框聚焦发光 ===== */
.form-input:focus,
.input:focus,
.textarea:focus,
select.form-input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-bg, rgba(99, 102, 241, 0.15)) !important;
  outline: none;
}

/* ===== 11. 暗色模式深化补充 ===== */
[data-theme="dark"] .data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}
[data-theme="dark"] .context-menu {
  background: #1a1a24;
  border-color: #2a2a3a;
}
[data-theme="dark"] .component-item:hover,
[data-theme="dark"] .list-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* ===== 12. 主题切换过渡（避免生硬跳变） ===== */
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease !important;
}

/* ===== 13. 空状态 SVG 插画增强 ===== */
.empty-state-illustration {
  width: 130px;
  height: 110px;
  margin: 0 auto 4px;
  opacity: 0.9;
}
.empty-state-illustration .es-circle {
  fill: var(--primary-bg, rgba(99, 102, 241, 0.12));
}
.empty-state-illustration .es-main {
  fill: var(--primary);
}
.empty-state-illustration .es-accent {
  fill: #f59e0b;
}
.empty-state-illustration .es-line {
  stroke: var(--text-tertiary);
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
}

/* ===== 14. 玻璃拟态延伸（桌面端侧边栏/顶栏） ===== */
@media (min-width: 768px) {
  .sidebar {
    background: color-mix(in srgb, var(--bg-card) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

/* ===== 15. 微渐变背景（主内容区） ===== */
.main .content {
  background:
    radial-gradient(ellipse at top right, rgba(99, 102, 241, 0.04), transparent 50%),
    radial-gradient(ellipse at bottom left, rgba(16, 185, 129, 0.03), transparent 50%);
}

/* ===== 16. 列显隐配置面板 ===== */
.column-settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 60;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 10px 12px;
  animation: scaleIn 0.15s ease-out;
}
.column-settings-panel .cs-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 2px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s ease;
}
.column-settings-panel .cs-item:hover {
  background: var(--bg-hover);
}
.column-settings-panel .cs-item input {
  accent-color: var(--primary);
}
.column-settings-panel .cs-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

/* ===== 17. 生命周期条 ===== */
.lifecycle-bar {
  display: flex;
  gap: 3px;
  margin-top: 10px;
}
.lifecycle-seg {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border-light);
  transition: background 0.3s ease;
}
.lifecycle-seg.done {
  background: var(--primary);
}
.lifecycle-seg.done.warn {
  background: var(--success, #10b981);
}

/* ===== 18. 数字滚动 ===== */
.stat-card-value,
.stat-value {
  font-variant-numeric: tabular-nums;
}

/* ===== 19. 汇总报表小计条 ===== */
.summary-row-highlight {
  background: var(--primary-bg) !important;
  font-weight: 600;
}

/* ===== 20. 筛选栏固定 + 吸顶 ===== */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-card, #fff);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 var(--border-light);
  margin-bottom: 12px !important;
}
[data-theme="dark"] .filter-bar {
  background: #141420;
}

/* ===== 21. 详情弹窗改善 ===== */
.modal-lg .modal-body {
  max-height: 70vh;
  overflow-y: auto;
}
/* ===== 22. 表单增强：必填红星 + 校验错误 ===== */
.label .req-star {
  color: var(--danger, #ef4444);
  margin-left: 2px;
}
.input.field-error,
.select.field-error,
.textarea.field-error {
  border-color: var(--danger, #ef4444) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}
.field-error-hint {
  color: var(--danger, #ef4444);
  font-size: 12px;
  margin-top: 4px;
  display: none;
}
.field-error-hint.show { display: block; }
/* 客户自动补全输入提示 */
#pf_clientName {
  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='%23999' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* ===== 23. 虚拟滚动表格（大数据量窗口化渲染） ===== */
.table-responsive.vt-active .data-table tbody tr {
  height: 36px;
}
.table-responsive.vt-active .data-table tbody tr td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-responsive.vt-active .data-table tbody tr td.money-cell,
.table-responsive.vt-active .data-table tbody tr td[style*="text-align:center;"] {
  overflow: visible;
}
.table-responsive.vt-active .data-table tbody tr.vt-spacer {
  /* 高度由 JS 内联 style 撑起，此处不得声明 height（含 !important 会压制内联样式） */
  box-shadow: none !important;
}
.table-responsive.vt-active .data-table tbody tr.vt-spacer td {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  white-space: normal;
}
.table-responsive.vt-active .data-table tbody tr.vt-spacer:hover td {
  background: transparent !important;
}
.table-responsive.vt-active .data-table tbody tr:hover td.vt-spacer {
  background: transparent !important;
}
