/* The New popup of a related list (COMMAND-755, public/record-form): a form on the shared shell (modal.js) over a
   dimmed page; at the bottom on a phone, in the middle on a wide screen (the shell's medium width, never wider than the
   screen). Loaded by index.html after app.css, so it uses the app's colours. No design yet: the POC marker (poc-ui). */

.record-form-back {
  position: fixed; inset: 0; z-index: 21;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; background: rgba(0, 0, 0, 0.45);
}
@media (min-width: 900px) { .record-form-back { align-items: center; } }
.record-form { border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 8px 28px rgb(0 0 0 / 25%); }
.record-form .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.record-form h2 { margin: 0; font-size: 1.05rem; }
.record-form-close { flex: none; font-size: 1.4rem; line-height: 1; }
.record-form-fields { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.record-form-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.record-form-label { font-size: 0.85rem; font-weight: 600; }
.record-form-req { color: var(--danger); }
.record-form-field .input { width: 100%; }
.record-form-bad .input, .record-form-bad .picker-field { outline: 2px solid var(--danger); outline-offset: 1px; }
.record-form-i18n { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 600px) { .record-form-i18n { grid-template-columns: 1fr 1fr; } }
.record-form-lang { display: flex; flex-direction: column; gap: 2px; }
.record-form-parent { display: flex; min-height: 40px; align-items: center; }
.record-form-error { margin: 0; }
.record-form .modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
/* A multi-line box (COMMAND-810: the popup and the field pencil). */
.record-form-textarea { min-height: 5.5em; resize: vertical; font: inherit; }

/* A read-only field (COMMAND-812): greyed, its hint (why it cannot change here) under it. */
.record-form-locked .input, .record-form-locked .pill-list, .record-form-locked .switch { opacity: 0.6; }
.record-form-locked .input { background: var(--surface-2, transparent); cursor: not-allowed; }
.record-form-hint { margin: 2px 0 0; }
.record-form textarea.input { min-height: 88px; resize: vertical; }

/* The wide popup (COMMAND-812, size 'wide': Edit of a record). On a phone it fills the screen, full height, its middle
   scrolling on its own; from 900px it is min(960px, 100vw - 64px) wide with the fields in two columns, a long text, an
   i18n text and a list of names over both. */
.record-form-back-wide { padding: 0; align-items: stretch; }
.modal-wide {
  width: 100vw; height: 100vh; height: 100dvh;
  max-height: 100vh; max-height: 100dvh;
  border-radius: 0;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.record-form-span { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .record-form-back-wide { padding: 16px; align-items: center; }
  .modal-wide {
    width: min(960px, 100vw - 64px); height: auto;
    max-height: calc(85vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(85dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 14px;
    padding-top: 0; padding-bottom: 0;
  }
  .modal-wide .record-form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; align-items: start; }
  .modal-wide .record-form-error { grid-column: 1 / -1; }
}

/* A form with a formatted text (COMMAND-920, kind html; the window carries rich-edit-fit): the body a column, the text
   the last field and the rest of the window's height. On a computer the wide window grows with the text, which takes at
   least about half the screen, up to 90% of the screen (its body then scrolls). The amber callout of a clash (a session
   changed the title or the text while the PO was editing) sits at the top of the body. */
.rich-edit-fit .modal-body { display: flex; flex-direction: column; min-height: 0; }
.rich-edit-fit .record-form-rich-form { flex: 1; min-height: 0; }
.record-form-rich { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.record-form-rich .rich-edit { flex: 1; min-height: 0; }
.record-form-rich .rich-edit-box { flex: 1; }
.rich-edit-readonly .rich-edit-box { cursor: default; opacity: 0.8; }
.record-form-clash { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.record-form-clash-text { flex-basis: 100%; margin: 0; }
@media (min-width: 900px) {
  .modal-wide.rich-edit-fit {
    height: auto;
    max-height: calc(90vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(90dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .modal-wide.rich-edit-fit .record-form-rich .rich-edit-box { min-height: 55vh; }
}

/* COMMAND-1050: a colour field — the picker (a swatch) and its '#rrggbb' beside it. */
.record-form-color { display: flex; align-items: center; gap: 8px; }
.record-form-color-pick { flex: none; width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; }
.record-form-color-text { flex: 1 1 auto; min-width: 0; max-width: 10rem; font-family: ui-monospace, monospace; }
