/* ============================================================
   O layout (.page/.sidebar/.main/.top-row/.content) é definido
   pelo CSS isolado de MainLayout.razor.css/NavMenu.razor.css.
   Este arquivo antigo tinha uma versão desatualizada dessas mesmas
   classes (sidebar de 250px) que não é mais usada, mas continuava
   carregada e conflitando — em telas mobile, a regra ".main {
   margin-left: 250px }" daqui não tinha nada no CSS novo que a
   sobrescrevesse, empurrando o conteúdo inteiro 250px para a
   direita e estourando o layout em telas pequenas. Removida.
   ============================================================ */

/* ============ OVERFLOW HORIZONTAL: TRAVA DE SEGURANÇA ============ */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

img, table, .table-responsive, iframe, video, canvas, svg {
    max-width: 100%;
}

/* ============ TOAST FLUTUANTE ============ */
.fc-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1090;
    min-width: 280px;
    max-width: min(420px, calc(100vw - 2rem));
    padding: 0.85rem 1rem;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    animation: fc-toast-in .2s ease;
}

.fc-toast--sucesso { background: #198754; }
.fc-toast--erro    { background: #dc3545; }

@keyframes fc-toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Cards expansíveis/minimizáveis (módulo Jurídico e demais telas) */
.collapsible-card {
    padding: 0;
}

.collapsible-card-header {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    user-select: none;
}

.collapsible-card-header::-webkit-details-marker {
    display: none;
}

.collapsible-card-header::before {
    content: "▸";
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.15s ease-in-out;
    color: #6c757d;
}

.collapsible-card[open] > .collapsible-card-header::before {
    transform: rotate(90deg);
}

.collapsible-card-title {
    font-weight: 600;
}

/* ============ LISTA EM CARDS (tabelas largas em mobile) ============
   Reaproveitável por qualquer tela: substitui uma <table> larga por uma
   lista de "cards" com os campos em flex-wrap (rótulo em cima, valor
   embaixo). Os campos quebram linha e o card cresce em altura conforme
   o espaço disponível, então tanto celular quanto monitor desktop
   sempre veem a linha inteira, sem precisar de rolagem horizontal —
   diferente de .table-responsive, que só empurra o problema pra
   rolagem lateral (inclusive no desktop, se a janela não for larga o
   bastante). Ver Components/Pages/Estoque/Recebimentos/Index.razor
   pro primeiro uso. */
.linhas-lista {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.linha-card {
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: #fff;
}

.linha-card:nth-child(odd) {
    background: #f8f9fa;
}

.linha-campos {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 1.5rem;
}

.linha-campo {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
}

.linha-campo-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
    margin-bottom: 0.1rem;
}

.linha-campo-valor {
    font-size: 0.92rem;
    overflow-wrap: anywhere;
}

.linha-acoes {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

/* Em telas estreitas, cada campo ocupa a linha inteira (label em cima do valor)
   em vez de tentar caber vários lado a lado — garante que nada fica cortado nem
   precisa de scroll lateral no celular. */
@media (max-width: 576px) {
    .linha-campo {
        flex: 1 1 100%;
    }

    .linha-acoes {
        margin-left: 0;
        width: 100%;
    }
}

/* ============ TELAS "PLANILHA" (Financeiro: contas a pagar, caixa, banco...) ============
   Visual compacto, tipo Excel: fonte menor, grade com bordas, cabeçalho fixo ao rolar e
   textos longos cortados com reticências (o texto inteiro aparece no title/tooltip).
   Uso: envolver a tela em <div class="tela-planilha"> e a tabela em
   <div class="planilha-scroll"><table class="tabela-planilha">...</table></div>. */
.tela-planilha {
    font-size: 0.82rem;
}

.tela-planilha h1,
.tela-planilha h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.tela-planilha > p.text-muted,
.tela-planilha .subtitulo {
    font-size: 0.78rem;
    margin-bottom: 0.5rem;
}

.tela-planilha .card {
    margin-bottom: 0.5rem !important;
}

.tela-planilha .card-header {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
}

.tela-planilha .card-body {
    padding: 0.5rem 0.6rem;
}

.tela-planilha .form-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 0.1rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.tela-planilha .form-control,
.tela-planilha .form-select {
    font-size: 0.8rem;
    padding: 0.2rem 0.45rem;
    min-height: calc(1.5em + 0.4rem + 2px);
}

.tela-planilha .form-select {
    padding-right: 1.6rem;
    background-position: right 0.4rem center;
}

.tela-planilha .btn:not(.btn-link) {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
}

.tela-planilha .row {
    --bs-gutter-y: 0.4rem;
    --bs-gutter-x: 0.6rem;
}

.tela-planilha .alert {
    padding: 0.3rem 0.6rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.planilha-scroll {
    overflow: auto;
    max-height: calc(100vh - 230px);
    border: 1px solid #c8ccd0;
    border-radius: 0.25rem;
    background: #fff;
}

.tabela-planilha {
    width: 100%;
    max-width: none;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.78rem;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
    margin: 0;
}

.tabela-planilha th,
.tabela-planilha td {
    padding: 0.18rem 0.4rem;
    border-right: 1px solid #e3e6e9;
    border-bottom: 1px solid #e3e6e9;
    white-space: nowrap;
    vertical-align: middle;
}

.tabela-planilha thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eef1f4;
    color: #343a40;
    font-weight: 600;
    font-size: 0.74rem;
    border-bottom: 1px solid #c8ccd0;
    user-select: none;
}

.tabela-planilha thead th[role="button"]:hover {
    background: #e2e6ea;
}

.tabela-planilha tbody tr:nth-child(even) td {
    background: #f8f9fa;
}

.tabela-planilha tbody tr:hover td {
    background: #fff8d6;
}

.tabela-planilha tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: #eef1f4;
    font-weight: 600;
    border-top: 1px solid #c8ccd0;
}

.tabela-planilha .num {
    text-align: right;
}

.tabela-planilha .valor-negativo {
    color: #b02a37;
}

.tabela-planilha .valor-positivo {
    color: #146c43;
}

/* Texto longo: corta com reticências; o title mostra o texto inteiro. */
.tabela-planilha .col-texto {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tabela-planilha .col-texto-curto {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Campo editável dentro da célula, com cara de célula de planilha. */
.tabela-planilha td.celula-editavel {
    padding: 0;
    min-width: 160px;
}

.tabela-planilha td.celula-editavel .form-control {
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 0.78rem;
    padding: 0.18rem 0.4rem;
    min-height: 0;
    box-shadow: none;
}

.tabela-planilha td.celula-editavel .form-control:focus {
    background: #fff;
    outline: 2px solid #217346;
    outline-offset: -2px;
}

.tabela-planilha .acoes {
    text-align: center;
}

.tabela-planilha .acoes .btn {
    font-size: 0.72rem;
    padding: 0 0.35rem;
    line-height: 1.4;
}

.tabela-planilha .badge {
    font-size: 0.68rem;
    font-weight: 500;
}

/* Cabeçalho com ordenação e autofiltro (componente CabecalhoPlanilha). */
.tabela-planilha thead th {
    overflow: visible;
}

.tabela-planilha thead th.cab-aberto {
    z-index: 30;
}

/* Com o autofiltro aberto, a caixa ganha altura para o popup não ficar cortado (tabelas pequenas). */
.planilha-scroll:has(.autofiltro) {
    min-height: 340px;
}

.cab-planilha {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    justify-content: space-between;
}

.num .cab-planilha {
    justify-content: flex-end;
}

.cab-planilha-titulo {
    cursor: pointer;
}

.cab-planilha-seta {
    font-size: 0.65rem;
    margin-left: 0.15rem;
}

.cab-planilha-btn {
    border: 1px solid #c8ccd0;
    background: #fff;
    border-radius: 2px;
    font-size: 0.65rem;
    line-height: 1;
    padding: 1px 3px;
    color: #495057;
    cursor: pointer;
}

.cab-planilha-btn:hover {
    background: #e2e6ea;
}

.cab-planilha-btn.ativo {
    background: #217346;
    border-color: #217346;
    color: #fff;
}

.autofiltro {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 20;
    width: 240px;
    background: #fff;
    border: 1px solid #adb5bd;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
    padding: 0.35rem;
    font-weight: 400;
    text-align: left;
    white-space: normal;
    text-transform: none;
}

.num .autofiltro {
    left: auto;
    right: 0;
}

.autofiltro hr {
    margin: 0.25rem 0;
}

.autofiltro-acao {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    font-size: 0.76rem;
    padding: 0.15rem 0.3rem;
}

.autofiltro-acao:hover {
    background: #e8f2ec;
}

.autofiltro-lista {
    max-height: 190px;
    overflow: auto;
    border: 1px solid #dee2e6;
    margin-top: 0.25rem;
    padding: 0.15rem 0;
}

.autofiltro-item {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    padding: 0.05rem 0.35rem;
    font-size: 0.76rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.autofiltro-item:hover {
    background: #f1f3f5;
}

.autofiltro-item span {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============ TODAS AS TABELAS (visual planilha) ============
   Deixa as tabelas Bootstrap (.table) de todas as telas compactas, com grade e cabeçalho
   cinza, como a .tabela-planilha. Só na tela (impressão fica como estava). Para manter o
   visual antigo numa tabela específica, adicione a classe .table-classica. */
@media screen {
    .content .table:not(.table-classica) {
        font-size: 0.8rem;
        line-height: 1.3;
        font-variant-numeric: tabular-nums;
        border-color: #e3e6e9;
        --bs-table-striped-bg: #f8f9fa;
        --bs-table-hover-bg: #fff8d6;
    }

    .content .table:not(.table-classica) > :not(caption) > * > * {
        padding: 0.22rem 0.45rem;
        border-right: 1px solid #e3e6e9;
        vertical-align: middle;
    }

    .content .table:not(.table-classica) > thead > tr > th,
    .content .table:not(.table-classica) > thead.table-light > tr > th,
    .content .table:not(.table-classica) > thead.table-dark > tr > th {
        background: #eef1f4;
        color: #343a40;
        font-weight: 600;
        font-size: 0.75rem;
        border-bottom: 1px solid #c8ccd0;
        white-space: nowrap;
    }

    .content .table:not(.table-classica) > tbody > tr:hover > * {
        --bs-table-bg-state: #fff8d6;
    }

    .content .table:not(.table-classica) > tfoot > tr > * {
        background: #eef1f4;
        font-weight: 600;
        border-top: 1px solid #c8ccd0;
    }

    .content .table:not(.table-classica) .btn-sm {
        font-size: 0.75rem;
        padding: 0.1rem 0.45rem;
    }

    .content .table:not(.table-classica) .form-control-sm,
    .content .table:not(.table-classica) .form-select-sm {
        font-size: 0.78rem;
        padding-top: 0.1rem;
        padding-bottom: 0.1rem;
        min-height: 0;
    }

    .content .table:not(.table-classica) .badge {
        font-size: 0.7rem;
        font-weight: 500;
    }

    .content .table-responsive {
        border: 1px solid #c8ccd0;
        border-radius: 0.25rem;
    }

    .content .table-responsive > .table {
        margin-bottom: 0;
    }
}

/* Na impressão, a tabela sai inteira (sem caixa de rolagem). */
@media print {
    .planilha-scroll {
        max-height: none !important;
        overflow: visible !important;
        border: 0;
    }

    .tabela-planilha thead th,
    .tabela-planilha tfoot td {
        position: static;
    }
}
