/* ============================================================
   TABELA EM GRID UNIFICADO
   Cada coluna se ajusta ao maior conteúdo (header + body)
   Compatível com HTML do TagTable.php
   ============================================================ */

.table.modelo {
    display: grid;
    grid-auto-rows: auto;
    grid-auto-rows: min-content;
    gap: var(--gap_md);
    max-width: 100%;
    scrollbar-width: none;
}

body:not(:has(.modal)) .table.modelo:has(.no_data_row) {
    /* max-width: 100%;
    width: 520px !important; */
}

/* =========================
   TÍTULO + BOTÕES DE AÇÃO
   ========================= */
.table.modelo .table_title_actionButtons_container {
    display: grid;
    grid-template-columns: 1fr auto;
    /* align-items: self-start; */
    /* gap: var(--gap_sm); */
    position: sticky;
    top: 0px;
    z-index: 5;
}

.table.modelo .table_title_actionButtons_container:empty {
    display: none;
}

.table.modelo .table_title_actionButtons_container:has(.table_action_buttons_container) {
    /* gap: var(--gap_sm); */
}

.table.modelo .table_title_actionButtons_container .table_title {
    /* background: var(--cor_principal);
    color: var(--cor_white); */
    padding: var(--padding);
    box-shadow: 0px 0px 0px 1px inset #00000017;
    border-radius: var(--border_radius);
}

.table.modelo .table_title_actionButtons_container .table_action_buttons_container {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: min-content;
    gap: var(--gap_sm);
    height: 100%;
    margin-left: var(--gap_sm);

    &:not(:has(> :not(.hidden))) {
        display: none !important;
    }
}

.table.modelo .table_action_buttons_container .action_button {
    cursor: pointer;
    padding: 0px var(--padding);
    min-width: calc(var(--padding) * 6);
    text-align: left;
    font-size: 12px;
    border-radius: var(--border_radius);
    transition: 0.3s;
}


/* =========================
   CONTAINER PRINCIPAL DA TABELA
   ========================= */
.table.modelo .table_header_body_container_shadow {
    box-shadow: 0px 2px 4px 0px #00000052;
    box-shadow: 0px 10px 15px -10px #00000052;
    border-radius: var(--border_radius);
    overflow: auto;
}

.table.modelo .table_header_body_container {
    display: grid;
    border-radius: var(--border_radius);
    overflow-x: auto;

    /* Define o grid unificado (todas as colunas compartilham largura) */
    grid-auto-rows: min-content;
    grid-template-columns: auto;
    /* ajusta automaticamente */
}

/* =========================
   HEADER E BODY (usam display: contents)
   ========================= */
.table.modelo .header,
.table.modelo .body {
    display: contents;
    /* herdam o grid do container principal */

    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;

    background: var(--cor_white);
}

.table.modelo .body {
    .row {

        .table_item:first-child {}
    }
}

/* =========================
   LINHAS (usam display: contents)
   ========================= */
.table.modelo .row {
    display: contents;
    /* cada célula se encaixa nas colunas globais */

    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
}

/* =========================
   CABEÇALHO
   ========================= */
.table.modelo .header .row {
    background: var(--cor_principal_escura);
}

.table.modelo .header .table_item {
    background: var(--cor_principal_escura);
    color: var(--cor_white);
    padding: var(--padding);
    position: sticky;
    top: 0;
    z-index: 3;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: auto;
    /* Somente para contrapor o .no_grow */


    /* background: var(--cor_white);
    color: var(--cor_principal);
    border-bottom: 1px solid var(--cor_light_gray);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 12px; */
}

.table.modelo .header .table_item:empty {
    padding: 0px;
}

.table.modelo .header .table_item[data-attr] {
    cursor: pointer;
    padding-left: 20px;
}

.table.modelo .header .table_item[data-attr]::before {
    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 900);
    content: "\f0dc";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    opacity: 0.6;
    transition: 0.3s;
}

