// studio - views - certificates
// ====================

// Table of Contents
// * +Layout - Certificates
// * +Main - Collection
// * +Main - Certificate
// * +Signatories -Certificate


// * +Layout - Certificates
// ====================
.view-certificates {
  .content-primary, .content-supplementary {
    @include box-sizing(border-box);

    float: left;
  }

  .content-primary {
    width: flex-grid(9, 12);
    margin-right: flex-gutter();

    .notice-moduledisabled {
      @extend %ui-well;
      @extend %t-copy-base;

      background-color: $white;
      padding: ($baseline*1.5) $baseline;
      text-align: center;
    }

    .no-content {
      @extend %no-content;
    }

    .wrapper-certificates {
      .title {
        @extend %t-title4;
        @extend %t-strong;
      }

      .copy {
        @extend %t-copy-sub1;
      }

      .instructions {
        @extend %t-copy-sub1;

        margin-bottom: $baseline;
      }
    }

    .certificate-settings {
      margin-bottom: $baseline;
    }

    .actual-course-title {
      @extend %t-strong;

      margin-bottom: $baseline;
    }
  }

  .content-supplementary {
    width: flex-grid(3, 12);
  }

  .certificate-info-section{
    overflow: auto;

    .course-title-section, .course-number-section{
      min-width: 47%;

      @include margin-right(2%);
    }
  }
}

