@use '../../../style/variables.scss';

.usernameEditor {
  width: 100%;

  .display {
    display: flex;
    align-items: center;
    gap: 12px;

    .label {
      font-size: 16px;
      color: variables.$lightgray-200;
    }

    .username {
      font-size: 18px;
      font-weight: 500;
      color: variables.$white;
    }

    .editButton {
      padding: 4px 12px !important;
      font-size: 14px;
      color: variables.$purple !important;
      border: 1px solid variables.$purple !important;
      border-radius: 8px;
      background: none;

      &:hover {
        background-color: rgba(variables.$purple, 0.1);
      }
    }
  }

  .editor {
    display: flex;
    flex-direction: column;
    gap: 8px;

    .inputWrapper {
      display: flex;
      align-items: center;
      position: relative;

      .prefix {
        position: absolute;
        left: 12px;
        font-size: 18px;
        color: variables.$lightgray-200;
      }

      .input {
        flex: 1;
        padding: 8px 12px 8px 32px;
        font-size: 18px;
        background-color: rgba(255, 255, 255, 0.1);
        border: 1px solid variables.$lightgray-400;
        border-radius: 8px;
        color: variables.$white;

        &:focus {
          outline: none;
          border-color: variables.$purple;
          background-color: rgba(255, 255, 255, 0.15);
        }
      }

      .loader {
        position: absolute;
        right: 12px;
        width: 20px;
        height: 20px;
        animation: spin 1s linear infinite;
      }
    }

    .validation {
      font-size: 14px;
      padding: 4px 8px;
      border-radius: 4px;

      &.valid {
        color: #4caf50;
        background-color: rgba(76, 175, 80, 0.1);
      }

      &.invalid {
        color: #f44336;
        background-color: rgba(244, 67, 54, 0.1);
      }
    }

    .actions {
      display: flex;
      gap: 8px;
      justify-content: flex-end;
      margin-top: 8px;

      button {
        padding: 6px 16px !important;
        font-size: 14px;
        border-radius: 8px;

        &:first-child {
          background: none;
          color: variables.$lightgray-200 !important;
          border: 1px solid variables.$lightgray-400 !important;
        }

        &:last-child {
          background-color: variables.$purple !important;
          color: variables.$white !important;
          border: none !important;

          &:disabled {
            opacity: 0.5;
            cursor: not-allowed;
          }
        }
      }

      .buttonLoader {
        width: 16px;
        height: 16px;
        animation: spin 1s linear infinite;
      }
    }
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
