/* ============================================
   CST Design System - Tabelas
   Estilos unificados para tabelas do modulo CST
   ============================================ */

/* ===== CONTAINER DA TABELA ===== */
.cst-tabela-container {
    border-radius: var(--cst-radius-lg);
    overflow: hidden;
}

.cst-table-scroll-wrapper {
    max-height: 65vh;
    overflow: auto;
    position: relative;
}

/* ===== TABELA BASE ===== */
.cst-table-enhanced {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    font-family: var(--cst-font-family);
}

/* ===== HEADER DA TABELA ===== */
.cst-table-enhanced thead {
    position: sticky;
    top: 0;
    z-index: 3;
}

.cst-table-enhanced thead tr {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%);
}

.cst-table-enhanced th {
    padding: 10px 8px;
    font-weight: var(--cst-font-weight-semibold);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--cst-white);
    white-space: nowrap;
    border-bottom: 2px solid var(--cst-primary-dark);
}

/* ===== FOOTER DA TABELA ===== */
.cst-table-enhanced tfoot {
    position: sticky;
    bottom: 0;
    z-index: 3;
}

.cst-table-enhanced .cst-total-row-footer,
.cst-table-enhanced .total-row-footer {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%);
}

.cst-table-enhanced .cst-total-row-footer td,
.cst-table-enhanced .total-row-footer td {
    padding: 12px 8px;
    font-weight: var(--cst-font-weight-bold) !important;
    color: var(--cst-white);
    border-top: 2px solid var(--cst-primary-dark);
}

/* ===== CELULAS DO CORPO ===== */
.cst-table-enhanced td {
    padding: 8px 8px;
    border-bottom: 1px solid var(--cst-neutral-200);
    vertical-align: middle;
}

/* ===== COLUNAS STICKY ===== */

/* Coluna sticky esquerda (primeira coluna - CC, Fazenda, etc) - CORPO da tabela */
.cst-col-sticky-left,
.col-sticky-left {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 200px;
    max-width: 280px;
}

/* Background padrao para celulas do corpo (td) */
td.cst-col-sticky-left,
td.col-sticky-left {
    background: var(--cst-surface);
}

/* HEADER da tabela - coluna sticky esquerda com cor primaria */
.cst-table-enhanced thead .cst-col-sticky-left,
.cst-table-enhanced thead .col-sticky-left,
thead th.col-sticky-left,
thead th.cst-col-sticky-left {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%) !important;
    z-index: 4;
    color: var(--cst-white) !important;
}

/* Garante visibilidade do texto no header da coluna sticky - alta especificidade */
.cst-table-enhanced thead th.col-sticky-left,
.cst-table-enhanced thead th.cst-col-sticky-left,
.custos-table thead th.col-sticky-left,
.custos-cc-table-enhanced thead th.col-sticky-left,
.custos-fazenda-table-enhanced thead th.col-sticky-left,
.custos-fazenda-table-enhanced thead th.col-fazenda,
table thead tr th.col-sticky-left,
table thead tr th.col-fazenda {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%) !important;
    color: var(--cst-white) !important;
    font-weight: var(--cst-font-weight-semibold);
    text-transform: uppercase;
}

.cst-table-enhanced .cst-total-row-footer .cst-col-sticky-left,
.cst-table-enhanced .total-row-footer .col-sticky-left {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%);
    z-index: 4;
}

/* Coluna sticky direita (Total) */
.cst-col-sticky-right,
.col-sticky-right {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--cst-success-bg);
    min-width: 90px;
}

.cst-table-enhanced thead .cst-col-sticky-right,
.cst-table-enhanced thead .col-sticky-right {
    background: var(--cst-success-dark);
    z-index: 4;
}

.cst-table-enhanced .cst-total-row-footer .cst-col-sticky-right,
.cst-table-enhanced .total-row-footer .col-sticky-right {
    background: var(--cst-success-darker);
    z-index: 4;
}

/* ===== LARGURAS DAS COLUNAS ===== */
.cst-col-descricao,
.col-cc,
.col-fazenda {
    text-overflow: ellipsis;
    overflow: hidden;
}

