/* BLACK X ERP — Canonical contrast and identity normalization.
   Loaded after the component CSS so surface/text contracts remain authoritative. */
html[data-blackx-ui="dark-green-contrast-20260804"] { --bx-identity-version: "dark-green-contrast-20260804"; }
body.blackx-identity { color: var(--bx-text-on-light); }

/* Light operational surfaces always use dark, low-glare text. */
body.blackx-identity :where(
  .card, .blackx-card, .blackx-panel, .blackx-kpi-card, .dashboard-card, .report-card,
  .module-card, .erp-card, .erp-panel, .erp-module-card, .projects-panel, .auth-card,
  .bx-card, .bx-dashboard-panel, .bx-report-panel, .bx-operational-section, .erp-section,
  .erp-page-card, .bx-record-card, .blackx-dashboard-module-card, .modal-content,
  .bx-report-head, .bx-report-filter, .erp-page-head, .bx-page-head, .blackx-page-header,
  .page-header, .bg-light, .bg-white, [data-bx-surface="light"], .bx-on-light
) {
  color: var(--bx-text-on-light) !important;
}
body.blackx-identity :where(
  .card, .blackx-card, .blackx-panel, .blackx-kpi-card, .dashboard-card, .report-card,
  .module-card, .erp-card, .erp-panel, .erp-module-card, .projects-panel, .auth-card,
  .bx-card, .bx-dashboard-panel, .bx-report-panel, .bx-operational-section, .erp-section,
  .erp-page-card, .bx-record-card, .blackx-dashboard-module-card, .modal-content,
  .bx-report-head, .bx-report-filter, .erp-page-head, .bx-page-head, .blackx-page-header,
  .page-header, .bg-light, .bg-white, [data-bx-surface="light"], .bx-on-light
) :where(h1, h2, h3, h4, h5, h6, label, legend, dt, strong) {
  color: var(--bx-text-on-light-strong) !important;
}
body.blackx-identity :where(
  .card, .blackx-card, .blackx-panel, .blackx-kpi-card, .dashboard-card, .report-card,
  .module-card, .erp-card, .erp-panel, .erp-module-card, .projects-panel, .auth-card,
  .bx-card, .bx-dashboard-panel, .bx-report-panel, .bx-operational-section, .erp-section,
  .erp-page-card, .bx-record-card, .blackx-dashboard-module-card, .modal-content,
  .bx-report-head, .bx-report-filter, .erp-page-head, .bx-page-head, .blackx-page-header,
  .page-header, .bg-light, .bg-white, [data-bx-surface="light"], .bx-on-light
) :where(p, small, .text-muted, .text-secondary, .form-text, .helptext) {
  color: var(--bx-text-on-light-muted) !important;
}

/* Dark shell and dark feature surfaces always use light text. */
body.blackx-identity :where(
  .blackx-topbar, .blackx-universal-sidebar, .blackx-page-loader, .blackx-page-loader__panel,
  .auth-brand-panel, .bx-dashboard-hero, .blackx-page-hero, .erp-hero,
  .blackx-user-menu__panel, .blackx-language-switcher__panel, .dropdown-menu,
  .bg-dark, .bg-primary, .bg-success, .text-bg-dark, .text-bg-primary, .text-bg-success,
  [data-bx-surface="dark"], .bx-on-dark
) {
  color: var(--bx-text-on-dark) !important;
}
body.blackx-identity :where(
  .blackx-topbar, .blackx-universal-sidebar, .blackx-page-loader, .blackx-page-loader__panel,
  .auth-brand-panel, .bx-dashboard-hero, .blackx-page-hero, .erp-hero,
  .blackx-user-menu__panel, .blackx-language-switcher__panel, .dropdown-menu,
  .bg-dark, .bg-primary, .bg-success, .text-bg-dark, .text-bg-primary, .text-bg-success,
  [data-bx-surface="dark"], .bx-on-dark
) :where(h1, h2, h3, h4, h5, h6, p, span, small, strong, b, label, legend, dt, dd, a:not(.btn):not(.blackx-btn)) {
  color: inherit !important;
}
body.blackx-identity :where(
  .blackx-topbar, .blackx-universal-sidebar, .blackx-page-loader, .blackx-page-loader__panel,
  .auth-brand-panel, .bx-dashboard-hero, .blackx-page-hero, .erp-hero,
  .blackx-user-menu__panel, .blackx-language-switcher__panel, .dropdown-menu,
  .bg-dark, .bg-primary, .bg-success, .text-bg-dark, .text-bg-primary, .text-bg-success,
  [data-bx-surface="dark"], .bx-on-dark
) :where(small, .text-muted, .text-secondary, .form-text, .helptext) {
  color: var(--bx-text-on-dark-muted) !important;
}

