/* ==========================================
   basic-data.css — 基础资料工作区
   结构对齐合同管理：紧凑搜索栏 + 左树 + 主面板 + 底部
   ========================================== */

/* ===== 页面骨架 ===== */
.bd-page {
    height: calc(100vh - 72px);
    min-height: 560px;
    display: flex;
    flex-direction: column;
}

.bd-page-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 10px 10px;
    overflow: hidden;
}

/* ===== 搜索栏 ===== */
.bd-searchbar {
    flex: 0 0 auto;
}

.bd-searchbar .ctr-search-input {
    width: 250px;
    height: 30px;
    min-height: 30px;
}

.bd-searchbar .bd-select {
    height: 30px;
    min-height: 30px;
    min-width: 118px;
    padding: 0 30px 0 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 13px;
    font-family: var(--font-family);
}

.bd-searchbar .btn {
    height: 30px;
    min-height: 30px;
    padding: 0 9px;
}

.bd-searchbar .prt-incomplete-filter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--color-text-secondary);
    white-space: nowrap;
    cursor: pointer;
}

/* ===== 左树 + 主面板 ===== */
.bd-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 8px;
}

.bd-tree {
    height: 100%;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

/* ===== 左树层级：分组标题 > 「全部」 > 一级分类 > 子分类 ===== */
.ctr-filter-tree .ctr-tree-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: 0.2px;
}

.ctr-filter-tree .ctr-tree-title-main i {
    color: var(--color-primary);
}

.ctr-filter-tree .ctr-tree-node {
    font-size: 13px;
    font-weight: 400;
    color: var(--color-text-secondary);
}

.ctr-filter-tree .ctr-tree-node.is-all {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.ctr-filter-tree .ctr-tree-node.ctr-depth-1 {
    font-weight: 500;
    color: var(--color-text);
}

.ctr-filter-tree .ctr-tree-node.ctr-depth-2 {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--color-text-secondary);
}

.ctr-filter-tree .ctr-tree-node.ctr-depth-3,
.ctr-filter-tree .ctr-tree-node.ctr-depth-4,
.ctr-filter-tree .ctr-tree-node.ctr-depth-5 {
    font-size: 12px;
    font-weight: 400;
    color: var(--color-text-tertiary);
}

.ctr-filter-tree .ctr-tree-node.active {
    font-weight: 600;
    color: var(--color-primary);
}

.ctr-filter-tree .dict-row-inactive .ctr-tree-label {
    text-decoration: line-through;
    opacity: 0.65;
}

.ctr-filter-tree .ctr-tree-node:focus-visible,
.ctr-filter-tree .ctr-tree-title:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    border-radius: 6px;
}

.cat-row:focus-within .cat-actions {
    opacity: 1;
}

.bd-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-card);
    overflow: hidden;
}

.bd-panel-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 10px;
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-card);
}

.bd-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.bd-summary {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

.bd-hint {
    margin: 0;
    padding: 6px 10px 0;
    font-size: 12px;
    color: var(--color-text-tertiary);
}

.bd-table-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

/* ===== 紧凑表格 ===== */
.bd-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.bd-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    height: 36px;
    padding: 4px 10px;
    background: var(--color-bg);
    color: var(--color-text-tertiary);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--color-border);
}

.bd-table tbody td {
    height: 38px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--color-border-light);
    white-space: nowrap;
    vertical-align: middle;
}

.bd-table tbody tr:last-child td {
    border-bottom: none;
}

.bd-table tbody tr:hover {
    background: var(--color-table-hover);
}

.bd-table .prt-row-inactive .prt-name {
    color: var(--color-text-tertiary);
    text-decoration: line-through;
}

.bd-table .text-end {
    text-align: right;
}

.bd-table .bd-ellipsis {
    display: inline-block;
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.bd-table .prt-name.bd-ellipsis {
    max-width: 220px;
}

.bd-table .prt-addr.bd-ellipsis {
    max-width: 160px;
}

.bd-table .btn-sm {
    height: 24px;
    min-height: 24px;
    padding: 0 7px;
    font-size: 12px;
    line-height: 22px;
}

.bd-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

/* ===== 底部合计 / 分页 ===== */
.bd-main .prt-pagination,
.bd-main .gds-pagination {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 10px;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-card);
}

.bd-main .page-info {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

.bd-main .page-btns {
    display: flex;
    gap: 4px;
}

.bd-main .page-btns button {
    min-width: 26px;
    height: 26px;
    padding: 0 7px;
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    background: var(--color-card);
    color: var(--color-text-secondary);
    font-size: 12px;
    cursor: pointer;
}

.bd-main .page-btns button:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.bd-main .page-btns button.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.bd-main .page-btns button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== 数据字典左侧类型导航 ===== */
.bd-dict-types {
    padding: 4px;
}

.bd-dict-types .ctr-tree-group {
    margin: 0;
    padding: 2px 0;
    border-top: 1px solid var(--color-border-light);
}

.bd-dict-types .ctr-tree-group:first-child {
    border-top: none;
}

.bd-dict-types .dict-type-tab {
    display: block;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 400;
    font-family: var(--font-family);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.bd-dict-types .dict-type-tab:hover {
    background: var(--color-table-hover);
}

.bd-dict-types .dict-type-tab.active {
    background: var(--color-primary-soft, rgba(0, 122, 255, 0.12));
    color: var(--color-primary);
    font-weight: 600;
}

/* 数据字典内容区沿用分类树样式，但去掉外层重复滚动 */
.bd-main .cat-tree {
    padding: 4px 6px 8px;
}

.bd-dict-types .ctr-tree-title {
    position: static;
    cursor: default;
    padding: 7px 10px 4px;
}

.bd-main .dict-table-wrap {
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
}

.bd-main .dict-table {
    min-width: 480px;
}

.bd-main .dict-table th,
.bd-main .dict-table td {
    height: 38px;
    padding: 6px 10px;
    font-size: 13px;
}

.bd-main .dict-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--color-bg);
}

/* ===== 响应式 ===== */
@media (max-width: 991.98px) {
    .bd-page {
        height: auto;
        min-height: 0;
    }

    .bd-page-body {
        overflow: visible;
    }

    .bd-layout {
        grid-template-columns: 1fr;
    }

    .bd-tree {
        height: auto;
        max-height: 180px;
    }

    .bd-table-scroll {
        max-height: 56vh;
    }
}

/* ===== 暗色 ===== */
[data-theme="dark"] .bd-dict-types .dict-type-tab.active {
    background: rgba(10, 132, 255, 0.22);
}
