/* flow module: how each clinic works. Pay first at the desk, the nurse's
   screen, the lone doctor's screen, the workflow settings and the visit form
   builder, the clinic's own visit fields, and the prescription papers.
   Flat, tokens only, logical properties. Print sheets are always paper white. */

/* ------------------------------------------------------- pay at the desk */

.flow-pay-line {
  margin-block-start: 6px;
}
.flow-pay-row {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.flow-pay {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}
.flow-pay.is-paid {
  background: var(--ok-soft);
  color: var(--ok);
}
.flow-pay.is-due {
  background: var(--danger-soft);
  color: var(--danger);
}
.flow-collect {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.flow-collect input[name='amount']:not([type='hidden']) {
  width: 92px;
  min-height: 34px;
  padding: 4px 8px;
}
.flow-collect select {
  width: auto;
  max-width: 170px;
  min-height: 34px;
  padding: 4px 8px;
}
.flow-gate-pay .flow-collect input[name='amount']:not([type='hidden']),
.flow-gate-pay .flow-collect select {
  width: 130px;
  min-height: 44px;
}
.flow-locked {
  color: var(--muted);
  background: var(--surface-2);
  border-style: dashed;
  cursor: not-allowed;
}
.flow-locked:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}
.flow-gate .empty p {
  font-size: 1.02rem;
  color: var(--ink);
}
.flow-gate-pay {
  display: flex;
  justify-content: center;
  padding-block: 4px 12px;
}
.flow-walkin-pay {
  padding: 8px 12px 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* ------------------------------------------------------ online bookings */

.flow-pending {
  border-color: var(--warn);
}
.flow-pending .card-head h2 .ic {
  color: var(--warn);
}
.flow-pending-list li {
  flex-wrap: wrap;
}
.flow-pending-list li > .flow-pending-who {
  flex: 1 1 220px;
}
.flow-pending-list .row-actions {
  flex-wrap: wrap;
}
.flow-pending-who {
  display: flex;
  flex-direction: column;
  flex: 1 1 220px;
  min-width: 0;
}
.flow-bk-note {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
}
.flow-bk-wait > .ic {
  color: var(--warn);
}

/* ------------------------------------------------------------- triage */

a.flow-tri-row {
  color: inherit;
}
a.flow-tri-row:hover {
  text-decoration: none;
  border-color: var(--brand);
}
.flow-tri-row.is-current {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}
.flow-vitals-in {
  border: 0;
  padding: 0;
  margin: 0;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.flow-vitals-in input {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
/* In a queue row the nurse's numbers are one compact line of chips. */
.q-main > .vitals,
.flow-tri-row .vitals {
  gap: 4px;
  margin-block-start: 6px;
}
.q-main > .vitals span,
.flow-tri-row .vitals span {
  flex-direction: row;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
}
.q-main > .vitals small,
.flow-tri-row .vitals small {
  font-size: 0.7rem;
}
.flow-from-tri {
  font-weight: 500;
  color: var(--ok);
}
.flow-alert-info {
  background: var(--info-soft);
  color: var(--info);
}

/* ------------------------------------------------------- the lone doctor */

.flow-now {
  border-width: 2px;
  border-color: var(--brand);
}
.flow-next {
  border-color: var(--warn);
}
.flow-now-who {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-block-end: 10px;
}
.flow-now-who > span:last-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.flow-big-no {
  width: 72px;
  height: 72px;
  font-size: 2rem;
  border-radius: 18px;
  background: var(--brand);
  color: var(--on-brand);
  border-color: transparent;
}
.flow-next .flow-big-no {
  background: var(--warn-soft);
  color: var(--warn);
}
.flow-big-name {
  font-size: 1.35rem;
  line-height: 1.3;
}
.flow-now-tri {
  padding: 10px 12px;
  margin-block-end: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.flow-gate-inline {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
}
.flow-gate-inline p {
  margin: 0 0 8px;
}
.q-row.is-next {
  border-color: var(--warn);
}
.flow-steps {
  margin: 0;
  padding-inline-start: 18px;
  color: var(--ink-2);
}
.flow-steps li + li {
  margin-block-start: 6px;
}

/* ----------------------------------------------------- workflow settings */

.flow-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-end: 16px;
}
.flow-subnav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.flow-presets {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
}
.flow-preset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.flow-preset h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.98rem;
}
.flow-preset h3 .ic {
  color: var(--brand);
}
.flow-preset p {
  margin: 0;
  color: var(--ink-2);
}
.flow-preset > .inline-form,
.flow-preset > .btn {
  margin-block-start: auto;
  align-self: flex-start;
}
.flow-preset.is-on {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.flow-preset-on {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-block-start: auto !important;
  color: var(--brand-ink) !important;
  font-weight: 600;
  font-size: 0.86rem;
}
.flow-preset-diff summary {
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-2);
}
.flow-preset-diff ul {
  margin: 6px 0 4px;
  padding-inline-start: 18px;
  font-size: 0.84rem;
  color: var(--ink-2);
}
.flow-preset-diff p {
  margin-block: 4px;
}
.flow-wf .card {
  margin-block-end: 0;
}
.stack-lg.flow-wf {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-block-end: 18px;
}
.flow-sub {
  padding-inline-start: 26px;
}
.flow-sub.is-off {
  opacity: 0.5;
}
.flow-gap {
  margin-block-start: 12px;
}
.flow-choice {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  margin-block-end: 8px;
}
.flow-sections {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.flow-sections li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.flow-sections li .check {
  flex: 1;
  margin: 0;
  padding: 6px 8px;
}
.flow-sections li:has(input[type='checkbox']:not(:checked)) {
  background: var(--surface-2);
  color: var(--muted);
}
.flow-move {
  display: inline-flex;
}
.flow-move .icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.flow-vitals-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0 12px;
}
.flow-docs {
  display: grid;
  gap: 0 18px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ------------------------------------------------------- the form builder */

.flow-form-list li > span {
  flex: 1;
}
.flow-editor {
  display: grid;
  gap: 18px;
  align-items: start;
}
@media (min-width: 1100px) {
  .flow-editor {
    grid-template-columns: minmax(0, 1fr) 400px;
  }
  .flow-editor > aside {
    position: sticky;
    inset-block-start: calc(var(--top-h) + 16px);
    max-height: calc(100vh - var(--top-h) - 32px);
    overflow: auto;
  }
}
.flow-editor .card {
  margin-block-end: 0;
}
.flow-ed-section + .flow-ed-section {
  margin-block-start: 14px;
}
.flow-ed-section h3 {
  margin: 0 0 6px;
  color: var(--ink-2);
  font-size: 0.86rem;
}
.flow-ed-fields {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.flow-ed-fields > li {
  padding: 8px 12px;
}
.flow-ed-fields > li + li {
  border-block-start: 1px solid var(--line);
}
.flow-ed-fields > li:target {
  background: var(--brand-soft);
}
.flow-ed-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.flow-ed-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 200px;
  min-width: 0;
}
.flow-ed-row .row-actions {
  display: inline-flex;
}
.flow-ed-row .icon-btn {
  width: 34px;
  height: 34px;
}
.flow-ed-edit summary {
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--brand-ink);
  font-weight: 600;
  width: fit-content;
}
.flow-ed-edit[open] {
  margin-block: 8px 4px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 12px;
}
@media (max-width: 560px) {
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
  .grid-3 > :first-child {
    grid-column: 1 / -1;
  }
}
.flow-preview [inert] {
  opacity: 0.95;
}

/* --------------------------------------------- the clinic's visit fields */

.flow-form .card-head h2 .ic {
  color: var(--violet);
}
.flow-section + .flow-section {
  margin-block-start: 6px;
  padding-block-start: 10px;
  border-block-start: 1px solid var(--line);
}
.flow-section h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--ink-2);
}
.flow-grid {
  display: grid;
  gap: 0 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.flow-grid .flow-wide {
  grid-column: 1 / -1;
}
.flow-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.flow-print {
  display: inline-grid;
  place-items: center;
  color: var(--info);
}
.flow-num {
  display: flex;
  align-items: center;
  gap: 6px;
}
.flow-num input {
  flex: 1;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.flow-num small {
  color: var(--muted);
  white-space: nowrap;
}
.flow-bmi {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.flow-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.flow-chip {
  position: relative;
  cursor: pointer;
}
.flow-chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.flow-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.86rem;
  font-weight: 500;
  user-select: none;
}
.flow-chip:hover span {
  border-color: var(--brand);
}
.flow-chip input:checked + span {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
}
.flow-chip input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.flow-chip.is-alert input:checked + span {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}
.flow-chips.is-scale .flow-chip span {
  min-width: 36px;
  justify-content: center;
  padding-inline: 6px;
  font-variant-numeric: tabular-nums;
}
.flow-pairs {
  display: grid;
  gap: 6px;
  margin-block-end: 14px;
}
.flow-pair {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.flow-pair-head span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.flow-pair-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-2);
}
.flow-pair-label .hint {
  font-weight: 400;
}
.flow-pair-label .flow-unit {
  margin-inline: 6px;
  font-weight: 500;
  color: var(--muted);
}
.flow-pair input {
  min-height: 40px !important;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 560px) {
  .flow-pair {
    grid-template-columns: 1fr 1fr;
  }
  .flow-pair-label {
    grid-column: 1 / -1;
  }
  .flow-pair-head span:first-child {
    display: none;
  }
}
.flow-out input,
.flow-out .flow-bmi,
input.flow-out {
  border-color: var(--danger) !important;
  background: var(--danger-soft) !important;
  color: var(--danger);
  font-weight: 700;
}
.field.flow-out > .flow-label::after,
.field.flow-out > label::after {
  content: 'برّه الطبيعي';
  padding: 0 8px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 700;
}
.flow-orders > .card:last-child {
  margin-block-end: 18px;
}
.flow-keys {
  margin-inline-start: auto;
  align-self: center;
}
.flow-keys kbd {
  font-size: 0.72rem;
}

/* weight trend */
.flow-trend {
  margin-block-start: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.flow-trend-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.88rem;
}
.flow-trend-head strong {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.flow-trend-svg {
  display: block;
  width: 100%;
  max-width: 420px;
  height: 80px;
  margin-block: 8px;
  color: var(--brand);
  /* the line runs oldest to newest left to right, like a chart is read */
  direction: ltr;
}
.flow-trend-svg circle {
  fill: var(--surface);
  stroke: currentColor;
  stroke-width: 2;
}
.flow-trend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.flow-trend-list li {
  display: flex;
  flex-direction: column;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.8rem;
}
.flow-trend-list strong {
  font-variant-numeric: tabular-nums;
}

/* values in the patient's timeline */
.flow-tl {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-block: 4px;
}
.flow-tl span {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.8rem;
}
.flow-tl small {
  color: var(--muted);
}
.flow-tl .is-out {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
  font-weight: 600;
}
.flow-mini-rx th,
.flow-mini-rx td {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------- the prescription */

.rx-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
  margin: 0;
  padding: 6px 0;
  border-block-end: 1px solid #ccc;
  font-size: 0.84rem;
}
.rx-fields > div {
  display: flex;
  gap: 6px;
}
.rx-fields dt {
  color: #555;
}
.rx-fields dt::after {
  content: ':';
}
.rx-fields dd {
  margin: 0;
  font-weight: 600;
}
.rx-fields .is-out dd {
  text-decoration: underline;
}
.rx-en {
  font-family: system-ui, 'Segoe UI', 'IBM Plex Sans Arabic', sans-serif;
}
.rx-en .rx-items strong,
.rx-en .rx-items span,
.rx-en .rx-items em,
.rx-en .rx-notes {
  text-align: left;
}
.rx-en .rx-symbol {
  font-family: Georgia, serif;
  font-style: italic;
}
.rx-sheet.rx-a4 {
  width: 210mm;
  min-height: 297mm;
  padding: 14mm 16mm;
  font-size: 1.06rem;
  page: rx-a4;
}
.rx-sheet.rx-a4 .rx-top h1 {
  font-size: 1.5rem;
}
.rx-sheet.rx-a4.rx-blank-head {
  padding-block-start: 60mm;
}
.rx-sheet.rx-half {
  width: 210mm;
  min-height: 0;
  height: 148.5mm;
  padding: 8mm 12mm;
  overflow: hidden;
  border-block-end: 1px dashed #999;
  page: rx-half;
}
.rx-sheet.rx-half.rx-blank-head {
  padding-block-start: 32mm;
}
.rx-sheet.rx-half .rx-qr svg {
  width: 16mm;
  height: 16mm;
}
@page rx-a4 {
  size: A4;
  margin: 0;
}
@page rx-half {
  size: A4;
  margin: 0;
}
@media print {
  .rx-sheet.rx-a4 {
    width: auto;
    min-height: calc(297mm - 1px);
  }
  .rx-sheet.rx-half {
    width: auto;
    height: 148.5mm;
    border-block-end: 1px dashed #999;
  }
}

/* glasses */
.flow-glasses-title {
  margin: 10px 0 2px;
  font-size: 1.05rem;
  color: var(--brand);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.flow-glasses-title small {
  font-size: 0.8rem;
  color: #555;
}
.flow-glasses-table {
  width: 100%;
  border-collapse: collapse;
  margin-block: 10px;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.flow-glasses-table th,
.flow-glasses-table td {
  border: 1px solid #bbb;
  padding: 6px 8px;
  text-align: center;
}
.flow-glasses-table thead th {
  background: #f1f1f1;
}
.flow-glasses-table tbody th {
  text-align: start;
  white-space: nowrap;
}
.flow-glasses-group th {
  background: #fafafa;
  text-align: start !important;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}
.flow-sign {
  margin-block-start: auto;
  padding-block-start: 18px;
  text-align: end;
}

/* --------------------------------------------- the waiting-room screen */

.tv-now .flow-tv-name {
  font-size: 1.6rem;
  font-style: normal;
  font-weight: 600;
}
.tv-next b {
  flex-direction: column;
  line-height: 1.1;
}
.tv-next b small {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.85;
}
