/* DB PHYSICS — UI contrast corrections
   UI-only override layer. Intentionally does not modify background,
   liquid-bg.js, animation CSS, animation timing, or visual effects. */

:root {
  --dbp-ui-light-text: #172033;
  --dbp-ui-light-muted: #475569;
  --dbp-ui-dark-text: #f1f5f9;
  --dbp-ui-dark-muted: #cbd5e1;
}

/* LIGHT THEME: improve low-contrast labels inside dashboard surfaces. */
html:not([data-theme="dark"]) body :is(
  .admin-card, .glass-card, .glass, .card, .record-card,
  .payment-glass-card, .modalbox, [role="dialog"]
) {
  color: var(--dbp-ui-light-text);
}

html:not([data-theme="dark"]) body :is(
  .admin-card, .glass-card, .glass, .card, .record-card,
  .payment-glass-card, .modalbox, [role="dialog"]
) :is(.text-slate-400, .text-gray-400) {
  color: #64748b !important;
}

html:not([data-theme="dark"]) body :is(
  .admin-card, .glass-card, .glass, .card, .record-card,
  .payment-glass-card, .modalbox, [role="dialog"]
) :is(.text-slate-500, .text-gray-500) {
  color: #475569 !important;
}

html:not([data-theme="dark"]) body :is(
  .admin-card, .glass-card, .glass, .card, .record-card,
  .payment-glass-card, .modalbox, [role="dialog"]
) :is(.text-slate-600, .text-gray-600) {
  color: #334155 !important;
}

html:not([data-theme="dark"]) body .admin-card :is(h1,h2,h3,h4,p,label,small,td) {
  color: #1f2937;
}

html:not([data-theme="dark"]) body .admin-card .muted,
html:not([data-theme="dark"]) body .admin-card .section-title {
  color: #475569 !important;
}

html:not([data-theme="dark"]) body .admin-card .text-white:not(
  .btn-primary, .btn-danger, .btn-success, .bg-indigo-600 *, .bg-purple-600 *
) {
  color: #172033 !important;
}

/* Form controls and dropdown choices must remain readable in both themes. */
body :is(input, select, textarea, .field) {
  font: inherit;
}

html:not([data-theme="dark"]) body :is(input, select, textarea, .field) {
  color: #172033 !important;
  -webkit-text-fill-color: #172033;
  background-color: rgba(255,255,255,.94);
  border-color: rgba(100,116,139,.48);
}

html:not([data-theme="dark"]) body :is(input, select, textarea)::placeholder {
  color: #64748b !important;
  -webkit-text-fill-color: #64748b;
  opacity: 1;
}

body select option {
  color: #172033;
  background: #fff;
}

/* Payment method / proof selectors: make the selected state obvious. */
body label:has(> input[type="radio"]),
body label:has(> input[type="checkbox"]) {
  cursor: pointer;
}

html:not([data-theme="dark"]) body label:has(> input[type="radio"]:checked),
html:not([data-theme="dark"]) body label:has(> input[type="checkbox"]:checked) {
  color: #312e81;
  background-color: #eef2ff;
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 2px rgba(99,102,241,.12);
}

html:not([data-theme="dark"]) body label:has(> input[type="radio"]),
html:not([data-theme="dark"]) body label:has(> input[type="checkbox"]) {
  color: #334155;
}

/* Admin tables: prevent fixed dark table text on dark glass panels. */
html:not([data-theme="dark"]) body .admin-card th { color: #475569 !important; }
html:not([data-theme="dark"]) body .admin-card td { color: #334155 !important; }

/* DARK THEME: keep nested light utility surfaces from producing white-on-white
   or dark-on-dark combinations inside cards and dialogs. */
html[data-theme="dark"] body :is(
  .admin-card, .glass-card, .glass, .card, .record-card,
  .payment-glass-card, .modalbox, [role="dialog"]
) {
  color: var(--dbp-ui-dark-text) !important;
}

html[data-theme="dark"] body :is(
  .admin-card, .glass-card, .glass, .card, .record-card,
  .payment-glass-card, .modalbox, [role="dialog"]
) :is(
  .bg-white, .bg-white\/70, .bg-white\/80, .bg-white\/90,
  .bg-slate-50, .bg-slate-50\/80, .bg-slate-100
) {
  color: #f1f5f9 !important;
  background-color: rgba(30,41,59,.88) !important;
  border-color: rgba(203,213,225,.22) !important;
}

html[data-theme="dark"] body :is(
  .admin-card, .glass-card, .glass, .card, .record-card,
  .payment-glass-card, .modalbox, [role="dialog"]
) :is(h1,h2,h3,h4,p,label,small,li,td,th,b,strong,span,div) {
  color: #e2e8f0;
}

/* Preserve semantic status colours and high-contrast action buttons. */
html[data-theme="dark"] body :is(
  .bg-emerald-50, .bg-emerald-100, .bg-green-50, .bg-green-100
) { background-color: rgba(20,83,45,.48) !important; }
html[data-theme="dark"] body :is(.text-emerald-700,.text-emerald-800,.text-green-700,.text-green-800) {
  color: #bbf7d0 !important;
}
html[data-theme="dark"] body :is(.bg-rose-50,.bg-rose-100,.bg-red-50,.bg-red-100) {
  background-color: rgba(127,29,29,.48) !important;
}
html[data-theme="dark"] body :is(.text-rose-600,.text-rose-700,.text-red-600,.text-red-700) {
  color: #fecaca !important;
}
html[data-theme="dark"] body :is(.bg-amber-50,.bg-amber-100) {
  background-color: rgba(120,53,15,.48) !important;
}
html[data-theme="dark"] body :is(.text-amber-700,.text-amber-800) {
  color: #fde68a !important;
}

html[data-theme="dark"] body :is(input,select,textarea,.field) {
  color: #f8fafc !important;
  -webkit-text-fill-color: #f8fafc;
  background-color: rgba(15,23,42,.88) !important;
  border-color: rgba(203,213,225,.42) !important;
}

html[data-theme="dark"] body :is(input,select,textarea)::placeholder {
  color: #cbd5e1 !important;
  -webkit-text-fill-color: #cbd5e1;
  opacity: 1;
}

html[data-theme="dark"] body select option {
  color: #f1f5f9;
  background: #1e293b;
}

html[data-theme="dark"] body label:has(> input[type="radio"]:checked),
html[data-theme="dark"] body label:has(> input[type="checkbox"]:checked) {
  color: #e0e7ff !important;
  background-color: rgba(79,70,229,.30) !important;
  border-color: #818cf8 !important;
  box-shadow: 0 0 0 2px rgba(129,140,248,.16);
}

html[data-theme="dark"] body .admin-card th { color: #cbd5e1 !important; }
html[data-theme="dark"] body .admin-card td { color: #e2e8f0 !important; }
html[data-theme="dark"] body .admin-card .muted,
html[data-theme="dark"] body .admin-card .section-title { color: #cbd5e1 !important; }

html[data-theme="dark"] body :is(.bg-indigo-50,.bg-indigo-100,.bg-purple-50,.bg-purple-100,.bg-blue-50,.bg-blue-100) {
  background-color: rgba(49,46,129,.42) !important;
}
html[data-theme="dark"] body :is(.text-indigo-600,.text-indigo-700,.text-purple-600,.text-purple-700,.text-blue-600,.text-blue-700) {
  color: #c7d2fe !important;
}
