/* =======================================================
   NIGHT MODE / DARK MODE — Comprehensive Fix
   Selector: body.nightmode or body[data-theme="dark"]
   One file to rule them all. Fix here = fix everywhere.
   ======================================================= */

:root {
  --nm-bg:           #1a2035;
  --nm-bg-card:      #1e2a45;
  --nm-bg-surface:   #243050;
  --nm-bg-input:     #1e2a45;
  --nm-bg-header:    #151e32;
  --nm-bg-hover:     #2a3a5c;
  --nm-border:       #2d3f65;
  --nm-text:         #c8d4e8;
  --nm-text-muted:   #7a90b5;
  --nm-text-heading: #e0eaff;
  --nm-link:         #5a9fd4;
  --nm-shadow:       rgba(0,0,0,0.4);
}

/* -------------------------------------------------------
   1. BODY & PAGE WRAPPER
------------------------------------------------------- */
body.nightmode,
body[data-theme="dark"] {
  background-color: var(--nm-bg) !important;
  color: var(--nm-text) !important;
}

/* -------------------------------------------------------
   2. CONTENT WRAPPER / MAIN AREA
------------------------------------------------------- */
body.nightmode .content-wrapper,
body[data-theme="dark"] .content-wrapper,
body.nightmode .page-wrapper,
body[data-theme="dark"] .page-wrapper,
body.nightmode .main-wrapper,
body[data-theme="dark"] .main-wrapper {
  background-color: var(--nm-bg) !important;
}

/* -------------------------------------------------------
   3. CARDS / BOXES / PANELS
------------------------------------------------------- */
body.nightmode .card,
body[data-theme="dark"] .card,
body.nightmode .box,
body[data-theme="dark"] .box,
body.nightmode .panel,
body[data-theme="dark"] .panel,
body.nightmode .box-body,
body[data-theme="dark"] .box-body {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text) !important;
}

body.nightmode .card-header,
body[data-theme="dark"] .card-header,
body.nightmode .box-header,
body[data-theme="dark"] .box-header {
  background-color: var(--nm-bg-surface) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text-heading) !important;
}

body.nightmode .card-body,
body[data-theme="dark"] .card-body,
body.nightmode .card-footer,
body[data-theme="dark"] .card-footer {
  background-color: var(--nm-bg-card) !important;
  color: var(--nm-text) !important;
}

/* -------------------------------------------------------
   4. DATATABLES — COMPREHENSIVE FIX
   (Fix once here, fixes ALL pages with DataTables)
------------------------------------------------------- */

/* Table wrapper */
body.nightmode .dataTables_wrapper,
body[data-theme="dark"] .dataTables_wrapper {
  color: var(--nm-text) !important;
}

/* Table itself */
body.nightmode table.dataTable,
body[data-theme="dark"] table.dataTable,
body.nightmode .table,
body[data-theme="dark"] .table {
  background-color: var(--nm-bg-card) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-border) !important;
}

/* Table header */
body.nightmode table.dataTable thead th,
body[data-theme="dark"] table.dataTable thead th,
body.nightmode table.dataTable thead td,
body[data-theme="dark"] table.dataTable thead td,
body.nightmode .table > thead > tr > th,
body[data-theme="dark"] .table > thead > tr > th {
  background-color: var(--nm-bg-header) !important;
  color: var(--nm-text-heading) !important;
  border-color: var(--nm-border) !important;
}

/* Table body rows */
body.nightmode table.dataTable tbody tr,
body[data-theme="dark"] table.dataTable tbody tr,
body.nightmode .table > tbody > tr > td,
body[data-theme="dark"] .table > tbody > tr > td,
body.nightmode .table > tbody > tr > th,
body[data-theme="dark"] .table > tbody > tr > th {
  background-color: var(--nm-bg-card) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-border) !important;
}

/* Table striped alternate rows */
body.nightmode table.dataTable tbody tr:nth-child(even),
body[data-theme="dark"] table.dataTable tbody tr:nth-child(even),
body.nightmode .table-striped > tbody > tr:nth-of-type(odd),
body[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) {
  background-color: var(--nm-bg-surface) !important;
}

/* Table hover */
body.nightmode table.dataTable tbody tr:hover,
body[data-theme="dark"] table.dataTable tbody tr:hover,
body.nightmode .table-hover > tbody > tr:hover,
body[data-theme="dark"] .table-hover > tbody > tr:hover {
  background-color: var(--nm-bg-hover) !important;
}

