/*
 * 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;
}

.nv-kpi-strip__item:hover {
    background: rgba(13, 27, 42, 0.04);
    color: #0d1b2a;
}

.nv-kpi-strip__item.is-active {
    background: #0d1b2a;
    color: #fff;
    font-weight: 600;
}

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

.nv-kpi-strip__item strong {
    font-size: 1.05rem;
    color: #0d1b2a;
    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;
}

.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(13, 27, 42, 0.18);
    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 {
    background: linear-gradient(135deg, #0d1b2a 0%, #1e3a5f 100%);
    color: #fff;
    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;
}

.nv-detail-drawer__subtitle {
    margin: 2px 0 0;
    font-size: 0.78rem;
    opacity: 0.85;
    font-family: 'Roboto Mono', monospace;
}

.nv-detail-drawer__close {
    background: rgba(255,255,255,0.18);
    color: #fff;
    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: rgba(255,255,255,0.28);
}

.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: #0d1b2a;
    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: #0d1b2a;
    color: #fff;
}

/* 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; }
}
