/* =====================================================================================================================
   forms.css — Wave 3 (owner §5 field layout, §6 transfers): the operation screens' field rows and hints.
   Loaded AFTER app.css (App.razor). Only the treasury operation screens use these classes (cashbox transfer, cheque, voucher,
   mixed collection); everything else keeps app.css as it is. No inline styles on help / warning texts: one .hint block.
   ===================================================================================================================== */

/* the operation fields in ONE horizontal row on desktop where the space allows; the grid wraps by itself when it does not */
.doc-head.op-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:var(--s2) var(--s3);align-items:end}
.doc-head.op-row > label{display:flex;flex-direction:column;gap:3px;min-width:0;margin:0}
.doc-head.op-row > label > .inp,.doc-head.op-row > label > .lk,.doc-head.op-row > label > select.inp{margin-top:0;width:100%;min-width:0;max-width:100%}
.doc-head.op-row > label > small{min-height:0}
.doc-head.op-row > label > .pin,.doc-head.op-row > label > .method-pin{align-self:flex-start}
/* the one wide field of a row (notes / description) takes the whole row */
.doc-head.op-row > label.wide{grid-column:1 / -1}

/* help / warning texts under the field group — one block, no inline styles */
.doc > div.hint,.doc > .hint.block{display:flex;flex-wrap:wrap;gap:4px 12px;align-items:baseline;font-size:12px;color:var(--muted);margin:-4px 2px var(--s2)}
.doc > div.hint b,.doc > .hint.block b{color:var(--ink)}
.doc > div.hint .warn,.hint .warn{color:var(--danger);font-weight:600}
.doc > div.hint .field-err{flex:1 1 100%}
.doc > div.hint .btn.sm{margin-inline-start:4px}

/* the reason a disabled action button cannot be used right now — next to the button, same line */
.doc-actions [data-reason]{font-size:11.5px;align-self:center;white-space:normal;max-width:100%}
.doc-actions [data-action-error]{align-self:center;flex:1 1 100%;font-size:12px}
.action-panel [data-reason]{font-size:11.5px;align-self:center}
.action-panel label.grow{flex:1 1 280px}
.action-panel .pad,.alert .pad{margin-inline:4px}

/* phones: one column, nothing scrolls sideways, the same tab order */
@media (max-width:560px){
  .doc-head.op-row{grid-template-columns:1fr}
  .doc-head.op-row > label.wide{grid-column:auto}
  .doc > div.hint,.doc > .hint.block{flex-direction:column;align-items:stretch;gap:4px}
  .doc-actions [data-reason],.doc-actions [data-action-error]{flex:1 1 100%}
}

/* post-waves (E, 2026-10-25): the advisory overdraft warning of the transfer / payment screens — visible as a warning strip with the
   figures (amount vs balance, shortfall). Advisory only: the server refuses the posting (cashbox.overdraft) unless the company allows it. */
