/* 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-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 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;
}

.nested-row__qty {
  flex: 0 1 90px;
}

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

.nested-row__remove {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--color-danger);
  font-size: 1rem;
  cursor: pointer;
  padding: var(--space-2);
}

/* 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__qty,
  .nested-row__unit {
    flex: 0 1 auto;
    width: 100%;
  }

  .nested-row__remove {
    align-self: flex-end;
    margin-top: calc(var(--space-1) * -1);
  }
}

.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);
}
