/* MsTreeGrid Styles */
.mstreegrid-container {
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
    border: 1px solid var(--msgrid-border-color, #dee2e6);
    background-color: #ffffff;
    font-size: var(--msgrid-font-size, 13px);
    width: 100%;
}

/* Tự động ôm sát nội dung khi ít dòng để triệt tiêu khoảng trắng thừa */
.mstreegrid-container.mstreegrid-autofit {
    height: auto !important;
}

.mstreegrid-container.mstreegrid-autofit .mstreegrid-content {
    flex: 0 1 auto !important;
}

/* Khung cuộn nội dung */
.mstreegrid-content {
    flex: 1 1 0px !important;
    min-height: 0 !important;
    width: 100%;
    overflow-y: auto !important;
    overflow-x: auto !important;
    position: relative;
    outline: none;
    -webkit-overflow-scrolling: touch;
}

/* Bảng */
.mstreegrid-table {
    table-layout: fixed;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0 !important;
    background-color: #ffffff;
}

.mstreegrid-table thead tr:not(.msgrid-filter-tr):not(.mstreegrid-filter-tr) > th:not(.msgrid-filter-th),
.mstreegrid-table th:not(.msgrid-filter-th) {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--msgrid-header-bg, #00676b);
    color: var(--msgrid-header-color, #ffffff);
    padding: 0 4px !important;
    height: 36px;
    min-height: 36px;
    box-sizing: border-box;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid #004d50;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    user-select: none;
    cursor: pointer;
    vertical-align: middle;
}

.mstreegrid-table td {
    padding: 5px 8px !important;
    border-bottom: 1px solid #dee2e6;
    border-right: 1px solid #f0f0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

/* GridLines: Both */
.mstreegrid-gridlines-both td,
.mstreegrid-gridlines-both th {
    border-right: 1px solid #dee2e6 !important;
    border-bottom: 1px solid #dee2e6 !important;
}

/* GridLines: Vertical */
.mstreegrid-gridlines-vertical td {
    border-bottom: none !important;
    border-right: 1px solid #dee2e6 !important;
}

/* GridLines: None */
.mstreegrid-gridlines-none td,
.mstreegrid-gridlines-none th {
    border: none !important;
}

/* Text wrap */
.mstreegrid-textwrap .mstreegrid-table td {
    white-space: normal !important;
    word-break: break-word;
}

/* Hover & Selected Row */
.mstreegrid-row:hover td {
    background-color: var(--msgrid-hover-bg, #eaf3f3);
}

.mstreegrid-row.mstreegrid-row-selected td {
    background-color: var(--msgrid-selected-bg, #FFF6DE) !important;
    color: var(--msgrid-selected-color, #000000);
}

/* Nhóm gốc đầu tiên (Root / Level 0) */
.mstreegrid-row-level-0 td {
    color: #092328 !important;
    font-weight: 600;
}

.mstreegrid-row-level-0 .mstreegrid-expander-btn i {
    color: #092328 !important;
    font-weight: bold;
}

.mstreegrid-row-level-0 .mstreegrid-treecell-content,
.mstreegrid-row-level-0 .mstreegrid-treecell-content span,
.mstreegrid-row-level-0 .mstreegrid-treecell-content strong {
    color: #092328 !important;
}

/* Tree Cell & Expander */
.mstreegrid-treecell {
    display: inline-flex;
    align-items: center;
    width: 100%;
    overflow: hidden;
}

.mstreegrid-expander-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 3px;
    margin-right: 4px;
    padding: 0;
    transition: background-color 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.mstreegrid-expander-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

.mstreegrid-expander-btn i.ph-caret-down {
    color: #00676b;
    font-size: 14px;
    font-weight: bold;
}

.mstreegrid-expander-btn i.ph-caret-right {
    color: #6c757d;
    font-size: 14px;
}

.mstreegrid-expander-spacer {
    display: inline-block;
    width: 18px;
    min-width: 18px;
    height: 18px;
    margin-right: 4px;
}

.mstreegrid-treecell-content {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nút lệnh */
.mstreegrid-commands button.ms-command-btn {
    padding: 2px 6px;
    font-size: 12px;
    line-height: 1.2;
    border-radius: 3px;
}

/* Checkbox */
.mstreegrid-checkbox {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #00676b;
}

/* Footer / Pager */
.mstreegrid-pager {
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

/* Filter Row (Đồng bộ màu nền bằng màu row hover) */
.mstreegrid-table thead tr.msgrid-filter-tr > th,
.mstreegrid-table thead tr.mstreegrid-filter-tr > th,
.mstreegrid-table thead tr > th.msgrid-filter-th,
.mstreegrid-table th.msgrid-filter-th,
.mstreegrid-filter-tr th,
.mstreegrid-filter-tr td,
.mstreegrid-filter-th,
.mstreegrid-thead .msgrid-filter-tr th {
    position: sticky;
    top: 36px;
    z-index: 9;
    background-color: var(--msgrid-hover-bg, #eaf3f3) !important;
    color: #1f2937 !important;
    border-bottom: 1px solid var(--msgrid-border-color, #dee2e6) !important;
    border-right: 1px solid var(--msgrid-border-color, #dee2e6) !important;
}
