/* ===========================================================================
   forms.css - form grid, inputs, selects, validation states
   =========================================================================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px 18px;
}

.col-1  { grid-column: span 1; }
.col-2  { grid-column: span 2; }
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }
.col-10 { grid-column: span 10; }
.col-11 { grid-column: span 11; }
.col-12 { grid-column: span 12; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.field label .req { color: var(--danger); font-weight: 700; }

.control {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea.control { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; line-height: 1.55; }

.control::placeholder { color: var(--text-3); }
.control:hover:not(:disabled):not([readonly]) { border-color: var(--text-3); }
.control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.control:disabled,
.control[readonly] {
  background: var(--surface-3);
  color: var(--text-2);
  cursor: not-allowed;
}

select.control {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.field-hint { font-size: 11.5px; color: var(--text-3); }
.field-error { font-size: 11.5px; color: var(--danger); display: none; }

.field.has-error .control { border-color: var(--danger); }
.field.has-error .control:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.field.has-error .field-error { display: block; }

/* input with a leading symbol (currency / percent) */
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .affix {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  font-size: 13px;
  pointer-events: none;
}
.input-affix .affix.right { left: auto; right: 12px; }
.input-affix .control.has-prefix { padding-left: 28px; }
.input-affix .control.has-suffix { padding-right: 30px; }

/* file input */
.file-drop {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  padding: 16px;
  text-align: center;
  color: var(--text-2);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.file-drop:hover { border-color: var(--accent); background: var(--surface); }
.file-drop input[type="file"] { display: none; }
.file-drop .icon { color: var(--text-3); margin-bottom: 4px; }
.file-drop .file-name { font-size: 12.5px; color: var(--accent); margin-top: 4px; }

/* checkbox + radio */
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; cursor: pointer; }
.check span { color: var(--text-2); }

/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .slider {
  width: 40px; height: 22px;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  position: relative;
  transition: background var(--t-fast);
  flex: none;
}
.switch .slider::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--t-fast);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--accent-ring); }

/* filter bar */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.filter-bar .field label { font-size: 11.5px; }
.filter-actions { display: flex; gap: 8px; align-items: end; }

.search-field { position: relative; }
.search-field .icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.search-field .control { padding-left: 36px; }

/* form page layout */
.form-sections { display: flex; flex-direction: column; gap: 16px; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  z-index: 20;
}
.form-actions .spacer { margin-left: auto; }