.table.modelo .header .table_item[data-order="asc"]::before {
    content: "\f0d7";
    opacity: 1;
}

.table.modelo .header .table_item[data-order="desc"]::before {
    content: "\f0d8";
    opacity: 1;
}

/* =========================
   CORPO DA TABELA
   ========================= */
.table.modelo .body .table_item {
    /* background: var(--cor_white); */
    /* border-bottom: 1px solid #eee; */
    padding: 0 var(--padding);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    align-content: center;
    min-height: 32px;
}

.table.modelo .body .table_item.has_items {
    /* display: flex;
    align-items: center;
    
    align-items: flex-start;
    padding-top: var(--gap_sm);
    padding-bottom: var(--gap_sm);
    flex-wrap: wrap;
    gap: var(--gap_sm); */

    /* Alteração apó fazer o GRID do tagTable existir e o agendamento_array ficar errado */
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;

    padding-top: var(--gap_sm);
    padding-bottom: var(--gap_sm);

    gap: 2px var(--gap_sm);

    &:has(.flex_column) {
        flex-direction: column;
        justify-content: space-around;
        align-items: flex-start;
        gap: var(--gap_sm);
        padding-top: var(--padding);
        padding-bottom: var(--padding);
    }
}

.table.modelo .body .table_item:has(.table_sub_item.no_padding) {
    padding: 0 !important;
}

.table.modelo .body .table_item:has(.table_action_button) {
    padding: 0 !important;
}

.table.modelo .body .table_item:has(.chip) {
    /* padding: 0px calc(var(--padding) / 2); */
}

.table.modelo .body .table_item:has(.sticky_left) {
    position: sticky !important;
    left: 0px;
    z-index: 1;
    background: var(--cor_white);
}

.table.modelo:not(.cards) .body .row:nth-child(even) {
    background: #fff;
    filter: brightness(0.97);
}

.table.modelo .body .row:has([name=selected_rows]:checked) .table_sub_item:not(.table_action_button) {
    text-decoration: line-through;
    opacity: 0.6;
    pointer-events: none;
}

@media (pointer: fine) {
    .table.modelo .body .row:hover {
        background: #fff;
        /* cursor: pointer; */
        z-index: 2;
        box-shadow: 0px 2px 3px -1px #00000052;
        filter: brightness(0.95) !important;
    }
}

/* =========================
   CÉLULAS
   ========================= */
.table.modelo .table_item.has_items .table_sub_item {
    height: auto;

    &:empty {
        display: none;
    }
}

.table.modelo .table_sub_item {
    /* padding: 3px var(--padding); */
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    /* white-space: nowrap; */
    text-overflow: ellipsis;
    /* align-content: center; */
    display: grid;
    grid-auto-flow: column;
    justify-content: start;
    gap: var(--gap_sm);
    align-items: center;
}

/* .table.modelo .table_sub_item:first-child {
    padding-left: var(--padding);
}
.table.modelo .table_sub_item:last-child {
    padding-right: var(--padding);
} */

/* =========================
   LINHA DE “SEM DADOS”
   ========================= */
.table.modelo .no_data_row {
    display: grid;
    grid-auto-flow: column;
    grid-column: 1 / -1;
    background: var(--cor_lighter_red);
    color: var(--cor_dark_red);
    padding: var(--padding) calc(var(--padding) * 2);
    text-align: center;
    /* border-top: 2px solid var(--cor_white); */
    align-items: center;
    justify-content: center;
    gap: var(--gap_sm);
}

/* =========================
   BOTÕES DE CHECKBOX (DENTRO DAS CÉLULAS)
   ========================= */
.table.modelo .table_sub_item.table_action_button input[name="selected_rows"] {

    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;

}

/* =========================
   BOTÕES DE AÇÃO (DENTRO DAS CÉLULAS)
   ========================= */
.table.modelo .table_item:has(.table_action_button) {
    /* width: max(40px, calc(var(--padding) * 5)); */
}

