/* Recipe create/edit form. */
.recipe-form {
  max-width: 760px;
  margin: 0 auto;
  padding-bottom: var(--space-7);
}

.form-errors {
  background: #f9e7e4;
  color: var(--color-danger);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}

.form-errors h3 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-body);
  font-size: 1rem;
}

.form-errors ul {
  margin: 0;
  padding-left: var(--space-5);
}

.form-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-4) var(--space-5) var(--space-5);
  margin: 0 0 var(--space-5);
}

.form-section legend {
  font-weight: 700;
  padding: 0 var(--space-2);
}

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

.form-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.form-field input[type="text"],
.form-field input[type="url"],
.form-field input[type="number"],
.form-field input[type="search"],
.form-field textarea {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
}

.form-field--checkbox label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-text);
  cursor: pointer;
}

.form-field--checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.form-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.form-row .form-field {
  flex: 1 1 140px;
}

.form-hint {
  margin: var(--space-1) 0 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.nested-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.nested-row[hidden] {
  display: none;
}

.nested-row textarea,
.nested-row input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
}

.nested-row--step textarea {
  flex: 1;
}

.nested-row__number {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-top: var(--space-2);
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nested-row__name {
  flex: 2 1 160px;
}

/* Quantity: one number, or "min – max" when the range toggle is on. */
.quantity-field {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.quantity-field input {
  width: 72px;
  min-width: 0;
}

.quantity-field__max {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.quantity-field__max[hidden] {
  display: none;
}

.quantity-field__dash {
  color: var(--color-text-muted);
}

.quantity-field__toggle {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.quantity-field__toggle[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}

/* No spinner arrows: they step by tiny decimals and aren't useful here. */
.nested-row input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.nested-row input[type="number"]::-webkit-inner-spin-button,
.nested-row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.nested-row__unit {
  flex: 0 1 110px;
}

/* Move up / move down / remove. 44px squares so they're easy to tap. */
.nested-row__actions {
  display: flex;
  flex-shrink: 0;
  gap: var(--space-1);
}

.nested-row__move,
.nested-row__remove {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font: inherit;
  font-size: 1.15rem;
  cursor: pointer;
}

.nested-row__move {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.nested-row__move:hover:not(:disabled) {
  border-color: var(--color-text-muted);
}

.nested-row__move:disabled {
  opacity: 0.35;
  cursor: default;
}

.nested-row__remove {
  border: none;
  background: none;
  color: var(--color-danger);
}

/* Ingredient-specific layout: show as three columns on desktop,
   stack into three rows on small screens and show a separator. */
.nested-row--ingredient {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.nested-row--ingredient:last-child {
  border-bottom: none;
}

@media (max-width: 640px) {
  .nested-row--ingredient {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .nested-row__name,
  .nested-row__unit {
    flex: 0 1 auto;
    width: 100%;
  }

  .quantity-field input,
  .quantity-field__max {
    flex: 1;
    width: auto;
  }

  .nested-row--step {
    flex-wrap: wrap;
  }

  .nested-row--step .nested-row__actions {
    flex-basis: 100%;
    justify-content: flex-end;
  }

  .nested-row--ingredient .nested-row__actions {
    align-self: flex-end;
  }
}

.form-submit {
  display: flex;
  gap: var(--space-3);
}

/* Import modal */
.import-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.import-modal[hidden] {
  display: none;
}

.import-modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
}

.import-modal__content {
  position: relative;
  background: var(--color-bg);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.import-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.import-modal__header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.import-modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.import-modal__close:hover {
  color: var(--color-text);
}

.import-modal__body {
  padding: var(--space-5);
  flex: 1;
}

.import-modal__footer {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding: var(--space-5);
  border-top: 1px solid var(--color-border);
}
