/*
 * NV UX Components — primitivas reutilizáveis pra reduzir densidade visual
 *
 * 1. nv-kpi-strip       — barra horizontal compacta de KPIs (substitui cards grandes)
 * 2. nv-detail-drawer   — drawer lateral pra detalhes (master/detail)
 * 3. nv-density-toggle  — toggle compact/comfortable + classes de densidade
 * 4. nv-table-compact   — tabela densa com hover ativo
 */

/* ============================================================
 * KPI STRIP — barra horizontal de filtros/contadores
 * Substitui os cards grandes do topo das listagens
 * ============================================================ */
.nv-kpi-strip {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: stretch;
    margin: 14px 0;
    padding: 4px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.nv-kpi-strip__item {
    flex: 1 1 auto;
    min-width: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--color-muted, #6c757d);
    font-size: 0.84rem;
    line-height: 1.2;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    border: 0;
    background: transparent;
}

/* Tema claro (13/09/2026): o ativo deixou de ser um bloco marinho — é a tinta
   laranja da marca com texto grafite (5,2:1). Tokens em style.css (:root --nv-*). */
.nv-kpi-strip__item:hover {
    background: rgba(28, 25, 23, 0.04);
    color: var(--nv-ink, #1c1917);
}

.nv-kpi-strip__item.is-active {
    background: var(--nv-primary-soft, #fff3e8);
    color: var(--nv-primary-ink-2, #a34f12);
    box-shadow: inset 0 0 0 1px var(--nv-primary-line, #f5cfae);
    font-weight: 600;
}

.nv-kpi-strip__item.is-active strong {
    color: var(--nv-ink, #1c1917);
}
/* o !important de baixo pinta de branco o número do ativo COLORIDO (verde,
   âmbar…); o ativo padrão agora é claro e o número volta a ser grafite */
.nv-kpi-strip__item.is-active:not(.is-ok):not(.is-warn):not(.is-err):not(.is-info) strong {
    color: var(--nv-ink, #1c1917) !important;
}

.nv-kpi-strip__item strong {
    font-size: 1.05rem;
    color: var(--nv-ink, #1c1917);
    font-weight: 700;
}

/* Cores por estado */
.nv-kpi-strip__item.is-ok strong { color: #059669; }
.nv-kpi-strip__item.is-warn strong { color: #d97706; }
.nv-kpi-strip__item.is-err strong { color: #dc2626; }
.nv-kpi-strip__item.is-info strong { color: #6366f1; }

.nv-kpi-strip__item.is-ok.is-active { background: #059669; }
.nv-kpi-strip__item.is-warn.is-active { background: #d97706; }
.nv-kpi-strip__item.is-err.is-active { background: #dc2626; }
.nv-kpi-strip__item.is-info.is-active { background: #6366f1; }

.nv-kpi-strip__item.is-active strong {
    color: #fff !important;
}

/* O número já virava branco no chip colorido ativo, mas o RÓTULO ao lado dele
   continuava herdando o laranja escuro do .is-active padrão — laranja escuro
   sobre fundo vermelho não se lê. Virou visível em 03/10/2026, quando o painel
   de análise do Catálogo passou a jogar o operador para o chip "Perdendo" o
   tempo todo. O chip colorido ativo é sólido: tudo dentro dele é branco. */
.nv-kpi-strip__item.is-ok.is-active,
.nv-kpi-strip__item.is-warn.is-active,
.nv-kpi-strip__item.is-err.is-active,
.nv-kpi-strip__item.is-info.is-active {
    color: #fff;
    box-shadow: none;
}

.nv-kpi-strip__sep {
    width: 1px;
    background: #dee2e6;
    margin: 4px 0;
    flex: 0 0 auto;
}

/* Versão sem fundo (mais discreto) */
.nv-kpi-strip--flat {
    background: transparent;
    border: 0;
    padding: 0;
    border-bottom: 1px solid #e9ecef;
    border-radius: 0;
    padding-bottom: 8px;
}

/* ============================================================
 * DETAIL DRAWER — painel lateral à direita pra detalhes
 * Substitui modais de detalhes + reduz colunas da tabela
 * ============================================================ */
.nv-detail-drawer {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: none;
    pointer-events: none;
}

.nv-detail-drawer.is-open {
    display: block;
    pointer-events: auto;
}

.nv-detail-drawer__overlay {
    position: absolute;
    inset: 0;
    background: rgba(28, 25, 23, 0.22);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nv-detail-drawer.is-open .nv-detail-drawer__overlay {
    opacity: 1;
}

.nv-detail-drawer__panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 560px;
    max-width: 95vw;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

.nv-detail-drawer.is-open .nv-detail-drawer__panel {
    transform: translateX(0);
}

.nv-detail-drawer__header {
    /* claro, como o cabeçalho das telas: fio laranja no topo + borda embaixo */
    background: linear-gradient(120deg, #ffffff 0%, #ffffff 55%, #fff4ea 100%);
    color: var(--nv-ink, #1c1917);
    border-top: 3px solid var(--nv-primary, #e37220);
    border-bottom: 1px solid var(--nv-line, #e9e4de);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.nv-detail-drawer__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--nv-ink, #1c1917);
}

.nv-detail-drawer__subtitle {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: var(--nv-muted, #6b6560);
    font-family: 'Roboto Mono', monospace;
}

.nv-detail-drawer__close {
    background: var(--nv-line-soft, #f2eee9);
    color: var(--nv-ink-soft, #44403c);
    border: 0;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 0.92rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nv-detail-drawer__close:hover {
    background: var(--nv-primary-soft, #fff3e8);
    color: var(--nv-primary-ink-2, #a34f12);
}
.nv-detail-drawer__close:focus-visible {
    outline: 2px solid var(--nv-primary, #e37220);
    outline-offset: 2px;
}

.nv-detail-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}

.nv-detail-drawer__footer {
    border-top: 1px solid #e9ecef;
    padding: 12px 18px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: #f8f9fa;
}

/* Seções dentro do drawer */
.nv-detail-section {
    margin-bottom: 18px;
}

.nv-detail-section__title {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    margin: 0 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e9ecef;
}

.nv-detail-section dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 14px;
    row-gap: 6px;
    margin: 0;
    font-size: 0.86rem;
}

.nv-detail-section dt {
    color: #6c757d;
    font-weight: 400;
}

.nv-detail-section dd {
    margin: 0;
    color: var(--nv-ink, #1c1917);
    font-weight: 500;
}

/* Linha clicável (que abre o drawer) */
.nv-row-clickable {
    cursor: pointer;
    transition: background 0.1s;
}

.nv-row-clickable:hover {
    background: rgba(99, 102, 241, 0.04);
}

.nv-row-clickable.is-selected {
    background: rgba(99, 102, 241, 0.08);
    box-shadow: inset 3px 0 0 #6366f1;
}

/* ============================================================
 * DENSITY TOGGLE — controle de densidade
 * ============================================================ */
.nv-density-toggle {
    display: inline-flex;
    gap: 0;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    font-size: 0.78rem;
}

.nv-density-toggle button {
    background: transparent;
    border: 0;
    padding: 6px 10px;
    cursor: pointer;
    color: #6c757d;
    font-size: 0.84rem;
    line-height: 1;
    transition: background 0.15s;
}

.nv-density-toggle button:hover {
    background: #f1f3f5;
}

.nv-density-toggle button.is-active {
    background: var(--nv-primary-soft, #fff3e8);
    color: var(--nv-primary-ink-2, #a34f12);
}

/* Classes aplicadas em <body> para controlar densidade global da listagem */
body.nv-density-compact .nv-density-target {
    /* Compacto: 1 linha, sem descrição */
}

body.nv-density-compact .nv-density-target .nv-density-hide-compact {
    display: none !important;
}

body.nv-density-compact .nv-density-target tr {
    height: 36px;
}

body.nv-density-compact .nv-density-target td,
body.nv-density-compact .nv-density-target th {
    padding: 4px 8px !important;
    font-size: 0.78rem;
}

body.nv-density-compact .nv-density-target .nv-pill {
    font-size: 0.7rem;
    padding: 1px 6px;
}

/* Modo confortável (default) — nada precisa mudar */
body.nv-density-comfortable .nv-density-target tr {
    height: auto;
}

/* ============================================================
 * TOOLBAR — barra superior compacta com ações
 * ============================================================ */
.nv-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 12px 0;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.nv-toolbar__group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.nv-toolbar__group + .nv-toolbar__group {
    border-left: 1px solid #e9ecef;
    padding-left: 8px;
    margin-left: 4px;
}

.nv-toolbar__spacer {
    flex: 1;
}

.nv-toolbar input[type="search"] {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.84rem;
    min-width: 200px;
}

/* ============================================================
 * TABLE COMPACT — tabela densa com hover acentuado
 * ============================================================ */
.nv-table-compact {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    background: #fff;
}

.nv-table-compact thead th {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 8px 10px;
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.nv-table-compact tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
}

.nv-table-compact tbody tr:last-child td {
    border-bottom: 0;
}

.nv-table-compact .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Empty state */
.nv-table-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

/* Responsive */
@media (max-width: 900px) {
    .nv-detail-drawer__panel { width: 100%; }
    .nv-kpi-strip__item { min-width: 70px; padding: 5px 8px; font-size: 0.78rem; }
    .nv-toolbar input[type="search"] { min-width: 140px; }
}

/* --- NVConfirm: caixa de confirmação do sistema (substitui o confirm() do navegador) --- */
.nvcf{ position:fixed; inset:0; z-index:99999; display:flex; align-items:center; justify-content:center; padding:20px; }
.nvcf__fundo{ position:absolute; inset:0; background:rgba(28,25,23,.42); backdrop-filter:blur(2px); }
.nvcf__cx{ position:relative; width:100%; max-width:460px; background:var(--ck-surface, #fff);
  color:var(--ck-ink, #1c1917); border-radius:16px; padding:22px 22px 18px;
  box-shadow:0 18px 50px rgba(28,25,23,.26); animation:nvcf-in .13s ease-out; }
@keyframes nvcf-in{ from{ opacity:0; transform:translateY(6px) scale(.985); } to{ opacity:1; transform:none; } }
.nvcf__tt{ margin:0 0 8px; font-size:1.02rem; font-weight:800; line-height:1.3; }
.nvcf__tx{ margin:0 0 6px; font-size:.88rem; line-height:1.5; color:var(--ck-ink, #1c1917); }
.nvcf__det{ margin:0; font-size:.8rem; line-height:1.45; color:var(--ck-muted, #64748b); }
.nvcf__acoes{ display:flex; gap:8px; justify-content:flex-end; margin-top:18px; flex-wrap:wrap; }
.nvcf__b{ appearance:none; font-family:inherit; font-size:.84rem; font-weight:700; cursor:pointer;
  padding:9px 16px; border-radius:10px; border:1px solid var(--ck-border, #e2e8f0); background:var(--ck-surface, #fff);
  color:var(--ck-ink, #1c1917); }
.nvcf__b:hover{ border-color:var(--ck-green, #2f7a5e); }
.nvcf__b:focus-visible{ outline:2px solid var(--ck-green, #2f7a5e); outline-offset:2px; }
.nvcf__b--sim{ background:var(--ck-green, #2f7a5e); border-color:var(--ck-green, #2f7a5e); color:#fff; }
.nvcf__b--sim:hover{ filter:brightness(1.06); }
.nvcf__b--sim.is-perigo{ background:#b0524b; border-color:#b0524b; }
body.nvcf-aberto{ overflow:hidden; }
@media (max-width:480px){
  .nvcf__acoes{ flex-direction:column-reverse; }
  .nvcf__b{ width:100%; }
}
