/**
 * @file
 * Manage styles for form.
 */

:root {
  --form-spacing: 1.5rem;
  --form-spacing-s: calc(var(--form-spacing) * .67);
  --form-spacing-xs: calc(var(--form-spacing) / 3);
  --form-item-spacing: var(--form-spacing);

  /* Label font-size * line-height */
  --form-label-line-height: calc(1rem * 1.5rem);
  /* Spacing between label and input. */
  --form-label-input-spacing: .5rem;
}

/* Provide a class to remove spacing. */
.dsfr4drupal-form--no-spacing {
  --form-spacing: 0;
}

/* Unset form spacing for default DSFR forms. */
.fr-follow__newsletter,
.fr-search-bar {
  --form-spacing: 0;
}

/* Provide a class to wrap form with borders. */
.dsfr4drupal-form--bordered {
  padding: var(--form-spacing-xs) var(--form-spacing-s) var(--form-spacing-s);
  border: 1px solid var(--border-default-grey);
}

.fr-checkbox-group + .fr-checkbox-group,
.fr-radio-group + .fr-radio-group {
  margin-top:  .25rem;
}

.form-actions a + button,
.form-actions button + button,
.form-actions button + a {
  margin-left: var(--form-item-spacing);
}

.fr-label > .field-edit-link {
  font-size: .75em;
}

.fr-label .field-edit-link > button {
  padding: 0;
}

.fr-upload-group {
  padding: var(--form-spacing-xs) var(--form-spacing) var(--form-spacing);
  border: 1px solid var(--border-default-grey);
}

.fr-upload-group > label {
  font-weight: 700;
}

/* Remove specific spacing into fieldset - START */
.fr-fieldset__content .fr-checkbox-group input[type="checkbox"] + label::before,
.fr-fieldset__content .fr-radio-group:not(.fr-radio-rich) input[type="radio"] + label::before {
  top: auto;
}

.fr-fieldset__content .fr-checkbox-group label,
.fr-fieldset__content .fr-radio-group label {
  padding: 0;
}
/* Remove specific spacing into fieldset - END */

main[role="main"] > .fr-container > form,
main[role="main"] > .fr-container--fluid > form {
  margin-block: var(--form-spacing);
}

.form-wrapper:not(:last-child) {
  margin-bottom: var(--form-item-spacing);
}

.form-wrapper.js-filter-wrapper {
  font-size: .75em;
}

/* Disable table scrolling into form item - START */
.form-item .fr-table__container {
  overflow: initial;
}

.form-item .fr-table > table caption {
  max-width: calc(100vw - 2rem);
}

.form-item .fr-table .fr-table__wrapper .fr-table__content table th,
.form-item .fr-table .fr-table__wrapper .fr-table__content table td {
  white-space: normal;
}
/* Disable table scrolling into form - END */

.js-filter-wrapper {
  margin-top: calc(var(--form-item-spacing) * -.75);
}

.js input.form-autocomplete {
  padding-right: 2.5rem;
  background-position: calc(100% - 1rem) 50%;
}

.paragraphs-tabs-wrapper {
  padding: var(--form-spacing-xs) var(--form-spacing) var(--form-spacing);
  border: 1px solid var(--border-default-grey);
}

.paragraphs-tabs-wrapper > .form-item {
  margin-block: 0;
}