// * +Main - Collection
// ====================
.view-certificates {
  .wrapper-collection {
    @extend %ui-window;

    position: relative;
    outline: none;

    &:hover .collection .actions {
      opacity: 1;
    }

    .collection-details {
      padding: $baseline ($baseline*1.5);
    }

    .collection-header {
      margin-bottom: 0;
      border-bottom: 0;
      padding-bottom: 0;
    }

    .collection-info {
      @extend %t-copy-sub1;

      &.certificate-info-inline {
        margin: ($baseline/2) 0;
      }

      &.collection-info-inline {
        display: table;
        width: 70%;
        margin: ($baseline/4) 0 ($baseline/2) $baseline;

        li {
          @include box-sizing(border-box);

          display: table-cell;
          margin-right: 1%;
          padding: ($baseline/4) 0;
        }
      }
    }

    .collection-items {
      margin-left: $baseline;
      margin-bottom: ($baseline*0.75);

      .item {
        @extend %t-copy-lead1;

        padding: ($baseline/7) 0 ($baseline/4);
        border-top: 1px solid $gray-l4;
        white-space: nowrap;

        &:first-child {
          border-top: none;
        }

        .name {
          overflow: hidden;
          text-overflow: ellipsis;
          display: inline-block;
          vertical-align: middle;
          width: 75%;
          margin-right: 5%;
        }
      }
    }

    .collection-details {
      .actions {
        @include transition(opacity .15s .25s ease-in-out);

        position: absolute;
        top: $baseline;
        right: $baseline;
        opacity: 0;

        .action {
          display: inline-block;
          vertical-align: middle;
          margin-right: ($baseline/4);

          .edit {
            @extend %ui-btn-non-blue;
          }

          .edit-signatory {
            @extend %ui-btn-non-blue;
          }

          .delete {
            @extend %ui-btn-non;

            &.is-disabled {
              background-color: $gray-l3;
              color: $gray-l6;
            }
          }
        }
      }
    }

    .collection-references {
      @extend %t-copy-sub1;

      box-shadow: 0 2px 2px 0 $shadow inset;
      padding: $baseline ($baseline*1.5) $baseline ($baseline*2.5);
      color: $gray-l1;

      .usage {
        margin-left: $baseline;

        .usage-unit {
          padding: ($baseline/4) 0;

          a {
            @extend %t-strong;
          }

          .fa-warning {
            margin: ($baseline/4) ($baseline/2) 0 ($baseline*1.5);
            color: $orange;
          }

          .fa-times-circle {
            margin: ($baseline/4) ($baseline/2) 0 ($baseline*1.5);
            color: $red-l2;
          }
        }
      }
    }

    .collection-edit {
      @include box-sizing(border-box);

      border-radius: 2px;
      width: 100%;
      background: $white;

      .message {
        margin-bottom: 0;
      }

      .wrapper-form {
        padding: $baseline ($baseline*1.5);

        label {
          @extend %t-strong;
        }
      }

      .action-add-signatory {
        @extend %ui-btn-flat-outline;

        display: block;
        width: 100%;
        margin-top: ($baseline*0.75);
        padding: ($baseline/2) $baseline;
      }

      .disableClick {
        @extend %ui-disabled;

        color: $gray-l1;
      }

      .tip {
        @extend %t-copy-sub2;

        @include transition(color, 0.15s, ease-in-out);

        display: block;
        margin-top: ($baseline/2);
        color: $gray-d1;
      }

      .is-focused .tip {
        color: $gray-d2;
      }


      .collection-fields {
        @extend %cont-no-list;

        margin-bottom: $baseline;
      }

      .field {
        margin: 0 0 ($baseline*0.75) 0;

        &:last-child {
          @extend %wipe-last-child;
        }

        &.required {
          label {
            @extend %t-strong;
          }

          label::after {
            margin-left: ($baseline/4);
            content: "*";
          }
        }

        label, input, textarea {
          display: block;
        }

        textarea {
          resize: vertical;
        }

        label {
          @extend %t-copy-sub1;

          @include transition(color, 0.15s, ease-in-out);

          margin: 0 0 ($baseline/4) 0;

          &.is-focused {
            color: $blue;
          }
        }

        //this section is borrowed from _account.scss - we should clean up and unify later
        input, textarea {
          @extend %t-copy-base;

          height: 100%;
          width: 100%;
          padding: ($baseline/2);

          &.long {
            width: 100%;
          }

          &.short {
            width: 25%;
          }

          ::-webkit-input-placeholder {
            color: $gray-l4;
          }

          :-moz-placeholder {
            color: $gray-l3;
          }

          ::-moz-placeholder {
            color: $gray-l3;
          }

          :-ms-input-placeholder {
            color: $gray-l3;
          }

          &:focus {
            + .tip {
              color: $gray-d2;
            }
          }
        }

        &.error {
          label {
            color: $red;
          }

          input {
            border-color: $red;
          }
        }
      }

      label.required {
        @extend %t-strong;

        &::after {
          margin-left: ($baseline/4);
          content: "*";
        }
      }

      .field.add-collection-name {
        label {
          width: 50%;

          @extend %t-title5;

          display: inline-block;
          vertical-align: bottom;
        }

        .certificate-id {
          display: inline-block;
          width: 45%;
          text-align: right;
          vertical-align: top;
          color: $gray-l1;

          .certificate-value {
            @extend %t-strong;

            white-space: nowrap;
            margin-left: ($baseline*0.5);
          }
        }
      }

      .actions {
        box-shadow: inset 0 1px 2px $shadow;
        border-top: 1px solid $gray-l1;
        padding: ($baseline*0.75) $baseline;
        background: $gray-l6;

        .action {
          margin-right: ($baseline/4);

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

        .action-primary {
          @extend %btn-primary-blue;

          padding: ($baseline/4) $baseline;
        }

        .action-secondary {
          @extend %btn-secondary-gray;

          padding: ($baseline/4) $baseline;
        }

        .wrapper-delete-button {
          float: right;
          padding: ($baseline/4) ($baseline/2);

          .is-disabled {
            color: $gray-l3;
          }
        }

        &.custom-signatory-action {
          position: relative;
          top: 0;
          left: 0;
          opacity: 1;
        }
      }

      .copy {
        @extend %t-copy-sub2;

        margin: ($baseline) 0 ($baseline/2) 0;
        color: $gray;

        strong {
          @extend %t-strong;
        }
      }
    }

    .action-add-item {
      @extend %ui-btn-flat-outline;
      @extend %t-action2;
      @extend %t-strong;

      display: block;
      width: 100%;
      margin: ($baseline*1.5) 0 0 0;
      padding: ($baseline/2);
    }
  }

  // add/new collection
  .action-add {
    @extend %ui-btn-flat-outline;

    display: block;
    width: 100%;
    margin-top: ($baseline*0.75);
    padding: ($baseline/2) $baseline;

    &.is-hidden {
      display: none;
    }

    .icon {
      display: inline-block;
      vertical-align: middle;

      @include margin-right($baseline/2);
    }
  }

  .action-add-hidden {
    visibility: hidden;
  }
}

// * +Main - Certificate
// ====================
// TO-DO: refactor to use collection styling where possible.
.view-certificates .activate-cert {
  margin-left: 5px;
}

.view-certificates .certificates {
  .certificate-details, .certificate-edit {
    .title {
      @extend %t-title4;
      @extend %t-strong;

      margin-bottom: ($baseline/2);
    }
  }

  .certificate-edit {
    .add-collection-name label {
      padding-right: 5%;
      overflow: hidden;
      text-overflow: ellipsis;
      vertical-align: bottom;
    }

    .field-group {
      @include clearfix();

      margin: 0 0 ($baseline/2) 0;
      padding: ($baseline/4) 0 0 0;

      .group-allocation,
      .field {
        display: inline-block;
        vertical-align: middle;
        margin: 0 3% 0 0;
      }

      .group-allocation {
        max-width: 10%;
        min-width: 5%;
        color: $gray-l1;
      }

      .field {
        position: relative;

        &.long {
          width: 80%;
        }

        &.short {
          width: 10%;
        }
      }

      .action-close {
        @include transition(color $tmg-f2 ease-in-out);

        @extend %t-action1;

        display: inline-block;
        border: 0;
        padding: 0;
        background: transparent;
        color: $blue-l3;
        vertical-align: middle;

        &:hover {
          color: $blue;
        }
      }
    }
  }
}

// * +Signatories -Certificate
// ====================
// TO-DO: refactor to use collection styling where possible.
.view-certificates .certificates {
  .signatory-details, .signatory-edit {
    @extend %ui-window;

    border-color: $gray-l4;

    .signatory-panel-header {
      @extend %t-strong;

      background-color: $gray-l5;
      padding: ($baseline/2) ($baseline*0.75);
      border-bottom: 1px solid $gray-l5;
      border-top-left-radius: 3px;
      border-top-right-radius: 3px;
    }

    .signatory-panel-body {
      padding: $baseline;

      .signatory-image {
        margin-top: 20px;
      }

      .signature-image {
        max-width: 450px;
      }
    }

    .signatory-panel-body label {
      font-weight: 600;
    }

    .signatory-panel-edit {
      float:right;
      padding: 8px;
      position: inherit;
    }
  }

  .signatory-edit {

    // TO-DO: remove icon styling, use save / cancel pattern for Studio
    .signatory-panel-close, .signatory-panel-save, .signatory-panel-delete {
      float:right;
      padding:10px;
    }

    .tip {
      @extend %t-copy-sub2;

      @include transition(color, 0.15s, ease-in-out);

      display: block;
      margin-top: ($baseline/4);
      color: $gray-d1;
    }

    .field {
      margin-bottom: $baseline;

      &:last-child {
        @extend %wipe-last-child;
      }

      &.required {
        label {
          @extend %t-strong;
        }

        label::after {
          margin-left: ($baseline/4);
          content: "*";
        }
      }

      label, input, textarea {
        display: block;
      }

      textarea {
        resize: vertical;
      }

      label {
        @extend %t-copy-sub1;

        @include transition(color, 0.15s, ease-in-out);

        margin: 0 0 ($baseline/4) 0;

        &.is-focused {
          color: $blue;
        }
      }

      //TO-DO: this section is borrowed from _account.scss - we should clean up and unify later
      input, textarea {
        @extend %t-copy-base;

        height: 100%;
        width: 100%;
        padding: ($baseline/2);

        &.long {
          width: 100%;
        }

        &.short {
          width: 25%;
        }

        ::-webkit-input-placeholder {
          color: $gray-l4;
        }

        :-moz-placeholder {
          color: $gray-l3;
        }

        ::-moz-placeholder {
          color: $gray-l3;
        }

        :-ms-input-placeholder {
          color: $gray-l3;
        }

        &:focus {
          + .tip {
            color: $gray-d1;
          }
        }
      }

      &.error {
        label {
          color: $red;
        }

        input {
          border-color: $red;
        }

        .message-error{
          color: $red;
        }
      }

      .signature-upload-wrapper {
        @include clearfix();

        width: flex-grid(12, 12);

        .signature-upload-input-wrapper {
          float: left;
          width: flex-grid(7, 12);
          margin-right: flex-gutter();
        }

        .action-upload-signature {
          @extend %ui-btn-flat-outline;

          float: right;
          width: flex-grid(4, 12);
          margin-top: ($baseline/4);
          padding: ($baseline/2) $baseline;
        }
      }

      .current-signature-image {
        margin-bottom: ($baseline/2);
        padding: ($baseline/2) $baseline;
        background: $gray-l5;
        text-align: center;

        .wrapper-signature-image {
          display: block;
          width: 375px;
          line-height: 200px;
          overflow: hidden;
          margin: 0 auto;
          border: 1px solid $gray-l4;
          box-shadow: 0 1px 1px $shadow-l1;
          padding: ($baseline/2);
          background: $white;
        }

        .signature-image {
          vertical-align: middle;
          width: 100%;
          max-height: 100%;
        }
      }
    }
  }
}