.table.modelo .table_sub_item.table_action_button {
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 100%;
    min-width: calc(var(--padding) * 6);
    width: 100%;
    cursor: pointer;
    padding: var(--padding);
    text-align: center;
    transition: 0.2s;
    border-radius: 0;
    /* box-shadow: -3px 0px 0px 0px inset #00000017; */
    box-shadow: 0px 0px 0px 1px inset #00000017;

    /* box-shadow: -9px 0px 4px -6px inset #00000030; */
    span {
        font-weight: normal !important;
    }

    i {
        width: 15px;
    }
}

@media (pointer: fine) {
    .table.modelo .table_sub_item.table_action_button:hover {
        /* opacity: 0.6; */
    }
}

/* Mantém as cores originais */
.table.modelo .table_action_button.action_edit,
.table.modelo .table_action_button.action_edit::before {
    background: var(--cor_yellow);
    color: var(--cor_darker_yellow);

    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 900);
    content: var(--fa);
    --fa: "\f044";
}

.table.modelo .table_action_button.action_view,
.table.modelo .table_action_button.action_view::before {
    background: var(--cor_light_blue);
    color: var(--cor_darker_blue);

    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 900);
    content: var(--fa);
    --fa: "\f06e";
}

.table.modelo .table_action_button.action_delete,
.table.modelo .table_action_button.action_delete::before {
    background: var(--cor_red);
    color: var(--cor_white);

    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 900);
    content: var(--fa);
    --fa: "\f55a";
}

.table.modelo .table_action_button.action_add,
.table.modelo .table_action_button.action_add::before {
    background: var(--cor_light_green);
    color: var(--cor_darker_green);

    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 900);
    content: var(--fa);
    --fa: "\f0fe";
}

/* .table.modelo .table_action_button.action_sincronize,
.table.modelo .table_action_button.action_sincronize::before {
    background: var(--cor_yellow);
    color: var(--cor_darker_yellow);
    
    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 900);
    content: var(--fa);
    --fa: "\f247";
} */
.table.modelo .table_action_button.action_select:hover::before {
    color: var(--cor_red);
}

.table.modelo .table_action_button.action_select:has(input[type="checkbox"]:not(:checked)),
.table.modelo .table_action_button.action_select:has(input[type="checkbox"]:not(:checked))::before {
    background: var(--cor_principal_escura);
    color: var(--cor_gray);

    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 400);
    content: var(--fa);
    --fa: "\f146";
}

.table.modelo .table_action_button.action_select.drag_selecting:has(input[type="checkbox"]:not(:checked))::before {
    background: var(--cor_principal_escura);
    color: var(--cor_yellow);

    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 400);
    content: var(--fa);
    --fa: "\f146";
}

.table.modelo .table_action_button.action_select:has(input[type="checkbox"]:not(:checked)):hover::before {
    color: var(--cor_yellow);
}

.table.modelo .table_action_button.action_select:has(input[type="checkbox"]:checked),
.table.modelo .table_action_button.action_select:has(input[type="checkbox"]:checked)::before {
    background: var(--cor_principal_escura);
    color: var(--cor_yellow);

    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 900);
    content: var(--fa);
    --fa: "\f14a";
}

.table.modelo .table_action_button.action_select:has(input[type="radio"]:not(:checked)),
.table.modelo .table_action_button.action_select:has(input[type="radio"]:not(:checked))::before {
    background: var(--cor_principal_escura);
    color: var(--cor_gray);

    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 400);
    content: var(--fa);
    --fa: "\f111";
}

.table.modelo .table_action_button.action_select:has(input[type="radio"]:not(:checked)):hover::before {
    color: var(--cor_yellow);
}

.table.modelo .table_action_button.action_select:has(input[type="radio"]:checked),
.table.modelo .table_action_button.action_select:has(input[type="radio"]:checked)::before {
    background: var(--cor_principal_escura);
    color: var(--cor_yellow);

    font-family: var(--fa-style-family, "Font Awesome 6 Free");
    font-weight: var(--fa-style, 900);
    content: var(--fa);
    --fa: "\f192";
}