/* DataTable Sort arrows */
body.nightmode table.dataTable thead .sorting::before,
body.nightmode table.dataTable thead .sorting::after,
body.nightmode table.dataTable thead .sorting_asc::before,
body.nightmode table.dataTable thead .sorting_asc::after,
body.nightmode table.dataTable thead .sorting_desc::before,
body.nightmode table.dataTable thead .sorting_desc::after,
body[data-theme="dark"] table.dataTable thead .sorting::before,
body[data-theme="dark"] table.dataTable thead .sorting::after,
body[data-theme="dark"] table.dataTable thead .sorting_asc::before,
body[data-theme="dark"] table.dataTable thead .sorting_asc::after,
body[data-theme="dark"] table.dataTable thead .sorting_desc::before,
body[data-theme="dark"] table.dataTable thead .sorting_desc::after {
  color: var(--nm-text-muted) !important;
}

/* DataTable search input */
body.nightmode .dataTables_filter input,
body[data-theme="dark"] .dataTables_filter input {
  background-color: var(--nm-bg-input) !important;
  color: var(--nm-text) !important;
  border: 1px solid var(--nm-border) !important;
}

/* DataTable length select */
body.nightmode .dataTables_length select,
body[data-theme="dark"] .dataTables_length select {
  background-color: var(--nm-bg-input) !important;
  color: var(--nm-text) !important;
  border: 1px solid var(--nm-border) !important;
}

/* DataTable info text */
body.nightmode .dataTables_info,
body[data-theme="dark"] .dataTables_info {
  color: var(--nm-text-muted) !important;
}

/* DataTable empty row message */
body.nightmode table.dataTable tbody td.dataTables_empty,
body[data-theme="dark"] table.dataTable tbody td.dataTables_empty {
  color: var(--nm-text-muted) !important;
}

/* DataTable footer total row */
body.nightmode table.dataTable tfoot td,
body[data-theme="dark"] table.dataTable tfoot td,
body.nightmode table.dataTable tfoot th,
body[data-theme="dark"] table.dataTable tfoot th,
body.nightmode .table > tfoot > tr > td,
body[data-theme="dark"] .table > tfoot > tr > td {
  background-color: var(--nm-bg-surface) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-border) !important;
}

/* DataTable Buttons (Copy, Excel, PDF, Print, CSV, Columns) */
body.nightmode .dt-buttons .btn,
body[data-theme="dark"] .dt-buttons .btn,
body.nightmode .dt-button,
body[data-theme="dark"] .dt-button {
  background-color: var(--nm-bg-surface) !important;
  color: var(--nm-text-heading) !important;
  border-color: var(--nm-border) !important;
}
body.nightmode .dt-buttons .btn:hover,
body[data-theme="dark"] .dt-buttons .btn:hover,
body.nightmode .dt-button:hover,
body[data-theme="dark"] .dt-button:hover {
  background-color: var(--nm-bg-hover) !important;
}

body.nightmode div.dataTables_wrapper div.dataTables_filter label,
body[data-theme="dark"] div.dataTables_wrapper div.dataTables_filter label,
body.nightmode div.dataTables_wrapper div.dataTables_length label,
body[data-theme="dark"] div.dataTables_wrapper div.dataTables_length label {
  color: var(--nm-text) !important;
}

/* -------------------------------------------------------
   5. PAGINATION
------------------------------------------------------- */
body.nightmode .pagination > li > a,
body[data-theme="dark"] .pagination > li > a,
body.nightmode .pagination > li > span,
body[data-theme="dark"] .pagination > li > span {
  background-color: var(--nm-bg-surface) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-link) !important;
}

body.nightmode .pagination > .active > a,
body[data-theme="dark"] .pagination > .active > a,
body.nightmode .pagination > .active > span,
body[data-theme="dark"] .pagination > .active > span {
  background-color: #2b6cb0 !important;
  border-color: #2b6cb0 !important;
  color: #fff !important;
}

body.nightmode .pagination > .disabled > a,
body[data-theme="dark"] .pagination > .disabled > a,
body.nightmode .pagination > .disabled > span,
body[data-theme="dark"] .pagination > .disabled > span {
  background-color: var(--nm-bg-surface) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text-muted) !important;
}

/* -------------------------------------------------------
   6. FORM INPUTS, SELECTS, TEXTAREAS
------------------------------------------------------- */
body.nightmode input,
body[data-theme="dark"] input,
body.nightmode select,
body[data-theme="dark"] select,
body.nightmode textarea,
body[data-theme="dark"] textarea,
body.nightmode .form-control,
body[data-theme="dark"] .form-control {
  background-color: var(--nm-bg-input) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-border) !important;
}

body.nightmode input::placeholder,
body[data-theme="dark"] input::placeholder,
body.nightmode textarea::placeholder,
body[data-theme="dark"] textarea::placeholder {
  color: var(--nm-text-muted) !important;
}

