/* styles/forms.css — sectioned enterprise forms and controls */

.form-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
@media (max-width: 1100px) { .form-shell { grid-template-columns: minmax(0, 1fr); } }

/* Left-hand section rail: shows progress through a long capture form */
.form-rail {
  position: sticky;
  top: calc(var(--toolbar-h) + var(--sp-5));
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-2) 0;
}
.rail-item {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 0; background: none; text-align: left;
  border-left: 3px solid transparent;
}
.rail-item:hover { background: var(--bg-subtle); }
.rail-item.is-active { border-left-color: var(--brand-green); background: var(--bg-subtle); }
.rail-no {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%;
  background: var(--bg-inset); color: var(--text-secondary);
  font-size: var(--fs-11); font-family: var(--font-mono);
  display: grid; place-items: center; margin-top: 1px;
}
.rail-item.is-active .rail-no { background: var(--brand-green); color: #fff; }
.rail-item.is-complete .rail-no { background: var(--success); color: #fff; }
.rail-name { font-size: var(--fs-13); font-weight: var(--fw-medium); }
.rail-meta { font-size: var(--fs-11); color: var(--text-secondary); }

.form-section { margin-bottom: var(--sp-4); }
.form-section-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding-bottom: var(--sp-2);
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.form-section-title { font-size: var(--fs-15); font-weight: var(--fw-semibold); }
.form-section-hint { font-size: var(--fs-12); color: var(--text-secondary); margin-top: 2px; }

.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-4); }
.field-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field.span-full { grid-column: 1 / -1; }
@media (max-width: 1000px) { .field-grid, .field-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .field-grid, .field-grid.cols-2, .field-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .field.span-2, .field.span-3 { grid-column: auto; } }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label {
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 4px;
}
.field .req { color: var(--danger); font-weight: var(--fw-bold); }
.field .opt { color: var(--text-muted); font-weight: var(--fw-regular); font-size: var(--fs-11); }

.input, .select, .textarea {
  width: 100%;
  height: 32px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-surface);
  font-size: var(--fs-13);
  color: var(--text);
  transition: border-color var(--t-hover), background var(--t-hover);
}
.textarea { height: auto; min-height: 72px; padding: var(--sp-2); resize: vertical; line-height: 1.45; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-green); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input[readonly] { background: var(--bg-subtle); color: var(--text-secondary); }
.input.is-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.select {
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235F6B65' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.input-group { display: flex; align-items: stretch; }
.input-group .addon {
  display: inline-flex; align-items: center;
  padding: 0 var(--sp-2);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: var(--fs-12);
  font-family: var(--font-mono);
  white-space: nowrap;
}
.input-group .addon:first-child { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-group .addon:last-child { border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.input-group .input:not(:first-child) { border-radius: 0 var(--radius) var(--radius) 0; }
.input-group .input:not(:last-child) { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .input:only-child { border-radius: var(--radius); }

.field-hint { font-size: var(--fs-11); color: var(--text-muted); }
.field-error { font-size: var(--fs-11); color: var(--danger); display: flex; align-items: center; gap: 4px; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); background: var(--danger-bg); }

/* Checkbox / radio rows */
.check-row { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: var(--fs-13); padding: 3px 0; }
.check-row label { cursor: pointer; }
.check-row .chk { margin-top: 2px; flex: 0 0 15px; }

.radio {
  appearance: none;
  width: 15px; height: 15px; flex: 0 0 15px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-surface);
  display: inline-grid; place-content: center;
  margin-top: 2px;
}
.radio::after {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #fff; transform: scale(0); transition: transform 120ms ease;
}
.radio:checked { background: var(--brand-green); border-color: var(--brand-green); }
.radio:checked::after { transform: scale(1); }

/* Toggle switch — settings only */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--sp-2); }
.switch input { position: absolute; opacity: 0; width: 34px; height: 18px; margin: 0; cursor: pointer; }
.switch .track {
  width: 34px; height: 18px; border-radius: 9px;
  background: var(--border-strong);
  transition: background var(--t-hover);
  flex: 0 0 34px;
}
.switch .track::after {
  content: ""; display: block;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; margin: 2px;
  transition: transform var(--t-hover);
}
.switch input:checked + .track { background: var(--brand-green); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus-ring); }

/* Sticky form action bar */
.form-actions {
  position: sticky;
  bottom: 0;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  margin-top: var(--sp-4);
}
.form-actions .spacer { flex: 1 1 auto; }
.form-status { font-size: var(--fs-12); color: var(--text-secondary); display: flex; align-items: center; gap: var(--sp-2); }

/* Read-only computed summary strip inside forms */
.calc-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface-alt);
  overflow: hidden;
}
.calc-cell { padding: var(--sp-3); border-right: 1px solid var(--border); }
.calc-cell:last-child { border-right: 0; }
.calc-label { font-size: var(--fs-11); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.calc-value { font-family: var(--font-mono); font-size: var(--fs-16); font-weight: var(--fw-semibold); margin-top: 2px; }
.calc-value.is-gold { color: #8A6912; }
