/* =========================================================
   NEXENG TABLE CORE v1
   Archivo global: /assets/nxg-core/nxg-table-core-v1.css
   Uso: base limpia para apps tipo tabla NEXENG.
   No contiene lógica técnica específica de una app.
   ========================================================= */

:root {
    --nxg-core-header-h: 70px;
    --nxg-core-actions-h: 48px;
    --nxg-core-summary-h: 58px;
    --nxg-core-sticky-top: calc(var(--nxg-core-header-h) + var(--nxg-core-actions-h) + var(--nxg-core-summary-h));
    --nxg-core-blue: #0284c7;
    --nxg-core-cyan: #06b6d4;
    --nxg-core-text: #0f2137;
    --nxg-core-muted: #64748b;
    --nxg-core-line: rgba(15, 87, 130, .14);
    --nxg-core-line-strong: rgba(2, 132, 199, .32);
    --nxg-core-input-bg: rgba(255, 252, 220, .92);
    --nxg-core-calc-bg: rgba(226, 243, 252, .82);
    --nxg-core-card: rgba(255,255,255,.94);
}

/* Shell ancho para apps técnicas */
.nx-app-shell.nxg-table-core,
.nxg-table-core .nx-app-shell,
.nx-iaq-shell.nxg-table-core,
.nx-duct-sizer-table-v4.nxg-table-core {
    --nx-max: 1920px;
    width: min(100% - 18px, var(--nx-max)) !important;
}

/* Header compacto estándar */
.nxg-table-core .nx-topbar,
body.nxg-table-core .nx-topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 1200 !important;
    min-height: var(--nxg-core-header-h) !important;
    margin: 0 !important;
    width: 100% !important;
    border-radius: 0 0 18px 18px !important;
    border-top: 0 !important;
    padding: 8px 24px !important;
    background: rgba(255,255,255,.96) !important;
    backdrop-filter: blur(18px) !important;
    box-shadow: 0 12px 32px rgba(15,35,60,.10) !important;
}

.nxg-table-core .nx-brand,
body.nxg-table-core .nx-brand {
    min-height: 52px !important;
    gap: 10px !important;
}

