/* APK Final Readability Guard 2027
   Static CSS only. No observers, no redraw loops.
   Purpose: prevent white-on-white / gray-on-dark text issues in filter chips,
   dark mode panels, DataTables controls, and legacy inline button styles. */

/* ---------- Light mode filter chips / old filter buttons ---------- */
html:not([data-apk-theme="dark"]) body #main .apk-filter-chip,
html:not([data-apk-theme="dark"]) body #main .apk-filter-chips a,
html:not([data-apk-theme="dark"]) body #main .apk-filter-panel a,
html:not([data-apk-theme="dark"]) body #main .apk-sp-filterbar a,
html:not([data-apk-theme="dark"]) body #main .apk-sp-filter-row a,
html:not([data-apk-theme="dark"]) body #main a.apk-filter-chip,
html:not([data-apk-theme="dark"]) body #main button.apk-filter-chip{
  background:#ffffff!important;
  background-image:none!important;
  color:#14233d!important;
  -webkit-text-fill-color:#14233d!important;
  border:1px solid #bfd3f3!important;
  opacity:1!important;
  visibility:visible!important;
  text-shadow:none!important;
}

html:not([data-apk-theme="dark"]) body #main .apk-filter-chip.is-active,
html:not([data-apk-theme="dark"]) body #main .apk-filter-chips a.is-active,
html:not([data-apk-theme="dark"]) body #main .apk-filter-panel a.is-active,
html:not([data-apk-theme="dark"]) body #main .apk-sp-filterbar a.is-active,
html:not([data-apk-theme="dark"]) body #main .apk-sp-filter-row a.is-active,
html:not([data-apk-theme="dark"]) body #main a.apk-filter-chip.is-active,
html:not([data-apk-theme="dark"]) body #main button.apk-filter-chip.is-active{
  background:linear-gradient(135deg,#ec4899 0%,#4f46e5 100%)!important;
  color:#ffffff!important;
  -webkit-text-fill-color:#ffffff!important;
  border-color:transparent!important;
}

/* Legacy year/month filters using .btn-danger + inline styles. */
html:not([data-apk-theme="dark"]) body #main a.btn,
html:not([data-apk-theme="dark"]) body #main button.btn{
  -webkit-text-fill-color:currentColor;
}
html:not([data-apk-theme="dark"]) body #main a.btn-danger,
html:not([data-apk-theme="dark"]) body #main button.btn-danger{
  color:#ffffff!important;
  -webkit-text-fill-color:#ffffff!important;
}

/* ---------- Dark mode global readable surfaces ---------- */
html[data-apk-theme="dark"] body,
body[data-apk-theme="dark"]{
  color:#eef6ff!important;
}

html[data-apk-theme="dark"] body #main,
body[data-apk-theme="dark"] #main{
  color:#eef6ff!important;
}

html[data-apk-theme="dark"] body #main .card,
html[data-apk-theme="dark"] body #main .card-body,
html[data-apk-theme="dark"] body #main .form-group,
html[data-apk-theme="dark"] body #main .modal-content,
html[data-apk-theme="dark"] body #main .apk-entry-dialog,
html[data-apk-theme="dark"] body #main .table-responsive,
html[data-apk-theme="dark"] body #main .dataTables_wrapper,
html[data-apk-theme="dark"] body #main .pf-card,
html[data-apk-theme="dark"] body #main .pf-status-card,
html[data-apk-theme="dark"] body #main .apk-filter-panel,
html[data-apk-theme="dark"] body #main .apk-sp-filterbar,
body[data-apk-theme="dark"] #main .card,
body[data-apk-theme="dark"] #main .card-body,
body[data-apk-theme="dark"] #main .form-group,
body[data-apk-theme="dark"] #main .modal-content,
body[data-apk-theme="dark"] #main .apk-entry-dialog,
body[data-apk-theme="dark"] #main .table-responsive,
body[data-apk-theme="dark"] #main .dataTables_wrapper,
body[data-apk-theme="dark"] #main .pf-card,
body[data-apk-theme="dark"] #main .pf-status-card,
body[data-apk-theme="dark"] #main .apk-filter-panel,
body[data-apk-theme="dark"] #main .apk-sp-filterbar{
  background:#0f2036!important;
  background-image:none!important;
  color:#eef6ff!important;
  -webkit-text-fill-color:initial!important;
  border-color:rgba(125,170,235,.30)!important;
}