/* Ícones */
.table.modelo .table_sub_item.table_action_button::before {
    text-shadow: 2px 2px 3px #0000003d;
    line-height: normal;
}

/* =========================
   COMPLEMENTOS
   ========================= */
.table.modelo .table_item i {
    /* width: 15px; */
    text-align: center;
    line-height: normal;
}

.table.modelo .table_sub_item.chip {
    width: fit-content;
    margin: 2px 0px;
}

.table.modelo .body .table_item:has(img) {
    padding: 0px;
}

.table.modelo .table_sub_item p {
    color: inherit;
}

.table.modelo .table_sub_item u {
    color: inherit;
}

.table.modelo .table_sub_item a {
    color: var(--cor_blue);

    &:hover {
        text-decoration: underline !important;
    }
}

.table.modelo .table_sub_item img {
    height: 32px;
    scale: 1;
}

.table.modelo .body .table_item mark {
    background: var(--cor_red);
    color: var(--cor_white);
}

/* Não sei pq tinha esse bloco de codigo */
/* Mas estava ferrando com a LOJA */
/* @media (min-width:600px){
    .modal .table.modelo.cards .body{
        display: flex !important;
        flex-wrap: nowrap !important;
    }
} */
.table.modelo.cards {

    .table_header_body_container_shadow {
        box-shadow: none;
    }

    .header {
        display: none;
    }

    .body {
        display: flex;
        gap: var(--gap_lg) var(--gap_sm);
        flex-wrap: wrap;
        /* justify-content: center; */
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        width: fit-content;
        width: 100%;
        max-width: 100%;

        .row {
            display: flex;
            flex-direction: column;
            gap: var(--gap_sm);
            grid-column: auto;
            flex: 0 0 auto;
            border-radius: var(--border_radius);
            padding: var(--padding);
            /* background: var(--cor_light_gray); */

            @media (max-width: 800px) {
                /* width: calc(50% - var(--gap_sm)); */
            }

            &:hover {
                box-shadow: none;
                cursor: pointer;

                .table_sub_item:has(img)::after {}

                img {
                    scale: 1.1;
                }
            }
        }

        .table_item {
            min-height: 0px;
            padding: 0px var(--padding);
            white-space: normal;
            padding: 0px !important;

            &:has(.chip) {
                padding: 0px !important;
            }

            &:has(img) {
                /* margin-bottom: 10px; */
            }

            &:has(.table_sub_item.grow) {
                flex-grow: 1;
            }

            &:has(.table_sub_item.table_action_button) {
                /* padding: 0px var(--padding) !important; */
            }

            .table_sub_item {
                white-space: normal;
                box-shadow: none;

                &:has(img) {
                    aspect-ratio: 16 / 9;
                    border-radius: var(--border_radius);
                    overflow: hidden;
                    align-content: center;
                    position: relative;

                    &::after {
                        content: "";
                        position: absolute;
                        width: 100%;
                        height: 100%;
                        border: 2px solid #00000080;
                        box-sizing: border-box;
                        transition: 0.3s;
                    }
                }

                img {
                    transition: 0.3s;
                }

                &.table_action_button {
                    border-radius: var(--border_radius);
                }
            }

        }

    }

    .table_sub_item {

        img {
            width: 100%;
            height: auto;
        }
    }

}

@media (max-width: 600px) {

    .table.modelo {
        width: 100% !important;

        .body {
            .row {}

            .table_item {
                min-height: 42px;
            }
        }

    }

    .table.modelo .table_title_actionButtons_container {

        /* display: flex;
        flex-direction: column; */
        .table_action_buttons_container {
            display: flex;

            .action_button {
                padding: var(--padding);
                flex: 1 1 auto;
            }
        }
    }

    /* body:not(:has(.modal)) .table.modelo:has(.no_data_row) {
        width: 100% !important;
    } */

    /* .table.modelo .body .table_item{
        min-height: 52px;
    } */



}