/* Task Helper — form boxes + "Arrange form" + Fields-screen groups (job-intake.md §13). Copyright Rapid Surveys Pty Ltd.
 * Calm on purpose: a box heading is one weight with a hairline under it, not a heavy card. App tokens only. */

/* ── Boxes on the task form ── */
/* An OPEN box must LOOK like a box (Gary, job-intake §13): an outlined container with a faint tint, its heading as
   the top bar; a closed box is just that bar. The outline uses the app's darker grey (--branch #8a94a2, about 3.1:1
   against the white panel; the hairline --line is too faint for this). Fields in no box sit OUTSIDE, after a gap. */
.fl-boxes { --fl-edge: var(--branch, #8a94a2); display: flex; flex-direction: column; gap: 12px; margin: 4px 0 22px; }
.fl-box { border: 1px solid var(--fl-edge); border-radius: 12px; background: rgba(47,109,246,.035); overflow: hidden; }
.fl-head { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; margin: 0; padding: 8px 12px;
  background: rgba(47,109,246,.085); border: 0; border-radius: 0; color: var(--ink); font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer; }
.fl-head:hover { background: rgba(47,109,246,.13); }
.fl-chev { width: 16px; height: 16px; flex: none; color: var(--muted); transition: transform .15s; }
.fl-closed .fl-chev { transform: rotate(-90deg); }
.fl-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fl-count { flex: none; font-size: 12px; font-weight: 400; color: var(--muted); }
.fl-body { padding: 12px 14px 2px; border-top: 1px solid var(--fl-edge); }
.fl-body[hidden] { display: none; }
@media (max-width: 480px) { .fl-body { padding: 10px 10px 0; } .fl-head { padding: 8px 10px; } }

/* ── Arrange form ── */
.fl-arr { max-width: 620px; }
.fl-abox { margin: 0 0 14px; padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.fl-ahead { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }
.fl-ahead .fl-bname { flex: 1 1 160px; min-width: 0; margin: 0; padding: 8px 10px; font-size: 15px; font-weight: 600; }
.fl-open { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--muted); white-space: nowrap; }
.fl-open input { width: auto; margin: 0; }
.fl-list { list-style: none; margin: 0; padding: 4px 0; min-height: 36px; border-radius: 8px; }
.fl-list.fl-drop { background: var(--hover); outline: 1px dashed var(--accent); }
.fl-item { display: flex; align-items: center; gap: 6px; padding: 4px 0 4px 2px; border-top: 1px solid var(--line); }
.fl-item:first-child { border-top: 0; }
.fl-grip { color: var(--muted); cursor: grab; letter-spacing: -2px; font-size: 13px; user-select: none; }
.fl-iname { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.fl-mini { width: 34px; height: 32px; padding: 0; flex: none; font-size: 15px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; }
.fl-mini:disabled { opacity: .35; }
.fl-to { width: auto; max-width: 9.5em; flex: none; margin: 0; padding: 6px; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; color: var(--ink); }
.fl-empty { padding: 6px 2px; font-size: 13px; color: var(--muted); }
.fl-loose .fields-h3 { margin-top: 4px; }
.fl-arr-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 14px; }
.fl-arr-tools select { width: auto; margin: 0; padding: 8px; font-size: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfd; color: var(--ink); }
.fl-danger { color: var(--err) !important; }
.fl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 480px) { .fl-item { flex-wrap: wrap; } .fl-grip { display: none; } .fl-iname { flex-basis: 100%; } .fl-to { max-width: none; flex: 1 1 auto; } }
@media (pointer: coarse) { .fl-mini { width: 44px; height: 44px; } .fl-to, .fl-arr-tools select { min-height: 44px; } .fl-open { min-height: 44px; } }

/* ── Fields screen groups ── */
.fg-head { display: flex; align-items: center; gap: 6px; margin: 14px 0 2px; border-bottom: 1px solid var(--line); }
.fg-toggle { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; min-height: 40px; margin: 0; padding: 6px 2px; background: none; border: 0; border-radius: 0;
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; text-align: left; cursor: pointer; }
.fg-toggle:hover { color: var(--ink); }
.fg-toggle[aria-expanded="false"] .fl-chev { transform: rotate(-90deg); }
.fg-n { font-weight: 400; letter-spacing: 0; }
.fg-name { overflow-wrap: anywhere; }
.fg-tools { display: flex; gap: 4px; flex: none; }
.fg-tools .fl-mini { width: auto; min-width: 34px; padding: 0 8px; font-size: 13px; }
.fg-rename { flex: 1; display: flex; gap: 6px; align-items: center; padding: 4px 0; }
.fg-rename input { flex: 1; min-width: 0; margin: 0; padding: 8px; font-size: 14px; }
.fg-rename button { width: auto; }
.fg-new { display: flex; gap: 8px; align-items: center; margin: 8px 0 2px; }
.fg-new input { flex: 1; min-width: 0; margin: 0; }
.fg-new button { width: auto; flex: none; }
.fi-grp { width: auto; max-width: 9em; margin: 0; padding: 6px; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; color: var(--ink); }
.fe-grouplab { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 6px 0 0; } .fe-grouplab select { width: auto; padding: 6px 8px; }
.fg-msg { margin: 4px 0; }
@media (pointer: coarse) { .fg-toggle { min-height: 44px; } .fg-tools .fl-mini { min-width: 44px; height: 44px; } .fi-grp { min-height: 44px; } }

/* ── "Add a field" through the groups (field set editor) ── */
.fp { flex: 1 1 100%; display: flex; flex-direction: column; gap: 4px; }
.fp .fp-q { margin: 0; }
.fp-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; max-height: 320px; overflow-y: auto; }
.fp-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; margin: 0; padding: 8px 12px; background: var(--card); color: var(--ink); border: 0; border-top: 1px solid var(--line); border-radius: 0; font: inherit; font-size: 14px; font-weight: 400; text-align: left; cursor: pointer; }
.fp-row:first-child { border-top: 0; }
.fp-row:hover:not(:disabled) { background: var(--hover); }
.fp-row:disabled { color: var(--muted); cursor: default; }
.fp-l { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fp-x { flex: none; font-size: 12px; color: var(--muted); }
.fp-all { font-weight: 600; color: var(--accent); }
.fp-back { color: var(--accent); font-weight: 600; }
.fp-gname { margin: 0; padding: 6px 12px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-top: 1px solid var(--line); }
.fp-none { margin: 0; padding: 10px 12px; }
.fp-msg { margin: 2px 0 0; }

/* ── A FIXED box (e.g. "Client", §28): always on the form; moved and set to start open, never removed or renamed ── */
.fl-bfixed { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; border: 0 !important; background: none !important; }
.fl-lockt { font-size: 12px; font-weight: 400; color: var(--muted); }
.fl-lockeditem .fl-lockt { flex: none; max-width: 9.5em; }
.fl-afixed { border-bottom-style: dashed; }
/* BRIEF-1183: bulk editing in Arrange form */
.fl-selbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 10px; }
.fl-sellab { font-size: 13px; font-weight: 600; color: var(--muted); }
.fl-selbar input[type=search] { flex: 1 1 140px; min-width: 0; width: auto; margin: 0; padding: 7px 10px; font-size: 14px; border: 1px solid var(--line); border-radius: 9px; }
.fl-selbar select { width: auto; margin: 0; padding: 7px; font-size: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfd; color: var(--ink); }
.fl-selbar .chip, .fl-bulk .chip { width: auto; }
.fl-sel { flex: none; width: 20px; height: 20px; margin: 0 2px; accent-color: var(--accent); }
.fl-nosel { flex: none; width: 24px; }
.fl-item.fl-ticked { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.fl-bulk { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px -4px 0; padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 -6px 16px rgba(20, 28, 40, .12); }
.fl-bulkn { font-weight: 700; margin-right: 4px; }
.fl-bulkto { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.fl-bulkto select { width: auto; max-width: 11em; margin: 0; padding: 6px; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; color: var(--ink); }
@media (max-width: 480px) { .fl-item .fl-iname { flex: 1 1 calc(100% - 44px); flex-basis: calc(100% - 44px); } }   /* the tick box and the name share the first line */
@media (pointer: coarse) { .fl-sel { width: 26px; height: 26px; } .fl-nosel { width: 30px; } .fl-selbar .chip, .fl-bulk .chip, .fl-selbar select, .fl-selbar input[type=search], .fl-bulkto select { min-height: 44px; } }
