/* ==========================================================================
   InsAgGrid in SSO (replacement for DevExpress DxGrid / DxTreeList).

   .app-grid wraps an InsAgGrid and takes the page's grid class (for example
   .role-management-grid in RoleManagement.razor.css), which sets the height of
   the whole grid — toolbar and table — as it did on DxGrid. The table fills
   what the toolbar leaves.
   ========================================================================== */
.app-grid {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

/* Empty-state block over the empty grid body (was DxGrid EmptyDataAreaTemplate); the grid's own
   "no rows" text is blanked with NoRowsText=" ". */
.app-grid > .app-grid-empty-overlay {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-25%);
    pointer-events: none;
}

.app-grid > .ins-aggrid-root {
    flex: 1 1 auto;
    height: auto;
}

.app-grid .ins-ag-grid {
    flex: 1 1 auto;
    min-height: 0;
}

/* Page toolbar (search + page buttons) in the grid's leading toolbar slot. */
.app-grid-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}

.app-grid-toolbar .grid-toolbar-buttons {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}

/* ---------- Cell classes (Helpers/GridCellCss) -----------------------------
   The <code>, <strong>, text-muted and coloured text of the DxGrid cell
   templates; badges, chips and cell buttons are INS.AgGrid renderers. */
.ins-ag-grid .ag-cell.app-cell-code {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 87.5%;
    color: #e83e8c;
}

/* DxGrid TextAlignment="Center" (cells: CellClassField "app-cell-center"; header: HeaderClass) */
.ins-ag-grid .ag-cell.app-cell-center {
    text-align: center;
}

.ins-ag-grid .ag-header-cell.app-header-center .ag-header-cell-label {
    justify-content: center;
}

.ins-ag-grid .ag-cell.app-cell-strong {
    font-weight: 700;
}

.ins-ag-grid .ag-cell.app-cell-muted {
    color: var(--color-text-muted, #6c757d);
}

.ins-ag-grid .ag-cell.app-cell-success { color: var(--ins-ui-success-text, #17663f); }
.ins-ag-grid .ag-cell.app-cell-warning { color: var(--ins-ui-warning-text, #9a3f06); }
.ins-ag-grid .ag-cell.app-cell-danger { color: var(--ins-ui-danger-text, #8f120c); }
.ins-ag-grid .ag-cell.app-cell-primary { color: var(--ins-ui-primary, #194898); }

html[data-bs-theme='dark'] .ins-ag-grid .ag-cell.app-cell-code { color: #f472b6; }

/* Badge cell that reads as plain muted text (NavigationManagement "Public"). */
.ins-ag-grid .ins-ag-badge.app-badge-plain {
    padding: 0;
    background: transparent;
    color: var(--color-text-muted, #6c757d);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
}

/* ---------- Tree cells (TreeField: DxTreeList, DxGrid grouping) -------------
   INS.AgGrid renders arrow + label (+ "{Field}_sub" second line); the layout is
   the host's: the arrow in an 18px column, the second line under the label. */
.ins-ag-grid .ins-ag-tree-cell {
    display: inline-grid;
    grid-template-columns: 18px minmax(0, auto);
    align-items: center;
    max-width: 100%;
    vertical-align: middle;
}

.ins-ag-grid .ins-ag-tree-arrow {
    grid-row: 1 / span 2;
    align-self: center;
    color: var(--ins-ui-text-secondary, #344054);
    font-size: 16px;
    line-height: 1;
    text-align: center;
    cursor: pointer;
}

.ins-ag-grid .ins-ag-tree-label,
.ins-ag-grid .ins-ag-tree-sub {
    grid-column: 2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ins-ag-grid .ins-ag-tree-sub {
    color: var(--color-text-muted, #6c757d);
    font-size: 12px;
    line-height: 16px;
}

.ins-ag-grid .ag-cell:has(.ins-ag-tree-sub) {
    display: flex;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
    line-height: 18px;
}

.app-grid-count {
    white-space: nowrap;
}

/* ==========================================================================
   Usage Dashboard (/admin/usage-dashboard) — chiều cao theo trang.
   Đặt ở file GLOBAL thay vì .razor.css vì bundle isolated (INS.Frontend.bundle.scp.css)
   có URL cố định và được Cloudflare cache — không bust được sau deploy (dev 18/11).
   File này có ?v= trong index.html, bump khi sửa.
   ========================================================================== */
.usage-userstats-grid {
    height: clamp(14rem, calc(100vh - 36rem), 24rem);
}

.usage-never-grid {
    height: clamp(20rem, calc(100vh - 26rem), 44rem);
}

@media (max-width: 991.98px) {
    .usage-userstats-grid {
        height: 16rem;
    }

    .usage-never-grid {
        height: 28rem;
    }
}
