// shared styles used
// on both the login and
// create account modals
.login-modal,
.create-account {
  .modal-body {
    &.has-alt-auth {
      background: var(--tertiary-or-tertiary-low);
    }
  }
  .btn-flat.btn.modal-close svg {
    color: rgba(var(--primary-rgb), 0.5);
    &:hover {
      color: rgba(var(--primary-rgb), 0.85);
    }
  }
  #login-buttons:not(.hidden) {
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    align-items: stretch;
    min-height: 75px;
    order: 2;

    &:focus-within,
    &:hover {
      button:not(:hover):not(:focus) {
        opacity: 0.75;
      }
    }

    button {
      margin: 0.35em 0;
      &:first-of-type {
        margin-top: 0;
      }
      &:last-of-type {
        margin-bottom: 0;
      }
      &:lang(zh_CN) {
        min-width: 200px;
      }
      &:first-of-type:last-of-type {
        &.oauth2_basic {
          // Handles a strange fringe case where OAuth2 and account approval are enabled
          margin-left: auto;
          margin-right: auto;
          justify-content: center;
        }
      }
    }
  }

  .tip {
    display: block;
    overflow: hidden;
    word-wrap: break-word;
    margin-bottom: 0;
    max-width: 280px;
    @media screen and (min-width: 500px) {
      max-width: 400px;
    }
  }
}

.has-alt-auth {
  .tip {
    max-width: 100%;
  }
}

.login-modal:not(.hidden).has-alt-auth.no-local-login {
  padding: 0 2em !important;
  min-width: 350px !important;
  .login-right-side {
    width: 100%;
    padding: 2em 0;
    #login-buttons:not(.hidden) {
      width: 80%;
      .btn.btn-social:first-of-type {
        margin-top: 2em;
      }
      .btn.btn-social,
      .btn,
      .login-with-email-button {
        border: 1px solid var(--primary-low-mid);
        margin-bottom: 0.5em;
        &:hover,
        &:focus {
          background: var(--primary-very-low) !important;
        }
      }
    }
  }
}

// styles used on
// login modal only
.login-modal:not(.hidden) {
  padding: 0 !important;
  .login-modal-body.has-alt-auth {
    min-width: 700px;
    .login-left-side {
      align-self: stretch;
      width: calc(60% - 4em);
    }
    .login-right-side {
      width: 35%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      #login-buttons {
        button {
          &.login-with-email-button {
            border-radius: 4px;
            .d-icon {
              color: #000 !important;
            }
            &:hover,
            &:focus {
              box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25);
              .d-icon {
                color: #000 !important;
              }
            }
          }
        }
      }
    }
  }
  .login-left-side {
    background: var(--secondary);
    width: calc(100% - 4em);
    display: flex;
    flex-direction: column;
    padding: 3em 3em 2.5em;
    .login-welcome-header {
      .login-title {
        line-height: $line-height-small;
        font-size: $font-up-6;
      }
      .login-subheader {
        font-size: 1.125em !important;
      }
    }
    #credentials {
      display: flex;
      flex-direction: column;
      align-items: flex-start !important;
    }
    #login-form {
      margin: 3em 0 1.25em 0;
    }
    .modal-footer {
      display: flex;
      flex-direction: row;
      width: 100%;
      padding: 0;
      border: 0;
    }
  }

  .modal-body,
  #credentials {
    display: flex;
    align-items: center;

    &.hidden {
      display: none;
    }
  }
}

.login-modal-body.second-factor {
  max-width: 30em;
  .login-left-side {
    width: 100%;
    #login-form {
      margin: 2em 0 0 0;
    }
  }
  #new-account-link {
    display: none;
  }
  .modal-footer {
    margin-top: 1em;
  }
}

.login-form {
  .tip {
    &:not(:empty) {
      min-height: 1.75em;
      &.bad .svg-icon {
        vertical-align: middle;
      }
    }
  }
}

