/*
 * mPanel refresh — a restyle layered over the Cuba Admin theme.
 *
 * Loaded LAST by every header (inc/header2.php, headermed.php, head-login.php,
 * rombakheader.php, doctor-rombakheader.php). Delete that one <link> line to
 * get the original look back; nothing else depends on this file.
 *
 * Direction: a clinical instrument, not a marketing dashboard. The people using
 * it are a nurse mid-encounter on an iPad and a doctor scanning a queue, so the
 * priorities are legibility, contrast and unambiguous state. Colour means
 * something (green = ready, blue = act, red = something is wrong) and is not
 * used for decoration.
 *
 * Signature: numbers are set in IBM Plex Mono with tabular figures — vitals,
 * record ids, dates, counts — so they read like a monitor readout and line up
 * in columns.
 *
 * What prompted it, measured on the add-staff form: input borders were #efefef
 * on white (1.1:1 contrast; WCAG 1.4.11 asks 3:1) and typed text and
 * placeholder were the same #898989, so a filled field and an empty one looked
 * identical.
 */

:root {
  --ink:        #14212B;   /* primary text */
  --ink-2:      #4A5B68;   /* secondary text, labels */
  --ink-3:      #6B7B88;   /* placeholder, hints — 4.6:1 on white */
  --surface:    #F4F7F9;   /* page background */
  --panel:      #FFFFFF;
  --line:       #DCE3E9;   /* card and table dividers */
  --field:      #7F909E;   /* form field borders — 3.3:1 on white */
  --field-ro:   #EEF2F5;   /* read-only fields */
  --brand:      #1A7FB5;   /* POD blue, darkened from the logo's #32ABE2 to pass AA as text */
  --brand-soft: #E3F1F9;
  --ok:         #1B8F5F;
  --ok-soft:    #E2F4EC;
  --alert:      #C62839;
  --alert-soft: #FBE7E9;
  --wait:       #8A6D1F;
  --wait-soft:  #FBF3DC;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-sm: 6px;
  --r:    10px;
  --shadow: 0 1px 2px rgba(20, 33, 43, .06), 0 2px 8px rgba(20, 33, 43, .04);
  --focus: 0 0 0 3px rgba(26, 127, 181, .28);
}

/* ---- Base ------------------------------------------------------------------ */

html body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--surface);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

html body h1, html body h2, html body h3, html body h4, html body h5, html body h6,
html body .page-title h3, html body .card .card-header h5 {
  font-family: var(--sans);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}

html body .page-wrapper .page-body-wrapper,
html body .page-wrapper .page-body-wrapper .page-body {
  background: var(--surface);
}

/* The signature: numbers as instrument readouts. Tables stay in the sans —
 * names in mono read like code — but with tabular figures so dates and ids
 * still align down a column. */
html body table.dataTable td {
  font-variant-numeric: tabular-nums;
}
html body .static-top-widget h4,
html body .static-top-widget .counter,
html body input[type="number"],
html body input[type="date"],
html body input[type="time"],
html body .readout {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

a { color: var(--brand); }

/* ---- Cards ----------------------------------------------------------------- */

html body .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
html body .card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--line);
  padding: 20px 24px;
}
html body .card .card-body { padding: 24px; }

/* ---- Forms -----------------------------------------------------------------
 * The theme sets field colours through selectors up to specificity 0,4,1
 * (.theme-form select.form-control:not([size]):not([multiple])). Matching that
 * rule by rule would mean dozens of selectors; these few properties are the
 * one place this file uses !important, and only for form fields.
 */

html body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]), select, textarea):is(.form-control, .form-select),
html body .theme-form :is(input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]), select, textarea),
html body .dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--field) !important;
  background-color: var(--panel) !important;
  color: var(--ink) !important;
  font-family: var(--sans);
  font-size: 15px;
  min-height: 44px;            /* touch target */
  border-radius: var(--r-sm);
  box-shadow: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}

html body :is(input, select, textarea)::placeholder {
  color: var(--ink-3) !important;
  opacity: 1;
}

html body :is(input, select, textarea):focus,
html body :is(input, select, textarea):focus-visible {
  border-color: var(--brand) !important;
  box-shadow: var(--focus) !important;
  outline: none;
}

html body :is(input, select, textarea)[readonly],
html body :is(input, select, textarea):disabled {
  background-color: var(--field-ro) !important;
  border-color: var(--line) !important;
  color: var(--ink-2) !important;
}

html body input[type="file"].form-control {
  border: 1px dashed var(--field) !important;
  background: var(--surface) !important;
  padding: 8px;
  min-height: 44px;
}

html body :is(label, .col-form-label, .form-label):not(.badge) {
  color: var(--ink-2);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: .01em;
}

html body input[type="checkbox"], html body input[type="radio"] {
  accent-color: var(--brand);
  width: 18px;
  height: 18px;
}

/* ---- Buttons --------------------------------------------------------------- */

