/* 全局字体与颜色变量 */
:root {
  --color-basic-bg: #e6f4ea;
  --color-basic-text: #1b5e20;
  --color-manual-bg: #f5e7ff;
  --color-manual-text: #7c3aed;
  --color-standard-bg: #fff3e0;
  --color-standard-text: #e65100;
  --color-enterprise-bg: #e3f2fd;
  --color-enterprise-text: #0d47a1;

  --color-border-soft: rgba(15, 23, 42, 0.08);
  --color-border-strong: rgba(15, 23, 42, 0.18);
  --color-surface: #ffffff;
  --color-surface-soft: #f8fafc;
}

/* 防止页面加载时的布局跳动 */
html {
  /* 预先分配滚动条空间 */
  overflow-y: scroll;
}

/* 确保body有最小高度 */
body {
  min-height: 100vh;
}

/* 为关键容器预先分配空间 */
.version-switcher-wrapper {
  min-height: 60px;
}

body {
  font-family: "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.matrix-shell {
  border-radius: 1rem;
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), transparent 55%),
    radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.08), transparent 55%);
  padding: 1.25rem;
  border: 1px solid var(--color-border-soft);
}

.matrix-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.matrix-scroll::-webkit-scrollbar {
  height: 8px;
}

.matrix-scroll::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.65);
  border-radius: 999px;
}

.matrix-scroll::-webkit-scrollbar-track {
  background-color: transparent;
}


.matrix-grid {
  display: grid;
  grid-auto-rows: minmax(3rem, auto);
  border-radius: 0.75rem;
  background: var(--color-surface);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--color-border-strong);
}

.matrix-header-cell,
.matrix-row-header {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--color-border-soft);
  border-right: 1px solid var(--color-border-soft);
  font-size: 0.82rem;
}

.matrix-header-cell:last-child,
.matrix-row-header:last-child,
.matrix-cell:last-child {
  border-right: none;
}

.matrix-header-cell {
  background: linear-gradient(to bottom, #f8fafc, #eef2ff);
  font-weight: 600;
  color: #0f172a;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
}

.matrix-header-sticky {
  position: sticky;
  top: 0;
  z-index: 10;
}

.matrix-row-header {
  position: sticky;
  left: 0;
  z-index: 15;
  background: #f9fafb;
  font-weight: 500;
  color: #111827;
}

.matrix-row-header strong {
  font-weight: 600;
}

/* 屏幕阅读器可见但视觉隐藏 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 列内合并块背景 */
.matrix-block {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.18rem 0.22rem;
  border-radius: 0.75rem;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
  overflow: hidden;
  z-index: 1;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.matrix-block-label {
  font-weight: 600;
  font-size: 0.82rem;
  position: relative;
  z-index: 1;
}

.matrix-block::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  opacity: 0;
  transition: opacity 150ms ease;
}

.matrix-block.dimmed {
  filter: saturate(0.85) brightness(0.96);
}

.matrix-block.dimmed::before {
  background: rgba(248, 250, 252, 0.88);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.28);
  opacity: 1;
}

.matrix-block.focus-block {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.32);
  filter: saturate(1.08) brightness(1.03);
}

.matrix-cell {
  padding: 0.75rem 0.9rem;
  border-right: 1px solid var(--color-border-soft);
  font-size: 0.82rem;
  text-align: center;
  cursor: default;
  position: relative;
  background: transparent;
  z-index: 2;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease, filter 150ms ease;
}

.matrix-cell.group-divider {
  border-bottom: 1px solid var(--color-border-soft);
}

.matrix-cell span {
  font-weight: 600;
}

.level-basic {
  background: radial-gradient(circle at top left, rgba(34, 197, 94, 0.16), transparent 55%),
    var(--color-basic-bg);
  color: var(--color-basic-text);
}

.level-manual {
  background: radial-gradient(circle at top left, rgba(168, 85, 247, 0.08), transparent 55%),
    var(--color-manual-bg);
  color: var(--color-manual-text);
}

.level-standard {
  background: radial-gradient(circle at top left, rgba(245, 158, 11, 0.18), transparent 55%),
    var(--color-standard-bg);
  color: var(--color-standard-text);
}

.level-enterprise {
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.22), transparent 55%),
    var(--color-enterprise-bg);
  color: var(--color-enterprise-text);
}

.matrix-cell:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
  z-index: 5;
}

.matrix-cell.issue-focus-ring {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.9), 0 12px 26px rgba(15, 23, 42, 0.32);
  z-index: 4;
}

.matrix-cell.intersection-ring {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.96), 0 16px 34px rgba(30, 64, 175, 0.55);
  z-index: 5;
}