body.nightmode input:focus,
body[data-theme="dark"] input:focus,
body.nightmode select:focus,
body[data-theme="dark"] select:focus,
body.nightmode textarea:focus,
body[data-theme="dark"] textarea:focus,
body.nightmode .form-control:focus,
body[data-theme="dark"] .form-control:focus {
  background-color: var(--nm-bg-input) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-link) !important;
  box-shadow: 0 0 0 0.2rem rgba(90, 159, 212, 0.25) !important;
}

/* Readonly / Disabled inputs */
body.nightmode input[readonly],
body[data-theme="dark"] input[readonly],
body.nightmode input:disabled,
body[data-theme="dark"] input:disabled,
body.nightmode select:disabled,
body[data-theme="dark"] select:disabled {
  background-color: #141d30 !important;
  color: var(--nm-text-muted) !important;
}

/* Input group addon */
body.nightmode .input-group-addon,
body[data-theme="dark"] .input-group-addon,
body.nightmode .input-group-text,
body[data-theme="dark"] .input-group-text {
  background-color: var(--nm-bg-surface) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-border) !important;
}

/* -------------------------------------------------------
   7. SELECT2 DROPDOWNS
------------------------------------------------------- */
body.nightmode .select2-container--default .select2-selection--single,
body[data-theme="dark"] .select2-container--default .select2-selection--single,
body.nightmode .select2-container--default .select2-selection--multiple,
body[data-theme="dark"] .select2-container--default .select2-selection--multiple {
  background-color: var(--nm-bg-input) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text) !important;
}

body.nightmode .select2-container--default .select2-selection--single .select2-selection__rendered,
body[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--nm-text) !important;
}

body.nightmode .select2-container--default .select2-selection--single .select2-selection__arrow b,
body[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--nm-text-muted) transparent transparent transparent !important;
}

body.nightmode .select2-dropdown,
body[data-theme="dark"] .select2-dropdown {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text) !important;
}

body.nightmode .select2-container--default .select2-results__option,
body[data-theme="dark"] .select2-container--default .select2-results__option {
  background-color: var(--nm-bg-card) !important;
  color: var(--nm-text) !important;
}

body.nightmode .select2-container--default .select2-results__option--highlighted[aria-selected],
body[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--nm-bg-hover) !important;
  color: var(--nm-text-heading) !important;
}

body.nightmode .select2-container--default .select2-search--dropdown .select2-search__field,
body[data-theme="dark"] .select2-container--default .select2-search--dropdown .select2-search__field {
  background-color: var(--nm-bg-input) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-border) !important;
}

/* -------------------------------------------------------
   8. MODALS
------------------------------------------------------- */
body.nightmode .modal-content,
body[data-theme="dark"] .modal-content {
  background-color: var(--nm-bg-card) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-border) !important;
}

body.nightmode .modal-header,
body[data-theme="dark"] .modal-header {
  background-color: var(--nm-bg-surface) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text-heading) !important;
}

body.nightmode .modal-footer,
body[data-theme="dark"] .modal-footer {
  background-color: var(--nm-bg-surface) !important;
  border-color: var(--nm-border) !important;
}

body.nightmode .modal-title,
body[data-theme="dark"] .modal-title {
  color: var(--nm-text-heading) !important;
}

body.nightmode .modal-body,
body[data-theme="dark"] .modal-body {
  background-color: var(--nm-bg-card) !important;
}

body.nightmode .close,
body[data-theme="dark"] .close {
  color: var(--nm-text) !important;
  opacity: 0.7;
}

/* -------------------------------------------------------
   9. DROPDOWNS
------------------------------------------------------- */
body.nightmode .dropdown-menu,
body[data-theme="dark"] .dropdown-menu {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) !important;
}

body.nightmode .dropdown-item,
body[data-theme="dark"] .dropdown-item {
  color: var(--nm-text) !important;
}

body.nightmode .dropdown-item:hover,
body[data-theme="dark"] .dropdown-item:hover,
body.nightmode .dropdown-item:focus,
body[data-theme="dark"] .dropdown-item:focus {
  background-color: var(--nm-bg-hover) !important;
  color: var(--nm-text-heading) !important;
}

body.nightmode .dropdown-divider,
body[data-theme="dark"] .dropdown-divider {
  border-color: var(--nm-border) !important;
}

/* -------------------------------------------------------
   10. BREADCRUMBS
------------------------------------------------------- */
body.nightmode .breadcrumb,
body[data-theme="dark"] .breadcrumb {
  background-color: transparent !important;
  color: var(--nm-text-muted) !important;
}

