/*!
 * Booking.js
 * http://timekit.io
 * (c) 2015 Timekit Inc.
 */

// Imports

@import 'variables';
@import 'utils';

// Classes
.fc {
  .fc-toolbar {
    z-index: 10;
    > button {
      cursor: pointer;
    }
  }
}
.bookingjs {
  position: relative;
  font-family: $fontFamily;
  font-size: 13px;
  border-radius: 4px;
  background-color: white;
  box-shadow: 0 3px 40px 0 rgba(0, 0, 0, 0.15);
  margin: 20px auto 20px auto;
  z-index: 10;
  opacity: 1;
  color: $textColor;
  border-top: 1px solid $borderColor;
  min-height: 200px;

  &.has-avatar {
    margin-top: 60px;
  }

  &-calendar {
    border-bottom: 1px solid #ececec;

    .fc-toolbar {

      .is-small.has-avatar.has-displayname & {
        padding-bottom: 24px;
      }

      .is-small.has-avatar & .fc-right h2 {
        display: none;
      }
    }
  }

  // Timezone Helper

  &-footer {
    position: relative;
    color: $textLighterColor;
    text-align: left;
    padding: 0px 15px;
    background-color: $bgColor;
    min-height: 30px;
    line-height: 30px;
    z-index: 40;
    border-radius: 0 0 4px 4px;
    font-size: 12px;
    overflow: hidden;

    .is-small & {
      padding: 3px 15px;
      min-height: 25px;
    line-height: 25px;
    }

    &-tz {
      float: left;

      &-picker {
        display: inline-block;

        &:hover &-select,
        &-select:focus {
          color: $textColor;
          border-color: darken($borderColor, 10%);
        }

        &:hover &-arrowdown {
          opacity: 0.6;
        }

        &-select {
          appearance: none;
          background: transparent;
          font-size: inherit;
          padding: 1px 20px 1px 5px;
          transition: border 0.2s ease, color 0.2s ease;
          border-radius: 3px;
          border: 1px solid $borderColor;
          color: $textLighterColor;
          outline: none;
          max-width: 220px;

          &::-ms-expand {
            display: none; // hide the default arrow in ie10 and ie11
          }

          .is-small & {
            max-width: 180px;
          }
        }

        &-arrowdown {
          position: relative;
          display: inline-block;
          pointer-events: none;
          opacity: 0.3;
          left: -19px;
          top: -2px;
          transition: opacity 0.2s ease;

          svg {
            width: 8px;
            height: 5px;
          }
        }
      }

      .bookingjs-timezoneicon {
        height: 10px;
        width: 10px;
        margin-right: 5px;

        .is-small & {
          display: none;
        }
      }
    }

    &-by {
      float: right;
      transition: color 0.2s ease;
      color: $textLighterColor;
      text-decoration: none;
      outline: none;

      .bookingjs-timekitlogo {
        width: 12px;
        height: 12px;
        margin-left: 5px;
        top: 1px;
        position: relative;

        path {
          transition: fill 0.2s ease;
          fill: $textLighterColor;
        }

        .is-small & {
          display: none;
        }
      }

      &:hover,
      &:focus {
        color: $textColor;

        .bookingjs-timekitlogo path {
          fill: $textColor;
        }
      }

      .is-small & {
        float: left;
      }
    }
  }

  // Image avatar

  &-avatar {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 150px;
    border: 3px solid white;
    box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.13);
    overflow: hidden;
    z-index: 40;

    .is-small & {
      top: -40px;
    }
    background-color: white;

    img {
      max-width: 100%;
      vertical-align: middle;
      display: inline-block;
      width: 80px;
      height: 80px;

      .is-small & {
        width: 70px;
        height: 70px;
      }
    }
  }

  &-displayname,
  .fc-header-toolbar .fc-toolbar-chunk:first-child {
    position: absolute;
    top: 0;
    left: 0;
    padding: 15px 20px;
    color: $textColor;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    @media only screen and (max-width: 300px) {
      width: 40%;
    }
    @media only screen and (min-width: 300px) {
      width: 45%;
    }
    @media only screen and (min-width: 480px) {
      width: 65%;
    }
    @media only screen and (min-width: 640px) {
      width: 75%;
    }

    .is-small.has-avatar & {
      top: 44px;
      padding: 0px 20px;
      text-align: center;
      left: 0;
      right: 0;
      box-sizing: border-box;
    }
  }

  // Book page

  &-bookpage {
    position: absolute;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    background-color: $bgColor;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: 4px;
    text-align: center;

    &.show {
      opacity: 1;
    }

    &-close {
      position: absolute;
      top: 0;
      right: 0;
      padding: 18px;
      transition: opacity 0.2s ease;
      opacity: 0.3;

      &:hover {
        opacity: 1;
      }
    }

    &-header {
      margin-bottom: 30px;
    }

    &-date,
    h2 {
      text-align: center;
      font-size: 34px;
      font-weight: 400;
      margin-top: 50px;
      margin-bottom: 10px;

      .is-small & {
        font-size: 27px;
      }
    }

    &-time,
    &-resource,
    h3 {
      text-align: center;
      font-size: 17px;
      font-weight: 400;
      margin-bottom: 15px;
      margin-top: 10px;

      .is-small & {
        font-size: 15px;
        margin-bottom: 15px;
      }
    }

    &-resource-prefix {
      text-align: center;
      font-size: 10px;
      font-weight: 300;
      display: inline-block;
      position: relative;
      &:before {
        content: "";
        display: block;
        width: 40px;
        height: 0;
        border-top: 1px solid $borderColor;
        position: absolute;
        left: -45px;
        top: 7px;
      }
      &:after {
        content: "";
        display: block;
        width: 40px;
        height: 0;
        border-top: 1px solid $borderColor;
        position: absolute;
        right: -45px;
        top: 7px;
      }

      .is-small & {
        // font-size: 15px;
        // margin-bottom: 35px;
      }
    }
  }

  &-closeicon {
    height: 15px;
    width: 15px;
  }

  // Book page form

  &-form {
    width: 350px;
    margin: 0 auto;
    text-align: left;
    position: relative;

    .is-small & {
      width: 90%;
    }

    .cancel-text {
      font-size: 14px;
      font-weight: 800;
      color: $errorColor;
    }
    &-text {
      font-size: 11px;
      margin-right: 1em;
      color: $primaryColor;
    }

    &-box {
      overflow: hidden;
      position: relative;
      line-height: normal;
      box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1);
    }

    &-success-message {
      position: absolute;
      top: -999px;
      left: 0;
      right: 0;
      padding: 30px;
      z-index: 10;
      background-color: white;
      opacity: 0;
      transition: opacity 0.3s ease;
      line-height: normal;

      .is-small & {
        padding: 22px 10px;
      }

      .title {
        font-size: 20px;
        display: block;
        margin-bottom: 25px;
      }

      &-body {
        display: block;
        position: relative;
        transform: translateY(-50%);
        top: 50%;

        .booked-email {
          color: $textLighterColor;
        }
      }
    }

    &.success &-success-message {
      opacity: 1;
      top: 0;
      bottom: 0;
    }

    &-field {
      position: relative;
      
      .field-required {
        box-shadow: inset 0px 0px 1px 1px $errorColor;
      }
    }

    &-field--dirty &-input {
      &:invalid {
        box-shadow: inset 0px 0px 1px 1px $errorColor;
      }
    }

    &-label {
      border: 0;
      outline: none;
      display: flex;
      font-size: 11px;
      text-align: left;
      margin-top: 10px;
      margin-bottom: 5px;
      color: $primaryColor;
      flex-direction: column;
    }

    &:first-child {
      &-label {
        margin-top: 0;
      }
    }

    &-input {
      @include formInput;
      padding: 10px 20px;

      &:read-only {
        cursor: not-allowed;
        font-style: italic;

        &:focus {
          box-shadow: inset 0px 0px 1px 1px #D8D8D8;
        }
      }
    }

    // Checkbox field

    &-field--checkbox {
      text-align: left;
      position: relative;
    }

    &-label--checkbox {
      display: block;
      padding: 10px;
      font-size: 1em;
      margin-left: 28px;
      color: $textLightColor;
      font-family: $fontFamily;
      border-bottom: 1px solid $borderColor;

      &:disabled {
        cursor: not-allowed;
        font-style: italic;
        &:focus {
          box-shadow: inset 0px 0px 1px 1px #D8D8D8;
        }
      }

      input[type=checkbox] {
        position: absolute;
        left: 3px;
        top: 9px;
      }
    }

    &-field--checkbox-multi {
      margin-bottom: 5px;
      label {
        position: relative;
        margin-left: 0;
        padding: 2px 0;
        border: 0;

        input[type=checkbox] {
          position: initial;
          margin-right: 10px;
        }
      }
    }

    // Textarea field

    &-input--textarea {
      overflow: auto;
    }

    // Select field

    &-field--select {
      text-align: left;
    }

    &-label--select {
      opacity: 1;
      top: 20px;
      font-size: 11px;
      color: $primaryColor;
    }

    &-input--select {
      @include formInput;
      padding: 5px 10px;
      appearance: none;
      border-radius: 0;
      background: transparent;
      line-height: 35px;
    }

    &-input-arrow--select {
      position: absolute;
      top: 34px;
      right: 25px;
      width: 12px;
      height: 7.42px;
      opacity: 0.2;
      transition: opacity 0.2s ease;
      pointer-events: none;
    }

    &-field--select:hover &-input-arrow--select {
      opacity: 0.5;
    }

    &-button {
      position: relative;
      transition: background-color 0.2s, max-width 0.3s;
      display: inline-block;
      padding: 13px 25px;
      background-color: $primaryColor;
      text-transform: uppercase;
      box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.15);
      color: white;
      border: 0px;
      border-radius: 3px;
      font-size: 1.1em;
      font-weight: 600;
      margin-top: 30px;
      cursor: pointer;
      height: 44px;
      outline: 0;
      text-align: center;
      max-width: 200px;

      .success-text,
      .error-text,
      .loading-text {
        transition: opacity 0.3s ease;
        position: absolute;
        top: 13px;
        left: 50%;
        transform: translateX(-50%);
        opacity: 0;
      }

      .inactive-text {
        text-transform: capitalize;
        white-space: nowrap;
        opacity: 1;
      }

      .loading-text svg {
        height: 19px;
        width: 19px;
        animation: spin 0.6s infinite linear;
      }

      .error-text svg {
        height: 15px;
        width: 15px;
        margin-top: 2px;
      }

      .success-text svg {
        height: 15px;
        margin-top: 2px;
        transform: scale(0);
        transition: transform 0.6s ease;
      }

      &:hover,
      &:focus {
        background-color: $primaryDarkColor;
      }

      &.button-shake {
        animation: shake 0.5s 1 ease;
      }
    }

    &.loading &-button,
    &.loading &-button:hover {
      max-width: 80px;
      background-color: #B1B1B1;
      cursor: not-allowed;

      .inactive-text { opacity: 0; }
      .loading-text { opacity: 1; }
    }

    &.error &-button,
    &.error &-button:hover {
      max-width: 80px;
      background-color: $errorColor;
      cursor: not-allowed;

      .inactive-text { opacity: 0; }
      .error-text { opacity: 1; }
    }

    &.success &-button,
    &.success &-button:hover {
      max-width: 80px;
      background-color: $successColor;
      cursor: pointer;

      .inactive-text { opacity: 0; }
      .success-text { opacity: 1; }

      .success-text svg {
        transform: scale(1);
      }
    }
  }

  &-loading {
    position: absolute;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    background-color: $bgColor;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.5s ease;
    border-radius: 4px;

    &.show {
      opacity: 1;
    }

    &-icon {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);

      svg {
        height: 30px;
        width: 30px;
        animation: spin 0.6s infinite linear;

        path {
          fill: $primaryColor;
        }
      }
    }

  }

  &-error {
    position: absolute;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    background-color: $bgColor;
    z-index: 31;
    opacity: 0;
    transition: opacity 0.5s ease;
    border-radius: 4px;

    &.show {
      opacity: 1;
    }

    &-inner {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      text-align: center;
      overflow: scroll;
      max-height: 100%;
      padding: 30px;
      box-sizing: border-box;
      width: 100%;
    }

    &-icon {
      svg {
        height: 30px;
        width: 30px;

        g {
          fill: $errorColor;
        }
      }
    }

    &-heading {
      color: $errorColor;
      font-size: 15px;
      margin: 15px 0;
    }

    &-text {
      font-size: 12px;
      color: $textLighterColor;
      word-break: break-word;
      overflow: scroll;

      &-messag {
        display: block;
      }
      &-context {
        display: block;
      }
    }

  }

}
