// Colors
@border-color: #B5B5B5;
@border-color-hover: #7d7d7d;
@text-color: #000000;
@background-color: #FAFAFA;
@background-hover: #FCFCFC;
@highlight-color: #219653;
@error-color: #CA2A2A;
@delete-color: #EC493A;
@black-40: lighten(#000000, 40%);
@black-45: lighten(#000000, 45%);
@black-75: lighten(#000000, 75%);
// Utils
@initial-container-height: 140px;
@radius-default: 4px;
// Animations
@curve-swing: cubic-bezier(0.645, 0.045, 0.355, 1);
@curve-springy: cubic-bezier(0.43, 0.48, 0.62, 1.07);
@curve-easeOutBack: cubic-bezier(0.175, 0.885, 0.32, 1.275);
@loader-scale-duration: 300ms;

.disabled() {
  cursor: not-allowed;
}

/* =========================================================================
   General
   ========================================================================= */

[data-braintree-id='wrapper'] {
  // dropin.js has display = 'none' to prevent flicker before CSS has loaded
  display: block !important;
  position: relative;
}

[data-braintree-id="svgs"] {
  display: none !important;
}

.braintree-dropin__disabled {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  cursor: not-allowed;
  z-index: 99999;

  &.braintree-hidden {
    display: none;
  }
}

.braintree-dropin * {
  box-sizing: border-box;
}

.braintree-dropin {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.2;
  margin: 0;
  min-width: 200px;
  padding: 0;

  .braintree-hidden {
    height: 0;
    margin: 0;
    opacity: 0;
    overflow: hidden;
    visibility: hidden;
  }
}

/* =========================================================================
   Loaders
   ========================================================================= */
.braintree-loader__container {
  height: @initial-container-height;
  opacity: 1;
  position: absolute;
  width: 100%;
  z-index: 2;
}

.braintree-loading {
  .braintree-heading,
  .braintree-toggle {
    visibility: hidden !important;
  }
}

.braintree-loaded {
  .braintree-loader__container {
    z-index: -2;
  }

  .braintree-loader__indicator {
    transform: translateY(-30%) scale(0);
  }
}

.braintree-loader__indicator {
  border: solid 2px @black-75;
  border-radius: 50%;
  height: 72px;
  margin: 0 auto;
  margin-top: -36px;
  position: relative;
  top: 50%;
  transition: transform @loader-scale-duration @curve-springy;
  width: 72px;

  &:before {
    animation: rotate 512ms infinite @curve-swing;
    border: solid 2px transparent;
    border-radius: 50%;
    border-top-color: @black-40;
    box-sizing: content-box;
    content: '';
    display: block;
    height: 100%;
    margin-left: -2px;
    margin-top: -2px;
    width: 100%;
  }
}

.braintree-loader__lock {
  fill: @black-40;
  left: 50%;
  margin-left: -7px;
  margin-top: -9px;
  position: absolute;
  top: 50%;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.braintree-sheet--loading {
  .braintree-sheet__content {
    opacity: 0.3;
  }

  .braintree-sheet__header::after {
    animation: loader-scale 1s infinite, loader-origin 1s steps(1) infinite;
    background: green;
    bottom: -2px;
    content: '';
    height: 2px;
    left: -1px;
    position: absolute;
    width: 100%;
  }
}

@keyframes loader-scale {
  0% {
    transform: scaleX(0);
  }

  50% {
    transform: scaleX(1);
  }

  100% {
    transform: scaleX(0);
  }
}

@keyframes loader-origin {
  0% {
    transform-origin: 0 0;
  }

  50% {
    transform-origin: 100% 0;
  }

  100% {
    transform-origin: 0 0;
  }
}

/* =========================================================================
   Headings
   ========================================================================= */
.braintree-placeholder,
.braintree-heading {
  color: @text-color;
  font-size: 16px;
  margin-bottom: 10px;
}

.braintree-placeholder {
  margin-bottom: 13px;
}

.braintree-icon--bordered {
  background: #FFFFFF;
  border: 1px solid #BBBBBB;
  border-radius: 3px;
  box-sizing: content-box;
}

/* =========================================================================
   Upper Container
   ========================================================================= */
.braintree-upper-container {
  border-radius: @radius-default;
  min-height: @initial-container-height;
  opacity: 1;
  position: relative;
  transition: min-height 600ms;
  width: 100%;
  z-index: 2;

  &:before {
    background-color: @background-color;
    border: 1px solid @border-color;
    border-radius: @radius-default;
    bottom: 5px;
    content: '';
    display: block;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: -3;
  }
}

.braintree-loaded .braintree-upper-container {
  min-height: inherit;

  &:before {
    border: 0px;
  }
}

/* =========================================================================
   Payment Options
   ========================================================================= */
.braintree-options {
  margin: 0 auto;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

.braintree-options-initial {
  max-height: 0;
  opacity: 0;
}

.braintree-options-list {
  margin: 0 auto;
  padding-bottom: 5px;
  width: 100%;
}

.braintree-option {
  align-items: center;
  background-color: @background-color;
  border-color: @border-color;
  border-style: solid;
  border-width: 0 1px 1px 1px;
  cursor: pointer;
  display: flex;
  padding: 12px 10px;

  &:hover {
    background: white;
  }

  &:hover .braintree-option__label {
    font-weight: 500;
  }

  &.braintree-disabled {
    background: #EAEAEA;
    .disabled();

    &:hover .braintree-option__label {
      font-weight: normal;
    }

    .braintree-option__label {
      color: #787878;
    }

    .braintree-option__disabled-message {
      float: right;
      font-size: 14px;

      span {
        border-bottom: 1px solid @border-color;
      }
    }
  }

  &:first-child {
    border-radius: @radius-default @radius-default 0 0;
    border-top-width: 1px;
  }

  &:last-child {
    border-radius: 0 0 @radius-default @radius-default;
  }

  .braintree-option__logo {
    display: flex;
    text-align: center;

    align-items: center;
  }

  .braintree-option__label {
    color: @text-color;
    font-size: 16px;
    margin-left: 20px;
    width: 100%;
  }
}

/* =========================================================================
   Apple Pay buttons
   ========================================================================= */
@supports (-webkit-appearance: -apple-pay-button) {
    .apple-pay-button {
        display: inline-block;
        -webkit-appearance: -apple-pay-button;
        cursor: pointer;
    }
}
@supports not (-webkit-appearance: -apple-pay-button) {
    .apple-pay-button {
        display: inline-block;
        background-size: 100% 60%;
        background-repeat: no-repeat;
        background-position: 50% 50%;
        border-radius: 5px;
        padding: 0px;
        box-sizing: border-box;
        min-width: 200px;
        min-height: 32px;
        max-height: 64px;
        cursor: pointer;
    }
    .apple-pay-button-black {
        background-image: -webkit-named-image(apple-pay-logo-white);
        background-color: black;
    }
    .apple-pay-button-white {
        background-image: -webkit-named-image(apple-pay-logo-black);
        background-color: white;
    }
    .apple-pay-button-white-with-line {
        background-image: -webkit-named-image(apple-pay-logo-black);
        background-color: white;
        border: .5px solid black;
    }
}

/* =========================================================================
   Sheets
   ========================================================================= */
.braintree-sheet {
  background-color: white;
  border: 1px solid @border-color;
  border-radius: @radius-default;
  display: none;
  margin: 0 auto;
  // NEXT_MAJOR_VERSION drop this when IE support is no longer required
  max-height: 600px; // IE11 doesn't support fit-content, so we need a backup value here
  max-height: fit-content;
  transition: transform 300ms, opacity 300ms, max-height 300ms ease;
  width: 100%;
}

.braintree-sheet--tokenized {
  max-height: 71px;
  opacity: 0.1;
  overflow: hidden;
  transform: translateY(20px);

  .braintree-sheet__header {
    opacity: 0.1;
  }

  .braintree-sheet__content {
    opacity: 0.1;
  }
}

.braintree-sheet--has-error {
  .braintree-sheet {
    border: 2px solid @error-color;
    border-radius: @radius-default @radius-default 0 0;
  }

  .braintree-methods--edit .braintree-method {
    border-left: 2px solid @error-color;
    border-right: 2px solid @error-color;

    &:first-child {
      border-top: 2px solid @error-color;
    }

    &:last-child {
      border-bottom: 2px solid @error-color;
    }
  }

}

.braintree-sheet__container {
  display: none;
  margin: 0 auto 13px;
  max-height: 0;
  opacity: 0;
}

.braintree-sheet__error {
  display: none;
  margin: 0 auto;
  width: 100%;
}

.braintree-sheet--has-error .braintree-sheet__error {
  color: @error-color;
  align-items: center;
  justify-content: center;
  display: flex;
  padding: 6px;
  position: relative;
  margin-top: 4px;

  .braintree-sheet__error-icon {
    height: 24px;
    margin-top: -12px;
    margin-right: 4px;
    position: relative;
    top: 4px;
    width: 24px;

    use {
      fill: @error-color;
    }
  }

  .braintree-sheet__error-text {
    color: @error-color;
    font-size: 14px;
    text-align: center;
  }
}

.braintree-show-methods .braintree-sheet--active {
  &.braintree-sheet--has-error .braintree-sheet {
    border-color: @error-color;
    border-radius: 5px 5px 0 0;
  }

  .braintree-sheet {
    border-radius: 5px;
    border-color: #219653;
    border-width: 2px;
  }
}

.braintree-sheet__header {
  align-items: center;
  border-bottom: 1px solid @border-color;
  display: flex;
  flex-wrap: wrap;
  padding: 12px 15px 0 12px;
  position: relative;

  .braintree-sheet__header-label {
    align-items: center;
    display: flex;
    flex-grow: 1;
    padding-bottom: 12px;
  }

  .braintree-sheet__label {
    font-size: 16px;
  }

  .braintree-sheet__logo--header {
    align-items: center;
    display: flex;
    text-align: center;
    width: 50px;
  }

  .braintree-sheet__card-icon {
    display: inline-block;
    padding-left: 5px;

    &.braintree-hidden {
      display: none;
    }
  }

  .braintree-sheet__text {
    color: @text-color;
    font-size: 16px;
    margin-left: 20px;
  }

  .braintree-sheet__icons {
    padding-bottom: 10px;
  }
}

.braintree-sheet__content--button {
  min-height: 84px;
  padding: 20px;
  text-align: center;

  .braintree-sheet__button--paypal {
    margin: 0 auto;

    iframe {
      display: inline-block !important;
    }
  }

  .braintree-sheet__button--venmo {
    max-width: 100%;

    use {
      cursor: pointer;
    }
  }

  .braintree-sheet__button--apple-pay {
    margin: 0 auto;

    iframe {
      display: inline-block !important;
    }
  }
}

.braintree-form__field-group--has-error {
  .braintree-form__icon-container {
    margin-top: -12px;
  }
}

/* =========================================================================
   Input Forms
   ========================================================================= */
.braintree-form__hosted-field {
  transition: border-color 100ms;

  iframe {
    margin: auto;
  }
}

.braintree-sheet__content--form {
  padding: 10px 15px 10px 10px;

  .braintree-form__notice-of-collection {
    font-size: 12px;
    margin: auto;
    text-align: center;
  }

  .braintree-form__field-group {
    margin-bottom: 10px;
    padding-left: 5px;

    &.braintree-form__field-group--has-error {
      margin-bottom: 3px;

      .braintree-form__field .braintree-form__hosted-field {
        border-color: @error-color;

        &:hover {
          border-color: @error-color;
        }
      }
    }

    .braintree-form__label {
      color: @text-color;
      display: block;
      font-size: 14px;
      font-weight: normal;
      line-height: 1.4;
      margin: 0;
      padding: 0;
      text-align: left;
    }

    .braintree-form__descriptor {
      color: @border-color;
      font-size: 13px;
      margin-left: 6px;
    }

    .braintree-form__field {
      position: relative;

      label {
        cursor: text;
        display: block;
        margin: 0;
      }

      .braintree-form__icon-container {
        margin-top: -14px;
        position: absolute;
        right: 11px;
        top: 50%;
      }

      .braintree-form__hosted-field {
        border: 1px solid @black-75;
        height: 44px;
        margin: 4px 0 0;
        padding: 0 8px;

        &:hover {
          border-color: @border-color-hover;
        }

        &.braintree-form__field--valid {
          border-color: @black-40;
        }

        input.braintree-form__raw-input {
          border:none;
          background-image:none;
          background-color:transparent;
          -webkit-box-shadow: none;
          -moz-box-shadow: none;
          box-shadow: none;
          width: 100%;
          height: 100%;
          font-size: 16px;
          font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
          color: rgb(0, 0, 0);

          &:focus {
            outline: none;
          }
        }
      }

      &.braintree-form__checkbox {
        float: left;

        input {
          margin: -5px 5px 0 0;
          padding: 0;
          line-height: 0;
          box-sizing: border-box;
        }
      }
    }

    &.braintree-form__field-group--has-error .braintree-form__field-secondary-icon,
    &.braintree-form__field-group--has-error.braintree-form__field-group--card-type-known .braintree-form__field-secondary-icon,
    &.braintree-form__field-group--has-error.braintree-form__field-group--is-focused .braintree-form__field-secondary-icon,
    .braintree-form__field-error-icon,
    .braintree-form__field-secondary-icon {
      display: none;
      transform: scale(0);
    }

    &.braintree-form__field-group--card-type-known .braintree-form__field-secondary-icon,
    &.braintree-form__field-group--has-error .braintree-form__field-error-icon,
    &.braintree-form__field-group--is-focused .braintree-form__field-secondary-icon {
      display: block;
      transform: scale(1);
    }

    .braintree-form__field-error {
      color: @error-color;
      display: none;
      font-size: 13px;
      line-height: 1.4;
      margin: 3px 0;
      padding: 0;
    }

    .braintree-form__field-error-icon {
      margin-top: 2px;

      use {
        fill: @error-color;
      }
    }

    &.braintree-form__field-group--has-error .braintree-form__field-error {
      display: block;
    }
  }

  .braintree-form__flexible-fields {
    display: flex;

    flex-wrap: wrap;
    justify-content: space-between;

    .braintree-form__field-group {
      flex-basis: 190px;
      flex-grow: 1;
    }
  }
}

/* =========================================================================
   Payment Methods
   ========================================================================= */
.braintree-method {
  align-items: center;
  background-color: white;
  border-color: @border-color;
  border-style: solid;
  border-width: 0 1px 1px 1px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  padding: 14px 10px;
  position: relative;
  transition: opacity 300ms, width 200ms @curve-easeOutBack, border-color 300ms, border-radius 300ms;
  width: 98%;
  z-index: 0;

  &:hover .braintree-method__label {
    font-weight: 500;
  }

  &:first-child {
    border-radius: @radius-default @radius-default 0 0;
    border-top-width: 1px;
  }

  &:last-child {
    border-radius: 0 0 @radius-default @radius-default;
  }

  &:only-child {
    border-radius: @radius-default;
  }

  .braintree-method__logo {
    align-items: center;
    display: flex;
    justify-content: center;
  }

  .braintree-method__label {
    color: @text-color;
    flex-grow: 1;
    font-size: 16px;
    margin-left: 20px;
    text-align: left;
    text-overflow: ellipsis;
    overflow: hidden;

    .braintree-method__label--small {
      font-size: 13px;
      font-weight: normal;
    }
  }

  .braintree-method__icon {
    background-color: @background-color;
    border-radius: 100px;
    fill: @background-color;
    height: 41px;
    width: 41px;
    padding: 10px;
    transform: scale(0);
    transition: transform 300ms @curve-easeOutBack;

    svg {
      width: 100%;
    }
  }
}

.braintree-methods--edit .braintree-method {
  cursor: auto;
}

.braintree-methods--active:not(.braintree-methods--edit) .braintree-method--active {
  border-radius: 5px;
  opacity: 1;
  width: 100%;
  z-index: 1;
  border-color: #219653;
  border-width: 2px;
  margin-top: -1px;
  margin-bottom: -1px;

  &:first-of-type {
    margin-top: 0;
  }

  &:last-of-type {
    margin-bottom: 0;
  }

  .braintree-method__check {
    background-color: @highlight-color;
  }

  .braintree-method__icon {
    fill: white;
    transform: scale(1);
  }

  .braintree-method__label {
    font-weight: bold;
  }
}

.braintree-method__delete-container {
  display: none;

  .braintree-method__delete {
    margin-right: 19px;
    height: 30px;
    width: 30px;
    padding: 7px;
    background-color: @delete-color;
    cursor: pointer;

    &:hover {
      background-color: darken(@delete-color, 15%);
      transform: scale(1.1);
    }


    svg {
      margin-top: -5px;
      margin-left: 1px;
    }
  }
}

.braintree-methods--edit {
  .braintree-method__delete-container {
    display: block;

    .braintree-method__delete {
      transform: scale(1);
    }
  }
}

.braintree-methods {
  display: none;
  margin: 0 auto 6px auto;
}

.braintree-delete-confirmation {
  display: none;
  overflow: hidden;
  background: #FAFAFA !important;
  color: #606060;
  font-size: 1.125em;

  [data-braintree-id="delete-confirmation__message"] {
    padding: 2.5em;
    text-align: center;
  }

  .braintree-delete-confirmation__button-container {
    display: flex;
    text-align: center;

    .braintree-delete-confirmation__button {
      border: none;
      border-top: 1px solid #B5B5B5;
      font-size: 1em;
      background: #FAFAFA;
      color: #C4C4C4;
      cursor: pointer;
      flex-grow: 2;
      padding: 0.75em;
    }

    [data-braintree-id="delete-confirmation__yes"] {
      color: white;
      background: @delete-color;
      border-left: solid 1px #b5b5b5;

      &:hover {
        background: darken(@delete-color, 15%);
      }
    }

    [data-braintree-id="delete-confirmation__no"] {
      color: @black-40;
      border-bottom-left-radius: 0.25em;

      &:hover {
        background: darken(@background-hover, 5%);
      }
    }
  }
}

.braintree-methods-initial {
  display: none;
  max-height: 0;
  opacity: 0;
}

.braintree-large-button {
  background: @background-color;
  border-radius: @radius-default;
  color: @text-color;
  cursor: pointer;
  font-size: 14px;
  margin: 0 auto;
  padding: 18px;
  text-align: center;
  width: 100%;

  &:hover {
    background: @background-hover;
    font-weight: 500;
  }

  &:hover span {
    border-color: black;
  }

  span {
    border-bottom: 1px solid @border-color;
    padding-bottom: 1px;
  }

  &.braintree-hidden {
    display: none;
  }
}

/* =========================================================================
   Dropin Visibility States
   ========================================================================= */
.braintree-show-card .braintree-card,
.braintree-show-methods .braintree-methods,
.braintree-show-delete-confirmation .braintree-delete-confirmation,
.braintree-show-options .braintree-options,
.braintree-show-paypal .braintree-paypal,
.braintree-show-paypalCredit .braintree-paypalCredit,
.braintree-show-applePay .braintree-applePay,
.braintree-show-googlePay .braintree-googlePay,
.braintree-show-venmo .braintree-venmo {
  display: block;
  height: auto;
  overflow: visible;
  visibility: visible;
}


[data-braintree-id='methods-label'],
[data-braintree-id='methods-edit'],
[data-braintree-id='choose-a-way-to-pay'] {
  position: absolute;
  transform: translateY(30px);
  transition: transform 200ms ease;
  visibility: hidden;
}

.braintree-show-methods [data-braintree-id='methods-label'],
.braintree-show-methods [data-braintree-id='methods-edit'],
.braintree-show-options [data-braintree-id='choose-a-way-to-pay'] {
  transform: none;
  visibility: visible;
}

.braintree-show-methods [data-braintree-id='methods-edit'] {
  right: 5px;
  text-decoration: underline;
  cursor: pointer;
}

.braintree-show-methods [data-braintree-id='methods-label'].braintree-no-payment-method-selected {
  transform: translateY(30px);
}

.braintree-show-methods.braintree-show-options [data-braintree-id='choose-a-way-to-pay'] {
  transform: translateY(30px);
  visibility: hidden;
}

/* =========================================================================
   Javascript hooks
   ========================================================================= */
.braintree-loaded [data-braintree-id='methods'],
.braintree-loaded [data-braintree-id='options'],
.braintree-loaded [data-braintree-id='sheet-container'] {
  // NEXT_MAJOR_VERSION drop this when IE support is no longer required
  max-height: 2000px; // IE11 doesn't support fit-content, so we need a backup value here
  max-height: fit-content; // Must set value here in order to have animation
  opacity: 1;
  transition: max-height 250ms @curve-easeOutBack, opacity 300ms linear 100ms;
  min-height: 0;
}

.braintree-loaded .braintree-sheet__container {
  display: block;
}

.braintree-show-methods,
.braintree-show-options {
  [data-braintree-id='other-ways-to-pay'] {
    display: none;
  }
}

.braintree-show-card [data-braintree-id='other-ways-to-pay'],
.braintree-show-methods [data-braintree-id='other-ways-to-pay'],
.braintree-show-paypal [data-braintree-id='other-ways-to-pay'],
.braintree-show-applePay [data-braintree-id='other-ways-to-pay'],
.braintree-show-googlePay [data-braintree-id='other-ways-to-pay'],
.braintree-show-venmo [data-braintree-id='other-ways-to-pay'] {
  display: block;
}

.braintree-loaded [data-braintree-id='methods'],
.braintree-loaded [data-braintree-id='options'] {
   transition: none;
}

.braintree-options {
  display: none;
}

/* =========================================================================
   Flexbox-free styling
   ========================================================================= */

[data-braintree-no-flexbox='true'] {
  .braintree-option:after {
    content: "";
    display: table;
    clear: both;
  }

  .braintree-option__label {
    float: left;
    width: auto;
  }

  .braintree-option__logo {
    float: left;
  }

  .braintree-sheet__header {
    display: table;
    width: 100%;
  }

  .braintree-sheet__header:after {
    content: "";
    display: table;
    clear: both;
  }

  .braintree-sheet__header-label {
    float: left;
  }

  .braintree-sheet__header-label:after {
    content: "";
    display: table;
    clear: both;
  }

  .braintree-sheet__logo--header {
    float: left;
  }

  .braintree-sheet__text {
    float: left;
    width: auto;
  }

  .braintree-sheet__icons {
    float: right;
  }

  .braintree-method__label {
    float: left;
    width: auto;
  }

  .braintree-method__logo {
    float: left;
  }

  .braintree-method:after {
    content: "";
    display: table;
    clear: both;
  }

  .braintree-method__icon-container {
    float: right;
    position: relative;
  }

  .braintree-method__icon-container:before {
    right: 0;
  }

  .braintree-method__icon {
    margin-right: 0;
    right: 0;
    position: absolute;
  }
}

@import 'cardinal-overrides';
