/* ========== Bases 表格可读性优化 ========== */
/* 适用：Bases 独立窗口 + 嵌入到笔记中的 Base */
/* 使用 Obsidian 主题变量，兼容深/浅色主题 */

/* ---- 作用域：Bases 独立窗口（data-type="bases"）---- */
.workspace-leaf-content[data-type="bases"],

/* ---- 作用域：嵌入的 Base ---- */
.bases-embed,
.block-language-base {

  /* 使用 Obsidian 内置表格变量，覆盖主题对 Bases 的干扰 */
  --table-border-width: 1px;
  --table-border-color: var(--background-modifier-border);
  --table-header-background: var(--background-modifier-border);
  --table-header-background-hover: var(--background-modifier-hover);
  --table-header-color: var(--text-normal);
  --table-row-alt-background: var(--background-secondary);
  --table-row-alt-background-hover: var(--background-modifier-hover);
  --table-row-background-hover: var(--background-modifier-hover);
}

/* ---- 表格视图专用（Table View）---- */
.workspace-leaf-content[data-type="bases"] .bases-view[data-view-type="table"],
.bases-embed .bases-view[data-view-type="table"],
.block-language-base .bases-view[data-view-type="table"] {
  --table-row-alt-background: var(--background-secondary);
}

/* ---- 直接作用于 Bases 容器内的 table ---- */
.workspace-leaf-content[data-type="bases"] table,
.bases-embed table,
.block-language-base table {
  border-collapse: collapse;
  border: 1px solid var(--background-modifier-border);
}

.workspace-leaf-content[data-type="bases"] thead,
.bases-embed thead,
.block-language-base thead {
  background-color: var(--table-header-background) !important;
  border-bottom: 2px solid var(--background-modifier-border-focus);
}

.workspace-leaf-content[data-type="bases"] thead th,
.bases-embed thead th,
.block-language-base thead th {
  font-weight: 600;
  padding: 8px 12px !important;
  color: var(--table-header-color);
  text-align: left;
  border-right: 1px solid var(--background-modifier-border);
}

.workspace-leaf-content[data-type="bases"] thead th:last-child,
.bases-embed thead th:last-child,
.block-language-base thead th:last-child {
  border-right: none;
}

/* 斑马纹 */
.workspace-leaf-content[data-type="bases"] tbody tr:nth-child(even),
.bases-embed tbody tr:nth-child(even),
.block-language-base tbody tr:nth-child(even) {
  background-color: var(--table-row-alt-background) !important;
}

/* 悬停高亮 */
.workspace-leaf-content[data-type="bases"] tbody tr:hover td,
.bases-embed tbody tr:hover td,
.block-language-base tbody tr:hover td,
.workspace-leaf-content[data-type="bases"] tbody tr:hover td a,
.bases-embed tbody tr:hover td a,
.block-language-base tbody tr:hover td a {
  background-color: var(--table-row-background-hover) !important;
}

.workspace-leaf-content[data-type="bases"] tbody td,
.bases-embed tbody td,
.block-language-base tbody td {
  padding: 6px 12px !important;
  border-right: 1px solid var(--background-modifier-border);
  border-bottom: 1px solid var(--background-modifier-border);
}

.workspace-leaf-content[data-type="bases"] tbody td:last-child,
.bases-embed tbody td:last-child,
.block-language-base tbody td:last-child {
  border-right: none;
}
