@import "mixins";

/**
 * Discount form.
 */
.commerce-discount-form {
  // Position the discount status block on top right region.
  position: relative;

  // Reset.
  .form-item-label {
    clear: both;

    .form-item {
      @include box;
    }
  }

  .form-item.form-type-radio {
    position: relative;

    .ajax-progress-throbber {
      position: absolute;
      right: -10px;

      .message {
        display: none;
      }
    }
  }

  // General block margins.
  #commerce-discount-fields-wrapper {
    .form-wrapper {
      margin-bottom: 15px;
    }

    .field-name-discount-usage-limit, .field-name-discount-usage-per-person {
      float: none;
      clear: both;
    }
  }

  #edit-actions {
    clear: both;
  }
}

/**
 * Choose discount type block.
 */
.form-item-commerce-discount-type {
  .form-radios {
    margin-top: 5px;

    .form-item {
      @include btn;

      [dir="ltr"] & {
        float: left;
      }

      [dir="rtl"] & {
        float: right;
      }

      &.selected {
        background-color: #eee;
      }

      .ajax-progress {
        display: none;
      }
    }
  }
}

#edit-commerce-discount-type {
  padding: 0;

  @include radio-buttons;

  margin-top: 10px;
  clear: none;

  .form-item {
    [dir="ltr"] & {
      float: left;
      margin-right: 20px;
    }

    [dir="rtl"] & {
      float: right;
      margin-left: 20px;
    }
  }
}

/**
 * Order/Product discount conditions block.
 */
.commerce-discount-box {
  div.inline-conditions-container > label {
    border-bottom: 1px solid $gray2;
    display: block;
    width: 100%;
  }
}

/**
 * Choose offer type block.
 */
.field-name-commerce-discount-offer {
  // Help with floaties inside.
  @include clearfix;

  border: 0;
  margin: 0;
  padding: 0;

  // Offer type options.
  .form-item-commerce-discount-fields-commerce-discount-offer-und-form-type.form-type-radios {
    padding-left: 0;
    padding-right: 0;
    [dir="ltr"] & {
      float: left;
      margin-right: 20px;
      padding-right: 20px;
      border-right: 1px dotted $gray2;
    }

    [dir="rtl"] & {
      float: right;
      margin-left: 20px;
      padding-left: 20px;
      border-left: 1px dotted $gray2;
    }

    .form-radios {
      @include radio-buttons;
      margin: 10px;
      padding: 0;

      .form-item {
        &.selected {
          background-color: #eee;
        }

        .ajax-progress {
          display: none;
        }
      }

      label {
        border-bottom: 0;

        [dir="ltr"] & {
          padding-left: 0;
        }

        [dir="rtl"] & {
          padding-right: 0;
        }
      }
    }
  }

  // Avoid collision with fields below.
  .commerce-offer-type-wrapper > .fieldset-wrapper {
    @include clearfix;
  }

  // The two columns for the offer type.
  .commerce-offer-fields-wrapper {
    padding: 0;
    [dir="ltr"] & {
      float: left;
    }

    [dir="rtl"] & {
      float: right;
    }
  }

  .form-wrapper .form-wrapper {
    .form-item {
      margin-bottom: 2px;
    }

    .form-wrapper {
      label {
        border-bottom: 0;

        [dir="ltr"] & {
          padding-left: 0;
        }

        [dir="rtl"] & {
          padding-right: 0;
        }
      }
    }
  }
}

/**
 * Discount dates block.
 */
.field-name-commerce-discount-date {
  clear: both;

  .form-wrapper fieldset.form-wrapper {
    margin: 0;
  }

  .fieldset-wrapper {
    background-color: transparent;
    display: inline-block;
    margin: 10px;
    padding: 4px;
    width: auto;
  }

  .container-inline-date {
    clear: none;

    [dir="ltr"] & {
      float: left;
    }

    [dir="rtl"] & {
      float: right;
    }

    .date-padding {
      [dir="ltr"] & {
        float: left;
      }

      [dir="rtl"] & {
        float: right;
      }
    }

    .form-text {
      background-image: url(../images/calendar.svg);
      background-repeat: no-repeat;
      background-position: calc(100% - 0.25em) center;
      background-size: 1.25em;
    }
  }

  // Date.css override.
  fieldset.date-combo .container-inline-date .date-padding {
    padding: 0;
  }
  // Vertical tab fix.
  fieldset.date-combo .fieldset-wrapper > .container-inline-date {
    padding-top: 0;
  }
}

/**
 * Usage block.
 */
.commerce-discount-usage {
  clear: both;

  .form-item.form-type-select {
    margin: 0;

    label {
      border-bottom: 1px solid $gray2;
    }
  }

  .form-item .form-select {
    [dir="ltr"] & {
      float: left;
    }

    [dir="rtl"] & {
      float: right;
    }

    margin: 10px;
  }

  .field-name-commerce-discount-max-uses {
    @include box;

    & > div {
      [dir="ltr"] & {
        float: left;
        margin-left: 30px;

        &:first-child {
          margin-left: 0;
        }
      }

      [dir="rtl"] & {
        float: right;
        margin-right: 30px;

        &:first-child {
          margin-right: 0;
        }
      }

      input[disabled] {
        background: #eee;
      }
    }
  }

  .field-type-number-integer {
    [dir="ltr"] & {
      float: left;
    }

    [dir="rtl"] & {
      float: right;
    }

    .form-item {
      padding: 0;
    }

    label {
      display: inline;
      font-weight: normal;

      [dir="ltr"] & {
        margin-left: 10px;
      }

      [dir="rtl"] & {
        margin-right: 10px;
      }
    }

    .form-disabled input {
      border: 0;
      background-color: transparent;
    }
  }
}

/**
 * Overview table.
 */
.view-commerce-discount-overview {
  .views-table {
    border: 0;

    tr, td {
      border: 0;
    }

    th {
      text-transform: none;
      .views-field-operations-dropbutton {
        width: 70px;
      }
    }

    td {
      .views-field-type {
        padding: 10px 20px;
      }

      .views-field-commerce-discount-usage li {
        list-style-type: none;

        &.first {
          color: $grayDark;
          font-style: italic;
        }
      }

      .views-field-enable-disable .item-list ul {
        width: 140px;
        border: 2px solid $grayDark;
        border-radius: 5px;
        height: 30px;

        li {
          display: block;
          width: 50%;

          [dir="ltr"] & {
            float: left;
          }

          [dir="rtl"] & {
            float: right;
          }

          text-transform: uppercase;
          padding: 5px 0;
          font-weight: bold;
          text-align: center;
          font-size: 12px;
          color: white;
          line-height: 20px;

          &.enabled {
            background-color: $green;
          }

          &.disabled {
            background-color: $gray4;
          }

          a {
            color: $grayDark;
          }
        }
      }

      .views-field-operations-dropbutton {
        position: relative;

        .ctools-dropbutton {
          border: 1px solid $gray2;
          border-radius: 10px;

          @include gradient;

          .ctools-content {
            border-right: 1px solid $gray2;
          }
        }
      }
    }
  }
}

.field-name-commerce-compatibility-strategy .field-widget-options-buttons .form-wrapper {
  clear: both;
}