html body .btn {
  font-family: var(--sans);
  font-weight: 600;
  border-radius: var(--r-sm);
  min-height: 40px;
  padding: 8px 18px;
  letter-spacing: .01em;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
html body .btn:focus-visible { box-shadow: var(--focus); outline: none; }

html body .btn-primary, html body .btn-primary:not(:disabled):not(.disabled) {
  background-color: var(--brand) !important;
  border-color: var(--brand) !important;
  color: #fff !important;
}
html body .btn-primary:hover { background-color: #156A98 !important; border-color: #156A98 !important; }

html body :is(.btn-light, .btn-secondary, .btn-outline-primary) {
  background: var(--panel) !important;
  border: 1px solid var(--field) !important;
  color: var(--ink) !important;
}

/* DataTables export buttons: the unstyled grey browser buttons. */
html body .dt-buttons .dt-button, html body button.dt-button {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  color: var(--ink-2) !important;
  border-radius: var(--r-sm) !important;
  font: 600 13px var(--sans) !important;
  padding: 6px 12px !important;
  margin-right: 6px;
  box-shadow: none !important;
}
html body .dt-buttons .dt-button:hover { border-color: var(--field) !important; color: var(--ink) !important; }

/* ---- State buttons in the live tables ---------------------------------------
 * The PHP writes pure #00cc00 / #ff0000 inline. Red read as "error" when it
 * means "not ready yet", so it becomes a neutral waiting state; green becomes
 * a calmer ok green. Inline styles need !important to override.
 */
html body a.btn[style*="#00cc00"] {
  background-color: var(--ok) !important;
  border-color: var(--ok) !important;
  color: #fff !important;
}
html body a.btn.on-call-btn[style*="#ff0000"] {
  background-color: var(--wait-soft) !important;
  border: 1px solid #E4CF8F !important;
  color: var(--wait) !important;
}
html body a.btn.on-call-btn[style*="#ff0000"]::after { content: " · waiting"; font-weight: 500; }

/* ---- Tables ---------------------------------------------------------------- */

html body table.dataTable {
  border-collapse: separate !important;
  border-spacing: 0;
}
html body table.dataTable thead th {
  background: var(--surface);
  color: var(--ink-2);
  font: 600 12.5px var(--sans);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--line) !important;
  white-space: nowrap;
}
html body table.dataTable tbody td {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  white-space: nowrap;          /* dates were wrapping over three lines */
  vertical-align: middle;
  font-size: 14px;
  color: var(--ink);
}
html body table.dataTable tbody tr:hover td { background: #F9FBFC; }
html body .dataTables_wrapper .dataTables_paginate .paginate_button.current,
html body .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--brand) !important;
  border-color: var(--brand) !important;
  color: #fff !important;
  border-radius: var(--r-sm);
}

/* ---- Stat cards on the dashboard --------------------------------------------
 * Four solid navy tiles with watermark icons were the loudest thing on the
 * page and carried the least information. Quiet panels; the number carries
 * the weight.
 */
html body .static-top-widget { position: relative; }
html body .card-body.bg-primary:has(.static-top-widget) {
  background: var(--panel) !important;
  border: 1px solid var(--line);
  border-radius: var(--r) !important;
  box-shadow: var(--shadow);
}
html body .static-top-widget .icon-bg { display: none; }
html body .static-top-widget :is(span, p, .m-0) { color: var(--ink-2) !important; font-weight: 600; font-size: 13px; }
html body .static-top-widget h4 { color: var(--ink) !important; font-size: 30px; font-weight: 500; }
html body .static-top-widget .align-self-center {
  background: var(--brand-soft) !important;
  border-radius: var(--r-sm);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
html body .static-top-widget .align-self-center svg {
  fill: none !important;
  stroke: var(--brand) !important;
  width: 24px;
  height: 24px;
}
html body .static-top-widget .align-self-center i {
  color: var(--brand) !important;
  font-size: 22px;
}

/* ---- Header ------------------------------------------------------------------ */

html body .page-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}
html body .page-header .mega-menu.outside .nav-link {
  background: transparent !important;
  color: var(--ink-2) !important;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
html body .page-header .level-menu.outside .nav-link {
  background: var(--brand) !important;
  color: #fff !important;
  border-radius: var(--r-sm);
}
html body .page-header .level-menu.outside .nav-link :is(svg, i) { stroke: #fff; color: #fff; }

/* ---- Sidebar ----------------------------------------------------------------- */

html body .sidebar-wrapper { border-right: 1px solid var(--line); box-shadow: none; }
html body .sidebar-wrapper .sidebar-main-title > div {
  background: transparent !important;
  padding: 18px 16px 6px !important;
}
html body .sidebar-wrapper .sidebar-main-title h6 {
  font-size: 11.5px !important;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3) !important;
}
html body .sidebar-wrapper .sidebar-main-title p { display: none; }
html body .sidebar-wrapper .sidebar-link span { color: var(--ink); font-weight: 500; }
html body .sidebar-wrapper .sidebar-link.active,
html body .sidebar-wrapper .sidebar-link:hover {
  background: var(--brand-soft) !important;
  border-radius: var(--r-sm);
}
html body .sidebar-wrapper .badge {
  background: var(--field-ro) !important;
  color: var(--ink-2) !important;
  font: 600 10.5px var(--sans);
  letter-spacing: .02em;
}

/* ---- Alerts ------------------------------------------------------------------ */

html body .alert { border-radius: var(--r-sm); border: 1px solid transparent; font-weight: 500; }
html body .alert-success { background: var(--ok-soft) !important; color: #145E40 !important; border-color: #B7E1CC; }
html body .alert-danger  { background: var(--alert-soft) !important; color: #8E1C29 !important; border-color: #F1BFC5; }

/* ---- Quality floor ----------------------------------------------------------- */

html body :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  html body * { transition: none !important; animation: none !important; }
}