/* Table headers are dark surfaces; table bodies remain light. */
body.blackx-identity :where(thead, .table thead, .erp-table thead, .projects-data-table thead, .bx-data-table thead),
body.blackx-identity :where(thead, .table thead, .erp-table thead, .projects-data-table thead, .bx-data-table thead) :where(th, a, span, small, strong) {
  color: var(--bx-text-on-dark) !important;
}
body.blackx-identity :where(tbody td, tbody th, .table tbody td, .erp-table tbody td, .projects-data-table tbody td, .bx-data-table tbody td) {
  color: var(--bx-text-on-light) !important;
}

/* Inputs are light editable surfaces even when embedded in a dark region. */
body.blackx-identity :where(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="hidden"]), select, textarea, .form-control, .form-select, .input-group-text) {
  color: var(--bx-text-on-light-strong) !important;
}
body.blackx-identity :where(input, textarea)::placeholder { color: #718583 !important; }
body.blackx-identity select option { color: var(--bx-text-on-light-strong) !important; background: #fff !important; }
body.blackx-identity .blackx-topbar .blackx-language-switcher select { color: var(--bx-text-on-dark) !important; }

/* Buttons own their foreground through --bx-button-color, including nested labels/icons. */
body.blackx-identity :where(.btn, .blackx-btn, button[type="submit"], button[type="button"], button[type="reset"], input[type="submit"], input[type="button"], input[type="reset"]) {
  color: var(--bx-button-color) !important;
}
body.blackx-identity :where(.btn, .blackx-btn, button[type="submit"], button[type="button"], button[type="reset"]) :where(span, small, strong, b, i, svg) {
  color: inherit !important;
}

/* Destructive actions are always red with a readable white foreground. */
body.blackx-identity :where(
  .btn-danger, .btn-outline-danger, .blackx-btn--danger,
  [data-action="delete"], [data-action="remove"], [data-blackx-danger], [data-remove-row],
  form[action*="/delete/"] :is(button, input[type="submit"]),
  form[action*="/remove/"] :is(button, input[type="submit"]),
  a[href*="/delete/"], a[href*="/remove/"]
) {
  --bx-button-bg: radial-gradient(circle at 50% 24%, var(--bx-danger-hot) 0%, var(--bx-danger) 46%, var(--bx-danger-deep) 100%);
  --bx-button-color: #fff;
  --bx-button-border: rgba(255, 82, 101, .60);
  color: #fff !important;
}

/* Compatibility utility normalization. */
body.blackx-identity .text-white,
body.blackx-identity .text-light { color: var(--bx-text-on-dark) !important; }
body.blackx-identity .text-dark,
body.blackx-identity .text-body { color: var(--bx-text-on-light) !important; }
body.blackx-identity .bg-dark { background: var(--bx-teal-900) !important; }
body.blackx-identity .bg-light,
body.blackx-identity .bg-white { background: var(--bx-metal-100) !important; }
body.blackx-identity .border { border-color: var(--bx-border) !important; }
body.blackx-identity .shadow,
body.blackx-identity .shadow-sm { box-shadow: var(--bx-shadow-sm) !important; }

@supports not (backdrop-filter: blur(2px)) {
  .card, .blackx-card, .blackx-panel, .blackx-kpi-card, .dashboard-card, .report-card, .module-card,
  .erp-card, .erp-panel, .erp-module-card, .projects-panel, .auth-card, .bx-card, .bx-dashboard-panel,
  .bx-report-panel, .bx-operational-section, .erp-section, .erp-page-card, .bx-record-card,
  .blackx-dashboard-module-card, .modal-content { background: rgba(255,255,255,.96); }
  .blackx-universal-sidebar__module { background: rgba(13,58,45,.92); }
}