.cst-col-value,
.col-value {
    min-width: 75px;
}

.cst-col-total,
.col-total {
    font-weight: var(--cst-font-weight-semibold);
    min-width: 100px;
}

/* ===== ZEBRA STRIPING E DESTAQUE DE LINHAS ===== */

/* Linhas pares (padrao) */
.cst-table-enhanced tbody tr {
    transition: background-color var(--cst-transition-fast);
}

/* Linhas impares */
.cst-table-enhanced tbody tr.cst-row-odd,
.cst-table-enhanced tbody tr.row-odd {
    background-color: var(--cst-neutral-50);
}

.cst-table-enhanced tbody tr.cst-row-odd .cst-col-sticky-left,
.cst-table-enhanced tbody tr.row-odd .col-sticky-left {
    background-color: var(--cst-neutral-50);
}

/* Hover */
.cst-table-enhanced tbody tr:hover {
    background-color: var(--cst-primary-bg) !important;
    box-shadow: inset 4px 0 0 var(--cst-primary);
}

.cst-table-enhanced tbody tr:hover .cst-col-sticky-left,
.cst-table-enhanced tbody tr:hover .col-sticky-left {
    background-color: var(--cst-primary-bg) !important;
}

/* ===== LINHAS DE GRUPO/SUBTOTAL ===== */
.cst-table-enhanced tbody tr.cst-row-grupo,
.cst-table-enhanced tbody tr.row-grupo {
    background-color: var(--cst-neutral-150) !important;
    font-weight: var(--cst-font-weight-semibold);
}

.cst-table-enhanced tbody tr.cst-row-grupo .cst-col-sticky-left,
.cst-table-enhanced tbody tr.row-grupo .col-sticky-left {
    background-color: var(--cst-neutral-150) !important;
}

/* Linhas de total parcial */
.cst-table-enhanced tbody tr.cst-row-total,
.cst-table-enhanced tbody tr.row-total {
    background-color: var(--cst-neutral-200) !important;
    font-weight: var(--cst-font-weight-bold);
}

.cst-table-enhanced tbody tr.cst-row-total .cst-col-sticky-left,
.cst-table-enhanced tbody tr.row-total .col-sticky-left {
    background-color: var(--cst-neutral-200) !important;
}

/* ===== FORMATACAO DE TEXTO ===== */
.cst-text-right,
.text-right {
    text-align: right;
}

.cst-text-center,
.text-center {
    text-align: center;
}

.cst-font-weight-bold,
.font-weight-bold {
    font-weight: var(--cst-font-weight-bold) !important;
}

/* ===== SOMBRA PARA INDICAR SCROLL ===== */
.cst-col-sticky-left::after,
.col-sticky-left::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    bottom: 0;
    width: 8px;
    background: linear-gradient(to right, rgba(0,0,0,0.08), transparent);
    pointer-events: none;
}

.cst-col-sticky-right::before,
.col-sticky-right::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    bottom: 0;
    width: 8px;
    background: linear-gradient(to left, rgba(0,0,0,0.08), transparent);
    pointer-events: none;
}

/* ===== FORMATACAO NUMERICA ===== */
.cst-table-enhanced td:not(.cst-col-descricao):not(.col-cc):not(.col-fazenda) {
    font-variant-numeric: tabular-nums;
}

/* ===== GRUPOS DE COLUNAS (DESTAQUE VISUAL) ===== */
.cst-col-group-estoque,
.col-group-estoque {
    /* Coluna de estoque - pode receber cor de fundo sutil se necessario */
}

.cst-col-group-financeiro,
.col-group-financeiro {
    /* Coluna financeira - pode receber cor de fundo sutil se necessario */
}

/* ===== ALIASES PARA COMPATIBILIDADE ===== */
/* Esses aliases garantem compatibilidade com os nomes de classe existentes */

.custos-table,
.custos-cc-table-enhanced,
.custos-fazenda-table-enhanced {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    font-family: var(--cst-font-family);
}

