/* PrivaNex · Forms CSS (04 Nov 2026)
 * Inline forms: filter bars, toolbars and short action forms (a field with its button).
 * Fields carry width:100% from the base style. Inside a flex row, every list or field then took a whole line,
 * and the button dropped below it. In a row, fields now take their natural width and line up with their buttons
 * at one height. Long forms (.dpc-field, .dpc-grid) are not changed.
 * Specificity is kept low on purpose (row class + one :not): a component that sets its own field width keeps it. */

:root {
  --pnx-inline-h: 36px;          /* one height for fields and buttons in a row */
  --pnx-inline-h-sm: 34px;
  --pnx-bar-bg: #F7F9FC;
  --pnx-bar-border: #DCE3EE;
  --pnx-field-bg: #FFFFFF;
  --pnx-navy: #10458F;
  --pnx-orange: #FF791F;
}

[data-theme=dark] { --pnx-bar-bg: var(--surface-2); --pnx-bar-border: var(--border); --pnx-field-bg: var(--surface); }

/* 1. Fields in a row keep their own width instead of a whole line */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, .dpc-input, select, input):where(:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image])):not(.dpc-sr) {
  width: auto;
  max-width: 100%;
  min-width: 0;
  flex: 0 1 auto;
  box-sizing: border-box;
}
/* lists: wide enough for their longest usual option, never a whole line */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, select):where(:not([multiple])):not(.dpc-sr) { flex: 0 1 15rem; min-width: 10.5rem; max-width: 20rem; }
/* text, search, e-mail and reason fields take the room left, up to a readable width */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input):where([type=text], [type=search], [type=email], [type=url], [type=tel], [type=password], :not([type])):not(.dpc-sr) { flex: 1 1 14rem; min-width: 10rem; max-width: 30rem; }
/* an inline form shown in a text block (no flex box): a readable field, its button beside it */
.dpc-inline-form > :where(.dpc-input, input):where([type=text], [type=search], :not([type])):not(.dpc-sr) { width: 16rem; }
/* short values */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input)[type=number]:not(.dpc-sr) { flex: 0 0 7rem; width: 7rem; min-width: 5.5rem; }
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input)[type=time]:not(.dpc-sr) { flex: 0 0 8.5rem; width: 8.5rem; }
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input):where([type=date], [type=month], [type=week]):not(.dpc-sr) { flex: 0 0 10.5rem; width: 10.5rem; }
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input)[type=datetime-local]:not(.dpc-sr) { flex: 0 0 13.5rem; width: 13.5rem; }
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input)[type=file]:not(.dpc-sr) { flex: 1 1 16rem; min-width: 12rem; max-width: 26rem; }
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input)[type=color]:not(.dpc-sr) { flex: 0 0 3rem; width: 3rem; padding: 2px; }
/* a list that allows several choices keeps a sensible box */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, select)[multiple]:not(.dpc-sr) { flex: 0 1 16rem; min-width: 12rem; max-width: 22rem; }

/* 2. One height: fields and buttons of a row line up */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, .dpc-input, select, input):where(:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=file]):not([type=submit]):not([type=button]):not([type=color]):not([multiple])):not(.dpc-sr) {
  height: var(--pnx-inline-h);
  min-height: var(--pnx-inline-h);
  padding-top: 0;
  padding-bottom: 0;
}
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, select):where(:not([multiple])):not(.dpc-sr) { padding-left: 12px; padding-right: 34px; }
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input):where([type=text], [type=search], [type=email], [type=url], [type=tel], [type=password], :not([type])):not(.dpc-sr) { padding-left: 12px; padding-right: 12px; }
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, .dpc-input, select, input):where(:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=file]):not([type=submit]):not([type=button]):not([type=color]):not([multiple])):where(.dpc-select--sm, .dpc-input--sm):not(.dpc-sr) {
  height: var(--pnx-inline-h-sm);
  min-height: var(--pnx-inline-h-sm);
  font-size: .8125rem;
}
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input)[type=file]:not(.dpc-sr) { min-height: var(--pnx-inline-h); padding-top: 3px; padding-bottom: 3px; }

/* a button next to fields: same height, never squeezed */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form):where(:has(> :where(.dpc-select, .dpc-input, select, input):where(:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image])))) > :where(.dpc-btn, button):not(.dpc-sr) {
  flex: 0 0 auto;
  height: var(--pnx-inline-h);
  min-height: var(--pnx-inline-h);
  white-space: nowrap;
}
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form):where(:has(> :where(.dpc-select--sm, .dpc-input--sm))) > :where(.dpc-btn--sm):not(.dpc-sr) {
  height: var(--pnx-inline-h-sm);
  min-height: var(--pnx-inline-h-sm);
  padding-left: 14px;
  padding-right: 14px;
}
/* a nested inline form inside a row keeps its fields on its line */
.dpc-row > :where(form.dpc-row, .dpc-inline-form):not(.dpc-sr) { flex: 0 1 auto; min-width: 0; }
/* a label shown before its field in a row */
.dpc-row > :where(label):not(.dpc-sr):not(.dpc-check) { flex: 0 0 auto; margin: 0; white-space: nowrap; }

