// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

@use '../mixins';
@use '../variables';

.ProfileEditor {
  margin-inline-start: 24px;
  margin-inline-end: 24px;

  &__icon {
    &--container {
      align-items: center;
      display: flex;
      font-size: 24px;
      justify-content: center;
      width: 20px;
      height: 20px;
    }

    &::after {
      -webkit-mask-size: 100%;
      content: '';
      display: block;
      height: 20px;
      width: 20px;

      @include mixins.light-theme {
        background-color: variables.$color-gray-75;
      }

      @include mixins.dark-theme {
        background-color: variables.$color-gray-15;
      }
    }

    &--name {
      &::after {
        @include mixins.light-theme {
          @include mixins.color-svg(
            '../images/icons/v3/person/person.svg',
            variables.$color-gray-75
          );
        }

        @include mixins.dark-theme {
          @include mixins.color-svg(
            '../images/icons/v3/person/person.svg',
            variables.$color-gray-15
          );
        }
      }
    }

    &--username {
      &::after {
        @include mixins.light-theme {
          @include mixins.color-svg(
            '../images/icons/v3/at/at.svg',
            variables.$color-gray-75
          );
        }

        @include mixins.dark-theme {
          @include mixins.color-svg(
            '../images/icons/v3/at/at.svg',
            variables.$color-gray-15
          );
        }
      }
    }

    &--username-link {
      &::after {
        @include mixins.light-theme {
          @include mixins.color-svg(
            '../images/icons/v3/qr_code/qr_code.svg',
            variables.$color-gray-75
          );
        }

        @include mixins.dark-theme {
          @include mixins.color-svg(
            '../images/icons/v3/qr_code/qr_code.svg',
            variables.$color-gray-15
          );
        }
      }
    }

    &--bio {
      &::after {
        @include mixins.light-theme {
          @include mixins.color-svg(
            '../images/icons/v3/edit/edit.svg',
            variables.$color-gray-75
          );
        }

        @include mixins.dark-theme {
          @include mixins.color-svg(
            '../images/icons/v3/edit/edit.svg',
            variables.$color-gray-15
          );
        }
      }
    }
  }

  &__row {
    padding-inline: 8px;
    padding-block: 12px;
  }

  &__divider {
    border-style: solid;
    border-bottom: none;

    @include mixins.light-theme {
      border-color: variables.$color-gray-15;
    }

    @include mixins.dark-theme {
      border-color: variables.$color-gray-75;
    }
  }

  hr {
    margin-block: 24px 12px;
  }

  &__info {
    @include mixins.font-body-2;
    margin-block: 12px;
    margin-inline: 8px;

    @include mixins.light-theme {
      color: variables.$color-gray-60;
    }
    @include mixins.dark-theme {
      color: variables.$color-gray-25;
    }

    a {
      font-weight: 600;
      text-decoration: none;
    }
  }

  &__username-menu {
    &__button {
      width: 20px;
      height: 20px;

      @include mixins.dark-theme {
        @include mixins.color-svg(
          '../images/icons/v3/chevron/chevron-down.svg',
          variables.$color-white
        );
      }
      @include mixins.light-theme {
        @include mixins.color-svg(
          '../images/icons/v3/chevron/chevron-down.svg',
          variables.$color-black
        );
      }
    }

    &__copy-icon {
      @include mixins.dark-theme {
        @include mixins.color-svg(
          '../images/icons/v3/copy/copy.svg',
          variables.$color-white
        );
      }
      @include mixins.light-theme {
        @include mixins.color-svg(
          '../images/icons/v3/copy/copy.svg',
          variables.$color-black
        );
      }
    }

    &__copy-link-icon {
      @include mixins.dark-theme {
        @include mixins.color-svg(
          '../images/icons/v3/link/link.svg',
          variables.$color-white
        );
      }
      @include mixins.light-theme {
        @include mixins.color-svg(
          '../images/icons/v3/link/link.svg',
          variables.$color-black
        );
      }
    }

    &__trash-icon {
      @include mixins.dark-theme {
        @include mixins.color-svg(
          '../images/icons/v3/trash/trash.svg',
          variables.$color-white
        );
      }
      @include mixins.light-theme {
        @include mixins.color-svg(
          '../images/icons/v3/trash/trash.svg',
          variables.$color-black
        );
      }
    }
  }

  &__error-icon {
    -webkit-mask-size: 100%;
    display: block;
    height: 20px;
    width: 20px;

    @include mixins.light-theme {
      @include mixins.color-svg(
        '../images/icons/v3/error/error-circle.svg',
        variables.$color-accent-red
      );
    }

    @include mixins.dark-theme {
      @include mixins.color-svg(
        '../images/icons/v3/error/error-circle.svg',
        variables.$color-accent-red
      );
    }
  }

  &__username-link {
    &__tooltip {
      padding: 0;
      background-color: unset;

      --container-padding: 12px;

      &__container {
        display: flex;
        flex-direction: row;
        padding: var(--container-padding);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
        border: 1px solid variables.$color-gray-20;
        border-radius: inherit;
        background-color: variables.$color-gray-02;
        transform-origin: 0 0; // needed for react-spring scale animation
        @include mixins.dark-theme {
          background-color: variables.$color-gray-75;
          border-color: variables.$color-gray-60;
        }
      }

      & {
        --direction-multiplier: 1;
      }
      &:dir(rtl) {
        --direction-multiplier: -1;
      }

      &__arrow {
        position: absolute;

        // stylelint-disable-next-line declaration-property-value-disallowed-list
        transform: translateY(calc(-50% - var(--container-padding)))
          translateX(
            calc(
              var(--direction-multiplier) * (20px - var(--container-padding))
            )
          )
          rotate(45deg);

        width: 14px;
        height: 14px;
        clip-path: polygon(0 100%, 0 0, 100% 0);

        border: inherit;
        background: inherit;
      }
      &__icon {
        width: 20px;
        height: 20px;
        margin-block-start: 4px;
        margin-inline: 4px 12px;

        @include mixins.dark-theme {
          @include mixins.color-svg(
            '../images/icons/v3/share/share.svg',
            variables.$color-white
          );
        }
        @include mixins.light-theme {
          @include mixins.color-svg(
            '../images/icons/v3/share/share.svg',
            variables.$color-black
          );
        }
      }

      &__content {
        text-align: start;

        h3 {
          @include mixins.font-body-2-bold;
          margin: 0;
        }

        p {
          @include mixins.font-subtitle;
          max-width: 240px;
          margin: 0;
        }
      }

      &__close {
        @include mixins.button-reset;
        @include mixins.button-focus-outline;

        & {
          width: 20px;
          height: 20px;
          padding: 0;
          margin: 0;
        }

        @include mixins.color-svg(
          '../images/icons/v3/x/x.svg',
          variables.$color-gray-45
        );
        @include mixins.dark-theme {
          @include mixins.color-svg(
            '../images/icons/v3/x/x.svg',
            variables.$color-gray-25
          );
        }
      }
    }
  }

  &__button-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    padding-block: 1em 16px;
    gap: 8px;

    .module-Button:not(:first-child) {
      margin-inline-start: 4px;
    }
  }
}

.ProfileEditor__Title {
  @include mixins.font-title-1;
  text-align: center;
  overflow-x: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-block: 0 4px;
  margin-inline: 0;
  @include mixins.light-theme() {
    color: variables.$color-gray-90;
  }
  @include mixins.dark-theme() {
    color: variables.$color-gray-05;
  }
}

.ProfileEditor__PhoneNumber {
  @include mixins.font-body-2;
  text-align: center;
  overflow-x: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-block: 0 14px;
  margin-inline: 0;
  @include mixins.light-theme() {
    color: variables.$color-black;
  }
  @include mixins.dark-theme() {
    color: variables.$color-white;
  }
}

.ProfileEditor__EditPhotoContainer {
  display: flex;
  justify-content: center;
  margin-block-end: 16px;
}