/* Dark text classes that often become unreadable on dark background. */
html[data-apk-theme="dark"] body #main .text-dark,
html[data-apk-theme="dark"] body #main .text-body,
html[data-apk-theme="dark"] body #main .text-muted,
html[data-apk-theme="dark"] body #main .text-secondary,
html[data-apk-theme="dark"] body #main .text-black-50,
html[data-apk-theme="dark"] body #main .small,
html[data-apk-theme="dark"] body #main small,
html[data-apk-theme="dark"] body #main label,
html[data-apk-theme="dark"] body #main .form-text,
html[data-apk-theme="dark"] body #main .dataTables_info,
html[data-apk-theme="dark"] body #main .dataTables_length label,
html[data-apk-theme="dark"] body #main .dataTables_filter label,
body[data-apk-theme="dark"] #main .text-dark,
body[data-apk-theme="dark"] #main .text-body,
body[data-apk-theme="dark"] #main .text-muted,
body[data-apk-theme="dark"] #main .text-secondary,
body[data-apk-theme="dark"] #main .text-black-50,
body[data-apk-theme="dark"] #main .small,
body[data-apk-theme="dark"] #main small,
body[data-apk-theme="dark"] #main label,
body[data-apk-theme="dark"] #main .form-text,
body[data-apk-theme="dark"] #main .dataTables_info,
body[data-apk-theme="dark"] #main .dataTables_length label,
body[data-apk-theme="dark"] #main .dataTables_filter label{
  color:#d7e5f7!important;
  -webkit-text-fill-color:#d7e5f7!important;
  opacity:1!important;
}

html[data-apk-theme="dark"] body #main h1,
html[data-apk-theme="dark"] body #main h2,
html[data-apk-theme="dark"] body #main h3,
html[data-apk-theme="dark"] body #main h4,
html[data-apk-theme="dark"] body #main h5,
html[data-apk-theme="dark"] body #main h6,
html[data-apk-theme="dark"] body #main p,
html[data-apk-theme="dark"] body #main td,
html[data-apk-theme="dark"] body #main th,
html[data-apk-theme="dark"] body #main li,
body[data-apk-theme="dark"] #main h1,
body[data-apk-theme="dark"] #main h2,
body[data-apk-theme="dark"] #main h3,
body[data-apk-theme="dark"] #main h4,
body[data-apk-theme="dark"] #main h5,
body[data-apk-theme="dark"] #main h6,
body[data-apk-theme="dark"] #main p,
body[data-apk-theme="dark"] #main td,
body[data-apk-theme="dark"] #main th,
body[data-apk-theme="dark"] #main li{
  color:#eef6ff!important;
  -webkit-text-fill-color:#eef6ff!important;
}

/* Dark mode filter chips: never white box with invisible text. */
html[data-apk-theme="dark"] body #main .apk-filter-chip,
html[data-apk-theme="dark"] body #main .apk-filter-chips a,
html[data-apk-theme="dark"] body #main .apk-filter-panel a,
html[data-apk-theme="dark"] body #main .apk-sp-filterbar a,
html[data-apk-theme="dark"] body #main .apk-sp-filter-row a,
html[data-apk-theme="dark"] body #main a.apk-filter-chip,
html[data-apk-theme="dark"] body #main button.apk-filter-chip,
body[data-apk-theme="dark"] #main .apk-filter-chip,
body[data-apk-theme="dark"] #main .apk-filter-chips a,
body[data-apk-theme="dark"] #main .apk-filter-panel a,
body[data-apk-theme="dark"] #main .apk-sp-filterbar a,
body[data-apk-theme="dark"] #main .apk-sp-filter-row a,
body[data-apk-theme="dark"] #main a.apk-filter-chip,
body[data-apk-theme="dark"] #main button.apk-filter-chip{
  background:#142844!important;
  background-image:none!important;
  color:#eef6ff!important;
  -webkit-text-fill-color:#eef6ff!important;
  border:1px solid rgba(125,170,235,.42)!important;
  box-shadow:0 8px 18px rgba(0,0,0,.22)!important;
  opacity:1!important;
  visibility:visible!important;
  text-shadow:none!important;
}

