/* =============================================================================================
   Utilizadores e permissões (VB6 chaves.frm) — a dense screen like the VB6 one, but readable:
   15px base, single-line rows, the module help as tooltips, solid panels and dark text for contrast.
   The whole page scrolls as one (the account card goes up with the rest; requested 2026-10-01).
   ============================================================================================= */
.utilizadores-grelha {
    --u-contorno: rgba(15, 36, 64, 0.42);
    --u-verde: #0d7048;
    display: grid;
    grid-template-columns: 13rem minmax(0, 1fr);
    gap: .75rem;
    align-items: start;
    font-size: .95rem;
    color: var(--cr-text);
}

@media (max-width: 1000px) {
    .utilizadores-grelha {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Solid panels: the gradient background no longer shows through the text. */
.utilizadores-grelha .painel {
    padding: .8rem 1rem .9rem;
    background: rgba(255, 255, 255, 0.96);
    border-color: var(--cr-line);
}

.utilizadores-grelha .painel-titulo {
    font-size: .76rem;
    color: var(--cr-ink-700);
    margin-bottom: .5rem;
}

.utilizadores-grelha .form-control-sm,
.utilizadores-grelha .form-select-sm {
    font-size: .9rem;
    min-height: 2rem;
    padding-top: .22rem;
    padding-bottom: .22rem;
    color: var(--cr-text);
    border-color: var(--u-contorno);
}

    .utilizadores-grelha .form-control-sm::placeholder {
        color: var(--cr-text-3);
        opacity: 1;
    }

.utilizadores-grelha .btn-outline-secondary {
    color: var(--cr-text-2);
    border-color: var(--u-contorno);
}

    .utilizadores-grelha .btn-outline-secondary:hover {
        color: #fff;
        background: var(--cr-text-2);
    }

.utilizadores-grelha .btn-sm {
    font-size: .88rem;
    padding: .3rem .8rem;
}

.btn-xs {
    font-size: .76rem;
    line-height: 1.2;
    padding: .14rem .5rem;
    border-radius: 6px;
}

/* ---- User list ---- */
.utilizadores-lista {
    display: flex;
    flex-direction: column;
}

.utilizadores-titulo {
    margin: 0;
    font-family: var(--cr-font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--cr-accent);
}

.utilizadores-total {
    margin: 0 0 .5rem;
    font-size: .82rem;
    color: var(--cr-text-2);
}

.utilizadores-lista nav {
    margin-top: .6rem;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
}

.utilizador-opcao {
    padding: .32rem .6rem;
    border-radius: 7px;
    color: var(--cr-text);
    text-decoration: none;
    overflow-wrap: anywhere;
}

    .utilizador-opcao:hover {
        background: var(--cr-blue-100);
    }

    /* The chosen user in a light blue (as the chosen unit on Início), with a bar on the left. */
    .utilizador-opcao.ativa {
        background: rgba(42, 91, 234, 0.12);
        box-shadow: inset 3px 0 0 var(--cr-blue-600);
        color: var(--cr-blue-600);
        font-weight: 600;
    }

/* ---- Record ---- */
.utilizadores-ficha,
.ficha-utilizador,
.ficha-corpo {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-width: 0;
}

    .utilizadores-ficha > .alert {
        flex: none;
    }

/* Account card: fields on the left, the buttons in the right-hand corner. */
.ficha-topo {
    flex: none;
    display: flex;
    align-items: flex-end;
    gap: 1rem 1.5rem;
}

.ficha-campos {
    flex: 1 1 auto;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(8rem, 1fr)) minmax(12rem, 2fr) minmax(7.5rem, .8fr) auto;
    gap: .5rem .8rem;
    align-items: end;
}

@media (max-width: 1400px) {
    .ficha-topo {
        flex-wrap: wrap;
    }

    .ficha-campos {
        grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    }
}

.ficha-botoes {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: .45rem;
    margin-left: auto;
}

.campo {
    display: flex;
    flex-direction: column;
    gap: .18rem;
    min-width: 0;
    margin: 0;
}

.campo-rotulo {
    font-family: var(--cr-font-display);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--cr-blue-600);
}