.nxg-table-core .nx-brand-mark,
body.nxg-table-core .nx-brand-mark {
    width: 52px !important;
    height: 52px !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    background: transparent !important;
    box-shadow: none !important;
    color: transparent !important;
    background-image: url("/assets/brand/nexeng-logo-header-clean-v20.png"), url("/assets/icons/nexeng-logo-header-clean-v20.png"), url("/assets/icons/icon-192.png") !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

.nxg-table-core .nx-brand-text strong,
body.nxg-table-core .nx-brand-text strong {
    font-size: .95rem !important;
    letter-spacing: .14em !important;
}

.nxg-table-core .nx-brand-text span,
body.nxg-table-core .nx-brand-text span {
    font-size: .68rem !important;
}

/* Botones */
.nxg-table-core .nx-btn,
body.nxg-table-core .nx-btn {
    min-height: 34px !important;
    padding: 0 14px !important;
    border-radius: 999px !important;
    font-size: .82rem !important;
    font-weight: 900 !important;
    white-space: nowrap !important;
}

/* Barra de acciones sticky */
.nxg-table-core .nx-action-dock,
body.nxg-table-core .nx-action-dock,
.nxg-table-core [data-nxg-actions],
body.nxg-table-core [data-nxg-actions] {
    position: sticky !important;
    top: var(--nxg-core-header-h) !important;
    z-index: 1100 !important;
    min-height: var(--nxg-core-actions-h) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    padding: 6px 24px !important;
    margin: 0 -24px 10px !important;
    border-bottom: 1px solid rgba(15,87,130,.12) !important;
    background: rgba(255,255,255,.94) !important;
    backdrop-filter: blur(16px) !important;
    box-shadow: 0 8px 22px rgba(15,35,60,.06) !important;
}

.nxg-table-core .nx-action-dock::before,
body.nxg-table-core .nx-action-dock::before,
.nxg-table-core [data-nxg-actions]::before,
body.nxg-table-core [data-nxg-actions]::before {
    content: "ACCIONES";
    flex: 0 0 auto;
    color: var(--nxg-core-blue);
    font-size: .70rem;
    font-weight: 950;
    letter-spacing: .18em;
}

/* Resumen compacto sticky */
.nxg-table-core .nx-summary-grid,
body.nxg-table-core .nx-summary-grid,
.nxg-table-core [data-nxg-summary],
body.nxg-table-core [data-nxg-summary] {
    position: sticky !important;
    top: calc(var(--nxg-core-header-h) + var(--nxg-core-actions-h)) !important;
    z-index: 1050 !important;
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 10px !important;
    padding: 10px 0 !important;
    margin-bottom: 10px !important;
    background: linear-gradient(180deg, rgba(245,248,252,.96), rgba(232,246,253,.92)) !important;
    backdrop-filter: blur(14px) !important;
}

.nxg-table-core .nx-summary-card,
body.nxg-table-core .nx-summary-card {
    min-height: 46px !important;
    padding: 9px 14px !important;
    border: 1px solid rgba(15,87,130,.13) !important;
    border-radius: 16px !important;
    background: rgba(255,255,255,.92) !important;
    box-shadow: 0 8px 22px rgba(15,35,60,.04) !important;
}

.nxg-table-core .nx-summary-card span,
body.nxg-table-core .nx-summary-card span {
    font-size: .66rem !important;
}

.nxg-table-core .nx-summary-card strong,
body.nxg-table-core .nx-summary-card strong {
    margin-top: 4px !important;
    font-size: 1.12rem !important;
}

/* Tabla genérica */
.nxg-table-core .nx-sheet-panel,
body.nxg-table-core .nx-sheet-panel,
.nxg-table-core [data-nxg-sheet-panel],
body.nxg-table-core [data-nxg-sheet-panel] {
    overflow: hidden !important;
    border: 1px solid var(--nxg-core-line-strong) !important;
    border-radius: 22px !important;
    background:
        linear-gradient(90deg, rgba(2,132,199,.035) 1px, transparent 1px),
        linear-gradient(rgba(2,132,199,.035) 1px, transparent 1px),
        rgba(255,255,255,.94) !important;
    background-size: 38px 38px !important;
    box-shadow: 0 14px 36px rgba(15,35,60,.06) !important;
}

.nxg-table-core .nx-sheet-scroll,
body.nxg-table-core .nx-sheet-scroll,
.nxg-table-core [data-nxg-sheet-scroll],
body.nxg-table-core [data-nxg-sheet-scroll] {
    width: 100% !important;
    overflow: auto !important;
    max-height: 68vh !important;
    min-height: 320px !important;
    overscroll-behavior: contain !important;
}

.nxg-table-core table.nx-sheet,
body.nxg-table-core table.nx-sheet,
.nxg-table-core .nx-iaq-sheet,
body.nxg-table-core .nx-iaq-sheet,
.nxg-table-core [data-nxg-sheet],
body.nxg-table-core [data-nxg-sheet] {
    width: max-content !important;
    min-width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    table-layout: fixed !important;
    font-size: .74rem !important;
}

.nxg-table-core table.nx-sheet th,
.nxg-table-core table.nx-sheet td,
.nxg-table-core .nx-iaq-sheet th,
.nxg-table-core .nx-iaq-sheet td,
.nxg-table-core [data-nxg-sheet] th,
.nxg-table-core [data-nxg-sheet] td,
body.nxg-table-core table.nx-sheet th,
body.nxg-table-core table.nx-sheet td,
body.nxg-table-core .nx-iaq-sheet th,
body.nxg-table-core .nx-iaq-sheet td,
body.nxg-table-core [data-nxg-sheet] th,
body.nxg-table-core [data-nxg-sheet] td {
    height: 36px !important;
    padding: 4px 6px !important;
    border-right: 1px solid rgba(120,184,215,.46) !important;
    border-bottom: 1px solid rgba(120,184,215,.46) !important;
    vertical-align: middle !important;
}

.nxg-table-core table.nx-sheet th,
.nxg-table-core .nx-iaq-sheet th,
.nxg-table-core [data-nxg-sheet] th,
body.nxg-table-core table.nx-sheet th,
body.nxg-table-core .nx-iaq-sheet th,
body.nxg-table-core [data-nxg-sheet] th {
    position: sticky !important;
    top: 0 !important;
    z-index: 50 !important;
    height: 38px !important;
    color: #35536f !important;
    background: linear-gradient(180deg, rgba(226,243,252,1), rgba(211,234,246,1)) !important;
    font-size: .62rem !important;
    font-weight: 950 !important;
    line-height: 1.05 !important;
    text-align: center !important;
    text-transform: uppercase !important;
    white-space: normal !important;
    backdrop-filter: blur(12px) !important;
}

.nxg-table-core .nx-editable,
.nxg-table-core td[data-nxg-editable],
body.nxg-table-core .nx-editable,
body.nxg-table-core td[data-nxg-editable] {
    background: var(--nxg-core-input-bg) !important;
}

.nxg-table-core .nx-calculated,
.nxg-table-core td[data-nxg-calculated],
body.nxg-table-core .nx-calculated,
body.nxg-table-core td[data-nxg-calculated] {
    background: var(--nxg-core-calc-bg) !important;
}

.nxg-table-core input,
.nxg-table-core select,
.nxg-table-core textarea,
body.nxg-table-core input,
body.nxg-table-core select,
body.nxg-table-core textarea {
    font: inherit;
}

.nxg-table-core table input,
.nxg-table-core table select,
body.nxg-table-core table input,
body.nxg-table-core table select {
    height: 27px !important;
    min-height: 27px !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 4px !important;
    background: transparent !important;
    font-size: .70rem !important;
    font-weight: 850 !important;
    outline: none !important;
}

.nxg-table-core table input:focus,
.nxg-table-core table select:focus,
body.nxg-table-core table input:focus,
body.nxg-table-core table select:focus {
    background: #fff !important;
    box-shadow: inset 0 0 0 2px rgba(2,132,199,.32) !important;
    border-radius: 8px !important;
}

/* Selección tipo Excel */
.nxg-cell-selected {
    position: relative !important;
    background: rgba(186,230,253,.72) !important;
    box-shadow: inset 0 0 0 2px rgba(2,132,199,.78) !important;
}

.nxg-selection-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 3500;
    max-width: min(420px, 92vw);
    padding: 12px 14px;
    border: 1px solid rgba(2,132,199,.22);
    border-radius: 16px;
    background: rgba(255,255,255,.96);
    color: var(--nxg-core-text);
    box-shadow: 0 14px 34px rgba(15,35,60,.14);
    font-size: .84rem;
    font-weight: 850;
}

@media (max-width: 900px) {
    .nxg-table-core .nx-summary-grid,
    body.nxg-table-core .nx-summary-grid,
    .nxg-table-core [data-nxg-summary],
    body.nxg-table-core [data-nxg-summary] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 640px) {
    .nxg-table-core .nx-topbar,
    body.nxg-table-core .nx-topbar {
        min-height: auto !important;
        padding: 8px 12px !important;
    }

    .nxg-table-core .nx-action-dock,
    body.nxg-table-core .nx-action-dock,
    .nxg-table-core [data-nxg-actions],
    body.nxg-table-core [data-nxg-actions] {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .nxg-table-core .nx-summary-grid,
    body.nxg-table-core .nx-summary-grid,
    .nxg-table-core [data-nxg-summary],
    body.nxg-table-core [data-nxg-summary] {
        grid-template-columns: 1fr !important;
    }
}
