﻿/* =========================================================================
   CRM Admin · UX 增强层 (2026-09-25)
   不动 admin.css，独立文件保证零回归
   覆盖：实时通话 widget / 暗色 toggle / 通知中心 / 撤销 toast /
        skeleton / 面包屑 / 最后更新时间 / 快捷键帮助 / 角色隐藏 / a11y
   ========================================================================= */

/* ---------- 1. 实时通话监控 widget (P0-1) ---------- */
.live-calls-widget {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfeff 100%);
  border: 1px solid #86efac;
  border-radius: 14px;
  margin-bottom: 16px;
}
.live-calls-widget.empty { background: #f8fafc; border-color: #e2e8f0; }
.live-calls-widget .lcw-stat { text-align: center; }
.live-calls-widget .lcw-num {
  font-size: 28px; font-weight: 700; color: #15803d;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.live-calls-widget .lcw-num.warn { color: #d97706; }
.live-calls-widget .lcw-num.crit { color: #dc2626; animation: lcw-pulse 1.5s infinite; }
.live-calls-widget .lcw-label { font-size: 12px; color: #475569; margin-top: 4px; }
.live-calls-widget .lcw-list {
  grid-column: 1 / -1; max-height: 160px; overflow-y: auto;
  border-top: 1px solid rgba(0,0,0,0.06); padding-top: 10px; margin-top: 4px;
}
.live-calls-widget .lcw-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 6px; font-size: 13px;
}
.live-calls-widget .lcw-row:hover { background: rgba(255,255,255,0.6); }
.live-calls-widget .lcw-row .lcw-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; animation: lcw-pulse 1.5s infinite; flex-shrink: 0;
}
.live-calls-widget .lcw-row .lcw-phone { font-weight: 600; color: #1e293b; }
.live-calls-widget .lcw-row .lcw-dur {
  margin-left: auto; font-variant-numeric: tabular-nums;
  color: #64748b; font-size: 12px;
}
@keyframes lcw-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.4); }
}
body.dark-mode .live-calls-widget { background: linear-gradient(135deg,#14532d33,#0c4a6e33); border-color: #16a34a; }
body.dark-mode .live-calls-widget .lcw-num { color: #4ade80; }
body.dark-mode .live-calls-widget .lcw-row .lcw-phone { color: #e2e8f0; }

/* ---------- 2. 顶栏按钮 (P0-2 / P1-7) ---------- */
.ux-topbar-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 6px; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  color: #475569; font-size: 14px; transition: all 0.15s;
}
.ux-topbar-btn:hover { background: #f1f5f9; color: #1e293b; }
body.dark-mode .ux-topbar-btn { color: #94a3b8; }
body.dark-mode .ux-topbar-btn:hover { background: #1e293b; color: #e2e8f0; }

.ux-bell { position: relative; }
.ux-bell .badge {
  position: absolute; top: 0; right: 0;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: #ef4444; color: #fff; border-radius: 8px;
  font-size: 10px; font-weight: 600; line-height: 16px;
  text-align: center; display: none;
}
.ux-bell .badge.show { display: block; animation: lcw-pulse 2s infinite; }

/* ---------- 3. 通知中心抽屉 (P1-7) ---------- */
.notif-drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  z-index: 9998; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.notif-drawer-overlay.show { opacity: 1; pointer-events: auto; }
.notif-drawer {
  position: fixed; top: 0; right: -380px; width: 360px; height: 100vh;
  background: #fff; box-shadow: -4px 0 16px rgba(0,0,0,0.1);
  z-index: 9999; transition: right 0.25s;
  display: flex; flex-direction: column;
}
.notif-drawer.show { right: 0; }
.notif-drawer-header {
  padding: 16px 18px; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
}
.notif-drawer-header h3 { margin: 0; font-size: 16px; }
.notif-drawer-actions { display: flex; gap: 8px; }
.notif-drawer-actions button {
  font-size: 12px; padding: 4px 10px; border-radius: 4px;
  border: 1px solid #e2e8f0; background: #fff; cursor: pointer;
  color: #64748b;
}
.notif-drawer-actions button:hover { background: #f8fafc; color: #1e293b; }
.notif-drawer-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.notif-item {
  padding: 10px 18px; border-bottom: 1px solid #f1f5f9;
  display: flex; gap: 10px; align-items: flex-start;
  cursor: pointer; transition: background 0.15s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eff6ff; }
.notif-item.unread:hover { background: #dbeafe; }
.notif-item .notif-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px;
  background: #cbd5e1;
}
.notif-item.unread .notif-dot { background: #3b82f6; }
.notif-item .notif-body { flex: 1; min-width: 0; }
.notif-item .notif-msg { font-size: 13px; color: #1e293b; line-height: 1.5; }
.notif-item .notif-time { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.notif-empty { text-align: center; padding: 60px 20px; color: #94a3b8; font-size: 13px; }

body.dark-mode .notif-drawer { background: #0f172a; color: #e2e8f0; }
body.dark-mode .notif-drawer-header { border-bottom-color: #1e293b; }
body.dark-mode .notif-item { border-bottom-color: #1e293b; }
body.dark-mode .notif-item .notif-msg { color: #e2e8f0; }
body.dark-mode .notif-item:hover { background: #1e293b; }
body.dark-mode .notif-drawer-actions button { background: #1e293b; border-color: #334155; color: #94a3b8; }

/* ---------- 4. 撤销 toast 增强 (P2-16) ---------- */
.ux-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 12px 18px;
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  font-size: 13px; z-index: 10000; display: flex; align-items: center; gap: 12px;
  animation: toast-slide-up 0.25s ease-out;
}
.ux-toast button {
  background: transparent; color: #60a5fa; border: 1px solid #60a5fa;
  padding: 3px 10px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.ux-toast button:hover { background: #60a5fa; color: #fff; }
@keyframes toast-slide-up {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ---------- 5. Skeleton loading (P1-10) ---------- */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 6px;
  display: inline-block;
}
.skeleton.line { height: 14px; margin: 6px 0; }
.skeleton.card { height: 80px; width: 100%; }
.skeleton.circle { border-radius: 50%; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
body.dark-mode .skeleton {
  background: linear-gradient(90deg, #1e293b 0%, #334155 50%, #1e293b 100%);
  background-size: 200% 100%;
}

/* ---------- 6. 最后更新时间 (P0-4) ---------- */
.ux-last-updated {
  font-size: 11px; color: #94a3b8;
  display: inline-flex; align-items: center; gap: 4px;
}
.ux-last-updated .ux-spinner {
  width: 10px; height: 10px; border: 1.5px solid #cbd5e1;
  border-top-color: #3b82f6; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.ux-last-updated.loading .ux-spinner { display: inline-block; }
.ux-last-updated:not(.loading) .ux-spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 7. 面包屑增强 (P1-11) ---------- */
.admin-breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.admin-breadcrumb .crumb-sep { color: #cbd5e1; font-size: 12px; }
.admin-breadcrumb .crumb-text { color: #475569; font-size: 13px; }
body.dark-mode .admin-breadcrumb .crumb-text { color: #94a3b8; }

/* ---------- 8. 快捷键帮助 modal (P1-9) ---------- */
.shortcut-help {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 9999; display: none; align-items: center; justify-content: center;
}
.shortcut-help.show { display: flex; }
.shortcut-help-panel {
  background: #fff; border-radius: 14px; padding: 28px 32px;
  max-width: 480px; width: 90%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.shortcut-help-panel h2 { margin: 0 0 18px; font-size: 18px; }
.shortcut-help-panel table { width: 100%; border-collapse: collapse; }
.shortcut-help-panel td { padding: 8px 4px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.shortcut-help-panel td:first-child { width: 40%; }
.shortcut-help-panel kbd {
  background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 4px;
  padding: 2px 8px; font-family: ui-monospace, monospace; font-size: 12px;
  display: inline-block; margin: 1px;
}
.shortcut-help-panel .close-row { text-align: right; margin-top: 16px; }
.shortcut-help-panel button {
  padding: 6px 16px; border-radius: 6px; border: 1px solid #cbd5e1;
  background: #fff; cursor: pointer;
}
body.dark-mode .shortcut-help-panel { background: #0f172a; color: #e2e8f0; }
body.dark-mode .shortcut-help-panel td { border-bottom-color: #1e293b; }
body.dark-mode .shortcut-help-panel kbd { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark-mode .shortcut-help-panel button { background: #1e293b; border-color: #334155; color: #e2e8f0; }

/* ---------- 9. 角色隐藏 (P1-12) ---------- */
.ux-role-hidden { display: none !important; }

/* ---------- 10. a11y 焦点环 (P2-13) ---------- */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}
body.dark-mode button:focus-visible, body.dark-mode a:focus-visible,
body.dark-mode input:focus-visible, body.dark-mode select:focus-visible {
  outline-color: #60a5fa;
}

/* ---------- 11. 表格批量操作栏 (P1-8) ---------- */
.ux-bulk-bar {
  display: none; align-items: center; gap: 12px;
  padding: 10px 16px; margin-bottom: 12px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 10px; font-size: 13px;
}
.ux-bulk-bar.show { display: flex; }
.ux-bulk-bar .count { font-weight: 600; color: #1d4ed8; }
.ux-bulk-bar button {
  padding: 4px 12px; border-radius: 6px; border: 1px solid #93c5fd;
  background: #fff; color: #1d4ed8; cursor: pointer; font-size: 12px;
}
.ux-bulk-bar button:hover { background: #dbeafe; }
.ux-bulk-bar .cancel { margin-left: auto; color: #64748b; border-color: #cbd5e1; }

/* ---------- 12. 未保存提示 banner (P0-5) ---------- */
.ux-dirty-banner {
  position: fixed; bottom: 70px; right: 24px;
  background: #f59e0b; color: #fff; padding: 10px 16px;
  border-radius: 8px; font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(245,158,11,0.3);
  display: none; z-index: 9999; align-items: center; gap: 10px;
}
.ux-dirty-banner.show { display: flex; }
.ux-dirty-banner button {
  background: rgba(255,255,255,0.2); border: 0; color: #fff;
  padding: 3px 8px; border-radius: 4px; cursor: pointer; font-size: 12px;
}

/* ---------- 13. skeleton for stat cards ---------- */
.skeleton-stat { background: linear-gradient(135deg,#f1f5f9,#e2e8f0); }
body.dark-mode .skeleton-stat { background: linear-gradient(135deg,#1e293b,#334155); }

/* ---------- 14. 通知项类型色彩 ---------- */
.notif-item.success .notif-dot { background: #10b981; }
.notif-item.error .notif-dot { background: #ef4444; }
.notif-item.warn .notif-dot { background: #f59e0b; }

/* ---------- 15. mobile fine-tune ---------- */
@media (max-width: 768px) {
  .notif-drawer { width: 100vw; }
  .live-calls-widget { grid-template-columns: repeat(2, 1fr); }
}