html[data-apk-theme="dark"] body #main .apk-filter-chip.is-active,
html[data-apk-theme="dark"] body #main .apk-filter-chips a.is-active,
html[data-apk-theme="dark"] body #main .apk-filter-panel a.is-active,
html[data-apk-theme="dark"] body #main .apk-sp-filterbar a.is-active,
html[data-apk-theme="dark"] body #main .apk-sp-filter-row a.is-active,
html[data-apk-theme="dark"] body #main a.apk-filter-chip.is-active,
html[data-apk-theme="dark"] body #main button.apk-filter-chip.is-active,
body[data-apk-theme="dark"] #main .apk-filter-chip.is-active,
body[data-apk-theme="dark"] #main .apk-filter-chips a.is-active,
body[data-apk-theme="dark"] #main .apk-filter-panel a.is-active,
body[data-apk-theme="dark"] #main .apk-sp-filterbar a.is-active,
body[data-apk-theme="dark"] #main .apk-sp-filter-row a.is-active,
body[data-apk-theme="dark"] #main a.apk-filter-chip.is-active,
body[data-apk-theme="dark"] #main button.apk-filter-chip.is-active{
  background:linear-gradient(135deg,#f052a7 0%,#4f46e5 100%)!important;
  color:#ffffff!important;
  -webkit-text-fill-color:#ffffff!important;
  border-color:transparent!important;
}

/* Inputs/selects/date/select2 in dark mode. */
html[data-apk-theme="dark"] body #main input,
html[data-apk-theme="dark"] body #main select,
html[data-apk-theme="dark"] body #main textarea,
html[data-apk-theme="dark"] body #main .form-control,
html[data-apk-theme="dark"] body #main .select2-selection,
html[data-apk-theme="dark"] body .select2-dropdown,
body[data-apk-theme="dark"] #main input,
body[data-apk-theme="dark"] #main select,
body[data-apk-theme="dark"] #main textarea,
body[data-apk-theme="dark"] #main .form-control,
body[data-apk-theme="dark"] #main .select2-selection,
body[data-apk-theme="dark"] .select2-dropdown{
  background:#10243d!important;
  color:#f8fbff!important;
  -webkit-text-fill-color:#f8fbff!important;
  border-color:rgba(125,170,235,.45)!important;
}
html[data-apk-theme="dark"] body #main input::placeholder,
html[data-apk-theme="dark"] body #main textarea::placeholder,
body[data-apk-theme="dark"] #main input::placeholder,
body[data-apk-theme="dark"] #main textarea::placeholder{
  color:#cbdaf0!important;
  -webkit-text-fill-color:#cbdaf0!important;
  opacity:1!important;
}

/* Buttons: keep button text visible, including Print/Finish/Done/Cancel. */
html[data-apk-theme="dark"] body #main button,
html[data-apk-theme="dark"] body #main .btn,
html[data-apk-theme="dark"] body #main .button,
html[data-apk-theme="dark"] body #main input[type="submit"],
html[data-apk-theme="dark"] body #main input[type="button"],
body[data-apk-theme="dark"] #main button,
body[data-apk-theme="dark"] #main .btn,
body[data-apk-theme="dark"] #main .button,
body[data-apk-theme="dark"] #main input[type="submit"],
body[data-apk-theme="dark"] #main input[type="button"]{
  opacity:1!important;
  visibility:visible!important;
  text-shadow:none!important;
}
html[data-apk-theme="dark"] body #main .btn-primary,
html[data-apk-theme="dark"] body #main .btn-info,
html[data-apk-theme="dark"] body #main .btn-success,
html[data-apk-theme="dark"] body #main .btn-danger,
html[data-apk-theme="dark"] body #main .apk-print-button,
html[data-apk-theme="dark"] body #main .print-button,
html[data-apk-theme="dark"] body #main .apk-flow-link,
body[data-apk-theme="dark"] #main .btn-primary,
body[data-apk-theme="dark"] #main .btn-info,
body[data-apk-theme="dark"] #main .btn-success,
body[data-apk-theme="dark"] #main .btn-danger,
body[data-apk-theme="dark"] #main .apk-print-button,
body[data-apk-theme="dark"] #main .print-button,
body[data-apk-theme="dark"] #main .apk-flow-link{
  color:#ffffff!important;
  -webkit-text-fill-color:#ffffff!important;
}