.campo-com-unidade {
    display: flex;
    align-items: center;
    gap: .35rem;
    color: var(--cr-text-2);
}

    .campo-com-unidade input {
        width: 4.5rem;
    }

.painel .form-check.campo-check {
    display: flex;
    align-items: center;
    gap: .45rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    cursor: pointer;
}

    .painel .form-check.campo-check .icone {
        margin-left: .15rem;
        color: var(--cr-warning);
    }

    .painel .form-check.campo-check .form-check-input {
        float: none;
        margin: 0;
    }

    .painel .form-check.campo-check .form-check-label {
        font-size: .9rem;
    }

/* ---- Permissions: four columns like the VB6 frames. The first (longest) spans two rows; the legend is a
   wide strip in the second row, under the shorter columns 2–4, in the bottom right of the card. ---- */
.permissoes-colunas > .permissoes-coluna:first-child {
    grid-row: span 2;
}

.permissoes-legenda {
    grid-column: 2 / -1;
    align-self: end;
    display: flex;
    align-items: baseline;
    gap: .4rem 1rem;
    padding: .5rem .75rem;
    border-radius: 9px;
    /* A clearer light blue, so the legend reads as its own box. */
    background: #e6eeff;
    border: 1px solid rgba(42, 91, 234, 0.25);
    font-size: .84rem;
}

.permissoes-legenda-titulo {
    flex: none;
    font-family: var(--cr-font-display);
    font-size: .92rem;
    font-weight: 700;
    color: var(--cr-ink-900);
}

.permissoes-legenda dl {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1.1rem;
    margin: 0;
}

    .permissoes-legenda dl > div {
        display: flex;
        align-items: baseline;
        gap: .35rem;
    }

    .permissoes-legenda dl > .legenda-larga {
        flex-basis: 100%;
    }

.permissoes-legenda dt {
    padding: .02rem .45rem;
    border-radius: 5px;
    border: 1px solid var(--cr-line-strong);
    background: #fff;
    font-weight: 700;
}

    .permissoes-legenda dt.legenda-nivel {
        font-weight: 600;
        color: var(--cr-text);
    }

.permissoes-legenda dd {
    margin: 0;
    line-height: 1.3;
    color: var(--cr-text-2);
}

.permissoes-colunas {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1.1fr)) minmax(18.5rem, .62fr);
    gap: .5rem 1.4rem;
    align-items: start;
}