.custos-table thead,
.custos-cc-table-enhanced thead,
.custos-fazenda-table-enhanced thead {
    position: sticky;
    top: 0;
    z-index: 3;
}

.custos-table thead tr,
.custos-cc-table-enhanced thead tr,
.custos-fazenda-table-enhanced thead tr {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%);
}

.custos-table th,
.custos-cc-table-enhanced th,
.custos-fazenda-table-enhanced th {
    padding: 10px 8px;
    font-weight: var(--cst-font-weight-semibold);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--cst-white);
    white-space: nowrap;
    border-bottom: 2px solid var(--cst-primary-dark);
}

/* Coluna sticky esquerda no header - garante background e texto visiveis */
.custos-table thead th.col-sticky-left,
.custos-cc-table-enhanced thead th.col-sticky-left,
.custos-fazenda-table-enhanced thead th.col-sticky-left,
.custos-fazenda-table-enhanced thead th.col-fazenda {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%);
    color: var(--cst-white) !important;
    z-index: 4;
}

.custos-table tfoot,
.custos-cc-table-enhanced tfoot,
.custos-fazenda-table-enhanced tfoot {
    position: sticky;
    bottom: 0;
    z-index: 3;
}

/* Garante fundo opaco no tfoot para evitar sobreposicao ao scrollar */
/* Usa cor primaria do sistema para consistencia visual */
.custos-table tfoot tr,
.custos-cc-table-enhanced tfoot tr,
.custos-fazenda-table-enhanced tfoot tr {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%);
}

.custos-table tfoot td,
.custos-cc-table-enhanced tfoot td,
.custos-fazenda-table-enhanced tfoot td {
    background: inherit;
    color: var(--cst-white);
}

/* === LINHA DE TOTAL (classe .total-row usada no tfoot) === */
.custos-table .total-row,
.custos-cc-table-enhanced .total-row,
.custos-fazenda-table-enhanced .total-row,
.cst-table-enhanced .total-row {
    background: linear-gradient(135deg, var(--cst-primary-light) 0%, var(--cst-primary) 100%) !important;
}

.custos-table .total-row td,
.custos-cc-table-enhanced .total-row td,
.custos-fazenda-table-enhanced .total-row td,
.cst-table-enhanced .total-row td {
    padding: 10px 8px;
    font-weight: var(--cst-font-weight-bold) !important;
    color: var(--cst-white) !important;
    border-top: 2px solid var(--cst-primary-dark);
    border-bottom: none;
}

.custos-table td,
.custos-cc-table-enhanced td,
.custos-fazenda-table-enhanced td {
    padding: 8px 8px;
    border-bottom: 1px solid var(--cst-neutral-200);
    vertical-align: middle;
}

.custos-table tbody tr,
.custos-cc-table-enhanced tbody tr,
.custos-fazenda-table-enhanced tbody tr {
    transition: background-color var(--cst-transition-fast);
    cursor: default;
}

.custos-table tbody tr.row-odd,
.custos-cc-table-enhanced tbody tr.row-odd,
.custos-fazenda-table-enhanced tbody tr.row-odd {
    background-color: var(--cst-neutral-50);
}

.custos-table tbody tr.row-odd .col-sticky-left,
.custos-cc-table-enhanced tbody tr.row-odd .col-sticky-left,
.custos-fazenda-table-enhanced tbody tr.row-odd .col-sticky-left {
    background-color: var(--cst-neutral-50);
}

.custos-table tbody tr:hover,
.custos-cc-table-enhanced tbody tr:hover,
.custos-fazenda-table-enhanced tbody tr:hover {
    background-color: var(--cst-primary-bg) !important;
    box-shadow: inset 4px 0 0 var(--cst-primary);
}

.custos-table tbody tr:hover .col-sticky-left,
.custos-cc-table-enhanced tbody tr:hover .col-sticky-left,
.custos-fazenda-table-enhanced tbody tr:hover .col-sticky-left {
    background-color: var(--cst-primary-bg) !important;
}

/* ===== CONTAINERS WRAPPER ===== */
.tabela-container {
    border-radius: var(--cst-radius-lg);
    overflow: hidden;
    margin-bottom: var(--cst-spacing-lg); /* Espaco antes do totalizador */
}