body.nightmode .breadcrumb-item a,
body[data-theme="dark"] .breadcrumb-item a {
  color: var(--nm-link) !important;
}

body.nightmode .breadcrumb-item.active,
body[data-theme="dark"] .breadcrumb-item.active {
  color: var(--nm-text-muted) !important;
}

/* -------------------------------------------------------
   11. PAGE TITLE / HEADINGS
------------------------------------------------------- */
body.nightmode h1, body.nightmode h2, body.nightmode h3,
body.nightmode h4, body.nightmode h5, body.nightmode h6,
body[data-theme="dark"] h1, body[data-theme="dark"] h2,
body[data-theme="dark"] h3, body[data-theme="dark"] h4,
body[data-theme="dark"] h5, body[data-theme="dark"] h6 {
  color: var(--nm-text-heading) !important;
}

body.nightmode p,
body[data-theme="dark"] p,
body.nightmode label,
body[data-theme="dark"] label,
body.nightmode span,
body[data-theme="dark"] span {
  color: inherit;
}

/* -------------------------------------------------------
   12. ALERTS / INFO BOXES
------------------------------------------------------- */
body.nightmode .alert,
body[data-theme="dark"] .alert {
  border-color: var(--nm-border) !important;
}

body.nightmode .alert-info,
body[data-theme="dark"] .alert-info {
  background-color: #1a3050 !important;
  color: #90c4e8 !important;
}

body.nightmode .alert-warning,
body[data-theme="dark"] .alert-warning {
  background-color: #3d2f00 !important;
  color: #ffd966 !important;
}

body.nightmode .alert-danger,
body[data-theme="dark"] .alert-danger {
  background-color: #3d0f0f !important;
  color: #f58080 !important;
}

body.nightmode .alert-success,
body[data-theme="dark"] .alert-success {
  background-color: #0f3020 !important;
  color: #6fcf97 !important;
}

/* -------------------------------------------------------
   13. HR / DIVIDERS / BORDERS
------------------------------------------------------- */
body.nightmode hr,
body[data-theme="dark"] hr {
  border-color: var(--nm-border) !important;
}

body.nightmode .border,
body[data-theme="dark"] .border,
body.nightmode .border-top,
body[data-theme="dark"] .border-top,
body.nightmode .border-bottom,
body[data-theme="dark"] .border-bottom {
  border-color: var(--nm-border) !important;
}

/* -------------------------------------------------------
   14. TABS & NAV-TABS
------------------------------------------------------- */
body.nightmode .nav-tabs,
body[data-theme="dark"] .nav-tabs {
  border-color: var(--nm-border) !important;
}

body.nightmode .nav-tabs .nav-link,
body[data-theme="dark"] .nav-tabs .nav-link {
  color: var(--nm-text) !important;
  border-color: transparent !important;
}

body.nightmode .nav-tabs .nav-link.active,
body[data-theme="dark"] .nav-tabs .nav-link.active,
body.nightmode .nav-tabs .nav-item.show .nav-link,
body[data-theme="dark"] .nav-tabs .nav-item.show .nav-link {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) var(--nm-border) var(--nm-bg-card) !important;
  color: var(--nm-text-heading) !important;
}

body.nightmode .tab-content,
body[data-theme="dark"] .tab-content {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) !important;
}

/* -------------------------------------------------------
   15. UI AUTOCOMPLETE
------------------------------------------------------- */
body.nightmode .ui-autocomplete,
body[data-theme="dark"] .ui-autocomplete {
  background-color: var(--nm-bg-card) !important;
  background-image: none !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text) !important;
}

body.nightmode .ui-menu-item,
body[data-theme="dark"] .ui-menu-item,
body.nightmode .ui-menu-item-wrapper,
body[data-theme="dark"] .ui-menu-item-wrapper {
  background-color: transparent !important;
  color: var(--nm-text) !important;
}

body.nightmode .ui-menu-item-wrapper.ui-state-active,
body[data-theme="dark"] .ui-menu-item-wrapper.ui-state-active,
body.nightmode .ui-menu-item-wrapper.ui-state-focus,
body[data-theme="dark"] .ui-menu-item-wrapper.ui-state-focus,
body.nightmode .ui-menu-item-wrapper.ui-state-hover,
body[data-theme="dark"] .ui-menu-item-wrapper.ui-state-hover {
  background: var(--nm-bg-hover) !important;
  background-image: none !important;
  color: var(--nm-text-heading) !important;
  border-color: var(--nm-border) !important;
}

body.nightmode .ui-autocomplete-loading,
body[data-theme="dark"] .ui-autocomplete-loading {
    background: var(--nm-bg-surface) url("../../plugins/autocomplete/loader2.gif") right center no-repeat !important;
}

