/* =========================================================
   AppDataTable

   Estilos independentes. Tokens --ui-* são opcionais:
   sem tema externo, cada variável usa seu valor de fallback.
   Medidas em rem; ícones SVG e spinner pertencem ao componente.
   ========================================================= */

.adt{
    display: block;
    width: 100%;
    font-family: var(--ui-font, system-ui, sans-serif);
    font-size: 0.75rem;
    color: var(--ui-ink, #202020);
}

/* ---- Barra de cima ---- */
.adt_bar{
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 0.0625rem solid var(--ui-line, #dedede);
    border-bottom: 0;
    border-radius: var(--ui-radius, .75rem) var(--ui-radius, .75rem) 0 0;
    background: var(--ui-surface, #fff);
}

.adt_search{
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
}

/* ---- Ícones próprios (SVG inline, gerados pelo helper icone()) ---- */
.adt_icon{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    line-height: 0;
}

.adt_icon svg{
    display: block;
    width: 1rem;
    height: 1rem;
}

.adt_search .adt_icon{
    position: absolute;
    left: 0.625rem;
    color: var(--ui-ink-2, #616161);
    pointer-events: none;
}

.adt_search .adt_icon svg{
    width: 0.875rem;
    height: 0.875rem;
}

.adt_search_input{
    width: 100%;
    height: 2rem;
    min-height: 2rem;
    padding: 0 0.75rem 0 2rem;
    border: 0.0625rem solid transparent;
    border-radius: var(--ui-radius-sm, .5rem);
    background: var(--ui-surface-2, #f6f6f6);
    box-shadow: none;
    font-size: 0.75rem;
}

.adt_search_input:focus{
    border-color: #ababab;
    background: var(--ui-surface, #fff);
    outline: 0.125rem solid #30303052;
    outline-offset: 0.0625rem;
}

.adt_tools{
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sem ferramentas, remove também o espaço que o gap reservaria ao lado da busca. */
.adt_tools:empty{
    display: none;
}

/* ---- Barra de seleção ---- */
.adt_selection{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 0.0625rem solid var(--ui-line, #dedede);
    border-bottom: 0;
    background: var(--ui-surface-3, #eee);
}

.adt_selection[hidden]{
    display: none;
}

.adt_selection_count{
    font-weight: var(--ui-weight-semibold, 600);
}

.adt_selection_actions{
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---- Tabela ---- */
.adt_frame{
    /* Tabela larga rola sozinha, sem empurrar a página inteira */
    overflow-x: auto;
    border: 0.0625rem solid var(--ui-line, #dedede);
    border-radius: 0 0 var(--ui-radius, .75rem) var(--ui-radius, .75rem);
    background: var(--ui-surface, #fff);
}

.adt_bar + .adt_frame,
.adt_selection + .adt_frame{
    border-top: 0;
}

.adt:not(:has(.adt_bar)) .adt_frame{
    border-radius: var(--ui-radius, .75rem);
}

.adt_table{
    width: 100%;
    border-collapse: collapse;
    background: var(--ui-surface, #fff);
}

.adt_table th,
.adt_table td{
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.adt_table thead th{
    height: 2.25rem;
    padding: 0.375rem 0.75rem;
    background: var(--ui-surface-2, #f6f6f6);
    border-bottom: 0.0625rem solid var(--ui-line, #dedede);
    color: var(--ui-ink-2, #616161);
    font-size: 0.75rem;
    font-weight: var(--ui-weight-medium, 500);
}

.adt_sortable{
    cursor: pointer;
    user-select: none;
}

.adt_sortable:hover{
    color: var(--ui-ink, #202020);
}

/* Ícone de ordenação: quadradinho cinza claro com a seta (pedido de
   08/09/2026). Coluna ordenável mostra as duas setinhas discretas; a coluna
   ordenada mostra UMA seta, verde, na direção atual. */
.adt_sort_box{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    margin-left: 0.375rem;
    vertical-align: -4px;
    border-radius: 0.3125rem;
    border: 0.0625rem solid var(--ui-line, var(--ui-line, #dedede));
    background: var(--ui-surface-3, #f1f2f3);
    flex: 0 0 auto;
    transition: background .12s, border-color .12s;
}
.adt_sort_icon{
    width: 0.75rem;
    height: 0.75rem;
    display: block;
}
.adt_sort_icon path{
    fill: none;
    stroke: var(--ui-ink-3, #8a8f94);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.adt_sort_icon .adt_sort_up,
.adt_sort_icon .adt_sort_down{
    display: none;
}
.adt_sortable:hover .adt_sort_box{
    border-color: var(--ui-line-2, var(--ui-line, #dedede));
    background: var(--ui-surface-3, #eee);
}
.adt_sortable:hover .adt_sort_icon path{
    stroke: var(--ui-ink, #202223);
}
.adt_sorted_asc .adt_sort_icon .adt_sort_both,
.adt_sorted_desc .adt_sort_icon .adt_sort_both{
    display: none;
}
/* Ordenada: fundo cinza claro e a seta em preto — a identidade do admin é
   preto e cinza, sem cor de destaque aqui. */
.adt_sorted_asc .adt_sort_icon .adt_sort_up,
.adt_sorted_desc .adt_sort_icon .adt_sort_down{
    display: block;
    stroke: var(--ui-ink, #202223);
    stroke-width: 2.2;
}
.adt_sorted_asc .adt_sort_box,
.adt_sorted_desc .adt_sort_box{
    border-color: var(--ui-line-2, var(--ui-line, #dedede));
}

.adt_table tbody td{
    height: 3.25rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 0.0625rem solid var(--ui-line-2, #ededed);
    color: var(--ui-ink, #202020);
    font-size: 0.75rem;
}

.adt_table tbody tr:last-child td{
    border-bottom: 0;
}

.adt_row:hover td{
    background: var(--ui-surface-2, #f6f6f6);
}

.adt_row_on td{
    background: #f0f6ff;
}

.adt_right{
    text-align: right !important;
}

/* ---- Coluna de seleção ---- */
.adt_col_check{
    width: 1.25rem;
    padding-right: 0 !important;
}

.adt_col_check input{
    width: 1rem;
    height: 1rem;
    min-height: 0;
    margin: 0;
    padding: 0;
    accent-color: var(--ui-ink, #202020);
    cursor: pointer;
}

/* ---- Conteúdo comum de célula ---- */
.adt_cell_media{
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.adt_thumb{
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border: 0.0625rem solid var(--ui-line, #dedede);
    border-radius: var(--ui-radius-sm, .5rem);
    background: var(--ui-surface-2, #f6f6f6);
    object-fit: cover;
}

.adt_thumb_round{
    border-radius: 50%;
}

.adt_thumb_wide{
    width: 6rem;
}

.adt_title{
    color: var(--ui-ink, #202020);
    font-weight: var(--ui-weight-medium, 500);
    text-decoration: none;
}

.adt_title:hover{
    text-decoration: underline;
}

.adt_sub{
    display: block;
    color: var(--ui-ink-2, #616161);
    font-size: 0.6875rem;
}

/* Selo de estado dentro da tabela */
.adt_badge{
    display: inline-block;
    padding: 0 0.5rem;
    border-radius: var(--ui-radius-sm, .5rem);
    background: var(--ui-surface-3, #eee);
    color: var(--ui-ink, #202020);
    font-size: 0.75rem;
    font-weight: var(--ui-weight-medium, 500);
    line-height: 1.25rem;
    white-space: nowrap;
}

.adt_badge_ok{ background: var(--ui-success-bg, #e7f5ed); color: var(--ui-success-ink, #16703b); }
.adt_badge_warn{ background: var(--ui-warning-bg, #fff5d6); color: var(--ui-warning-ink, #7a5500); }
.adt_badge_off{ background: var(--ui-surface-3, #eee); color: var(--ui-ink-2, #616161); }
.adt_badge_critical{ background: var(--ui-critical-bg, #ffebe9); color: var(--ui-critical-ink, #b42318); }

/* ---- Vazio e erro ---- */
.adt_empty td{
    height: auto !important;
    padding: 2.5rem 1.25rem !important;
    border-bottom: 0 !important;
}

.adt_empty_box{
    text-align: center;
}

.adt_empty_box .adt_icon{
    display: flex;
    margin: 0 auto 0.625rem;
    color: var(--ui-ink-3, #777);
}

.adt_empty_box .adt_icon svg{
    width: 1.375rem;
    height: 1.375rem;
}

.adt_empty_box .adt_mascote{
    display: block;
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto 0.5rem;
}

.adt_empty_box p{
    margin: 0;
    color: var(--ui-ink, #202020);
    font-size: 0.8125rem;
    font-weight: var(--ui-weight-semibold, 600);
}

.adt_empty_box small{
    display: block;
    margin-top: 0.25rem;
    color: var(--ui-ink-2, #616161);
    font-size: 0.75rem;
}

.adt_empty_box .btn{
    margin-top: 0.875rem;
}

/* ---- Esqueleto de carregamento ---- */
.adt_skeleton td{
    padding: 0.5rem 0.75rem !important;
}

.adt_skeleton span{
    display: block;
    height: 0.75rem;
    border-radius: 0.25rem;
    background: linear-gradient(90deg, var(--ui-surface-3, #ebebeb) 25%, var(--ui-surface-2, #f4f4f4) 37%, var(--ui-surface-3, #ebebeb) 63%);
    background-size: 400% 100%;
    animation: adt_pulse 1.2s ease-in-out infinite;
}

@keyframes adt_pulse{
    0%{ background-position: 100% 50%; }
    100%{ background-position: 0 50%; }
}

/* ---- Rodapé ---- */
.adt_foot{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border: 0.0625rem solid var(--ui-line, #dedede);
    border-top: 0;
    border-radius: 0 0 var(--ui-radius, .75rem) var(--ui-radius, .75rem);
    background: var(--ui-surface, #fff);
    color: var(--ui-ink-2, #616161);
}

.adt_foot[hidden]{
    display: none;
}

.adt_foot ~ .adt_frame,
.adt:has(.adt_foot:not([hidden])) .adt_frame{
    border-radius: 0;
}

.adt_pages{
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.adt_page{
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.5rem;
    border: 0;
    border-radius: var(--ui-radius-xs, .25rem);
    background: transparent;
    color: var(--ui-ink, #202020);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: var(--ui-weight-medium, 500);
    cursor: pointer;
}

.adt_page:hover:not(:disabled){
    background: var(--ui-surface-3, #eee);
}

.adt_page_on{
    background: var(--ui-ink, #202020);
    color: var(--ui-ink-invert, #fff);
}

.adt_page_on:hover{
    background: var(--ui-ink, #202020) !important;
}

.adt_page:disabled{
    color: var(--ui-ink-3, #777);
    cursor: not-allowed;
}

.adt_gap{
    padding: 0 0.125rem;
    color: var(--ui-ink-3, #777);
}

@media (max-width: 37.5rem){
    .adt_bar{
        flex-wrap: wrap;
    }

    .adt_foot{
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .adt_pages{
        justify-content: center;
    }
}

/* =========================================================
   Abas de visualização, menus, filtros aplicados
   ========================================================= */

/* ---- Abas ---- */
.adt_views{
    display: flex;
    align-items: center;
    gap: 0.125rem;
    padding: 0.375rem 0.5rem 0;
    border: 0.0625rem solid var(--ui-line, #dedede);
    border-bottom: 0;
    border-radius: var(--ui-radius, .75rem) var(--ui-radius, .75rem) 0 0;
    background: var(--ui-surface, #fff);
}

.adt_view{
    padding: 0.375rem 0.625rem;
    border: 0;
    border-radius: var(--ui-radius-xs, .25rem);
    background: transparent;
    color: var(--ui-ink-2, #616161);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: var(--ui-weight-medium, 500);
    cursor: pointer;
}

.adt_view:hover{
    background: var(--ui-surface-3, #eee);
    color: var(--ui-ink, #202020);
}

.adt_view_on{
    background: var(--ui-surface-3, #eee);
    color: var(--ui-ink, #202020);
}

.adt_views + .adt_bar{
    border-top: 0;
    border-radius: 0;
}

/* ---- Menus suspensos ---- */
.adt_menu_wrap{
    position: relative;
    display: inline-flex;
}

.adt_menu{
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    z-index: 40;
    min-width: 13.75rem;
    max-height: 21.25rem;
    overflow-y: auto;
    padding: 0.375rem;
    border-radius: var(--ui-radius-sm, .5rem);
    background: var(--ui-surface, #fff);
    box-shadow: var(--ui-shadow, 0 .25rem 1rem #0002);
}

.adt_menu[hidden]{
    display: none;
}

.adt_menu_group{
    padding: 0.25rem 0;
    border-bottom: 0.0625rem solid var(--ui-line-2, #ededed);
}

.adt_menu_group:last-child{
    border-bottom: 0;
}

.adt_menu_group > b{
    display: block;
    padding: 0.25rem 0.5rem;
    color: var(--ui-ink-2, #616161);
    font-size: 0.6875rem;
    font-weight: var(--ui-weight-semibold, 600);
    text-transform: uppercase;
    letter-spacing: .3px;
}

.adt_menu_item{
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 0;
    border-radius: var(--ui-radius-xs, .25rem);
    background: transparent;
    color: var(--ui-ink, #202020);
    font-family: inherit;
    font-size: 0.75rem;
    text-align: left;
    cursor: pointer;
}

.adt_menu_item:hover{
    background: var(--ui-surface-2, #f6f6f6);
}

.adt_menu_item input{
    width: 0.9375rem;
    height: 0.9375rem;
    min-height: 0;
    margin: 0;
    accent-color: var(--ui-ink, #202020);
}

.adt_menu_item_critical{
    color: var(--ui-critical-ink, #b42318);
}

/* ---- Linha do gerenciador de colunas ---- */
.adt_col_row{
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.adt_col_row .adt_menu_item{
    flex: 1 1 auto;
}

.adt_col_moves{
    flex: 0 0 auto;
    display: flex;
    gap: 0.125rem;
}

.adt_col_move{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: 0;
    border-radius: var(--ui-radius-xs, .25rem);
    background: transparent;
    color: var(--ui-ink-3, #777);
    line-height: 1;
    cursor: pointer;
}

.adt_col_move:hover:not(:disabled){
    background: var(--ui-surface-3, #eee);
    color: var(--ui-ink, #202020);
}

.adt_col_move:disabled{
    opacity: .3;
    cursor: not-allowed;
}

.adt_col_move .adt_icon svg{
    width: 0.75rem;
    height: 0.75rem;
}

/* ---- Filtros aplicados ---- */
.adt_chips{
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    border: 0.0625rem solid var(--ui-line, #dedede);
    border-bottom: 0;
    background: var(--ui-surface, #fff);
}

.adt_chips[hidden]{
    display: none;
}

.adt_chip{
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.25rem 0.125rem 0.625rem;
    border-radius: 62.4375rem;
    background: var(--ui-surface-3, #eee);
    color: var(--ui-ink, #202020);
    font-size: 0.75rem;
}

.adt_chip_x{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ui-ink-2, #616161);
    font-size: 0.875rem;
    line-height: 1;
    cursor: pointer;
}

.adt_chip_x:hover{
    background: rgba(0, 0, 0, .08);
    color: var(--ui-ink, #202020);
}

.adt_chips_clear{
    padding: 0.125rem 0.5rem;
    border: 0;
    background: transparent;
    color: var(--ui-focus, #245bd6);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: var(--ui-weight-medium, 500);
    cursor: pointer;
}

.adt_chips_clear:hover{
    text-decoration: underline;
}

/* ---- Ver só os selecionados ---- */
.adt_only_selected_wrap{
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-left: auto;
    color: var(--ui-ink-2, #616161);
    font-size: 0.75rem;
    cursor: pointer;
}

.adt_only_selected_wrap input{
    width: 0.9375rem;
    height: 0.9375rem;
    min-height: 0;
    margin: 0;
    accent-color: var(--ui-ink, #202020);
}

/* ---- Itens por página ---- */
.adt_per_page_wrap{
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--ui-ink-2, #616161);
    font-size: 0.75rem;
}

.adt_per_page{
    width: auto;
    height: 1.625rem;
    min-height: 0;
    padding: 0 1.625rem 0 0.5rem;
    border-radius: var(--ui-radius-xs, .25rem);
    font-size: 0.75rem;
}

@media (max-width: 37.5rem){
    .adt_views{
        overflow-x: auto;
    }

    .adt_selection{
        flex-wrap: wrap;
    }

    .adt_only_selected_wrap{
        margin-left: 0;
    }
}
.adt_frame{ min-height: var(--adt-page-height, 0); }
.adt_frame.adt_loading{ opacity: .5; cursor: progress; }

/* Base autônoma: tokens do host são opcionais, nenhum reset externo é necessário. */
.adt, .adt * { box-sizing: border-box; }
.adt [hidden] { display: none !important; }
.adt { min-width: 0; }
.adt input, .adt select, .adt button { font-family: inherit; }
.adt input, .adt select { color: inherit; }
.adt_button {
    display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
    min-height: 2rem; padding: .375rem .75rem; border: 1px solid var(--ui-line, #dedede);
    border-radius: .5rem; background: var(--ui-surface, #fff); color: var(--ui-ink, #202020);
    font: inherit; font-weight: 500; line-height: 1.25; text-decoration: none;
    cursor: pointer; appearance: none;
}
.adt_button:hover { background: var(--ui-surface-2, #f6f6f6); }
.adt_button:disabled { opacity: .45; cursor: not-allowed; }
.adt_button:focus-visible, .adt input:focus-visible, .adt select:focus-visible, .adt_row:focus-visible {
    outline: .125rem solid var(--ui-focus, #245bd6); outline-offset: .125rem;
}
.adt .adt_sort_button { border: 0; background: transparent; padding: 0; width: 100%; justify-content: space-between; text-align: inherit; }
.adt .adt_page { padding: .25rem .5rem; }
.adt .adt_page_on, .adt .adt_view_on { background: var(--ui-surface-3, #eee); font-weight: 700; }
.adt .adt_danger { color: var(--ui-critical-ink, #b42318); }
.adt .adt_col_move, .adt .adt_chip_x { padding: .25rem; min-height: 1.5rem; }
.adt .adt_menu_group { min-width: 0; margin: 0; border: 0; }
.adt .adt_menu_group legend { font-weight: 600; padding: .5rem; }
.adt .adt_menu { max-width: min(22rem, calc(100vw - 2rem)); max-height: 24rem; overflow: auto; }
.adt .adt_empty_box { gap: .75rem; }
.adt .adt_empty_box > .adt_icon svg { width: 2rem; height: 2rem; }
.adt_live {
    min-height: 2rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .375rem .5rem;
    border-left: .0625rem solid var(--ui-line, #dedede);
    border-right: .0625rem solid var(--ui-line, #dedede);
    background: var(--ui-surface, #fff);
    color: var(--ui-ink-2, #616161);
}

/* A faixa de status fica entre a barra/filtros e o frame. Ela precisa
   continuar o contorno e assumir a união com a tabela sem linha duplicada. */
.adt_live + .adt_frame {
    border-top: 0;
}
.adt_sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.adt_spinner, .adt_spinner svg { width: 1rem; height: 1rem; display: inline-block; flex: 0 0 auto; }
.adt_spinner_dot { fill: currentColor; }
.adt_spinner_track, .adt_spinner_arc { fill: none; stroke: currentColor; stroke-width: 1.5; }
.adt_spinner_track { opacity: .25; }
.adt_spinner_arc { transform-origin: center; animation: adt-spin .8s linear infinite; }
@keyframes adt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .adt_spinner_arc { animation: none; } .adt_skeleton span { animation: none; } }
.adt_details_col, .adt_details_row { display: none; }
.adt_details_list { margin: 0; display: grid; grid-template-columns: minmax(5rem, 1fr) minmax(0, 2fr); gap: .75rem; }
.adt_details_list dt { font-weight: 600; }
.adt_details_list dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.adt_details_list img { max-width: 100%; }
@media (max-width: 37.5rem) {
    .adt, .adt_table th, .adt_table tbody td, .adt .adt_menu_item { font-size: .875rem; }
    .adt .adt_search_input, .adt .adt_per_page { font-size: 1rem; }
    .adt_bar, .adt_foot { flex-wrap: wrap; }
    .adt_search { flex: 1 1 100%; }
    .adt_tools { flex-wrap: wrap; }
    .adt_table { table-layout: fixed; width: 100%; min-width: 0; }
    .adt_table th, .adt_table td { overflow-wrap: anywhere; white-space: normal; width: auto !important; }
    .adt_table .adt_mobile_hidden { display: none; }
    .adt_table .adt_details_col { display: table-cell; width: 3.5rem !important; }
    .adt_table .adt_col_check { width: 3rem !important; }
    .adt_details_row { display: table-row; }
    .adt_button, .adt_search_input, .adt_per_page, .adt_menu_item { min-height: 2.75rem; }
    .adt .adt_col_move, .adt .adt_chip_x { min-height: 2.75rem; min-width: 2.75rem; }
    .adt .adt_page { min-width: 2.75rem; }
    .adt_pages { flex-wrap: wrap; }
    .adt_menu_cols { right: 0; }
    .adt_cell_main, .adt_cell_text { min-width: 0; }
    .adt_details_toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
}