.table-scroll-wrapper {
    max-height: calc(100vh - 400px); /* Altura dinamica: viewport - headers/filtros/totalizador */
    min-height: 300px;
    overflow: auto;
    position: relative;
}

/* ===== ESPACAMENTO PARA TOTALIZADOR FIXO ===== */
.cst-espacamento-totalizador,
.espacamento-totalizador {
    height: 80px;
}

/* ===== AJUSTE DE PADDING PARA O TOTALIZADOR ===== */
.content-spacing-padding-bottom {
    padding-bottom: 160px; /* Espaco suficiente para totalizador fixo + margem */
}

/* ===== PRINT STYLES ===== */
@media print {
    .cst-table-enhanced thead {
        position: relative;
    }

    .cst-table-enhanced tfoot {
        position: relative;
    }

    .cst-col-sticky-left,
    .col-sticky-left,
    .cst-col-sticky-right,
    .col-sticky-right {
        position: relative;
    }

    .cst-table-enhanced thead tr {
        background: var(--cst-neutral-200) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .cst-table-enhanced th {
        color: var(--cst-neutral-900) !important;
    }

    .table-scroll-wrapper,
    .cst-table-scroll-wrapper {
        max-height: none;
        overflow: visible;
    }
}

/* ============================================
   CONFIGURACOES DE TABELA - PAINEL DE CONFIG
   ============================================ */

/* ===== DENSIDADES ===== */

/* Densidade Compacta */
.cst-tabela-compacta th,
.tabela-densidade-compacta th {
    padding: 6px 4px;
    font-size: 10px;
}

.cst-tabela-compacta td,
.tabela-densidade-compacta td {
    padding: 4px 4px;
    font-size: 11px;
    line-height: 1.2;
}

/* Densidade Normal (padrao) */
.cst-tabela-normal th,
.tabela-densidade-normal th {
    padding: 10px 8px;
    font-size: 11px;
}

.cst-tabela-normal td,
.tabela-densidade-normal td {
    padding: 8px 8px;
    font-size: 12px;
    line-height: 1.4;
}

/* Densidade Confortavel */
.cst-tabela-confortavel th,
.tabela-densidade-confortavel th {
    padding: 14px 10px;
    font-size: 12px;
}

.cst-tabela-confortavel td,
.tabela-densidade-confortavel td {
    padding: 12px 10px;
    font-size: 13px;
    line-height: 1.5;
}

/* ===== CORES DE ZEBRA ALTERNATIVA ===== */

/* Zebra Cinza (padrao) */
.cst-zebra-cinza tbody tr.row-odd,
.tabela-zebra-cinza tbody tr.row-odd {
    background-color: #f5f5f5;
}

.cst-zebra-cinza tbody tr.row-odd .col-sticky-left,
.tabela-zebra-cinza tbody tr.row-odd .col-sticky-left {
    background-color: #f5f5f5;
}

/* Zebra Azul */
.cst-zebra-azul tbody tr.row-odd,
.tabela-zebra-azul tbody tr.row-odd {
    background-color: #e3f2fd;
}

.cst-zebra-azul tbody tr.row-odd .col-sticky-left,
.tabela-zebra-azul tbody tr.row-odd .col-sticky-left {
    background-color: #e3f2fd;
}

/* Zebra Verde */
.cst-zebra-verde tbody tr.row-odd,
.tabela-zebra-verde tbody tr.row-odd {
    background-color: #e8f5e9;
}

.cst-zebra-verde tbody tr.row-odd .col-sticky-left,
.tabela-zebra-verde tbody tr.row-odd .col-sticky-left {
    background-color: #e8f5e9;
}

/* Sem Zebra */
.cst-sem-zebra tbody tr.row-odd,
.tabela-sem-zebra tbody tr.row-odd {
    background-color: transparent;
}

.cst-sem-zebra tbody tr.row-odd .col-sticky-left,
.tabela-sem-zebra tbody tr.row-odd .col-sticky-left {
    background-color: var(--cst-surface);
}

/* ===== CORES DE DESTAQUE DE GRUPOS ===== */

/* Destaque Azul */
.cst-grupo-azul tbody tr.row-grupo,
.tabela-grupo-azul tbody tr.row-grupo {
    background-color: #bbdefb !important;
}

.cst-grupo-azul tbody tr.row-grupo .col-sticky-left,
.tabela-grupo-azul tbody tr.row-grupo .col-sticky-left {
    background-color: #bbdefb !important;
}

/* Destaque Verde */
.cst-grupo-verde tbody tr.row-grupo,
.tabela-grupo-verde tbody tr.row-grupo {
    background-color: #c8e6c9 !important;
}

.cst-grupo-verde tbody tr.row-grupo .col-sticky-left,
.tabela-grupo-verde tbody tr.row-grupo .col-sticky-left {
    background-color: #c8e6c9 !important;
}

/* Destaque Laranja */
.cst-grupo-laranja tbody tr.row-grupo,
.tabela-grupo-laranja tbody tr.row-grupo {
    background-color: #ffe0b2 !important;
}

.cst-grupo-laranja tbody tr.row-grupo .col-sticky-left,
.tabela-grupo-laranja tbody tr.row-grupo .col-sticky-left {
    background-color: #ffe0b2 !important;
}

/* Sem destaque de grupo */
.cst-sem-destaque-grupo tbody tr.row-grupo,
.tabela-sem-destaque-grupo tbody tr.row-grupo {
    background-color: transparent !important;
    font-weight: var(--cst-font-weight-semibold);
}

/* ===== HOVER DESABILITADO ===== */
.cst-sem-hover tbody tr:hover,
.tabela-sem-hover tbody tr:hover {
    background-color: inherit !important;
    box-shadow: none !important;
}

/* ===== HIGHLIGHTS CONDICIONAIS ===== */

/* Top N maiores custos */
.cst-highlight-topn,
.highlight-topn {
    background-color: #c8e6c9 !important;
    font-weight: var(--cst-font-weight-semibold);
}

.cst-highlight-topn .col-sticky-left,
.highlight-topn .col-sticky-left {
    background-color: #c8e6c9 !important;
}

/* Valores altos (acima do limite) */
.cst-highlight-valor-alto,
.highlight-valor-alto {
    background-color: #ffecb3 !important;
}

.cst-highlight-valor-alto .col-sticky-left,
.highlight-valor-alto .col-sticky-left {
    background-color: #ffecb3 !important;
}

/* Valores zerados */
.cst-highlight-zerado,
.highlight-zerado {
    background-color: #f5f5f5;
    color: var(--cst-neutral-500);
}

/* Valor negativo em vermelho */
.cst-valor-negativo,
.valor-negativo {
    color: var(--cst-danger) !important;
}

/* ===== HEATMAP ===== */

/* Gradiente de cores para heatmap (do verde ao vermelho) */
.cst-heatmap-1 { background-color: #e8f5e9; } /* Menor valor - verde mais claro */
.cst-heatmap-2 { background-color: #c8e6c9; }
.cst-heatmap-3 { background-color: #a5d6a7; }
.cst-heatmap-4 { background-color: #81c784; }
.cst-heatmap-5 { background-color: #fff9c4; } /* Amarelo - meio */
.cst-heatmap-6 { background-color: #ffecb3; }
.cst-heatmap-7 { background-color: #ffe0b2; }
.cst-heatmap-8 { background-color: #ffccbc; }
.cst-heatmap-9 { background-color: #ffab91; }
.cst-heatmap-10 { background-color: #ff8a65; } /* Maior valor - vermelho */

/* ===== ALTURAS FIXAS ===== */

.table-scroll-wrapper.altura-300 {
    max-height: 300px;
}

.table-scroll-wrapper.altura-400 {
    max-height: 400px;
}

.table-scroll-wrapper.altura-500 {
    max-height: 500px;
}

.table-scroll-wrapper.altura-600 {
    max-height: 600px;
}

.table-scroll-wrapper.altura-fullscreen {
    max-height: calc(100vh - 250px);
}

.table-scroll-wrapper.altura-auto {
    max-height: none;
}

/* ===== COLUNAS SEM CONGELAMENTO ===== */

.tabela-sem-sticky-left .col-sticky-left,
.cst-sem-sticky-left .col-sticky-left {
    position: relative;
    left: auto;
}

.tabela-sem-sticky-right .col-sticky-right,
.cst-sem-sticky-right .col-sticky-right {
    position: relative;
    right: auto;
    background: var(--cst-surface);
}

/* ===== INDENTACAO DE GRUPOS ===== */

.cst-indent-0 .col-cc,
.tabela-indent-0 .col-cc {
    padding-left: 8px;
}

.cst-indent-16 .item-grupo .col-cc,
.tabela-indent-16 .item-grupo .col-cc {
    padding-left: 24px; /* 8px base + 16px indent */
}

.cst-indent-24 .item-grupo .col-cc,
.tabela-indent-24 .item-grupo .col-cc {
    padding-left: 32px; /* 8px base + 24px indent */
}

/* ===== SEPARADORES ENTRE GRUPOS ===== */

.cst-separador-linha tbody tr.grupo-fim,
.tabela-separador-linha tbody tr.grupo-fim {
    border-bottom: 2px solid var(--cst-neutral-300);
}

.cst-separador-espaco tbody tr.grupo-fim,
.tabela-separador-espaco tbody tr.grupo-fim {
    border-bottom: 8px solid transparent;
}

/* ===== COLUNAS CALCULADAS ===== */

.col-percentual-total {
    min-width: 70px;
    color: var(--cst-primary);
    font-weight: var(--cst-font-weight-semibold);
}

.col-custo-hora,
.col-custo-tonelada {
    min-width: 80px;
    color: var(--cst-success-dark);
}

/* ===== DRAWER DE CONFIGURACAO ===== */

.cst-config-drawer {
    --mud-drawer-background: var(--mud-palette-background);
}

.cst-config-drawer-header {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%);
    color: white;
    padding: 12px 16px;
}

.cst-config-drawer-header .mud-icon-root {
    color: white !important;
}

.cst-config-drawer-header .mud-typography {
    color: white !important;
}

.cst-config-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.cst-config-section {
    margin-bottom: 4px;
}

.cst-config-section .mud-expand-panel-header {
    padding: 8px 12px;
    min-height: 40px;
}

.cst-config-section .mud-expand-panel-content {
    padding: 0;
}

.cst-config-drawer-footer {
    border-top: 1px solid var(--mud-palette-lines-default);
    padding: 12px 16px;
    background: var(--mud-palette-surface);
}

.cst-density-group {
    width: 100%;
}

.cst-density-group .mud-button-root {
    flex: 1;
    min-height: 60px;
}

/* ============================================
   MUDDATAGRID - ESTILOS PARA RECURSOS LISTA
   ============================================ */

/* Container do DataGrid */
.cst-datagrid-container {
    border-radius: var(--cst-radius-lg);
}

/* Garantir que o MudDataGrid tenha scroll interno com header fixo */
.cst-datagrid-container .mud-table-container {
    overflow: auto !important;
}

.cst-datagrid-container .mud-table-head {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    /* Fallback de background para garantir visibilidade ao rolar */
    background: linear-gradient(135deg, var(--cst-primary, #1976d2) 0%, var(--cst-primary-dark, #0d47a1) 100%) !important;
}

.cst-datagrid-container .mud-table-head .mud-table-cell {
    background: transparent !important;
}

/* Densidades para MudDataGrid */
.cst-datagrid-container.densidade-compacta .mud-table-cell {
    padding: 4px 8px !important;
    font-size: 11px !important;
}

.cst-datagrid-container.densidade-compacta .mud-table-head .mud-table-cell {
    padding: 6px 8px !important;
    font-size: 10px !important;
}

.cst-datagrid-container.densidade-confortavel .mud-table-cell {
    padding: 12px 10px !important;
    font-size: 13px !important;
}

.cst-datagrid-container.densidade-confortavel .mud-table-head .mud-table-cell {
    padding: 14px 10px !important;
    font-size: 12px !important;
}

/* Coluna Total com destaque - FUNDO SOLIDO OBRIGATORIO */
/* Usando alta especificidade para garantir que sobrescreva o MudDataGrid */
.cst-datagrid .mud-table-body .mud-table-row .mud-table-cell.col-total-destaque,
.cst-datagrid .mud-table-body .mud-table-row td.col-total-destaque,
.cst-datagrid .mud-table-body td.col-total-destaque,
.cst-datagrid td.col-total-destaque,
.cst-datagrid .col-total-destaque {
    /* Verde solido - cor original do sistema */
    background-color: #e8f5e9 !important;
    background: #e8f5e9 !important;
    font-weight: var(--cst-font-weight-bold);
    /* Sombra sutil a esquerda para separacao visual */
    box-shadow: -4px 0 12px -2px rgba(0, 0, 0, 0.15);
    /* Borda para reforcar separacao */
    border-left: 1px solid rgba(76, 175, 80, 0.3);
}

/* Zebra para coluna Total - verde ligeiramente mais escuro nas linhas impares */
.cst-datagrid .mud-table-body .mud-table-row:nth-child(odd) .mud-table-cell.col-total-destaque,
.cst-datagrid .mud-table-body .mud-table-row:nth-child(odd) td.col-total-destaque,
.cst-datagrid .mud-table-row:nth-child(odd) .col-total-destaque {
    background-color: #c8e6c9 !important;
    background: #c8e6c9 !important;
}

/* Header da coluna Total - FUNDO SOLIDO usando gradiente padrao do sistema */
/* Classe especifica para header: col-total-header-destaque (aplicada via HeaderClass no Razor) */
.col-total-header-destaque,
th.col-total-header-destaque,
.mud-table-cell.col-total-header-destaque,
.mud-table-head .col-total-header-destaque,
.mud-table-head .mud-table-cell.col-total-header-destaque,
.cst-datagrid .mud-table-head .col-total-header-destaque,
.cst-datagrid-container .mud-table-head .col-total-header-destaque,
.cst-datagrid-container .mud-table-head .mud-table-cell.col-total-header-destaque {
    /* Mesmo gradiente do sistema para manter consistencia visual */
    background: linear-gradient(135deg, var(--cst-primary, #1976d2) 0%, var(--cst-primary-dark, #0d47a1) 100%) !important;
    /* Borda sutil para separacao */
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    /* Sem sombra no header */
    box-shadow: none;
}

/* Header da coluna Equipamento - FUNDO SOLIDO usando gradiente padrao do sistema */
/* Classe especifica para header: col-descricao-principal (aplicada via HeaderClass no Razor) */
.mud-table-head .col-descricao-principal,
.mud-table-head .mud-table-cell.col-descricao-principal,
.cst-datagrid .mud-table-head .col-descricao-principal,
.cst-datagrid-container .mud-table-head .col-descricao-principal,
.cst-datagrid-container .mud-table-head .mud-table-cell.col-descricao-principal {
    /* Mesmo gradiente do sistema para manter consistencia visual */
    background: linear-gradient(135deg, var(--cst-primary, #1976d2) 0%, var(--cst-primary-dark, #0d47a1) 100%) !important;
    /* Sombra sutil para separacao visual quando sticky */
    box-shadow: 2px 0 8px -2px rgba(0, 0, 0, 0.1);
}

/* Coluna Total sem destaque */
.cst-datagrid .col-total-normal {
    font-weight: var(--cst-font-weight-bold);
}

/* Zebra com cores alternativas para MudDataGrid */
.cst-datagrid.zebra-azul .mud-table-row:nth-child(odd) {
    background-color: #e3f2fd !important;
}

.cst-datagrid.zebra-verde .mud-table-row:nth-child(odd) {
    background-color: #e8f5e9 !important;
}

/* Header do DataGrid com cor primaria */
.cst-datagrid .mud-table-head {
    background: linear-gradient(135deg, var(--cst-primary) 0%, var(--cst-primary-dark) 100%);
}

.cst-datagrid .mud-table-head .mud-table-cell {
    color: white !important;
    font-weight: var(--cst-font-weight-semibold);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.3px;
}

/* Valores numericos com alinhamento tabular */
.cst-datagrid .mud-table-cell {
    font-variant-numeric: tabular-nums;
}

/* ===== COLUNAS STICKY - DESIGN SYSTEM ===== */

/* Coluna Equipamento (sticky left) - fundo solido APENAS no corpo da tabela */
.cst-datagrid .mud-table-body .col-descricao-principal {
    background-color: #ffffff !important;
    box-shadow: 2px 0 8px -2px rgba(0, 0, 0, 0.1);
}

/* Zebra para coluna Equipamento - APENAS corpo */
.cst-datagrid .mud-table-body .mud-table-row:nth-child(odd) .col-descricao-principal {
    background-color: #fafafa !important;
}

.cst-datagrid.zebra-azul .mud-table-body .mud-table-row:nth-child(odd) .col-descricao-principal {
    background-color: #e3f2fd !important;
}

.cst-datagrid.zebra-verde .mud-table-body .mud-table-row:nth-child(odd) .col-descricao-principal {
    background-color: #e8f5e9 !important;
}

/* Valor negativo */
.cst-datagrid .valor-negativo {
    color: var(--cst-danger) !important;
}

/* Highlight para valores altos */
.cst-datagrid .highlight-alto {
    background-color: #ffecb3 !important;
}

/* Highlight para top N */
.cst-datagrid .highlight-top {
    background-color: #c8e6c9 !important;
}

/* Highlight para zerados */
.cst-datagrid .highlight-zero {
    color: var(--cst-neutral-400);
}

/* ===== LARGURAS MINIMAS PARA COLUNAS ===== */

/* Coluna de descricao principal (Equipamento) */
.cst-datagrid .col-descricao-principal {
    min-width: 200px !important;
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Coluna de descricao secundaria (Centro de Custo, etc) */
.cst-datagrid .col-descricao {
    min-width: 140px !important;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Colunas de codigo (Setor, Classe) */
.cst-datagrid .col-codigo {
    min-width: 60px;
    max-width: 100px;
    text-align: center;
}

/* Colunas numericas - largura padrao */
.cst-datagrid .mud-table-cell {
    min-width: 75px;
}

/* Coluna Total - sempre com destaque de largura */
.cst-datagrid .col-total-destaque {
    min-width: 100px !important;
}

/* ===== AJUSTES POR DENSIDADE ===== */

/* Densidade Normal */
.cst-datagrid-container:not(.densidade-compacta):not(.densidade-confortavel) .col-descricao-principal {
    min-width: 220px !important;
}

.cst-datagrid-container:not(.densidade-compacta):not(.densidade-confortavel) .col-descricao {
    min-width: 160px !important;
}

.cst-datagrid-container:not(.densidade-compacta):not(.densidade-confortavel) .mud-table-cell {
    min-width: 85px;
}

/* Densidade Confortavel - larguras maiores */
.cst-datagrid-container.densidade-confortavel .col-descricao-principal {
    min-width: 260px !important;
    max-width: 380px;
}

.cst-datagrid-container.densidade-confortavel .col-descricao {
    min-width: 180px !important;
    max-width: 280px;
}

.cst-datagrid-container.densidade-confortavel .mud-table-cell {
    min-width: 95px;
}

.cst-datagrid-container.densidade-confortavel .col-codigo {
    min-width: 70px;
}

/* Densidade Compacta - larguras menores */
.cst-datagrid-container.densidade-compacta .col-descricao-principal {
    min-width: 160px !important;
    max-width: 240px;
}

.cst-datagrid-container.densidade-compacta .col-descricao {
    min-width: 120px !important;
    max-width: 180px;
}

.cst-datagrid-container.densidade-compacta .mud-table-cell {
    min-width: 65px;
}

.cst-datagrid-container.densidade-compacta .col-codigo {
    min-width: 50px;
}
