/* =========================================================
   NEXENG Duct Sizer Dark Mode Input + Logo Fix v3
   Corrige:
   - Logo poco visible en modo oscuro.
   - Inputs/selects/celdas de tabla con texto casi invisible.
   Capa CSS segura: no toca cálculos ni JS principal.
   ========================================================= */

/* LOGO EN MODO OSCURO
   El logo actual tiene texto azul/navy y se pierde sobre header oscuro.
   En modo oscuro lo aclaramos sin cambiar archivos de marca. */
body.nx-theme-dark .nx-brand-logo,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-brand-logo {
    filter: brightness(0) invert(1) drop-shadow(0 6px 18px rgba(0,174,239,.18)) !important;
    opacity: .96 !important;
}

/* Asegura que el logo tenga buen tamaño y no se aplaste */
body .nx-brand-logo,
body.nx-duct-sizer-core-shell-v1 .nx-brand-logo {
    object-fit: contain !important;
    object-position: left center !important;
}

/* TABLA EN MODO OSCURO
   La tabla usa fondos funcionales claros para distinguir editable/calculado.
   Por eso el texto dentro de las celdas debe permanecer oscuro. */
body.nx-theme-dark .nx-sheet tbody td,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td {
    color: #0f2238 !important;
    text-shadow: none !important;
}

/* Cualquier texto interno dentro de celdas claras */
body.nx-theme-dark .nx-sheet tbody td *,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td * {
    color: #0f2238 !important;
    text-shadow: none !important;
}

/* Inputs, selects y opciones dentro de tabla */
body.nx-theme-dark .nx-sheet tbody td input,
body.nx-theme-dark .nx-sheet tbody td select,
body.nx-theme-dark .nx-sheet tbody td textarea,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td input,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td select,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td textarea {
    color: #0f2238 !important;
    -webkit-text-fill-color: #0f2238 !important;
    background: transparent !important;
    text-shadow: none !important;
    opacity: 1 !important;
}

/* Selects dentro de tabla: que la flecha/texto no se pierdan */
body.nx-theme-dark .nx-sheet tbody td select,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td select {
    color-scheme: light !important;
}

/* Opciones del select al abrir menú */
body.nx-theme-dark .nx-sheet tbody td select option,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td select option {
    background: #ffffff !important;
    color: #0f2238 !important;
}

/* Celdas amarillas editables */
body.nx-theme-dark .nx-sheet tbody td.nx-cell-editable,
body.nx-theme-dark .nx-sheet tbody td.nx-editable,
body.nx-theme-dark .nx-sheet tbody td.is-editable,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.nx-cell-editable,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.nx-editable,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.is-editable {
    background: #fff7d0 !important;
    color: #0f2238 !important;
}

/* Celdas azules/grises calculadas */
body.nx-theme-dark .nx-sheet tbody td.nx-cell-calculated,
body.nx-theme-dark .nx-sheet tbody td.nx-calculated,
body.nx-theme-dark .nx-sheet tbody td.is-calculated,
body.nx-theme-dark .nx-sheet tbody td.nx-cell-locked,
body.nx-theme-dark .nx-sheet tbody td.nx-locked,
body.nx-theme-dark .nx-sheet tbody td.is-locked,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.nx-cell-calculated,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.nx-calculated,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.is-calculated,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.nx-cell-locked,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.nx-locked,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.is-locked {
    background: #dff2ff !important;
    color: #0f2238 !important;
}

/* Si la app pinta por columna usando fondos directos, forzamos lectura en todas las celdas del cuerpo */
body.nx-theme-dark .nx-sheet tbody tr td:nth-child(n),
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody tr td:nth-child(n) {
    color: #0f2238 !important;
}

/* Primera columna / encabezado de fila: mantenerla legible */
body.nx-theme-dark .nx-sheet tbody td:first-child,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td:first-child {
    color: #31546f !important;
    background: #eef8ff !important;
    font-weight: 950 !important;
}

/* Fila de totales: texto visible */
body.nx-theme-dark .nx-sheet tbody tr:last-child td,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody tr:last-child td,
body.nx-theme-dark .nx-sheet tfoot td,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tfoot td {
    color: #0f2238 !important;
    background: #e6f5ff !important;
    font-weight: 950 !important;
}

/* Encabezados de tabla: se mantienen oscuros con texto claro */
body.nx-theme-dark .nx-sheet thead th,
body.nx-theme-dark .nx-sheet thead th *,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet thead th,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet thead th * {
    color: #eaf6ff !important;
    -webkit-text-fill-color: #eaf6ff !important;
}

/* Botones/chips dentro de tabla: corregir casos puntuales */
body.nx-theme-dark .nx-sheet tbody td button,
body.nx-theme-dark .nx-sheet tbody td .nx-btn,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td button,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td .nx-btn {
    color: #0f5f86 !important;
    -webkit-text-fill-color: #0f5f86 !important;
    background: #e6f7ff !important;
    border-color: rgba(0,143,211,.24) !important;
}

/* Botón/estado OK dentro de tabla */
body.nx-theme-dark .nx-sheet tbody td .nx-status-ok,
body.nx-theme-dark .nx-sheet tbody td .nx-badge-ok,
body.nx-theme-dark .nx-sheet tbody td .nx-ok,
body.nx-theme-dark .nx-sheet tbody td [class*="ok"],
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td .nx-status-ok,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td .nx-badge-ok,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td .nx-ok,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td [class*="ok"] {
    color: #047857 !important;
    -webkit-text-fill-color: #047857 !important;
}

/* Acciones pequeñas copiar / eliminar */
body.nx-theme-dark .nx-sheet tbody td button[title],
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td button[title] {
    color: #294861 !important;
    background: #f8fbff !important;
    border-color: rgba(15,34,56,.10) !important;
}

/* Selección tipo Excel debe seguir notándose */
body.nx-theme-dark .nx-sheet tbody td.is-selected,
body.nx-theme-dark .nx-sheet tbody td.nx-selected,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.is-selected,
body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-sheet tbody td.nx-selected {
    outline: 2px solid #0877e8 !important;
    outline-offset: -2px !important;
    box-shadow: inset 0 0 0 999px rgba(8,103,216,.08) !important;
}

/* Inputs fuera de tabla se mantienen en dark mode normal */
body.nx-theme-dark input:not(.nx-sheet input),
body.nx-theme-dark select:not(.nx-sheet select),
body.nx-theme-dark textarea:not(.nx-sheet textarea),
body.nx-duct-sizer-core-shell-v1.nx-theme-dark input:not(.nx-sheet input),
body.nx-duct-sizer-core-shell-v1.nx-theme-dark select:not(.nx-sheet select),
body.nx-duct-sizer-core-shell-v1.nx-theme-dark textarea:not(.nx-sheet textarea) {
    color: #eaf6ff !important;
    -webkit-text-fill-color: #eaf6ff !important;
}

/* Mobile: logo más claro pero no gigante */
@media (max-width: 920px) {
    body.nx-theme-dark .nx-brand-logo,
    body.nx-duct-sizer-core-shell-v1.nx-theme-dark .nx-brand-logo {
        filter: brightness(0) invert(1) drop-shadow(0 4px 14px rgba(0,174,239,.14)) !important;
    }
}
