/*
 * Sprint 7/12 — tabelas, listas, paginação, modais, drawers e overlays.
 * Apenas aparência; densidade, dimensões e posicionamento permanecem os do Dia.
 */

/* Tabelas: cabeçalho marinho e corpo sem faixas brancas. */
html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table {
    background-color: var(--nuv-surface-parent) !important;
    border-color: var(--nuv-line) !important;
    color: var(--nuv-text) !important;
    box-shadow: inset 0 0 0 0.0625rem var(--nuv-line-subtle), var(--nuv-shadow-soft);
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table thead,
html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table thead tr {
    background: var(--nuv-header-band) !important;
    color: var(--nuv-text-on-header) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table th {
    background-color: transparent !important;
    border-color: var(--nuv-line-on-header) !important;
    color: var(--nuv-text-on-header) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table tbody tr {
    background-color: var(--nuv-surface-parent) !important;
    color: var(--nuv-text) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table tbody tr:nth-child(even) {
    background-color: var(--nuv-surface-child) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table tbody tr:hover {
    background-color: var(--nuv-surface-grandchild) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table tbody tr:is(
    .selected,
    .is-selected,
    [aria-selected="true"]
) {
    background-color: var(--nuv-info-bg) !important;
    box-shadow: inset 0.1875rem 0 0 var(--nuv-navy);
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table td {
    border-color: var(--nuv-line-subtle) !important;
    color: var(--nuv-text) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) table :where(caption, small, [class*="-secondary"], [class*="-muted"]) {
    color: var(--nuv-text-soft) !important;
}

/* Listas operacionais: divisórias leves e leitura contínua. */
html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) :where(
    ul[class*="-list"],
    ol[class*="-list"],
    div[class*="-list"]
) > :where(li, [role="listitem"], [class*="-row"], [class*="-item"]) {
    border-color: var(--nuv-line-subtle) !important;
    color: var(--nuv-text) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) :where(
    ul[class*="-list"],
    ol[class*="-list"],
    div[class*="-list"]
) > :where(li, [role="listitem"], [class*="-row"], [class*="-item"]):hover {
    background-color: rgba(var(--nuv-navy-rgb), .08) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) :where(
    ul[class*="-list"],
    ol[class*="-list"],
    div[class*="-list"]
) > :where(.selected, .is-selected, [aria-selected="true"]) {
    background-color: var(--nuv-info-bg) !important;
    box-shadow: inset 0.1875rem 0 0 var(--nuv-navy);
}

/* Paginação: mesmos controles, tratados como peças elevadas. */
html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) :where(
    .list-pagination-bar,
    [class*="-pagination"],
    [class*="-pager"]
) {
    border-color: var(--nuv-line-subtle) !important;
    color: var(--nuv-text-soft) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) :where(
    .list-pagination-btn,
    .list-pagination-page,
    [class*="-pagination"] button,
    [class*="-pager"] button
) {
    background-color: var(--nuv-surface-raised) !important;
    border-color: var(--nuv-line) !important;
    color: var(--nuv-text) !important;
    box-shadow: var(--nuv-shadow-soft) !important;
}

html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) :where(
    .list-pagination-btn,
    [class*="-pagination"] button,
    [class*="-pager"] button
):hover:not(:disabled) {
    background-color: var(--nuv-surface-hover) !important;
    border-color: var(--nuv-navy) !important;
    color: var(--nuv-navy-deep) !important;
}

/* Componentes flutuantes somente quando outra página estiver ativa. */
html[data-theme="cinza"] body:has(.main-content > .page.active:not(#page-relatorios)) :where(
    .modal,
    div[class*="overlay"],
    div[class*="scrim"],
    div[class*="backdrop"]
) {
    background-color: rgba(7, 25, 38, .58) !important;
    backdrop-filter: blur(0.1875rem);
    -webkit-backdrop-filter: blur(0.1875rem);
}

html[data-theme="cinza"] body:has(.main-content > .page.active:not(#page-relatorios)) :where(
    .modal-content,
    [class*="modal-card"],
    [class*="modal-panel"],
    [class*="drawer-panel"],
    [class*="drawer-content"],
    aside[class*="drawer"]
) {
    background-color: var(--nuv-surface-parent) !important;
    border-color: var(--nuv-line) !important;
    color: var(--nuv-text) !important;
    box-shadow: inset 0 0 0 0.0625rem var(--nuv-line-subtle), var(--nuv-shadow-popover) !important;
}

html[data-theme="cinza"] body:has(.main-content > .page.active:not(#page-relatorios)) :where(
    .modal-header,
    [class*="modal-card"] > header,
    [class*="modal-panel"] > header,
    [class*="drawer-panel"] > header,
    [class*="drawer-content"] > header,
    aside[class*="drawer"] > header
) {
    background: var(--nuv-header-band) !important;
    border-color: var(--nuv-line-on-header) !important;
    color: var(--nuv-text-on-header) !important;
}

html[data-theme="cinza"] body:has(.main-content > .page.active:not(#page-relatorios)) :where(
    .modal-header,
    [class*="modal-card"] > header,
    [class*="modal-panel"] > header,
    [class*="drawer-panel"] > header,
    [class*="drawer-content"] > header,
    aside[class*="drawer"] > header
) :where(h1, h2, h3, h4, p, span, button) {
    color: var(--nuv-text-on-header) !important;
}

html[data-theme="cinza"] body:has(.main-content > .page.active:not(#page-relatorios)) :where(
    .modal-body,
    [class*="modal-card"] > main,
    [class*="modal-panel"] > main,
    [class*="drawer-body"],
    [class*="drawer-content"] > main
) {
    background-color: var(--nuv-surface-parent) !important;
    color: var(--nuv-text) !important;
}

html[data-theme="cinza"] body:has(.main-content > .page.active:not(#page-relatorios)) :where(
    .modal-footer,
    [class*="modal-card"] > footer,
    [class*="modal-panel"] > footer,
    [class*="drawer-panel"] > footer,
    [class*="drawer-content"] > footer,
    aside[class*="drawer"] > footer
) {
    background-color: var(--nuv-surface-child) !important;
    border-color: var(--nuv-line-subtle) !important;
    color: var(--nuv-text) !important;
}

@media (prefers-reduced-motion: reduce) {
    html[data-theme="cinza"] .main-content > .page:not(#page-relatorios) :where(table tbody tr, li, [role="listitem"]),
    html[data-theme="cinza"] body:has(.main-content > .page.active:not(#page-relatorios)) :where(.modal, [class*="drawer"]) {
        transition: none !important;
    }
}
