/* ==========================================================================
   QZONE OMS — FORMS
   Inset fields on flat surfaces. Labels above, always visible (no floating
   labels — they hide the field's name exactly when a user is filling it in).
   ========================================================================== */

.qz-field { margin-bottom: var(--qz-s-4); min-width: 0; }

.qz-field__label {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  font-size: var(--qz-fs-2xs);
  font-weight: 600;
  letter-spacing: var(--qz-track-label);
  text-transform: uppercase;
  color: var(--qz-text-mute);
}
.qz-field__req { color: var(--qz-crit); font-weight: 700; }
.qz-field__hint { margin-top: 5px; font-size: var(--qz-fs-xs); color: var(--qz-text-mute); }
.qz-field__error { margin-top: 5px; font-size: var(--qz-fs-xs); font-weight: 500; color: var(--qz-crit); }

/* ---- The control itself ------------------------------------------------- */

.qz-input,
.qz-select,
.qz-textarea {
  display: block;
  width: 100%;
  min-height: var(--qz-control-h);
  padding: 0 var(--qz-s-3);
  border: 0;
  border-radius: var(--qz-r-md);
  background: var(--qz-surface-inset);
  box-shadow: var(--qz-ring);
  color: var(--qz-text);
  font-family: var(--qz-font-body);
  font-size: var(--qz-fs-sm);
  line-height: var(--qz-control-h);
  transition: box-shadow var(--qz-dur-fast) var(--qz-ease),
              background-color var(--qz-dur-fast) var(--qz-ease);
  appearance: none;
}

.qz-textarea {
  padding: var(--qz-s-2) var(--qz-s-3);
  line-height: var(--qz-lh-snug);
  min-height: 84px;
  resize: vertical;
}

.qz-input:hover, .qz-select:hover, .qz-textarea:hover { box-shadow: var(--qz-ring-strong); }

.qz-input:focus, .qz-select:focus, .qz-textarea:focus {
  outline: none;
  background: var(--qz-bg);
  box-shadow: inset 0 0 0 1px var(--qz-accent), 0 0 0 3px var(--qz-accent-weak);
}

.qz-input::placeholder, .qz-textarea::placeholder { color: var(--qz-text-faint); }

.qz-input:disabled, .qz-select:disabled, .qz-textarea:disabled,
.qz-input[readonly], .qz-textarea[readonly] {
  background: var(--qz-surface-2);
  color: var(--qz-text-faint);
  cursor: not-allowed;
}

/* Numeric and identifier inputs get the mono face so they align and read
   unambiguously (0/O, 1/l). */
.qz-input[type="number"],
.qz-input[type="date"],
.qz-input[type="time"],
.qz-input[type="datetime-local"],
.qz-input--mono {
  font-family: var(--qz-font-mono);
  font-variant-numeric: tabular-nums;
}

/* Native pickers follow the active theme */
.qz-input[type="date"],
.qz-input[type="time"],
.qz-input[type="datetime-local"],
.qz-input[type="month"] { color-scheme: inherit; }

