﻿/* ✅ Faz a grelha encolher à soma das colunas (evita "fundo de grupo" até ao fim) */
/*.verticalgrid-size .dxbl-grid-table,
.verticalgrid-size .dxbl-grid-header-table {
    width: max-content !important;
   
}*/
/* 1) MUITO IMPORTANTE: permitir shrink dentro de flex (tabs / form layout) */
.fc-vertical-grid-container,
.fc-vertical-grid-container .dxbl-row,
.fc-vertical-grid-container .dxbl-col,
.fc-vertical-grid-container .dxbl-fl-ctrl,
.vg-root,
.vg-grid-scroll {
    min-width: 0 !important;
}

/* 2) O grid deve ocupar a largura do container (popup/tab) */
.verticalgrid-size {
    width: 100%;
    min-width: 0 !important;
    height: calc(100vh - 300px);
    max-width: 100%;
    overflow: hidden; /* deixa scroll para o viewer interno */
}

    /* 3) O scroll viewer tem de poder "encolher" e detetar overflow */
    .verticalgrid-size .dxbl-scroll-viewer {
        width: 100%;
        min-width: 0 !important;
    }

    /* 4) A tabela pode ser maior que o viewer -> ativa scroll horizontal */
    .verticalgrid-size table.dxbl-grid-table {
        width: max-content !important;
        min-width: 100% !important;
    }

    /* Remove a empty column do DxGrid (header + body + footer) */
    .verticalgrid-size .dxbl-grid-empty-cell {
        display: none !important;
    }

    /* Garante que a tabela não fica com "gap" por causa do colgroup */
    .verticalgrid-size col.dxbl-grid-empty-cell {
        width: 0 !important;
    }
/* ---------- Header buttons (colunas ID) ---------- */
.vg-header-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    height: 24px;
    padding: 2px 0;
}

    /* Botões "ícone" (editar/guardar/cancelar/print/trash) */
    .vg-header-buttons > .btn,
    .vg-header-buttons .btn.vg-btn-preview,
    .vg-header-buttons .btn.text-primary,
    .vg-header-buttons .btn.text-success,
    .vg-header-buttons .btn.text-secondary,
    .vg-header-buttons .btn.text-danger {
        width: 24px;
        height: 24px;
        display: inline-flex;
        justify-content: center;
        align-items: center;
        border-radius: 6px;
        background: transparent;
        transition: background-color 0.15s ease-in-out;
        padding: 0;
        border: none;
    }

        .vg-header-buttons > .btn:hover,
        .vg-header-buttons .btn.vg-btn-preview:hover,
        .vg-header-buttons .btn.text-primary:hover,
        .vg-header-buttons .btn.text-success:hover,
        .vg-header-buttons .btn.text-secondary:hover,
        .vg-header-buttons .btn.text-danger:hover {
            background-color: rgba(0, 0, 0, 0.06);
        }

    .vg-header-buttons i.dx-icon {
        font-size: 18px;
        line-height: 1;
        margin: 0;
    }

    .vg-header-buttons .vg-toolbar .btn {
        width: 100% !important;
        height: 24px !important;
        min-width: 0 !important;
        white-space: normal !important;
        word-break: keep-all !important;
    }

