/*
Form paragraph.

Styleguide components.d_p.form
*/

// Colors.
$d-p-form-header-color: $color-odysseus !default;
$d-p-form-text-color: $color-odysseus !default;
$d-p-form-background: $color-agamemnon !default;
$d-p-form-line-color: $color-nestor !default;
$d-p-form-line-color-inverted: $color-agamemnon !default;
$d-p-form-table-color: $color-cassandra !default;

// Margins, paddings and sizes.
$d-p-form-header-margin-bottom: 10% !default;
$d-p-form-button-margin-top: 1rem !default;
$d-p-form-copy-margin-left: 1.25rem !default;
$d-p-form-copy-margin-right: 1.25rem !default;
$d-p-form-small-labels-spacing: 7px !default;

// Other settings
$d-p-form-background-opacity: 0.4 !default;

.theme-default {
  .paragraph--type--d-p-form {
    background: $d-p-form-background;
    color: $d-p-form-text-color;

    .field--name-field-d-main-title {
      color: $d-p-form-header-color;

      &::after {
        @include decoration-header-line-main-center($d-p-form-line-color, $d-p-form-line-color-inverted);
      }
    }

    @include media-breakpoint-up(md) {
      .left,
      .right {
        .field--name-field-d-main-title {
          &:last-child::after {
            display: none;
          }
        }
      }
    }
  }
}

.paragraph--type--d-p-form {
  position: relative;

  .d-media-background-wrapper {
    opacity: $d-p-form-background-opacity;
  }

  .content-wrapper {
    position: relative;
    z-index: 2;
  }

  form {
    margin: 0;

    .field--type-file.form-group {
      margin-top: $d-p-form-button-margin-top;
    }

    small.description {
      margin-top: $d-p-form-small-labels-spacing;
      display: inline-block;
    }

    // Multiple files attached.
    table {
      .draggable {
        .tabledrag-handle {
          display: flex;
          height: 60px;
          align-items: center;
          padding-top: 10px;

          .handle:after {
            color: $d-p-form-table-color;
          }
        }
      }
      .js-form-managed-file {
        span.file {
          padding-left: 20px;
          a {
            display: block;
            background-color: transparent;
            color: $d-p-form-table-color;
          }
        }
      }
    }

    .js-form-managed-file {
      label.form-check-label {
        display: flex;
        align-items: center;
        margin: $d-p-form-small-labels-spacing $d-p-form-copy-margin-left;
        input {
          margin-top: 0;
        }
      }

      span.file {
        padding-left: 0;
        display: inline;
        max-width: $button-max-width;
        width: 100%;
        margin-right: $d-p-form-copy-margin-right;
        height: fit-content;

        a {
          @include make-btn;
          text-transform: none;
          color: $d-p-form-text-color;
          background-color: $d-p-form-background;
          text-align: left;
          width: 100%;
          padding: 20px;
        }
      }
      .form-type-textfield {
        margin-top: $d-p-form-small-labels-spacing;
      }
    }

    .draggable {
      .js-form-managed-file {
        display: flex;
        flex-wrap: wrap;
      }
      .tabledrag-handle .handle {
        display: flex;
        background: none;
        width: unset;
        height: unset;

        &:hover {
          background: none;
          &::after {
            color: inherit;
          }
        }
        &::after {
          font-family: "fontello";
          content: "\f047";
          color: $d-p-form-text-color;
        }
      }
    }
  }
  .field--name-field-d-main-title {
    @include font-main-header;
    text-align: center;
  }

  .field--name-field-d-media-icon {
    text-align: center;
  }
  .form-actions {
    text-align: center;
    .btn {
      @include button-variant($background: $secondary, $border: $secondary);
      @include make-btn-max-width;
      margin-top: $d-p-form-button-margin-top;
    }
  }

  .form-item-copy {
    margin-left: $d-p-form-copy-margin-left;
  }

  .content {
    display: flex;
    flex-direction: column;
  }

  .left,
  .right {
    .content {
      @extend .mt-3
    }
    form {
      .name-and-mail {
        display: flex;
        flex-direction: column;
        @include media-breakpoint-up(md) {
          flex-direction: row;
          justify-content: space-between;
        }
        .form-item-name,
        .form-item-mail {
          width: 100%;
          @include media-breakpoint-up(md) {
            width: 48%;
          }
        }
      }
    }
  }

  @include media-breakpoint-up(md) {
    .right {
      .content {
        align-items: flex-start;
      }
      .field--name-field-d-main-title {
        text-align: left;
        &::after {
          margin-left: 0;
        }
      }
    }
    .left {
      .content {
        align-items: flex-end;
        text-align: right;
      }
      .field--name-field-d-main-title {
        text-align: right;
        &::after {
          margin-right: 0;
        }
      }
    }
  }
}

#geysir-modal .form-color {
  width: 60px;
  height: 30px;
  padding: 0;
}
