.changelly {
  --font-size-title: 20px;
  font-size: 14px;

  .changelly-widget {
    position: relative;
    margin: 0 auto;
    padding: 24px;
    background: #141414;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 24px 0 rgba(34, 41, 47, 0.24);
    overflow: hidden;

    @media (min-width: 768px) {
      width: 100%;
    }

    .changelly-widget__title {
      display: flex;
      align-items: center;
      font-size: var(--font-size-title);

      p {
        margin: 0 8px 0 0;
        color: #fff;
        font-weight: 700;
      }

      .title__back {
        display: inline-block;
        margin-right: 8px;
        cursor: pointer;

        svg {
          fill: var(--color-text);
          transition: fill 0.2s;
        }

        &:hover {
          svg {
            fill: #fff;
          }
        }
      }

      .title__steps {
        color: var(--color-primary);
      }
    }

    .changelly-widget__steps {
      position: relative;
      z-index: 10;

      .steps__progress {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
        margin-top: 12px;

        span {
          display: inline-block;
          width: 100%;
          height: 2px;
          border-radius: 8px;
          background: var(--color-primary);
          opacity: 0.5;
          transition: opacity 0.5s;
        }

        &.step-1 {
          span:nth-child(1) {
            opacity: 1;
          }
        }

        &.step-2 {

          span:nth-child(1),
          span:nth-child(2) {
            opacity: 1;
          }
        }

        &.step-3 {
          span {
            opacity: 1;
          }
        }
      }

      .steps__one {
        position: relative;

        .one__swap {
          position: relative;
          margin-top: 24px;

          .swap__coin {
            padding: 16px;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid var(--color-border);
            border-radius: 8px;
            transition: border 0.2s;

            &:has(.content__value:focus) {
              border-color: #fff;
            }

            .coin__content {
              display: flex;
              align-items: center;
              padding-top: 8px;

              img {
                width: 36px;
                height: 36px;
              }

              .content__info {
                padding: 0 12px 0 8px;

                .info__select {
                  display: flex;
                  align-items: center;
                  cursor: pointer;

                  span {
                    font-weight: 700;
                    font-size: var(--font-size-title);
                  }

                  svg {
                    fill: var(--color-text);
                  }
                }

                .info__coin {
                  display: flex;
                  align-items: center;
                  font-size: 11px;
                  white-space: nowrap;

                  span {
                    display: inline-block;
                    margin-left: 8px;
                    padding: 0 4px;
                    color: var(--tag-primary-color);
                    font-weight: 700;
                    background: var(--tag-secondary-color);
                    border-radius: 4px;
                  }
                }
              }

              .content__value {
                align-self: flex-start;
                width: 100%;

                input {
                  width: 100%;
                  color: var(--color-text);
                  font-weight: 700;
                  font-size: var(--font-size-title);
                  text-align: right;
                  background: none;
                  border: 0;
                  transition: color 0.2s;

                  &:focus {
                    color: #fff;
                    outline: none;
                  }
                }

                .value__helper {
                  display: block;
                  color: red;
                  text-align: right;
                }
              }
            }

            + .swap__coin {
              margin-top: 4px;
            }

            &.swap__coin--bottom {
              .content__value {
                display: flex;
                align-items: center;
                flex-wrap: wrap;

                input {
                  width: calc(100% - 18px);
                }

                .value__helper {
                  width: 100%;
                }

                .value__estimate {
                  display: inline-block;
                  width: 18px;
                  text-align: center;
                }

                .value__fixed {
                  display: none;
                  margin: -1px 0 0 2px;
                }
              }
            }
          }

          .swap__switch {
            position: absolute;
            z-index: 10;
            top: 50%;
            left: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            background: #141414;
            border: 1px solid var(--color-border);
            border-radius: 50%;
            transform: translate(-50%, -50%);
            cursor: pointer;
            transition: border 0.2s;

            svg {
              fill: var(--color-text);
              transition: fill 0.2s;
            }

            &:hover {
              border-color: #fff;

              svg {
                fill: #fff;
              }
            }
          }
        }

        .one__toggle {
          position: relative;
          margin-top: 24px;

          .toggle {
            display: inline-flex;
            align-items: center;
            cursor: pointer;

            .toggle__input {
              position: relative;
              width: 38px;
              height: 24px;
              border: 1px solid var(--color-border);
              border-radius: 24px;
              transition: border 0.2s;

              &::after {
                content: "";
                position: absolute;
                top: 4px;
                left: 4px;
                width: 14px;
                height: 14px;
                background: var(--color-text);
                border-radius: 50%;
                transition: background 0.2s, transform 0.2s;
              }
            }

            .toggle__label {
              margin-left: 8px;
              font-weight: 700;
            }

            &:hover {
              .toggle__input {
                border-color: #fff;
              }
            }
          }

          input {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border-width: 0;

            &:checked {
              + .toggle .toggle__input {
                background: var(--color-primary);

                &::after {
                  background: #fff;
                  transform: translateX(100%);
                }
              }
            }
          }

          &:has(.is-disabled) {
            opacity: 0.25;
            pointer-events: none;
          }
        }

        .one__next {
          margin-top: 24px;

          .button {
            width: 100%;
            font-weight: 700;
          }
        }
      }

      .steps__two {
        .two__address {
          display: flex;
          align-items: center;
          margin-top: 24px;

          .address__block {
            p {
              margin: 0;
            }

            .block__value {
              font-size: var(--font-size-title);
              color: #fff;
            }

            small {
              display: flex;
              align-items: center;

              span {
                display: inline-block;
                margin-left: 8px;
                padding: 0 4px;
                color: var(--tag-primary-color);
                font-weight: 700;
                font-size: 11px;
                line-height: 1.5;
                background: var(--tag-secondary-color);
                border-radius: 4px;
              }
            }
          }

          svg {
            margin: 0 8px;
            fill: var(--color-text);
          }
        }

        .two__rate {
          display: flex;
          align-items: center;

          .rate__currencies {
            padding: 12px 0;

            img {
              width: 24px;
              height: 24px;

              + img {
                margin-left: -12px;
              }
            }
          }

          p {
            margin: 0 0 0 8px;
          }

          .rate__text-fixed {
            display: none;
          }
        }

        .two__details {
          display: inline-flex;
          align-items: center;
          margin-top: 16px;
          cursor: pointer;
          transition: color 0.2s;

          svg {
            margin-left: 4px;
            fill: var(--color-text);
            transition: fill 0.2s;
          }

          &:hover {
            color: #fff;

            svg {
              fill: #fff;
            }
          }
        }

        .two__destination-address,
        .two__refund-address {
          position: relative;
          margin-top: 16px;

          span {
            position: absolute;
            top: 0;
            left: 8px;
            display: inline-block;
            margin-left: 8px;
            padding: 0 4px;
            color: var(--tag-primary-color);
            font-weight: 700;
            font-size: 11px;
            line-height: 1.5;
            background: var(--tag-secondary-color);
            border-radius: 4px;
            transform: translateY(-50%);
          }

          input {
            width: 100%;
            padding: 12px 8px;
            color: var(--color-text);
            background: #1c1c1c;
            border: 1px solid var(--color-border);
            border-radius: 4px;

            &.has-error {
              border-color: red;
            }
          }
        }

        .two__refund-address {
          display: none;
          padding-top: 16px;
          border-top: 1px solid var(--color-border);

          span {
            top: 16px;
          }

          .feedback {
            margin-top: 12px;
          }
        }

        .two__info {
          margin-top: 24px;

          a {
            font-weight: 700;
            text-decoration: underline;
          }
        }

        .two__next {
          margin-top: 24px;

          .button {
            width: 100%;
            font-weight: 700;
          }
        }
      }

      .changelly-widget__slide-out {
        position: absolute;
        z-index: 20;
        right: -24px;
        bottom: -24px;
        left: -24px;
        padding: 24px;
        background: #141414;
        border-radius: 8px 8px 0 0;
        transform: translateY(100%);
        transition: transform 0.2s;

        .slide-out__title {
          display: flex;
          align-items: center;

          p {
            margin: 0;
            color: #fff;
            font-size: var(--font-size-title);
          }

          .title__close {
            margin-left: auto;
            cursor: pointer;

            svg {
              fill: var(--color-text);
              transition: fill 0.2s;
            }

            &:hover {
              svg {
                fill: #fff;
              }
            }
          }
        }

        .slide-out__content {
          .content__info {
            margin: 16px 0 0;
            padding: 0;
            list-style: none;

            li {
              display: flex;
              align-items: center;
              justify-content: space-between;
              margin-bottom: 8px;
            }

            .info__value {
              display: flex;
              align-items: center;

              img {
                width: 12px;
                height: 12px;
                margin-right: 4px;
              }
            }

            .info__title--rate-fixed,
            .info__value--rate-fixed {
              display: none;
            }
          }

          .content__you-get {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding-top: 8px;
            border-top: 1px solid var(--color-border);

            .you-get__value {
              display: flex;
              align-items: center;

              img {
                width: 12px;
                height: 12px;
                margin-right: 4px;
              }
            }
          }

          .value__name {
            margin-left: 4px;
          }

          .value__protocol {
            display: inline-block;
            vertical-align: middle;
            margin-left: 4px;
            padding: 0 4px;
            color: var(--tag-primary-color);
            font-weight: 700;
            font-size: 10px;
            background: var(--tag-secondary-color);
            border-radius: 4px;
          }
        }

        &.is-visible {
          transform: translateY(0);
        }
      }

      &::after {
        content: "";
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: rgba(0, 0, 0, 0.9);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s, visibility 0.2s;
      }

      &:has(.js-fixed-rate:checked) {
        .swap__coin--bottom {
          .content__value {
            .value__estimate {
              display: none !important;
            }

            .value__fixed {
              display: inline-block !important;
            }
          }
        }

        .rate__text-floating,
        .info__title--rate-floating,
        .info__value--rate-floating {
          display: none !important;
        }

        .rate__text-fixed,
        .info__title--rate-fixed,
        .info__value--rate-fixed,
        .two__refund-address {
          display: block !important;
        }

        .service-fee {
          display: none !important;
        }
      }
    }

    .feedback {
      display: flex;
      align-items: center;
      padding: 8px;
      color: #00e0f7;
      font-size: 12px;
      background: #03191c;

      svg {
        width: 16px;
        height: 16px;
        margin-right: 8px;
        fill: #00e0f7;
      }

      p {
        margin: 0;
      }
    }


    &::after {
      content: "";
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      background: rgba(0, 0, 0, 0.9);
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.2s, visibility 0.2s;
    }

    &:has(.changelly-widget__slide-out.is-visible) {
      &::after {
        opacity: 1;
        visibility: visible;
      }

      .changelly-widget__steps {
        &::after {
          opacity: 1;
          visibility: visible;
        }
      }
    }
  }

  .changelly-modal {
    position: fixed;
    z-index: 9999;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    align-items: center;
    justify-content: center;

    &.is-visible {
      display: flex;
    }

    &::after {
      content: "";
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      background: rgba(0, 0, 0, 0.5);
    }

    .changelly-modal__content {
      position: relative;
      z-index: 10;
      width: 80vw;
      max-height: 80vh;
      background: #141414;
      border-radius: 16px;

      @media (min-width: 992px) {
        width: 500px;
      }

      .content__top {
        display: flex;
        align-items: center;
        padding: 24px 16px;

        .top__title {
          display: inline-block;
          margin-left: 16px;
          color: #fff;
          font-size: var(--font-size-title);
        }

        .top__back,
        .top__close {
          cursor: pointer;

          svg {
            fill: var(--color-text);
            transition: fill 0.2s;
          }

          &:hover {
            svg {
              fill: #fff;
            }
          }
        }

        .top__close {
          margin-left: auto;
        }
      }

      .content__search {
        padding: 0 16px 24px;

        input {
          width: 100%;
          padding: 12px 8px;
          color: var(--color-text);
          background: #1c1c1c;
          border: 1px solid var(--color-border);
          border-radius: 4px;
        }
      }

      .content__list {
        margin: 0;
        padding: 0 16px 24px;
        max-height: calc(80vh - 150px);
        list-style: none;
        overflow-y: auto;

        .list__currency {
          display: flex;
          align-items: center;
          padding: 16px 0;
          border-top: 1px solid var(--color-border);
          transition: background 0.2s;
          cursor: pointer;

          &:hover {
            background: #0f1114;
          }

          .currency__img {
            width: 36px;
            height: 36px;
          }

          .currency__content {
            padding-left: 8px;

            p {
              display: flex;
              align-items: center;
              margin: 0;
              font-weight: 700;
              font-size: var(--font-size-title);

              span {
                display: inline-block;
                margin-left: 8px;
                padding: 0 4px;
                color: var(--tag-primary-color);
                font-weight: 700;
                font-size: 11px;
                line-height: 1.5;
                background: var(--tag-secondary-color);
                border-radius: 4px;
              }
            }
          }

          .currency__selected {
            display: none;
            margin-left: auto;

            svg {
              fill: var(--color-primary);
            }

            &.is-selected {
              display: block;
            }
          }
        }
      }
    }
  }
}