body.nightmode .ui-autocomplete-loader-center,
body[data-theme="dark"] .ui-autocomplete-loader-center {
    background: var(--nm-bg-surface) url("../../plugins/autocomplete/loader1.gif") center center no-repeat !important;
}

/* -------------------------------------------------------
   16. DATE PICKER
------------------------------------------------------- */
body.nightmode .datepicker,
body[data-theme="dark"] .datepicker,
body.nightmode .daterangepicker,
body[data-theme="dark"] .daterangepicker {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text) !important;
}

body.nightmode .datepicker table tr td,
body[data-theme="dark"] .datepicker table tr td,
body.nightmode .datepicker table tr th,
body[data-theme="dark"] .datepicker table tr th {
  color: var(--nm-text) !important;
}

body.nightmode .datepicker table tr td.day:hover,
body[data-theme="dark"] .datepicker table tr td.day:hover {
  background-color: var(--nm-bg-hover) !important;
}

body.nightmode .datepicker table tr td.active,
body[data-theme="dark"] .datepicker table tr td.active {
  background-color: #2b6cb0 !important;
  color: #fff !important;
}

body.nightmode .datepicker table tr td.old,
body.nightmode .datepicker table tr td.new,
body[data-theme="dark"] .datepicker table tr td.old,
body[data-theme="dark"] .datepicker table tr td.new {
  color: var(--nm-text-muted) !important;
}

body.nightmode .daterangepicker .drp-calendar,
body[data-theme="dark"] .daterangepicker .drp-calendar,
body.nightmode .daterangepicker .calendar-table,
body[data-theme="dark"] .daterangepicker .calendar-table {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) !important;
}

body.nightmode .daterangepicker .ranges li,
body[data-theme="dark"] .daterangepicker .ranges li {
  background-color: var(--nm-bg-card) !important;
  color: var(--nm-text) !important;
}

body.nightmode .daterangepicker .ranges li:hover,
body[data-theme="dark"] .daterangepicker .ranges li:hover,
body.nightmode .daterangepicker .ranges li.active,
body[data-theme="dark"] .daterangepicker .ranges li.active {
  background-color: var(--nm-bg-hover) !important;
  color: var(--nm-text-heading) !important;
}

body.nightmode .daterangepicker td.available:hover,
body[data-theme="dark"] .daterangepicker td.available:hover,
body.nightmode .daterangepicker th.available:hover,
body[data-theme="dark"] .daterangepicker th.available:hover {
  background-color: var(--nm-bg-hover) !important;
}

body.nightmode .daterangepicker td.in-range,
body[data-theme="dark"] .daterangepicker td.in-range {
  background-color: #2b4562 !important;
}

body.nightmode .daterangepicker td.active,
body[data-theme="dark"] .daterangepicker td.active {
  background-color: #2b6cb0 !important;
  color: #fff !important;
}

body.nightmode .daterangepicker td.off, 
body.nightmode .daterangepicker td.off.in-range, 
body.nightmode .daterangepicker td.off.start-date, 
body.nightmode .daterangepicker td.off.end-date,
body[data-theme="dark"] .daterangepicker td.off, 
body[data-theme="dark"] .daterangepicker td.off.in-range, 
body[data-theme="dark"] .daterangepicker td.off.start-date, 
body[data-theme="dark"] .daterangepicker td.off.end-date {
  background-color: var(--nm-bg-body) !important;
  color: var(--nm-text-muted) !important;
}

body.nightmode .daterangepicker select.monthselect,
body[data-theme="dark"] .daterangepicker select.monthselect,
body.nightmode .daterangepicker select.yearselect,
body[data-theme="dark"] .daterangepicker select.yearselect {
  background-color: var(--nm-bg-body) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text) !important;
}

/* -------------------------------------------------------
   17. SMALL BOXES (Dashboard stat cards)
------------------------------------------------------- */
body.nightmode .small-box,
body[data-theme="dark"] .small-box {
  background-color: var(--nm-bg-card) !important;
}

body.nightmode .small-box p,
body.nightmode .small-box h3,
body[data-theme="dark"] .small-box p,
body[data-theme="dark"] .small-box h3 {
  color: #fff !important;
}

/* -------------------------------------------------------
   18. INFO BOXES (Icon boxes on dashboard)
------------------------------------------------------- */
body.nightmode .info-box,
body[data-theme="dark"] .info-box {
  background-color: var(--nm-bg-card) !important;
  color: var(--nm-text) !important;
}

body.nightmode .info-box-content,
body[data-theme="dark"] .info-box-content {
  color: var(--nm-text) !important;
}

