$popup-spacing: 20px;

$popup-list-border-color: #E7ECEE;
$popup-list-background-color: #F9F9FA;
$popup-list-toggle-checked-background-color: #FF7C70;
$popup-list-toggle-unchecked-background-color: #5F7C86;
$popup-list-toggle-height: 16px;
$popup-list-toggle-width: 30px;
$popup-list-toggle-padding: 1px;

.popup-header {
  margin: $popup-spacing;
  margin-bottom: 0;

  text-align: center;

  &__icon {
    height: 32px;
  }

  &__title {
    padding-top: 5px;
    color: black;
    font-size: 23px;
    font-weight: 500;
    margin-bottom: 20px;
    text-align: center; // necessary for Firefox
  }

  &__sitename {
    border-radius: 2px;
    padding: 10px;
    line-height: 1;
    background-color: #F4F5F7;
    color: #0078CA;
    display: inline-block;
  }
}

@keyframes spin { 100% { transform: rotate(-360deg); } }
@keyframes blink { 0% { opacity: .05; } 20% { opacity: 1; } 100% { opacity: .05; } }

.popup-scanning {
  margin: $popup-spacing;
  text-align: center;

  &__icon {
    height: 112px;
    width: 112px;
    margin: 0 auto;
    margin-bottom: 20px;

    img {
      animation: spin 1s ease-in-out infinite;
    }
  }

  &__title {
    font-weight: 600;
  }

  &__progress {
    padding-left: 2px;

    span {
      animation-name: blink;
      animation-duration: 1s;
      animation-iteration-count: infinite;
      animation-fill-mode: both;
    }

    span:nth-child(2) {
      animation-delay: .1s;
    }

    span:nth-child(3) {
      animation-delay: .2s;
    }
  }
}

.popup-list {
  margin-top: 30px;

  &__header {
    padding: 15px $popup-spacing;
    text-transform: uppercase;
    font-size: 13px;
    color: #5F7C86;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
  }

  &__title {
    font-weight: bold;
    padding-left: 5px;
    flex-grow: 1;
  }

  &__icon {
    display: inline-block;
    vertical-align: middle;

    svg {
      height: 16px;
      fill: currentColor;
      vertical-align: middle;
    }
  }

  &__control {
    appearance: none;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    padding-left: 10px;
    color: $blue;
    text-transform: uppercase;

    &:hover {
      color: #0078CA;
    }
  }

  &__items {
    background-color: $popup-list-background-color;
    border: 1px solid $popup-list-border-color;
  }
}

.popup-list-item {
  display: flex;
  justify-content: space-between;

  margin: 0 $popup-spacing;
  padding: 12px 0;
  line-height: $popup-list-toggle-height;

  border-bottom: 1px solid $popup-list-border-color;
  color: black;

  &:last-child {
    border-bottom: none;
  }

  &__title {
    padding-right: 10px;
  }

  &__description-tooltip {
    cursor: pointer;
    padding-left: 10px;
    visibility: hidden;
    display: inline-block;
    vertical-align: middle;

    svg {
      width: 16px;
      height: 16px;

      fill: $blue;
    }
  }

  &:hover {
    .popup-list-item__description-tooltip {
      visibility: visible;
    }
  }

  &__controls {
    flex-shrink: 0;
    position: relative;

    &:hover {
      .popup-list-item__deactivate-button {
        visibility: visible;
        opacity: 1;
        transform: translateX(0);
        color: white;
      }
    }
  }

  &__deactivate-button {
    padding: 2px 10px;
    padding-right: 4px;
    border-radius: 10px;
    line-height: 1;
    background: $blue;
    color: white;
    text-transform: uppercase;
    font-weight: bold;
    transition: all 0.2s;
    opacity: 0;
    transform: translateX(10%);
    position: absolute;
    right: 0;
    white-space: nowrap;
    visibility: hidden;

    &, &:hover {
      text-decoration: none;
    }

    svg {
      fill: white;
      height: 11px;
    }
  }

  &__toggle-label {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 600;
    line-height: $popup-list-toggle-height;
    vertical-align: top;
    padding-right: 4px;
  }

  &__toggle {
    vertical-align: top;

    .react-toggle-track {
      width: $popup-list-toggle-width;
      height: $popup-list-toggle-height;
    }

    .react-toggle-thumb {
      border: none;
      top: $popup-list-toggle-padding;
      left: $popup-list-toggle-width - $popup-list-toggle-height + $popup-list-toggle-padding;
      width: $popup-list-toggle-height - 2 * $popup-list-toggle-padding;
      height: $popup-list-toggle-height - 2 * $popup-list-toggle-padding;
    }

    &.react-toggle--checked .react-toggle-thumb {
      left: $popup-list-toggle-padding;
    }

    &:not(.react-toggle--checked) .react-toggle-track,
    &:not(.react-toggle--checked):hover:not(.react-toggle--disabled) .react-toggle-track {
      background-color: $popup-list-toggle-unchecked-background-color;
    }

    &.react-toggle--checked .react-toggle-track,
    &.react-toggle--checked:hover:not(.react-toggle--disabled) .react-toggle-track {
      background-color: $popup-list-toggle-checked-background-color;
    }
  }
}

.popup-footer {
  margin-top: $popup-spacing;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: #607c85;
  background-color: $popup-list-background-color;
  border-top: 1px solid $popup-list-border-color;

  &__link-text {
    overflow: hidden;
    text-overflow: ellipsis;

    a {
      color: inherit;

      &:hover {
        color: inherit;
        text-decoration: underline;
      }
    }
  }

  &__powered-by {
    opacity: 0.6;
    text-transform: uppercase;

    svg {
      fill: #607c85;
      height: 16px;
      margin: -4px 0;
      margin-left: 4px;
      width: auto;
    }
  }

  &:hover {
    background: $blue;
    color: white;
    border-top-color: $blue;

    .popup-footer__powered-by {
      opacity: 1;
      svg {
        fill: white;
      }
    }
  }
}


.popup-onboarding {
  padding: $popup-spacing 0;
  text-align: center;

  &__icon {
    margin-bottom: 15px;
    height: 32px;
  }

  &__title {
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
  }


  &__description {
    padding: $popup-spacing;
    line-height: 1.3;
    text-align: center;

    a {
      color: $blue;
      text-decoration: none;

      &:hover {
        text-decoration: underline;
        color: $blue;
      }
    }
  }


  &__dismiss-button {
    background: $blue;
    line-height: 1;
    border-radius: 12px;
    text-transform: uppercase;
    color: white;
    font-size: 14px;
    font-weight: bold;
    padding: 5px 25px;
    border: none;
    cursor: pointer;
    outline: 0;

    &:hover {
      text-decoration: underline;
    }
  }
}