/* Select chevron, drawn inline so it needs no asset and recolors with theme */
.qz-select {
  padding-right: var(--qz-s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236c737f' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--qz-s-3) center;
  background-size: 15px;
  cursor: pointer;
}
.qz-select[multiple] { background-image: none; padding-right: var(--qz-s-3); line-height: 1.5; padding-top: var(--qz-s-2); padding-bottom: var(--qz-s-2); }

/* Validation states */
.qz-input.is-invalid, .qz-select.is-invalid, .qz-textarea.is-invalid { box-shadow: inset 0 0 0 1px var(--qz-crit); }
.qz-input.is-valid,   .qz-select.is-valid,   .qz-textarea.is-valid   { box-shadow: inset 0 0 0 1px var(--qz-ok-line); }

/* ---- Input with a leading glyph or trailing action ---------------------- */

.qz-inputgroup { position: relative; display: flex; align-items: center; }
/* !important is required here: qzone/bridge sets a blanket `padding` on every
   text input to normalise the legacy views, and would otherwise slide the text
   back under the leading glyph. */
.qz-inputgroup > .qz-input { padding-left: var(--qz-s-8) !important; }
.qz-inputgroup__icon {
  position: absolute;
  left: var(--qz-s-3);
  display: grid;
  place-items: center;
  color: var(--qz-text-faint);
  font-size: 12px;
  pointer-events: none;
}
.qz-inputgroup__action {
  position: absolute;
  right: 4px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: var(--qz-r-pill);
  background: transparent;
  color: var(--qz-text-mute);
  font-size: 12px;
  cursor: pointer;
}
.qz-inputgroup__action:hover { background: var(--qz-surface-4); color: var(--qz-text); }
.qz-inputgroup:has(.qz-inputgroup__action) > .qz-input { padding-right: var(--qz-s-8); }

/* ---- Checkbox / radio --------------------------------------------------- */

.qz-check { display: flex; align-items: flex-start; gap: var(--qz-s-2); cursor: pointer; }
.qz-check + .qz-check { margin-top: var(--qz-s-2); }

.qz-check input[type="checkbox"],
.qz-check input[type="radio"] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  border: 0;
  border-radius: var(--qz-r-xs);
  background: var(--qz-surface-inset);
  box-shadow: inset 0 0 0 1px var(--qz-line-strong);
  cursor: pointer;
  appearance: none;
  transition: background-color var(--qz-dur-fast) var(--qz-ease), box-shadow var(--qz-dur-fast) var(--qz-ease);
}
.qz-check input[type="radio"] { border-radius: 50%; }

.qz-check input[type="checkbox"]:checked,
.qz-check input[type="radio"]:checked {
  background-color: var(--qz-accent);
  box-shadow: none;
}
.qz-check input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23140f0c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E");
  background-size: 13px;
  background-position: center;
  background-repeat: no-repeat;
}
.qz-check input[type="radio"]:checked {
  box-shadow: inset 0 0 0 4px var(--qz-surface-inset), inset 0 0 0 5px var(--qz-accent);
  background-color: var(--qz-accent);
}
/* Field labels are small-caps, but a checkbox's label is a sentence — reset the
   inherited casing/tracking rather than shouting the option at the user. */
.qz-check__text {
  font-size: var(--qz-fs-sm);
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: normal;
  text-transform: none;
  color: var(--qz-text-dim);
}
.qz-check__text strong { display: block; color: var(--qz-text); font-weight: 600; }

/* ---- Switch ------------------------------------------------------------- */

.qz-switch { display: inline-flex; align-items: center; gap: var(--qz-s-3); cursor: pointer; }
.qz-switch input {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 19px;
  border: 0;
  border-radius: 99px;
  background: var(--qz-surface-4);
  box-shadow: var(--qz-ring);
  cursor: pointer;
  appearance: none;
  transition: background-color var(--qz-dur) var(--qz-ease);
}
.qz-switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--qz-text-mute);
  transition: transform var(--qz-dur) var(--qz-ease), background-color var(--qz-dur) var(--qz-ease);
}
.qz-switch input:checked { background: var(--qz-accent); box-shadow: none; }
.qz-switch input:checked::after { background: var(--qz-on-accent); transform: translateX(15px); }

/* ---- Layout: form grid + fieldsets -------------------------------------- */

.qz-form-grid { display: grid; gap: 0 var(--qz-s-4); grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.qz-form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.qz-form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qz-span-2 { grid-column: span 2; }
.qz-span-all { grid-column: 1 / -1; }

@media (max-width: 767.98px) {
  .qz-form-grid, .qz-form-grid--2, .qz-form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .qz-span-2, .qz-span-all { grid-column: auto; }
}

.qz-fieldset { border: 0; margin: 0 0 var(--qz-s-5); padding: 0; }
.qz-fieldset__head {
  display: flex;
  align-items: center;
  gap: var(--qz-s-3);
  margin-bottom: var(--qz-s-4);
  padding-bottom: var(--qz-s-3);
  border-bottom: 1px solid var(--qz-line);
}
.qz-fieldset__title { margin: 0; font-family: var(--qz-font-display); font-size: var(--qz-fs-base); font-weight: 600; color: var(--qz-text); }
.qz-fieldset__sub { margin: 2px 0 0; font-size: var(--qz-fs-xs); color: var(--qz-text-mute); }

/* Form action bar — sticks to the bottom on long forms so Save is reachable
   without scrolling to the end. */
.qz-form-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--qz-s-2);
  margin-top: var(--qz-s-6);
  padding: var(--qz-s-3) 0;
  background: var(--qz-bg);
  border-top: 1px solid var(--qz-line);
}
.qz-form-actions__note { flex: 1 1 auto; font-size: var(--qz-fs-xs); color: var(--qz-text-mute); }