.matrix-row-header.dimmed,
.matrix-header-cell.dimmed {
  opacity: 0.4;
}

.matrix-cell.focus-cell {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.92), 0 12px 25px rgba(15, 23, 42, 0.28);
}

.matrix-cell.focus-intersection {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.95), 0 16px 32px rgba(30, 64, 175, 0.45);
}

/* tooltip */
.matrix-tooltip {
  position: fixed;
  z-index: 50;
  max-width: 19rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.96);
  color: #e5e7eb;
  font-size: 0.78rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.6);
  pointer-events: none;
}

.matrix-tooltip h4 {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.matrix-tooltip p {
  opacity: 0.9;
}

.matrix-tooltip small {
  display: block;
  margin-top: 0.28rem;
  opacity: 0.78;
}

.enterprise-tooltip {
  position: absolute;
  z-index: 55;
  min-width: 12rem;
  max-width: 20rem;
  padding: 0.6rem 0.8rem;
  border-radius: 0.5rem;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 0.75rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.cursor-pointer {
  cursor: pointer;
}

.matrix-tooltip[data-level="basic"] {
  border: 1px solid rgba(34, 197, 94, 0.85);
}

.matrix-tooltip[data-level="manual"] {
  border: 1px solid rgba(168, 85, 247, 0.85);
}

.matrix-tooltip[data-level="standard"] {
  border: 1px solid rgba(245, 158, 11, 0.9);
}

.matrix-tooltip[data-level="enterprise"] {
  border: 1px solid rgba(59, 130, 246, 0.95);
}

/* 小徽标 */
.badge-pill {
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 500;
}

.badge-basic {
  border: 1px solid rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.08);
  color: #15803d;
}

.badge-standard {
  border: 1px solid rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.08);
  color: #c2410c;
}

.badge-enterprise {
  border: 1px solid rgba(59, 130, 246, 0.6);
  background: rgba(59, 130, 246, 0.08);
  color: #1d4ed8;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--color-border-soft);
  box-shadow: 0 10px 22px rgba(148, 163, 184, 0.32);
}

.legend-swatch {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 0.45rem;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.25);
}

.legend-swatch.basic {
  background: var(--color-basic-bg);
}

.legend-swatch.manual {
  background: var(--color-manual-bg);
}

.legend-swatch.standard {
  background: var(--color-standard-bg);
}

.legend-swatch.enterprise {
  background: var(--color-enterprise-bg);
}

.legend-label {
  font-size: 0.78rem;
}

.legend-label strong {
  font-weight: 600;
}

/* 轻量 loading 骨架 */
.matrix-loading {
  border-radius: 0.75rem;
  border: 1px dashed var(--color-border-soft);
  padding: 1.5rem 1.75rem;
  background: repeating-linear-gradient(
      135deg,
      #f9fafb,
      #f9fafb 8px,
      #f3f4f6 8px,
      #f3f4f6 16px
    );
}

.matrix-loading-bar {
  height: 0.6rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #e5e7eb, #d1d5db, #e5e7eb);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -120% 0;
  }
  100% {
    background-position: 120% 0;
  }
}

/* 版本切换按钮样式 */
.version-switcher-wrapper {
  margin-bottom: 1rem;
}

.version-switcher {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.06);
  gap: 4px;
}

.version-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: none;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: all 200ms ease;
  font-family: "Noto Sans SC", system-ui, sans-serif;
}

.version-btn:hover {
  background: rgba(15, 23, 42, 0.04);
}

.version-btn.active {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.version-btn[data-version="personal"].active {
  background: linear-gradient(135deg, #9333ea, #a855f7);
  color: white;
}

.version-btn[data-version="enterprise"].active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
}

.version-btn[data-version="legacy"].active {
  background: linear-gradient(135deg, #64748b, #94a3b8);
  color: white;
}

.version-btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 24px !important;
  min-height: 24px !important;
  max-height: 24px !important;
  overflow: hidden;
}

.version-logo {
  display: block !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  width: 24px !important;
  height: 24px !important;
  max-width: 24px !important;
  max-height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  border-radius: 4px;
  object-fit: contain !important;
  object-position: center !important;
  line-height: 24px !important;
  vertical-align: middle !important;
}

/* 防止所有图片在加载时导致布局跳动 */
img {
  content-visibility: auto;
}

/* 给容器设置固定尺寸防止布局跳动 */
.version-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: none;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: all 200ms ease;
  font-family: "Noto Sans SC", system-ui, sans-serif;
  min-height: 44px; /* 确保按钮高度固定 */
}

.version-logo-grey {
  filter: grayscale(100%);
  opacity: 0.7;
}

.version-text {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.version-btn.active .version-text {
  font-weight: 600;
}
