/*
Copyright 2022 DigitalOcean

This code is licensed under the MIT License.
You may obtain a copy of the License at
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

.field-row {
  display: flex;
  flex-flow: row wrap;
  margin: 0 -.5rem;

  .field {
    flex-grow: 1;
    margin: 0 .5rem;
    text-align: left;
  }

  + .field-row,
  + .field {
    margin-top: 1rem;
  }
}

.field {
  &.is-horizontal {
    align-items: center;

    &.is-aligned-top {
      align-items: flex-start;

      > .field-label {
        &.has-margin-top {
          margin-top: .75rem;
        }

        &.has-small-margin-top {
          margin-top: .25rem;
        }
      }

      > p {
        @include font-medium;

        color: $dark-grey;
        font-size: 14px;
        margin: 0 .5rem;
      }
    }

    + .control {
      margin-top: .5rem;
    }
  }

  &.is-grouped {
    > .control {
      &:last-child {
        margin: .25rem 0 0;
      }

      &:not(:last-child) {
        margin: .25rem .75rem 0 0;
      }
    }
  }

  .is-changed {
    input {
      &:not(.vs__search) { // stylelint-disable-line selector-class-pattern
        &,
        &:focus {
          background: rgba($highlight, .35);
        }
      }
    }

    .checkbox,
    .radio,
    .text {
      background: rgba($highlight, .35);
    }

    label {
      &.text {
        padding: .25rem .5rem;
      }
    }

    .v-select {
      .vs__dropdown-toggle { // stylelint-disable-line selector-class-pattern
        background: rgba($highlight, .35);
      }
    }
  }

  label {
    @include font-medium;

    color: $dark-blue;
    font-size: 1rem;

    &.text {
      border-radius: $border-radius;
      color: $dark-grey;
      display: inline-block;
      font-size: 14px;
      padding: 0 .5rem;

      &.message {
        padding: 0;

        .message-body {
          display: inline-block;
        }
      }

      .fa-external-link-alt {
        margin: 0 0 0 .25rem;
      }
    }
  }

  .button {
    &.is-static {
      background: $panel;
      border: 1px solid $border;
      color: $dark-grey;
      padding: 0 ($margin * 1.5);
    }

    &.is-tiny {
      font-size: 14px;
      height: auto;
      line-height: normal;
      margin: .2rem .25rem;
      padding: ($margin * .5) ($margin * .75);
    }
  }

  .control {
    &:not(.is-expanded) {
      + .control {
        &:not(.is-expanded) {
          margin-top: .25rem;
        }
      }
    }

    input.is-danger {
      border-color: $danger;
    }
  }
}

.field-body {
  &.is-vertical {
    flex-direction: column;

    > .field {
      &:not(:last-child) {
        margin-bottom: .75rem;
      }
    }
  }
}

.checkbox,
.radio {
  border-radius: $border-radius;
  padding: .25rem .5rem;

  .pretty {
    line-height: 1.25;
    white-space: initial;

    &.p-icon {
      font-size: 18px;
      margin: 0;

      .state {
        .icon {
          top: 50%;
          transform: translateY(-50%);

          &::before {
            color: $panel;
            font-size: 14px;
          }
        }

        label {
          @include font-medium;

          color: $dark-grey;
          font-size: 14px;
          padding-left: calc(#{$margin * .5} + 1.5em);
          text-indent: initial;

          &::before,
          &::after {
            font-size: 18px;
            top: 50%;
            transform: translateY(-50%);
          }
        }
      }
    }
  }
}
