/* ============================================================================
   Theme adaptivity fix
   ----------------------------------------------------------------------------
   The app hard-codes light colors (#fff, #ccc, dark text) in many places, so
   FluentUI's Dark theme left those areas looking wrong. This file remaps the
   custom UI to FluentUI neutral design tokens, which flip automatically with
   the active theme -> works in BOTH Light and Dark.

   Loaded last; selectors are prefixed with `html` to raise specificity so they
   override the per-page <style> blocks (including their !important rules).
   ============================================================================ */

/* ---- Cards / containers / grids: surface + text + border follow theme ---- */
html .jv-table,
html .jr-grid,
html .fx-grid,
html .cust-grid,
html .idd-grid,
html .fx-entry-table,
html .erp-left,
html .erp-right,
html .ac-sample,
html .maingrid {
    background: var(--neutral-layer-1) !important;
    color: var(--neutral-foreground-rest) !important;
    border-color: var(--neutral-stroke-divider-rest) !important;
}

/* ---- Table / grid header ---- */
html .jv-table thead th,
html .fx-entry-table thead th,
html .ac-table th,
html .jr-grid .column-header,
html .fx-grid .column-header,
html .cust-grid .column-header,
html .idd-grid .column-header,
html fluent-data-grid-cell[cell-type="columnheader"] {
    background: var(--neutral-layer-3) !important;
    color: var(--neutral-foreground-rest) !important;
    border-bottom-color: var(--neutral-stroke-rest) !important;
}

/* ---- Body cells / rows ---- */
html .jv-table tbody td,
html .fx-entry-table tbody td,
html .ac-table td,
html fluent-data-grid-cell {
    color: var(--neutral-foreground-rest) !important;
    border-bottom-color: var(--neutral-stroke-divider-rest) !important;
}

/* Zebra striping */
html .jv-table tbody tr:nth-child(even),
html .fx-entry-table tbody tr:nth-child(even),
html .jr-grid fluent-data-grid-row:nth-of-type(even),
html .fx-grid fluent-data-grid-row:nth-of-type(even),
html .cust-grid fluent-data-grid-row:nth-of-type(even),
html .idd-grid fluent-data-grid-row:nth-of-type(even) {
    background: var(--neutral-layer-2) !important;
}

/* Row hover */
html .jv-table tbody tr:hover,
html .fx-entry-table tbody tr:hover,
html .jr-grid fluent-data-grid-row:hover,
html .fx-grid fluent-data-grid-row:hover,
html .cust-grid fluent-data-grid-row:hover,
html .idd-grid fluent-data-grid-row:hover {
    background: var(--neutral-fill-stealth-hover) !important;
}

/* ---- Inputs / selects (custom tables + login/sample forms) ---- */
html .jv-table input,
html .jv-table select,
html .fx-entry-table input,
html .fx-entry-table select,
html .form-control,
html .autocomplete-input,
html .fluent-select,
html .ac-select,
html .ac-input {
    background: var(--neutral-fill-input-rest, var(--neutral-layer-1)) !important;
    color: var(--neutral-foreground-rest) !important;
    border-color: var(--neutral-stroke-input-rest, var(--neutral-stroke-rest)) !important;
}

/* Read-only / emphasis cells */
html .jv-lcy,
html .ac-input[readonly],
html .form-control[readonly],
html input[readonly] {
    background: var(--neutral-layer-2) !important;
    color: var(--neutral-foreground-rest) !important;
}

/* Totals cards keep their accent text, surface follows theme */
html .jr-total {
    background: var(--neutral-layer-2) !important;
    border-color: var(--neutral-stroke-rest) !important;
}

/* Placeholders readable in dark */
html .form-control::placeholder,
html .autocomplete-input::placeholder,
html .ac-input::placeholder {
    color: var(--neutral-foreground-hint, #9aa5ad) !important;
}

/* ---- Generic catch-alls for inline hard-coded colors ---- */
/* Any element with an inline white background follows the theme surface. */
html [style*="background:#fff"],
html [style*="background: #fff"],
html [style*="background:#ffffff"],
html [style*="background: #ffffff"],
html [style*="background:#FFF"],
html [style*="background-color:#fff"],
html [style*="background-color: #fff"],
html [style*="background-color:#ffffff"] {
    background-color: var(--neutral-layer-1) !important;
}

/* The common light-grey card border follows the theme stroke. */
html [style*="1px solid #ccc"],
html [style*="1px solid #ddd"],
html [style*="1px solid #e"] {
    border-color: var(--neutral-stroke-divider-rest) !important;
}