@media (max-width: 575.98px) {
  .qz-form-actions { flex-wrap: wrap; }
  .qz-form-actions .qz-btn { flex: 1 1 auto; }
  .qz-form-actions__note { flex: 1 1 100%; margin-bottom: var(--qz-s-2); }
}

/* Form-level error summary */
.qz-errors {
  margin-bottom: var(--qz-s-5);
  padding: var(--qz-s-3) var(--qz-s-4);
  border-radius: var(--qz-r-md);
  border-left: 2px solid var(--qz-crit);
  background: var(--qz-crit-weak);
}
.qz-errors__title { font-size: var(--qz-fs-sm); font-weight: 600; color: var(--qz-crit); margin-bottom: var(--qz-s-1); }
.qz-errors ul { margin: 0; padding-left: var(--qz-s-4); }
.qz-errors li { font-size: var(--qz-fs-sm); color: var(--qz-text-dim); }

/* ---- File input --------------------------------------------------------- */

.qz-file {
  display: flex;
  align-items: center;
  gap: var(--qz-s-3);
  padding: var(--qz-s-3);
  border-radius: var(--qz-r-md);
  background: var(--qz-surface-inset);
  box-shadow: inset 0 0 0 1px var(--qz-line);
  cursor: pointer;
  transition: box-shadow var(--qz-dur-fast) var(--qz-ease);
}
.qz-file:hover { box-shadow: inset 0 0 0 1px var(--qz-accent-line); }
.qz-file input[type="file"] { flex: 1 1 auto; min-width: 0; font-size: var(--qz-fs-xs); color: var(--qz-text-dim); }
.qz-file input[type="file"]::file-selector-button {
  margin-right: var(--qz-s-3);
  padding: 5px var(--qz-s-3);
  border: 0;
  border-radius: var(--qz-r-pill);
  background: var(--qz-surface-4);
  color: var(--qz-text);
  font-family: var(--qz-font-body);
  font-size: var(--qz-fs-xs);
  font-weight: 600;
  cursor: pointer;
}

/* ---- OTP / code entry --------------------------------------------------- */

.qz-otp { display: flex; gap: var(--qz-s-2); justify-content: center; }
.qz-otp__digit {
  width: 44px;
  height: 52px;
  border: 0;
  border-radius: var(--qz-r-md);
  background: var(--qz-surface-inset);
  box-shadow: var(--qz-ring);
  color: var(--qz-text);
  font-family: var(--qz-font-mono);
  font-size: var(--qz-fs-lg);
  font-weight: 600;
  text-align: center;
  transition: box-shadow var(--qz-dur-fast) var(--qz-ease);
}
.qz-otp__digit:focus { outline: none; box-shadow: inset 0 0 0 1px var(--qz-accent), 0 0 0 3px var(--qz-accent-weak); }
.qz-otp__digit.filled { box-shadow: inset 0 0 0 1px var(--qz-accent-line); }

.qz-otp__sep { align-self: center; width: 10px; height: 1px; background: var(--qz-line-strong); flex: 0 0 auto; }

/* 30-second TOTP countdown ring */
.qz-otp-count { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: var(--qz-s-5); }
.qz-otp-count__ring { position: relative; display: grid; place-items: center; width: 56px; height: 56px; }
.qz-otp-count__ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.qz-otp-count__track { stroke: var(--qz-surface-4); }
.qz-otp-count__bar   { stroke: var(--qz-accent); }
.qz-otp-count__num {
  position: relative;
  font-family: var(--qz-font-mono);
  font-size: var(--qz-fs-sm);
  font-weight: 600;
  color: var(--qz-text);
}
.qz-otp-count__label { font-size: var(--qz-fs-2xs); color: var(--qz-text-mute); }

@media (max-width: 400px) {
  .qz-otp { gap: 5px; }
  .qz-otp__digit { width: 38px; height: 46px; font-size: var(--qz-fs-md); }
}
