/* SyncCore — Kapella basic-table pattern (tables & data grids) */

/* —— Container (card + responsive scroll) —— */
.app-ds-table-container .app-ds-table-surface {
    border: 1px solid var(--app-ds-border);
    border-radius: var(--app-ds-radius-md);
    background: var(--app-ds-bg-surface);
    overflow: hidden;
}

/* Table inside AppCard — no extra inner frame (Kapella card + table) */
.app-ds-card .app-ds-table-surface {
    border: none;
    border-radius: 0;
    background: transparent;
}

.app-ds-table-container .app-ds-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* —— MudTable / MudDataGrid (default SyncCore table) —— */
.app-ds-data-table.mud-table-root,
.app-ds-table-container .mud-table-root,
.mud-data-grid.app-ds-data-grid .mud-table-root {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.app-ds-data-table .mud-table-container,
.app-ds-table-container .mud-table-container,
.mud-data-grid.app-ds-data-grid .mud-table-container {
    border-radius: 0;
}

/* Header — Kapella: subtle label, bottom border only */
.app-ds-data-table .mud-table-head .mud-table-cell,
.app-ds-table-container .mud-table-head .mud-table-cell,
.mud-data-grid.app-ds-data-grid .mud-table-head .mud-table-cell {
    background-color: var(--app-ds-table-header-bg) !important;
    color: var(--app-ds-table-header-text) !important;
    font-size: var(--app-ds-font-size-sm);
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    padding: var(--app-ds-table-cell-py) var(--app-ds-table-cell-px) !important;
    border-bottom: 1px solid var(--app-ds-table-border) !important;
    border-top: none !important;
    white-space: nowrap;
}

/* Body cells — no vertical borders */
.app-ds-data-table .mud-table-body .mud-table-cell,
.app-ds-table-container .mud-table-body .mud-table-cell,
.mud-data-grid.app-ds-data-grid .mud-table-body .mud-table-cell {
    color: var(--app-ds-text-secondary);
    font-size: var(--app-ds-font-size-base);
    padding: var(--app-ds-table-cell-py) var(--app-ds-table-cell-px) !important;
    border-bottom: 1px solid var(--app-ds-table-border) !important;
    border-right: none !important;
    vertical-align: middle;
}

.app-ds-data-table .mud-table-body .mud-table-row:last-child .mud-table-cell,
.app-ds-table-container .mud-table-body .mud-table-row:last-child .mud-table-cell,
.mud-data-grid.app-ds-data-grid .mud-table-body .mud-table-row:last-child .mud-table-cell {
    border-bottom: none !important;
}

/* Striped rows (Kapella .table-striped) */
.app-ds-data-table.mud-table-striped .mud-table-body .mud-table-row:nth-of-type(odd),
.app-ds-table-container .mud-table-striped .mud-table-body .mud-table-row:nth-of-type(odd),
.mud-data-grid.app-ds-data-grid.mud-table-striped .mud-table-body .mud-table-row:nth-of-type(odd) {
    background-color: var(--app-ds-table-row-striped);
}

.app-ds-data-table.mud-table-striped .mud-table-body .mud-table-row:nth-of-type(odd) .mud-table-cell,
.app-ds-table-container .mud-table-striped .mud-table-body .mud-table-row:nth-of-type(odd) .mud-table-cell {
    background-color: inherit;
}

/* Hover (Kapella .table-hover → #eaeaf1) */
.app-ds-data-table .mud-table-body .mud-table-row {
    transition: background-color var(--app-ds-transition);
}

.app-ds-data-table .mud-table-body .mud-table-row:hover,
.app-ds-table-container .mud-table-body .mud-table-row:hover,
.mud-data-grid.app-ds-data-grid .mud-table-body .mud-table-row:hover {
    background-color: var(--app-ds-table-row-hover) !important;
}

.app-ds-data-table .mud-table-body .mud-table-row:hover .mud-table-cell,
.app-ds-table-container .mud-table-body .mud-table-row:hover .mud-table-cell {
    background-color: inherit !important;
    color: var(--app-ds-text-primary);
}

/* Comfortable density (Kapella default, not cramped) */
.app-ds-data-table.mud-table-dense .mud-table-cell,
.app-ds-table-container .mud-table-dense .mud-table-cell {
    padding-top: 0.625rem !important;
    padding-bottom: 0.625rem !important;
}

/* Bordered variant (optional) */
.app-ds-data-table--bordered .mud-table-body .mud-table-cell,
.app-ds-data-table--bordered .mud-table-head .mud-table-cell {
    border-right: 1px solid var(--app-ds-table-border) !important;
}

.app-ds-data-table--bordered .mud-table-head .mud-table-cell:last-child,
.app-ds-data-table--bordered .mud-table-body .mud-table-cell:last-child {
    border-right: none !important;
}

/* Progress bars inside tables (Kapella striped table) */
.app-ds-table-container .mud-progress-linear,
.app-ds-data-table .mud-progress-linear {
    height: 6px;
    border-radius: var(--app-ds-radius-pill);
    background: var(--app-ds-bg-muted);
}

.app-ds-table-container .mud-progress-linear .mud-progress-linear-bar,
.app-ds-data-table .mud-progress-linear .mud-progress-linear-bar {
    border-radius: var(--app-ds-radius-pill);
}

/* Row-actions cell — always first column, compact, never wraps */
.app-table-actions-cell {
    white-space: nowrap;
    width: 1%;
    padding-right: 0 !important;
}

/* Avatar + user cell in tables */
.app-ds-table-user-cell {
    display: flex;
    align-items: center;
    gap: var(--app-ds-space-3);
}

.app-ds-table-user-cell .mud-avatar {
    width: 2.25rem;
    height: 2.25rem;
}

/* Trend indicators (Sale column style) */
.app-ds-trend--up {
    color: var(--app-ds-color-success);
    font-weight: 600;
}

.app-ds-trend--down {
    color: var(--app-ds-color-danger);
    font-weight: 600;
}

/* MudDataGrid chrome */
.mud-data-grid.app-ds-data-grid {
    border: 1px solid var(--app-ds-border);
    border-radius: var(--app-ds-radius-md);
    background: var(--app-ds-bg-surface);
    font-size: var(--app-ds-font-size-base);
}

.mud-data-grid.app-ds-data-grid .mud-data-grid-toolbar {
    border-bottom: 1px solid var(--app-ds-border-subtle);
    padding: var(--app-ds-space-3) var(--app-ds-space-4);
}

/* Pagination footer */
.app-ds-table-container .mud-table-pagination {
    border-top: 1px solid var(--app-ds-border-subtle);
    color: var(--app-ds-text-secondary);
    font-size: var(--app-ds-font-size-sm);
}

/* Expandable audit row detail panel */
.app-ds-table-detail-row .mud-table-cell {
    background-color: var(--app-ds-bg-muted) !important;
    border-bottom: 1px solid var(--app-ds-table-border) !important;
    padding-top: 0 !important;
}

.app-ds-table-detail-panel {
    background: var(--app-ds-bg-surface);
    border: 1px solid var(--app-ds-border-subtle);
    border-radius: var(--app-ds-radius-md);
}

.app-ds-code-block {
    margin: 0;
    padding: var(--app-ds-space-3);
    background: var(--app-ds-bg-muted);
    border: 1px solid var(--app-ds-border-subtle);
    border-radius: var(--app-ds-radius-sm);
    font-size: 0.82em;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}
