/* Custom form controls. The native control stays in the DOM as the
   form's source of truth and is hidden here; these are the visible UI.
   Enhanced by ui.js / ui-select.js / ui-dropzone.js. */

/* The native control stays in the DOM (it is what actually submits) but
   must never take space. !important is deliberate: page-level form CSS
   is more specific than this utility, and a native select left at
   width:100% while absolutely positioned pushed the landing page 600px
   wider than the viewport. */
.sel-native,
.dz-native,
.clr-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden;
  clip-path: inset(50%);
  opacity: 0;
  pointer-events: none;
}

/* Floating-label text fields */
.field { position: relative; display: block; }
.field-label {
  position: absolute; left: 0.85rem; top: 0.72rem;
  color: var(--field-label, var(--ink-muted)); font-size: 1rem;
  pointer-events: none; transform-origin: left top;
  transition: transform var(--t) var(--ease-out), color var(--t) var(--ease);
}
.field.is-focus .field-label,
.field.is-filled .field-label { transform: translateY(-0.62rem) scale(0.75); }
.field.is-focus .field-label { color: var(--accent); }
.field .opt { font-size: 0.85em; margin-left: 0.35em; color: inherit; }
.field input,
.field textarea { padding-top: 1.35rem; padding-bottom: 0.4rem; }
.field textarea { padding-top: 1.5rem; }

/* Listbox */
/* min-width: 0 is what makes the truncation below actually bite: a grid
   or flex item's automatic minimum is its max-content width, so a
   nowrap option label widens the track instead of being clipped. */
.sel { position: relative; min-width: 0; }
.sel-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  width: 100%; min-width: 0; padding: 0.65rem 0.8rem;
  background: var(--field-face, var(--surface)); color: var(--field-ink, var(--ink));
  border: var(--hairline) solid var(--field-edge, var(--line-strong));
  border-radius: var(--radius-sm);
  font: inherit; text-align: left; cursor: pointer;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
/* An option's text is whatever the page put in the <option> — on the QR
   designer that is a slug plus a full destination URL, which has no
   break opportunity in it and pushed a 390px viewport to 510px. The
   button truncates; the open list wraps, because there the whole value
   is what the operator is choosing between. */
.sel-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sel-btn:hover { border-color: var(--accent); }
.sel-btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.sel-chev { transition: transform var(--t) var(--ease); opacity: 0.7; }
.sel.is-open .sel-chev { transform: rotate(180deg); }
.sel.is-open .sel-btn { border-color: var(--accent); box-shadow: var(--ring); }

.sel-list {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 15rem; overflow-y: auto; margin: 0; padding: 0.25rem; list-style: none;
  background: var(--surface-raised); color: var(--ink);
  border: var(--hairline) solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-deep);
}
.sel-opt {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.7rem; border-radius: var(--radius-sm);
  font-size: 0.95rem; cursor: pointer; overflow-wrap: anywhere;
}
.sel-opt:hover { background: var(--surface-sunken); }
.sel-opt[aria-selected='true'] {
  background: var(--accent); color: var(--on-accent); font-weight: 600;
}

/* Filter box, added by ui-select-search.js above SEARCH_FROM options.
   Sticky so it survives scrolling a long list. */
.sel-search {
  position: sticky; top: 0; z-index: 1;
  padding: 0.25rem 0.25rem 0.35rem; margin: -0.25rem -0.25rem 0.25rem;
  background: var(--surface-raised);
  border-bottom: var(--hairline) solid var(--line);
}
.sel-search-input {
  width: 100%; padding: 0.45rem 0.6rem; font: inherit; font-size: 0.92rem;
  background: var(--surface); color: var(--ink);
  border: var(--hairline) solid var(--line-strong); border-radius: var(--radius-sm);
}
.sel-search-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.sel-empty { padding: 0.6rem 0.7rem; font-size: 0.92rem; color: var(--ink-faint); }

/* Dropzone */
.dz {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  padding: 1.4rem 1rem; text-align: center; cursor: pointer;
  color: var(--field-ink, var(--ink-muted));
  background: var(--field-face, var(--surface));
  border: 1px dashed var(--field-edge, var(--line-strong));
  border-radius: var(--radius);
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease),
    box-shadow var(--t) var(--ease);
}
.dz:hover, .dz.is-over { border-color: var(--accent); border-style: solid; }
.dz.is-over { box-shadow: var(--ring); }
.dz:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.dz.is-bad { border-color: var(--garnet-ink); }
.dz .ico { opacity: 0.6; }
.dz-prompt { font-size: 0.95rem; }
.dz-link { color: var(--field-accent, var(--accent-ink)); text-decoration: underline; text-underline-offset: 2px; }
.dz-hint { font-size: 0.82rem; opacity: 0.85; }

.dz-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
/* Inherits the page's ink by default, which on the landing funnel is
   ivory — the same colour as the item's own face. Pin it to the field
   ink so the filename is never invisible. */
.dz-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem;
  color: var(--field-ink, var(--ink));
  background: var(--field-face, var(--surface-raised));
  border: var(--hairline) solid var(--field-edge, var(--line)); border-radius: var(--radius-sm);
}
.dz-thumb {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-sunken);
}
.dz-thumb-doc {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.dz-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; text-align: left; }
.dz-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.dz-size { font-size: 0.78rem; color: var(--ink-faint); }
.dz-remove {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; cursor: pointer;
  background: transparent; color: var(--ink-muted);
  border: var(--hairline) solid var(--line); border-radius: 50%;
  transition: all var(--t) var(--ease);
}
.dz-remove:hover { background: var(--garnet); color: var(--ivory); border-color: var(--garnet); }
.dz-remove:focus-visible { outline: none; box-shadow: var(--ring); }
.dz-error { margin-top: 0.5rem; font-size: 0.88rem; color: var(--garnet-ink); min-height: 1.2em; }
