/* Hub Projects — tema do Tabulator em tokens M3.
   Publicado só na instalação que seleciona o domínio (marcador {{DOMAIN_STYLES}} do
   index.html); por isso não entra no grafo de @import de assets/app.css.

   O CSS de fábrica do Tabulator NÃO é vendorizado: ele é inteiro de cor literal
   (#888, #e6e6e6, #3876ca…), e cor literal em CSS reprova o tools/design-audit.js.
   O que existe aqui é o mínimo estrutural que a lib precisa para funcionar — o
   `.tabulator-tableholder` rolar, o cabeçalho não quebrar linha, a célula respeitar a
   largura que o JS calcula — mais o tema em tokens de assets/css/00-tokens.css.

   A lib escreve largura e posição como estilo inline, em runtime; nada aqui compete com
   isso. Regra que precisar vencer o inline é sinal de opção errada na configuração da
   tabela, não de `!important`.

   Contrato: docs/projects-contracts.md §1 (Design System) e §7.1. */

.tabulator {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--chat-radius-md);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: var(--chat-font-body);
    font-size: 0.875rem;
    text-align: left;
}

/* ---- Cabeçalho ---- */

.tabulator .tabulator-header {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    white-space: nowrap;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 600;
    outline: none;
    user-select: none;
}

.tabulator .tabulator-header.tabulator-header-hidden {
    display: none;
}

.tabulator .tabulator-header .tabulator-header-contents {
    position: relative;
    overflow: hidden;
}

.tabulator .tabulator-header .tabulator-header-contents .tabulator-headers {
    display: inline-block;
}

.tabulator .tabulator-header .tabulator-col {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    justify-content: flex-start;
    box-sizing: border-box;
    overflow: hidden;
    vertical-align: bottom;
    border-right: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container);
    text-align: left;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
    position: relative;
    box-sizing: border-box;
    padding: var(--chat-space-2) var(--chat-space-3);
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title-holder {
    position: relative;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-title {
    padding-right: var(--chat-space-6);
}

/* A seta de ordenação é desenhada com borda (o próprio desenho do Tabulator): a cor é do
   token, e `transparent` não é cor literal. */
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-sorter {
    position: absolute;
    top: 0;
    bottom: 0;
    right: var(--chat-space-2);
    display: flex;
    align-items: center;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid var(--md-sys-color-outline);
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort='none'] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
    border-top: none;
    border-bottom: 5px solid var(--md-sys-color-outline);
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort='ascending'] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
    border-top: none;
    border-bottom: 5px solid var(--md-sys-color-primary);
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort='descending'] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
    border-bottom: none;
    border-top: 5px solid var(--md-sys-color-primary);
}

@media (hover: hover) and (pointer: fine) {
    .tabulator .tabulator-header .tabulator-col.tabulator-sortable.tabulator-col-sorter-element:hover {
        background: var(--md-sys-color-surface-container-high);
        cursor: pointer;
    }
}

/* ---- Corpo ---- */

.tabulator .tabulator-tableholder {
    position: relative;
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
}

.tabulator .tabulator-tableholder:focus {
    outline: none;
}

.tabulator .tabulator-tableholder .tabulator-table {
    position: relative;
    display: inline-block;
    overflow: visible;
    white-space: nowrap;
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
}

.tabulator .tabulator-tableholder .tabulator-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    min-width: 100%;
}

.tabulator .tabulator-tableholder .tabulator-placeholder[tabulator-render-mode='virtual'] {
    min-height: 100%;
}

.tabulator .tabulator-tableholder .tabulator-placeholder .tabulator-placeholder-contents {
    display: inline-block;
    padding: var(--chat-space-6);
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
    white-space: normal;
}

.tabulator-row {
    position: relative;
    box-sizing: border-box;
    min-height: 36px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface);
}

@media (hover: hover) and (pointer: fine) {
    .tabulator-row:hover {
        background: var(--md-sys-color-surface-container-low);
    }
}

.tabulator-row .tabulator-cell {
    display: inline-block;
    box-sizing: border-box;
    overflow: hidden;
    padding: var(--chat-space-2) var(--chat-space-3);
    border-right: 1px solid var(--md-sys-color-outline-variant);
    outline: none;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

/* ---- Grupos (as faixas de `projects_groups`) ---- */

.tabulator-row.tabulator-group {
    box-sizing: border-box;
    min-width: 100%;
    padding: var(--chat-space-2) var(--chat-space-3);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    font-weight: 600;
}

.tabulator-row.tabulator-group .tabulator-group-toggle {
    display: inline-block;
}

.tabulator-row.tabulator-group .tabulator-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: var(--chat-space-3);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 5px solid var(--md-sys-color-on-surface-variant);
    border-right: 0;
    vertical-align: middle;
}

.tabulator-row.tabulator-group.tabulator-group-visible .tabulator-arrow {
    margin-right: var(--chat-space-2);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--md-sys-color-on-surface-variant);
    border-bottom: 0;
}

.tabulator-row.tabulator-group span {
    margin-left: var(--chat-space-2);
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 400;
}

/* ---- Alça de redimensionamento de coluna ---- */

.tabulator .tabulator-col-resize-handle {
    position: relative;
    display: inline-block;
    width: 6px;
    margin-left: -3px;
    margin-right: -3px;
    vertical-align: middle;
    z-index: 11;
}

@media (hover: hover) and (pointer: fine) {
    .tabulator .tabulator-col-resize-handle:hover {
        cursor: ew-resize;
    }
}

.tabulator .tabulator-col-resize-handle:last-of-type {
    width: 3px;
    margin-right: 0;
}

.tabulator .tabulator-col-resize-guide {
    position: absolute;
    top: 0;
    width: 4px;
    height: 100%;
    margin-left: -0.5px;
    background: var(--md-sys-color-primary);
    opacity: 0.5;
}