body.nightmode .info-box-text,
body[data-theme="dark"] .info-box-text {
  color: var(--nm-text-muted) !important;
}

body.nightmode .info-box-number,
body[data-theme="dark"] .info-box-number {
  color: var(--nm-text-heading) !important;
}

/* -------------------------------------------------------
   19. CHARTS (chart containers)
------------------------------------------------------- */
body.nightmode .chart-container,
body[data-theme="dark"] .chart-container,
body.nightmode .chartjs-render-monitor,
body[data-theme="dark"] .chartjs-render-monitor {
  background-color: var(--nm-bg-card) !important;
}

/* Dashboard chart box wrappers */
body.nightmode .chart,
body[data-theme="dark"] .chart {
  background-color: var(--nm-bg-card) !important;
}

/* Canvas white bg override */
body.nightmode canvas,
body[data-theme="dark"] canvas {
  background-color: var(--nm-bg-card) !important;
}

/* Box-primary on dashboard (chart wrapper) */
body.nightmode .box.box-primary,
body[data-theme="dark"] .box.box-primary {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) !important;
}

body.nightmode .box.box-primary .box-header,
body[data-theme="dark"] .box.box-primary .box-header {
  background-color: var(--nm-bg-card) !important;
  color: var(--nm-text-heading) !important;
  border-bottom-color: var(--nm-border) !important;
}

body.nightmode .box.box-primary .box-header .box-title,
body[data-theme="dark"] .box.box-primary .box-header .box-title {
  color: var(--nm-text-heading) !important;
}

body.nightmode .box.box-primary .box-body,
body[data-theme="dark"] .box.box-primary .box-body {
  background-color: var(--nm-bg-card) !important;
  color: var(--nm-text) !important;
}

/* -------------------------------------------------------
   20. TOASTR NOTIFICATIONS
------------------------------------------------------- */
body.nightmode #toast-container > .toast,
body[data-theme="dark"] #toast-container > .toast {
  opacity: 0.95 !important;
}

/* -------------------------------------------------------
   21. SCROLLBAR STYLING
------------------------------------------------------- */
body.nightmode ::-webkit-scrollbar,
body[data-theme="dark"] ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

body.nightmode ::-webkit-scrollbar-track,
body[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--nm-bg) !important;
}

body.nightmode ::-webkit-scrollbar-thumb,
body[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--nm-border) !important;
  border-radius: 3px;
}

body.nightmode ::-webkit-scrollbar-thumb:hover,
body[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--nm-text-muted) !important;
}

/* -------------------------------------------------------
   22. PRINT BUTTONS (iCheck / checkbox)
------------------------------------------------------- */
body.nightmode .icheckbox_square-orange,
body[data-theme="dark"] .icheckbox_square-orange {
  filter: brightness(0.8) !important;
}

/* -------------------------------------------------------
   23. CUSTOM TABLE HEADER (used in many pages)
------------------------------------------------------- */
body.nightmode .custom_table_header,
body[data-theme="dark"] .custom_table_header {
  background-color: #2b3f7a !important;
  color: #fff !important;
}

/* -------------------------------------------------------
   24. LINKS
------------------------------------------------------- */
body.nightmode a,
body[data-theme="dark"] a {
  color: var(--nm-link);
}

body.nightmode a:hover,
body[data-theme="dark"] a:hover {
  color: #8bc4f0;
}

/* Unified Button Style for Night Mode (matches dt-buttons) */
body.nightmode .btn-primary,
body[data-theme="dark"] .btn-primary,
body.nightmode .btn-success,
body[data-theme="dark"] .btn-success,
body.nightmode .btn-warning,
body[data-theme="dark"] .btn-warning,
body.nightmode .btn-danger,
body[data-theme="dark"] .btn-danger,
body.nightmode .btn-info,
body[data-theme="dark"] .btn-info,
body.nightmode .btn-default,
body[data-theme="dark"] .btn-default {
  background-color: var(--nm-bg-surface) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text-heading) !important;
}
body.nightmode .btn-primary:hover,
body[data-theme="dark"] .btn-primary:hover,
body.nightmode .btn-success:hover,
body[data-theme="dark"] .btn-success:hover,
body.nightmode .btn-warning:hover,
body[data-theme="dark"] .btn-warning:hover,
body.nightmode .btn-danger:hover,
body[data-theme="dark"] .btn-danger:hover,
body.nightmode .btn-info:hover,
body[data-theme="dark"] .btn-info:hover,
body.nightmode .btn-default:hover,
body[data-theme="dark"] .btn-default:hover {
  background-color: var(--nm-bg-hover) !important;
}