@media (max-width: 1500px) {
    .permissoes-colunas {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

        .permissoes-colunas > .permissoes-coluna:first-child {
            grid-row: auto;
        }

    .permissoes-legenda {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .permissoes-colunas {
        grid-template-columns: minmax(0, 1fr);
    }
}

.permissoes-coluna {
    display: flex;
    flex-direction: column;
    gap: .8rem;
    min-width: 0;
}

.permissoes-grupo {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.permissoes-grupo-cabecalho {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding-bottom: .25rem;
    margin-bottom: .1rem;
    border-bottom: 2px solid rgba(42, 91, 234, 0.35);
}

    .permissoes-grupo-cabecalho legend {
        white-space: nowrap;
        float: none;
        width: auto;
        margin: 0;
        font-family: var(--cr-font-display);
        font-size: .98rem;
        font-weight: 700;
        color: var(--cr-ink-900);
    }

.utilizadores-grelha .permissoes-todos {
    width: auto;
    min-height: 1.65rem;
    padding: .05rem 1.6rem .05rem .5rem;
    font-size: .8rem;
    color: var(--cr-text-2);
    background-position: right .35rem center;
}

.tabela-permissoes {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: .9rem;
}

    .tabela-permissoes th,
    .tabela-permissoes td {
        padding: .07rem .2rem;
        border-bottom: 1px solid var(--cr-line-strong);
        vertical-align: middle;
    }

    .tabela-permissoes tr:hover th,
    .tabela-permissoes tr:hover td {
        background: rgba(42, 91, 234, 0.05);
    }

    /* The module name always whole: a long one (Mapa de acontecimentos, Inicialização férias / C.C.…) goes on to a
       second line instead of being cut with "…". */
    .tabela-permissoes th {
        font-weight: 500;
        line-height: 1.25;
        color: var(--cr-text);
        white-space: normal;
        overflow-wrap: anywhere;
    }

        .tabela-permissoes th label {
            cursor: pointer;
        }

    .tabela-permissoes .coluna-acesso {
        width: 7.6rem;
    }

    .tabela-permissoes .coluna-nivel {
        width: 3.3rem;
    }

    .tabela-permissoes .form-select-sm {
        min-height: 1.65rem;
        padding: .04rem 1.5rem .04rem .5rem;
        font-size: .88rem;
        background-position: right .4rem center;
    }

    /* Disabled level (with Supervisor it is always 9): still readable, just clearly inactive. */
    .tabela-permissoes select:disabled {
        opacity: 1;
        color: var(--cr-text-2);
        background-color: #e9edf3;
        border-style: dashed;
        cursor: not-allowed;
    }

/* The help of a module: a small "?" with the text as a tooltip. */
.permissao-ajuda {
    display: inline-grid;
    place-items: center;
    width: 1.05rem;
    height: 1.05rem;
    margin-left: .25rem;
    border-radius: 50%;
    font-size: .68rem;
    font-weight: 700;
    color: #fff;
    background: var(--cr-blue-600);
    cursor: help;
    vertical-align: .05rem;
}

.codigo-vb6 {
    width: 3.4rem;
    font-size: .74rem;
    color: var(--cr-text-2);
    white-space: pre;
    text-align: right;
}

/* The access level is easy to scan by colour, in the selects and in the legend. */
.tabela-permissoes select.nivel-0 {
    color: var(--cr-text-2);
    background-color: #eef2f8;
}

.tabela-permissoes select.nivel-1,
.permissoes-legenda .nivel-1,
.permissoes-legenda .nivel-2,
.permissoes-legenda .nivel-3 {
    color: var(--cr-text);
}

.tabela-permissoes select.nivel-4,
.permissoes-legenda .nivel-4 {
    color: var(--u-verde);
    font-weight: 700;
}

.tabela-permissoes select.nivel-5,
.permissoes-legenda .nivel-5 {
    color: var(--cr-blue-600);
    font-weight: 700;
}

.tabela-permissoes select.nivel-9 {
    color: var(--cr-warning);
}

/* ---- Tick-box lists (warnings, units, sections, terminals, functions) ---- */
.nota-compacta {
    margin: .25rem 0 .35rem;
    font-size: .82rem;
    line-height: 1.35;
    color: var(--cr-text-2);
}

/* Explanations go at the bottom of their card, under a thin line (requested 2026-10-01). */
.nota-rodape {
    margin: .55rem 0 0;
    padding-top: .4rem;
    border-top: 1px solid var(--cr-line);
}

.lista-compacta {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0 1rem;
    padding-top: .2rem;
}

    .painel .lista-compacta .form-check {
        margin: 0 0 .15rem;
        padding-left: 1.6em;
        font-size: .9rem;
        line-height: 1.4;
    }

    .painel .lista-compacta .form-check-input {
        width: 1.05em;
        height: 1.05em;
        margin-left: -1.6em;
        margin-top: .2em;
        border-color: var(--u-contorno);
    }

.botoes-marcar {
    display: flex;
    gap: .25rem;
}

.ficha-fundo {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: .75rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .ficha-fundo {
        grid-template-columns: minmax(0, 1fr);
    }
}

.lista-seccoes {
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
}

.lista-terminais,
.lista-funcoes {
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.subtitulo-funcoes {
    margin: .6rem 0 .1rem;
    padding-bottom: .25rem;
    border-bottom: 2px solid rgba(42, 91, 234, 0.35);
    font-family: var(--cr-font-display);
    font-size: .98rem;
    font-weight: 700;
    color: var(--cr-ink-900);
}

/* ---- Add a terminal of the RTA600 to the user's list ---- */
.novo-terminal {
    margin-top: .55rem;
    padding: .45rem .6rem .55rem;
    border: 1px dashed rgba(42, 91, 234, 0.45);
    border-radius: 9px;
    background: rgba(230, 237, 255, 0.45);
}

.novo-terminal-linha {
    display: flex;
    gap: .45rem;
    margin-top: .2rem;
}

    .novo-terminal-linha select {
        flex: 1 1 auto;
        min-width: 0;
    }