/* 2b. A short action form (one field and its buttons: a reason with Reject, a translation with Save, a filter with
 * its button) keeps the button on the field's line, also inside a table cell or next to other actions */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form):where(:has(> :is(select, textarea, input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]))):not(:has(> :is(select, textarea, input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button])) ~ :is(select, textarea, input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]))))):not(.dpc-sr) { flex-wrap: nowrap; }
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form):where(:has(> :is(select, textarea, input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]))):not(:has(> :is(select, textarea, input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button])) ~ :is(select, textarea, input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]))))) > :where(.dpc-select, .dpc-input, select, input):where(:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image])):not(.dpc-sr) { min-width: 6rem; }
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-page-head) > :where(form):is(.dpc-row, .dpc-actions, .dpc-inline-form) { flex: 0 1 auto; min-width: 0; }
/* a nested form whose field is text (a label, a reason, a note) takes the room left, so the text is not cut */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-page-head) > :where(form):is(.dpc-row, .dpc-actions, .dpc-inline-form):where(:has(> :is(input:not([type]), input[type=text], input[type=search]))) { flex: 1 1 18rem; max-width: 36rem; }

/* 2c. Inside a table cell, fields stay compact and wrap in pieces instead of one field per line */
:where(td, th) :is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, .dpc-input, select, input):where(:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image])):not(.dpc-sr) { flex: 0 1 auto; min-width: 4.5rem; max-width: 100%; }
:where(td, th) :is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input):where([type=text], [type=search], [type=email], :not([type])):not(.dpc-sr) { width: 100%; flex: 1 1 0; min-width: 5rem; }
/* (width 100% in a cell: the table sizes its columns from the content, not from the field) */
:where(td, th) :is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input)[type=number]:not(.dpc-sr) { flex: 0 0 5rem; width: 5rem; min-width: 4.5rem; }
:where(td, th) :is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-input, input)[type=time]:not(.dpc-sr) { flex: 0 0 7.5rem; width: 7.5rem; }
:where(td, th) :is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, select):not(.dpc-sr) { flex: 0 1 9rem; min-width: 7rem; }
:where(td, th) :is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(label, span):not(.dpc-sr) { white-space: nowrap; }

/* 3. Filter bars: the search and filter form above a list reads as one toolbar */
main form:is([method=GET], [method=get]).dpc-row:not(.dpc-card):not(.dpc-card__body):not(:is(.dpc-row, .dpc-actions, .dpc-page-head, .dpc-wrap-row, td) > *) {
  padding: 10px 12px;
  background: var(--pnx-bar-bg);
  border: 1px solid var(--pnx-bar-border);
  border-radius: 10px;
  gap: 8px 10px !important;
  align-items: center;
}
main form:is([method=GET], [method=get]).dpc-row > :where(.dpc-select, .dpc-input, select, input):not(.dpc-sr) { background-color: var(--pnx-field-bg); }
/* the filter button of a toolbar is its one action: navy outline, filled on hover */
main form:is([method=GET], [method=get]).dpc-row > .dpc-btn--secondary:where([type=submit]) { border-color: var(--pnx-navy); color: var(--pnx-navy); background: var(--pnx-field-bg); }
main form:is([method=GET], [method=get]).dpc-row > .dpc-btn--secondary:where([type=submit]):hover { background: var(--pnx-navy); color: #fff; }

/* dark theme: the navy outline becomes the link colour so it stays readable */
[data-theme=dark] main form:is([method=GET], [method=get]).dpc-row > .dpc-btn--secondary:where([type=submit]) { border-color: var(--link, #7FB5E8); color: var(--link, #7FB5E8); }
[data-theme=dark] main form:is([method=GET], [method=get]).dpc-row > .dpc-btn--secondary:where([type=submit]):hover { background: var(--primary, #2B6CB0); color: #fff; }

/* focus: one clear ring for every field of a row */
:is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, .dpc-input, select, input):focus-visible {
  outline: none;
  border-color: var(--pnx-navy);
  box-shadow: 0 0 0 3px rgba(16, 69, 143, .16);
}

/* 4. Narrow screens: fields of a row share the line two by two, then one per line */
@media (max-width: 720px) {
  :is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, .dpc-input, select, input):where(:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image])):not(.dpc-sr) { flex: 1 1 calc(50% - 10px); width: auto; max-width: none; min-width: 8rem; }
}
@media (max-width: 480px) {
  :is(.dpc-row, .dpc-actions, .dpc-wrap-row, .dpc-inline-form) > :where(.dpc-select, .dpc-input, select, input):where(:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image])):not(.dpc-sr) { flex: 1 1 100%; }
}

/* 5. Print: no toolbar background */
@media print { main form:is([method=GET], [method=get]).dpc-row { background: none; border: 0; padding: 0; } }