/* Fix White Flash in DataTables and global loaders */
body.nightmode .dataTables_processing,
body[data-theme="dark"] .dataTables_processing,
body.nightmode .overlay,
body[data-theme="dark"] .overlay,
body.nightmode .loading-overlay,
body[data-theme="dark"] .loading-overlay,
body.nightmode div#global-loader,
body[data-theme="dark"] div#global-loader {
  background-color: var(--nm-bg-surface) !important;
  color: var(--nm-text-body) !important;
}
body.nightmode .dataTables_processing .card,
body[data-theme="dark"] .dataTables_processing .card {
  background-color: var(--nm-bg-surface) !important;
}

/* Action Dropdown Buttons in Datatables */
body.nightmode table.dataTable tbody tr td .btn-group > .btn,
body[data-theme="dark"] table.dataTable tbody tr td .btn-group > .btn {
  background-color: var(--nm-bg-surface) !important;
  color: var(--nm-text-heading) !important;
  border-color: var(--nm-border) !important;
}
body.nightmode table.dataTable tbody tr td .btn-group > .btn:hover,
body[data-theme="dark"] table.dataTable tbody tr td .btn-group > .btn:hover {
  background-color: var(--nm-bg-hover) !important;
}

/* -------------------------------------------------------
   25. SUMMARY / TOTAL ROW in tables
------------------------------------------------------- */
body.nightmode .table tfoot tr td,
body[data-theme="dark"] .table tfoot tr td {
  font-weight: bold;
  color: var(--nm-text-heading) !important;
  background-color: var(--nm-bg-surface) !important;
}

/* -------------------------------------------------------
   26. SEARCH INPUT IN HEADER
------------------------------------------------------- */
body.nightmode .top-nav-search .form-control,
body[data-theme="dark"] .top-nav-search .form-control,
body.nightmode .searchinputs input,
body[data-theme="dark"] .searchinputs input {
  background-color: var(--nm-bg-surface) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-border) !important;
}

/* -------------------------------------------------------
   27. TABLE RESPONSIVE WRAPPER
------------------------------------------------------- */
body.nightmode .table-responsive,
body[data-theme="dark"] .table-responsive {
  background-color: var(--nm-bg-card) !important;
}

/* -------------------------------------------------------
   28. TEXT COLORS — make sure default text is readable
------------------------------------------------------- */
body.nightmode .text-muted,
body[data-theme="dark"] .text-muted {
  color: var(--nm-text-muted) !important;
}

body.nightmode .text-dark,
body[data-theme="dark"] .text-dark {
  color: var(--nm-text) !important;
}

/* -------------------------------------------------------
   29. POS SCREEN SPECIFIC
------------------------------------------------------- */
body.nightmode #pos-product-list .card,
body[data-theme="dark"] #pos-product-list .card,
body.nightmode .product-card,
body[data-theme="dark"] .product-card {
  background-color: var(--nm-bg-surface) !important;
  border-color: var(--nm-border) !important;
}

/* -------------------------------------------------------
   30. LIST GROUP (used in some forms/panels)
------------------------------------------------------- */
body.nightmode .list-group-item,
body[data-theme="dark"] .list-group-item {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text) !important;
}

body.nightmode .list-group-item:hover,
body[data-theme="dark"] .list-group-item:hover {
  background-color: var(--nm-bg-hover) !important;
}

/* -------------------------------------------------------
   31. WELL / PRE / CODE blocks
------------------------------------------------------- */
body.nightmode .well,
body[data-theme="dark"] .well,
body.nightmode pre,
body[data-theme="dark"] pre,
body.nightmode code,
body[data-theme="dark"] code {
  background-color: var(--nm-bg-surface) !important;
  color: var(--nm-text) !important;
  border-color: var(--nm-border) !important;
}

/* -------------------------------------------------------
   32. CUSTOM HOVER TABLE ROW (overrides light-mode shadow)
------------------------------------------------------- */
body.nightmode .custom_hover > tbody > tr:hover,
body[data-theme="dark"] .custom_hover > tbody > tr:hover {
  box-shadow: 0 0 12px 0 rgba(90, 159, 212, 0.2) !important;
  background-color: var(--nm-bg-hover) !important;
}

/* -------------------------------------------------------
   33. DSR / FORM SECTION HEADINGS
------------------------------------------------------- */
body.nightmode .section-title,
body[data-theme="dark"] .section-title,
body.nightmode .card-title,
body[data-theme="dark"] .card-title,
body.nightmode .box-title,
body[data-theme="dark"] .box-title {
  color: var(--nm-text-heading) !important;
}