.hint .warn[data-overdraft-warn]{flex:1 1 100%;display:block;padding:6px 10px;border-radius:var(--r-sm,6px);background:var(--warn-bg,#fff6d6);
  border:1px solid var(--warn-bd,#f0d890);border-inline-start:4px solid var(--danger,#b42318);color:var(--ink,#1d2a35);font-weight:500;line-height:1.6}
.hint .warn[data-overdraft-warn] b{color:var(--danger,#b42318);font-weight:700}
/* the reasons row of a toolbar never pushes the buttons: it wraps under them, one line per cause */
.doc-actions .hints[data-action-reasons]:empty{display:none}

/* P5 visual check (2026-11-02) */
/* P5-12: the reasons row sits on its own line under ALL the toolbar buttons (it used to push «إلغاء» onto a line of its own) */
.doc-actions .hints[data-action-reasons]{order:100;flex:1 1 100%}
/* P5-04: the units repair notice stacks text, table and actions; the repair choice keeps a readable width whatever the samples are */
.alert.units-repair{display:flex;flex-direction:column;align-items:stretch;gap:8px}
.alert.units-repair .grid-scroll{max-height:none}
.alert.units-repair .units-repair-choice{min-width:14rem}
.alert.units-repair td.muted{white-space:normal;min-width:12rem}
.units-repair-confirm{display:flex;flex-direction:column;gap:6px}
@media (max-width:560px){ .alert.units-repair .units-repair-choice{min-width:11rem} }
/* P5-05: «متاح N» on its own line under the unit — it was cut off without «…» and read as a wrong quantity */
.doc-lines td.c-unit{line-height:1.25;text-overflow:ellipsis}
.doc-lines td.c-unit .avail{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:10.5px}
/* P5-06: the suggested price's source under the field, one line, the rest in its tooltip */
.eb-price .eb-src{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;margin-top:2px;font-size:10.5px}
/* P5-08: a price that differs from the suggested one (needs «تعديل الأسعار», audited) is visibly marked on its line */
.doc-lines td.has-override{box-shadow:inset 3px 0 0 var(--warn,#b54708)}
.doc-lines .ce.price-overridden{color:var(--warn,#b54708);font-weight:700}
/* P5-09: the loading state of a list or card is not the empty state */
.empty[data-loading]{opacity:.7}

/* EXP-UI-01 هـ2 (owner decision 93, 2026-11-22): a cashbox field of the voucher / expense / transfer / mixed screens is two grid
   columns wide, so the longest real cashbox name (~42 characters, e.g. «البنك الأهلي المصري (1735000944076301018)») shows whole;
   the option text is the name only and the field's title is the full name. The balance (expense voucher) is the small line under it.
   On a phone (one column) the field takes the row, and the full name is repeated on that line, wrapping, in case the box is still
   narrower than the name. Display only. */
.doc-head > label.cashbox-field{grid-column:span 2;min-width:0}
.doc-head > label.cashbox-field > select.inp{text-overflow:ellipsis}
.cashbox-line{display:flex;flex-wrap:wrap;gap:2px 8px;font-size:11.5px;font-weight:400;line-height:1.35;margin-top:2px}
.cashbox-line .cashbox-full-name{display:none;color:var(--ink-2);overflow-wrap:anywhere;min-width:0}
.cashbox-line.name-only{display:none}
@media (max-width:560px){
  .doc-head > label.cashbox-field{grid-column:auto}
  .cashbox-line.name-only{display:flex}
  .cashbox-line .cashbox-full-name{display:inline}
}
/* EXP-UI-01 (owner decision 103, 2026-11-22): the operation rows (receipt / payment, mixed collection and its extra parts, cashbox
   transfer: auto-fit columns of ≥160px). The longest real name needs ~316px of text at 16px + 10px padding each side + the arrow ≈
   360px (≈ 330px at 14.5px, ≈ 350px at 15.5px — app.css :root and its ≥1600 / ≥1920 sizes). Two columns guarantee only ≥332px,
   which at 768px (16px text) showed «…» on the receipt voucher and leaves no margin at 1600–1919px. So: THREE columns where the
   row has room (≥504px at any width), and the WHOLE row where the fields grow to 16px (app.css «phones and touch screens»: ≤860px
   or a touch pointer). Above 860px the row always has ≥3 columns (viewport − 256px menu − padding ≥ 504px).
   The expense voucher's plain header (≥180px columns) keeps two: ≥372px; ≤1180px it is two columns, so that is the whole row. */
.doc-head.op-row > label.cashbox-field{grid-column:span 3}
@media (max-width:860px), (pointer:coarse){
  .doc-head.op-row > label.cashbox-field{grid-column:1 / -1}
}
/* EXP-UI-01 (owner decision 105, 2026-11-22): on the computer the cashbox TRANSFER pairs each kind filter with its cashbox — «نوع
   المصدر» beside «خزينة المصدر», «نوع الوجهة» beside «خزينة الوجهة» — instead of the auto-fit row. Only the transfer row (it alone
   holds [data-transfer-from-kind]); receipt / payment, mixed and expense are unchanged. 861–1279px: two columns (kind | cashbox per
   row; cashbox ≥ 403px). From 1280px: four columns (kind | source | kind | destination on one row; cashbox ≥ 350px). The longest real
   name needs ≈ 306px at 14.5px / 326px at 15.5px / 336px at 16px (a lookup: no arrow). ≤860px stays exactly as accepted (each
   cashbox on its own whole row). A browser without :has() drops these rules and keeps that accepted auto-fit layout. Display only. */
@media (min-width:861px){
  .doc-head.op-row:has(> label > [data-transfer-from-kind]){grid-template-columns:minmax(120px,1fr) minmax(0,3fr)}
  .doc-head.op-row:has(> label > [data-transfer-from-kind]) > label.cashbox-field{grid-column:auto}
}
@media (min-width:1280px){
  .doc-head.op-row:has(> label > [data-transfer-from-kind]){grid-template-columns:minmax(120px,1fr) minmax(0,3fr) minmax(120px,1fr) minmax(0,3fr)}
}
