/* ============ FORMS ============ */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 22px;
}
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}

.field {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--t-base);
  letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 6px;
}
.field-label .req { color: var(--danger); }
.field-help {
  font-size: 11.5px;
  color: var(--t-muted);
  line-height: 1.45;
}
.field-error {
  font-size: 11.5px;
  color: var(--danger);
  display: flex; align-items: center; gap: 4px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--t-base);
  font-size: 13px;
  font-family: inherit;
  outline: 0;
  transition: border-color 180ms, box-shadow 180ms, background 180ms;
}
.input::placeholder,
.textarea::placeholder { color: var(--t-light); }
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--bg-muted);
  color: var(--t-light);
  cursor: not-allowed;
}
.input.is-invalid,
.select.is-invalid,
.textarea.is-invalid {
  border-color: var(--danger);
}
.input.is-invalid:focus,
.select.is-invalid:focus,
.textarea.is-invalid:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.input-icon {
  position: relative;
}
.input-icon .ico {
  position: absolute;
  left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--t-light);
  pointer-events: none;
}
.input-icon .ico svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 2; fill: none; }
.input-icon .input { padding-left: 34px; }

/* Inline addon (e.g. https://) */
.input-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  overflow: hidden;
  transition: border-color 180ms, box-shadow 180ms;
}
.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input-group .addon {
  padding: 0 12px;
  display: grid; place-items: center;
  background: var(--bg-muted);
  color: var(--t-muted);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  border-right: 1px solid var(--border);
}
.input-group .input {
  border: 0;
  border-radius: 0;
  background: transparent;
}
.input-group .input:focus { box-shadow: none; }

/* Checkbox / radio */
.check {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--t-base);
  user-select: none;
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 16px; height: 16px;
  border: 1.5px solid var(--t-light);
  border-radius: 5px;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: all 160ms;
  background: var(--bg-card);
}
.check input:checked + .box {
  background: var(--primary);
  border-color: var(--primary);
}
.check input:checked + .box::after {
  content: '';
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.check.radio .box { border-radius: 50%; }
.check.radio input:checked + .box::after {
  width: 7px; height: 7px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  transform: none;
}
.check:hover .box { border-color: var(--primary); }
.check input:disabled + .box { opacity: 0.5; cursor: not-allowed; }

/* Toggle switch */
.switch {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--t-base);
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 34px; height: 20px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 200ms;
  flex-shrink: 0;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
  transition: transform 200ms cubic-bezier(.2,.7,.2,1);
}
.switch input:checked + .track {
  background: var(--primary);
  border-color: var(--primary);
}
.switch input:checked + .track::after {
  transform: translateX(14px);
}

/* Form actions row */
.form-actions {
  display: flex; gap: 10px; align-items: center;
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.form-actions .spacer { flex: 1; }