/* -------------------------------------------------------
   34. DASHBOARD COUNTS (Purchase List & Dashboard)
------------------------------------------------------- */
body.nightmode .dash-count,
body[data-theme="dark"] .dash-count {
  background-color: rgba(255, 159, 67, 0.15) !important;
  color: #ffb873 !important;
  border: 1px solid rgba(255, 159, 67, 0.3) !important;
}

body.nightmode .dash-count.das1,
body[data-theme="dark"] .dash-count.das1 {
  background-color: rgba(0, 207, 232, 0.15) !important;
  color: #61e3f5 !important;
  border: 1px solid rgba(0, 207, 232, 0.3) !important;
}

body.nightmode .dash-count.das2,
body[data-theme="dark"] .dash-count.das2 {
  background-color: var(--nm-bg-surface) !important;
  color: var(--nm-text-heading) !important;
  border: 1px solid var(--nm-border) !important;
}

body.nightmode .dash-count.das3,
body[data-theme="dark"] .dash-count.das3 {
  background-color: rgba(40, 199, 111, 0.15) !important;
  color: #5deb93 !important;
  border: 1px solid rgba(40, 199, 111, 0.3) !important;
}

body.nightmode .dash-count i,
body[data-theme="dark"] .dash-count i,
body.nightmode .dash-count svg,
body[data-theme="dark"] .dash-count svg,
body.nightmode .dash-count .info-box-text,
body[data-theme="dark"] .dash-count .info-box-text,
body.nightmode .dash-count .info-box-number,
body[data-theme="dark"] .dash-count .info-box-number {
  color: inherit !important;
}

/* -------------------------------------------------------
   34. PREMIUM CARDS (DSR Hisab Page)
------------------------------------------------------- */
body.nightmode .premium-card,
body[data-theme="dark"] .premium-card {
  background-color: var(--nm-bg-card) !important;
  border-color: var(--nm-border) !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4) !important;
}

body.nightmode .premium-card-header,
body[data-theme="dark"] .premium-card-header {
  background-color: var(--nm-bg-surface) !important;
  border-bottom-color: var(--nm-border) !important;
  color: var(--nm-text-heading) !important;
}

body.nightmode .premium-card-body,
body[data-theme="dark"] .premium-card-body {
  background: transparent !important;
  color: var(--nm-text) !important;
}
body.nightmode .premium-card-body *,
body[data-theme="dark"] .premium-card-body * {
  color: inherit;
}
body.nightmode .premium-card-body b,
body[data-theme="dark"] .premium-card-body b {
  color: var(--nm-text-heading) !important;
}

/* -------------------------------------------------------
   35. DAMAGE PROFILE VIEW
------------------------------------------------------- */
body.nightmode .cart-table th,
body[data-theme="dark"] .cart-table th {
  background: var(--nm-bg-surface) !important;
  color: var(--nm-text-heading) !important;
  border-bottom: 2px solid var(--nm-border) !important;
}

body.nightmode .cart-table td,
body[data-theme="dark"] .cart-table td {
  border-bottom: 1px solid var(--nm-border) !important;
  color: var(--nm-text) !important;
}

body.nightmode .cart-table tbody tr:hover,
body[data-theme="dark"] .cart-table tbody tr:hover {
  background: var(--nm-bg-dark) !important;
}

body.nightmode .cart-table tfoot td,
body[data-theme="dark"] .cart-table tfoot td {
  background: var(--nm-bg-surface) !important;
  border-top: 2px solid var(--nm-border) !important;
  color: var(--nm-text-heading) !important;
}

body.nightmode #btn-save-all:disabled,
body[data-theme="dark"] #btn-save-all:disabled {
  background: var(--nm-bg-surface) !important;
  color: #777 !important;
  border: 1px solid var(--nm-border) !important;
}

body.nightmode #btn-save-all,
body[data-theme="dark"] #btn-save-all {
  background: linear-gradient(135deg, rgba(39, 174, 96, 0.2) 0%, rgba(30, 132, 73, 0.3) 100%) !important;
  color: #5deb93 !important;
  box-shadow: none !important;
  border: 1px solid rgba(39, 174, 96, 0.5) !important;
}

body.nightmode #btn-save-all:hover,
body[data-theme="dark"] #btn-save-all:hover {
  background: linear-gradient(135deg, rgba(39, 174, 96, 0.3) 0%, rgba(30, 132, 73, 0.4) 100%) !important;
  color: #a7f3d0 !important;
}

body.nightmode #final_result_box .result-info,
body[data-theme="dark"] #final_result_box .result-info {
  background-color: var(--nm-bg-surface) !important;
  border-color: var(--nm-border) !important;
  color: var(--nm-text-heading) !important;
}