.vg-field-header {
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vg-btn-preview i.dx-icon {
    color: #292828;
}

.vg-btn-preview:hover i.dx-icon {
    color: #929292;
}

/* ========================================================= */
/* ✅ TOOLBAR (coluna CAMPO) — flex layout para acomodar      */
/*    botão "Novo Registo" + checkbox "Inserir FC anterior"   */
/* ========================================================= */
.vg-toolbar {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
    background-color: transparent;
    border-bottom: none;
    padding: 0 4px;
    min-height: 32px;
    height: auto;
    box-sizing: border-box;
}

    /* Sobrescreve o "32x32" aqui (botões legacy comentados, mas a regra fica) */
    .vg-toolbar .btn {
        width: auto !important;
        height: 30px !important;
        min-width: 0 !important;
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-size: 0.66rem;
        font-weight: 500;
        line-height: 1.05;
        border-radius: 6px;
        border: 1px solid rgba(0,0,0,0.08);
        background-color: #ffffff;
        color: #333;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        transition: all 0.2s ease-in-out;
        white-space: normal;
        word-break: keep-all;
        overflow: hidden;
        text-align: center;
        padding: 2px 6px !important;
    }

        .vg-toolbar .btn:hover {
            background-color: #eef2ff;
            color: #0d6efd;
            box-shadow: 0 2px 4px rgba(0,0,0,0.08);
        }

        .vg-toolbar .btn i {
            font-size: 16px;
            flex: 0 0 auto;
        }

    /* Botão "Novo Registo" (ec-btn-new) mantém tamanho natural no flex */
    .vg-toolbar .ec-btn {
        flex: 0 0 auto;
        width: auto !important;
    }

/* Cores dos botões */
.vg-btn-add i {
    color: #28a745;
}

.vg-btn-copy i {
    color: #17a2b8;
}

.vg-btn-preview2 i {
    color: #be8c02;
}

.vg-btn-add:hover i {
    color: #1f8b38;
}

.vg-btn-copy:hover i {
    color: #117a8b;
}

.vg-btn-preview2:hover i {
    color: #9e7504;
}

/* ---------- Coluna fixa "Campo" ---------- */
.vg-fixed-cell {
    display: block;
    width: 100%;
    height: 100%;
    padding: 6px 10px;
    box-sizing: border-box;
    color: #222;
}

.dxbl-grid-table td.dxbl-grid-fixed-cell:has(.vg-fixed-cell) {
    background-color: #f5f5f5 !important;
    border-color: #ddd !important;
}

/* ---------- Linhas de grupo ---------- */
.vg-group-row {
    display: block;
    width: 100%;
    height: 100%;
    padding: 6px 10px;
    box-sizing: border-box;
    font-weight: 600;
    font-size: 0.70rem;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ✅ Fundo do grupo APENAS nas células que têm o .vg-group-row */
.dxbl-grid-table td:has(.vg-group-row) {
    background-color: #e0e0e0 !important;
    border-color: #d0d0d0 !important;
    padding: 0 !important;
}

/* ✅ Zebra subtil, mas só nas células do grupo (não pinta a coluna "filler") */
.dxbl-grid-table tr:nth-of-type(even) td:has(.vg-group-row) {
    background-color: #d6d6d6 !important;
}

/* Remove divisões nas colunas não fixas (só nas células de grupo) */
.dxbl-grid-table td:has(.vg-group-row):not(.dxbl-grid-fixed-cell) {
    border-left: none !important;
    border-right: none !important;
}

/* Mantém borda na fixa (só nas células de grupo) */
.dxbl-grid-table td.dxbl-grid-fixed-cell:has(.vg-group-row) {
    border: 1px solid #ccc !important;
}

/* 🔹 Mantém checkbox + campo texto lado a lado e usa a largura da célula */
.vg-editing-pair {
    display: flex; /* <- em vez de inline-flex */
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%; /* <- ocupa a largura total da célula */
    min-width: 0; /* <- crucial para permitir encolher/esticar */
}

    /* checkbox não estica */
    .vg-editing-pair .dxbl-checkbox {
        flex: 0 0 auto;
    }

    /* 🔹 Campo texto/memo ocupa o resto (sem limite) */
    .vg-editing-pair .vg-inline-text,
    .vg-editing-pair .vg-inline-memo {
        flex: 1 1 0;
        width: 100%;
        min-width: 0; /* <- permite crescer/encolher no flex */
        max-width: none; /* <- remove o limite dos 400px */
        display: block !important;
    }

        /* 🔹 Força o controlo DevExpress e o input interno a ir a 100% */
        .vg-editing-pair .vg-inline-text .dxbl-textbox,
        .vg-editing-pair .vg-inline-memo .dxbl-memo,
        .vg-editing-pair .vg-inline-memo textarea,
        .vg-editing-pair .vg-inline-text input {
            width: 100% !important;
        }

/* 🔹 Aparência quando o campo está desativado */
.vg-inline-text:disabled,
.vg-inline-memo:disabled {
    background-color: #f8f8f8 !important;
    color: #888 !important;
    border-color: #ccc !important;
}



/* ---------- Modo leitura ---------- */
.vg-display {
    padding: 4px 6px;
    background: #fff;
    color: #222;
    white-space: pre-wrap;
    word-break: break-word;
}


.vg-display-bool {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 24px;
}

.vg-check-icon {
    color: #1f8b38; /* verde */
    font-size: 18px;
    line-height: 1;
}

/* ============================================================ */
/* Botão "Novo Registo" (e família ec-btn)                       */
/* ============================================================ */
.ec-btn {
    padding: 0 !important;
    border: 0;
    box-shadow: none;
    text-decoration: none !important;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color .15s ease, transform .12s ease, opacity .15s ease;
}

    .ec-btn:not(:disabled):hover {
        background-color: rgba(0, 0, 0, 0.06);
        transform: scale(1.08);
    }

    .ec-btn:not(:disabled):active {
        transform: scale(0.96);
    }

    .ec-btn:disabled {
        cursor: not-allowed;
        opacity: .55;
    }

.ec-xaf-icon {
    width: 16px;
    height: 16px;
    display: block;
    pointer-events: none;
}

.ec-btn-new {
    gap: 8px;
    padding: 6px 12px !important;
    border-radius: 8px;
    /*background-color: #f5f5f5;*/
    font-size: 14px;
    font-weight: 500;
    color: black;
}

.ec-btn-text {
    font-size: 12px;
}

/* ============================================================ */
/* Checkbox "Inserir dados da FC anterior"                       */
/* — alinhada em altura/padding/fonte com o botão Novo Registo  */
/* ============================================================ */
.vg-copy-prev {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px; /* igual ao .ec-btn-new */
    border-radius: 8px; /* igual ao .ec-btn-new */
    font-size: 14px; /* igual ao .ec-btn-new */
    font-weight: 500; /* igual ao .ec-btn-new */
    color: black; /* igual ao .ec-btn-new */
    background: transparent;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    transition: background-color .15s ease, opacity .15s ease;
}

    .vg-copy-prev:hover {
        background-color: rgba(0, 0, 0, 0.06);
    }

    .vg-copy-prev input[type="checkbox"] {
        cursor: pointer;
        margin: 0;
        width: 16px; /* mesmo tamanho do ícone do botão Novo */
        height: 16px;
        flex: 0 0 auto;
        accent-color: #1f8b38; /* tique verde quando marcada */
    }

.vg-copy-prev-disabled {
    opacity: 0.55; /* mesma opacidade do .ec-btn:disabled */
    cursor: not-allowed;
}

    .vg-copy-prev-disabled:hover {
        background-color: transparent; /* sem hover quando desativada */
    }

    .vg-copy-prev-disabled input[type="checkbox"] {
        cursor: not-allowed;
    }

.vg-copy-prev-text {
    white-space: nowrap;
    font-size: 12px; /* mesmo tamanho do .ec-btn-text */
    font-weight: 500;
    line-height: 1;
}