// styles used on the
// create account
// modal only
.d-modal.create-account {
  .create-account-body {
    min-width: 700px !important;
  }
  .modal-body:not(.reorder-categories):not(.poll-ui-builder):not(.poll-breakdown) {
    max-height: 70vh !important;
    overflow: hidden;
  }
  .has-alt-auth .create-account-form {
    display: grid;
    grid-template-columns: 65% 35%;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "header login-buttons"
      "form login-buttons"
      "footer login-buttons";
  }
  .create-account-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
  }
  .create-account-login-buttons {
    display: none;
  }
  .has-alt-auth .create-account-login-buttons {
    grid-area: login-buttons;
    padding: 1em;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    h3 {
      color: var(--secondary);
      text-align: center;
    }
    #login-buttons {
      button:first-of-type {
        margin-top: 0;
      }
    }
  }
  .modal-body {
    display: flex;
    padding: 0;
  }
  .modal-footer {
    grid-area: footer;
    background-color: var(--secondary);
    position: relative;
    &:before {
      content: "";
      display: block;
      position: absolute;
      width: 100%;
      pointer-events: none;
      top: calc(-1em - 1px);
      left: 0;
      height: 1em;
      background-image: linear-gradient(
        to bottom,
        rgba(var(--secondary-rgb), 0),
        rgba(var(--secondary-rgb), 1)
      );
    }
  }
  .login-welcome-header {
    grid-area: header;
    padding: 3em 2em 1em;

    .login-title {
      font-size: $font-up-6;
      line-height: $line-height-medium;
    }
    .login-subheader {
      font-size: 1.125em !important;
      align-self: start;
    }
  }

  .modal-body:not(.has-alt-auth) .login-form {
    &:after {
      width: 100%;
    }
  }

  .has-alt-auth .login-form,
  .login-form {
    background: var(--secondary);
    padding: 1em 0 0 0;
    grid-area: form;
    overflow-y: scroll;

    .input-group {
      padding: 0 2em;
      margin-bottom: 1em;
      input {
        width: 100%;
      }
      input:not(.value-entered):not(:focus) + label.alt-placeholder {
        top: 12px;
        left: 3em;
      }
      input:focus + label.alt-placeholder,
      input.value-entered + label.alt-placeholder {
        top: -8px;
        left: calc(3em - 0.25em);
      }
    }
    .password-confirmation {
      display: none;
    }
    scrollbar-color: rgba(var(--primary-rgb), 0.5) transparent;
    &::-webkit-scrollbar {
      width: 15px;
    }

    &::-webkit-scrollbar-track {
      box-shadow: inset 0 0 14px 14px transparent;
      border: 4px solid transparent;
    }

    &::-webkit-scrollbar-thumb {
      box-shadow: inset 0 0 14px 14px rgba(var(--primary-rgb), 0.5);
      border: 4px solid transparent;
      border-radius: 14px;
    }

    /* set button(top and bottom of the scrollbar) */
    &::-webkit-scrollbar-button {
      display: none;
    }
  }

  .user-fields {
    margin-bottom: 1em;
  }

  .user-field {
    &.text {
      label.control-label {
        left: 3em !important;
        max-width: calc(100% - 6em) !important;
      }
      &.value-entered label.control-label,
      label.control-label.value-entered {
        left: calc(3em - 0.25em) !important;
      }
    }
    display: flex;
    flex-direction: column;
    &.confirm {
      margin-top: 5px;
    }
  }

  .invites-show {
    padding-top: 20px;

    .two-col {
      margin-top: 30px;
    }
    .col-form {
      margin-left: 200px;
      .inline-invite-img {
        display: none;
      }
    }
    form {
      .controls,
      .input {
        margin-left: 20px;
      }
      input,
      label {
        margin-bottom: 0;
      }
      .user-field .control-label:not(.checkbox-label) {
        margin-left: 20px;
      }
    }
  }

  .tos-agree {
    margin-bottom: 12px;
  }
}

.password-reset,
.email-login,
.invites-show {
  .col-form {
    padding-left: 20px;
  }
  .col-image {
    width: 175px;
    img {
      width: 100%;
    }
  }
  h2 {
    margin-bottom: 12px;
  }
  input:not([type="checkbox"]) {
    // 80% width on checkboxes messes up the layout for custom fields
    width: 80%;
  }
}

.password-reset,
.email-login {
  .col-form {
    padding-top: 40px;
  }
}
