/* ==========================================================================
   ESTILOS GERAIS DA TABELA BI (DESKTOP & MOBILE)
   ========================================================================== */

.bi-table-container {
    width: 100%;
    overflow-y: auto;
    position: relative;
}

.bi-table {
    width: 100%;
    margin-bottom: 0;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Cabeçalho fixo no Desktop */
.bi-table thead th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    color: #495057;
    z-index: 2;
    border-bottom: 2px solid #dee2e6;
    box-shadow: inset 0 -1px 0 #dee2e6;
}

/* Estilo das linhas de subtotal e total geral */
.bi-table tr.table-secondary td {
    background-color: #e9ecef !important;
    font-weight: bold;
    border-top: 2px solid #dee2e6;
}

.bi-table tr.table-dark td {
    background-color: #343a40 !important;
    color: #ffffff !important;
    font-weight: bold;
}

/* ==========================================================================
   ADAPTAÇÃO MOBILE (CARD VIEW AUTOMÁTICO PARA TELAS < 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* Desfaz o comportamento de tabela tradicional */
    .bi-table, 
    .bi-table tbody, 
    .bi-table tr, 
    .bi-table td {
        display: block;
        width: 100% !important;
        white-space: normal !important;
    }

    /* Esconde o cabeçalho original no mobile */
    .bi-table thead {
        display: none;
    }

    /* Transforma cada linha (tr) em um Card flutuante independente */
    .bi-table tr {
        background: #ffffff;
        border: 1px solid #e3e6f0;
        border-radius: 8px;
        margin-bottom: 12px;
        box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.08);
        padding: 10px 15px;
    }

    /* Se for linha de Subtotal ou Total Geral, dá destaque no mobile */
    .bi-table tr.table-secondary {
        background-color: #eaecf4 !important;
        border-left: 4px solid #4e73df;
    }

    .bi-table tr.table-dark {
        background-color: #5a5c69 !important;
        border-left: 4px solid #1cc88a;
    }

    /* Transforma cada célula (td) em um layout flexível "Rótulo : Valor" */
    .bi-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right !important;
        padding: 6px 0;
        border-bottom: 1px solid #f8f9fc;
    }

    .bi-table td:last-child {
        border-bottom: none;
    }

    /* Injeta o rótulo (data-label) automaticamente à esquerda no mobile */
    .bi-table td::before {
        content: attr(data-label);
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.75rem;
        color: #858796;
        text-align: left;
        padding-right: 15px;
        flex-shrink: 0;
    }

    /* Tratamento especial para células vazias ou espaçadores de subtotal */
    .bi-table td:empty {
        display: none;
    }
}