/* Buttons, inputs and form controls. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  min-height: 36px;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--c-text);
  background: var(--c-surface-raised);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--c-surface-sunken); border-color: var(--c-accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  color: var(--c-on-accent);
  background: var(--c-accent);
  border-color: var(--c-accent);
}
.btn--primary:hover:not(:disabled) { background: var(--c-accent-hover); border-color: var(--c-accent-hover); }

/* Destructive actions are visually distinct from ordinary ones, because
   "disable firewall" and "refresh" must never look interchangeable. */
.btn--danger {
  color: var(--c-on-danger);
  background: var(--c-danger);
  border-color: var(--c-danger);
}
.btn--danger:hover:not(:disabled) { filter: brightness(1.12); }

.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover:not(:disabled) { background: var(--c-surface-raised); border-color: var(--c-border); }

.btn--sm { min-height: 28px; padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }

/* Busy state: the label is replaced by a spinner so the width does not jump. */
.btn[aria-busy="true"] { color: transparent; pointer-events: none; position: relative; }
.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  color: var(--c-text);
  animation: spin 620ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); }

.field__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field__hint { font-size: var(--text-xs); color: var(--c-text-subtle); }

.field__error { font-size: var(--text-xs); color: var(--c-danger); }

.input, .select, .textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--c-text);
  background: var(--c-surface-sunken);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  transition: border-color var(--duration-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--c-accent); outline: none; }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--c-danger); }
.input::placeholder { color: var(--c-text-subtle); }

.textarea { min-height: 120px; resize: vertical; font-family: var(--font-mono); }

.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 36px; height: 20px;
  background: var(--c-border-strong);
  border-radius: var(--radius-full);
  transition: background var(--duration) var(--ease);
  position: relative;
  flex-shrink: 0;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--c-on-accent);
  border-radius: var(--radius-full);
  transition: transform var(--duration) var(--ease);
}
.switch input:checked + .switch__track { background: var(--c-accent); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--c-accent); outline-offset: 2px; }
